祁阳图书馆智慧大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1017 lines
34 KiB

1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
12 months ago
1 year ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <div class="map-wrapper">
  3. <div class="map-content">
  4. <!-- 左边图书馆基本信息 -->
  5. <div class="lib-info">
  6. <div class="database-title">{{ libCurrent && libCurrent.name }}</div>
  7. <div class="lib-content">
  8. <div style="width: 5.175rem; height: 3rem; overflow: hidden;">
  9. <swiper v-if="swiperOption" :key="swiperKey" ref="mySwiper" class="swiperLib" :options="swiperOption">
  10. <swiper-slide v-for="(item,index) in displayedImages" :key="index">
  11. <div class="book-img" style="width: 100%; height: 3rem;">
  12. <img :src="item.cover" :onerror="defaultImg" style="width: 100%;">
  13. </div>
  14. </swiper-slide>
  15. <!-- 标页码 -->
  16. <div slot="pagination" class="swiper-pagination" />
  17. </swiper>
  18. </div>
  19. <ul class="lib-cont-item lib-cont01">
  20. <li>
  21. <img src="@/assets/images/map_18.png" alt="">
  22. <p>
  23. <span>藏书量</span>
  24. <span>{{ libCurrent && libCurrent.GCL }}<i></i></span>
  25. </p>
  26. </li>
  27. <li>
  28. <img src="@/assets/images/map_20.png" alt="">
  29. <p>
  30. <span>办证量</span>
  31. <span>{{ libCurrent && (libCurrent.countCard ? libCurrent.countCard : libCurrent.readerIdNum) }}<i></i></span>
  32. </p>
  33. </li>
  34. </ul>
  35. <ul class="lib-cont-item lib-cont02">
  36. <li>
  37. <img src="@/assets/images/map_28.png" alt="">
  38. <p>
  39. <span>占地面积</span>
  40. <span>{{ libCurrent && libCurrent.occupationArea }}<i>平方米</i></span>
  41. </p>
  42. </li>
  43. </ul>
  44. <div ref="scrollInfo" class="scroll-container">
  45. <div ref="marquee" class="lib-text" v-html="libCurrent && libCurrent.explain" />
  46. </div>
  47. </div>
  48. </div>
  49. <!-- map -->
  50. <div ref="chart" style="width: 920px; height: 924px; z-index: 999; border:1px solid rgba(0, 0, 0, 0);" />
  51. <div class="map-hx-bg">
  52. <div class="map-hx-small" />
  53. <div class="map-hx-big" />
  54. </div>
  55. <!-- 右边排行榜 -->
  56. <div class="read-num">
  57. <div class="database-title">读者统计</div>
  58. <div class="online">
  59. <p>本年累计办证人数</p>
  60. <p class="num"><span>{{ cardTotal }}</span><i></i></p>
  61. </div>
  62. <div class="lending-ranking">
  63. <h5>借阅Top10</h5>
  64. <div class="ranking-cont">
  65. <ul class="ranking-title">
  66. <li style="width: 0.8rem;">排名</li>
  67. <li style="width: 1.25rem; text-align: left; ">姓名</li>
  68. <li style="flex:1;" />
  69. <li style="width: 1.75rem; text-align: right; padding-right: .25rem;">借阅次数</li>
  70. </ul>
  71. <ul class="ranking-list">
  72. <li v-for="(item,index) in rankingWithPercentage" :key="index" :class="{ 'hovered': index === currentHover }">
  73. <div style="width: 1rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
  74. <div style="width: 1.25rem; text-align: left; ">{{ item.RDNAME }}</div>
  75. <div class="ranking-progress" style="flex:1; align-self: center;">
  76. <el-progress :percentage="item.percentage" :stroke-width="8" :show-text="false" color="#009afb" />
  77. </div>
  78. <div style="width: 1.75rem; text-align: right; padding-right: .25rem;">{{ item.TOTALNUM }}<i></i></div>
  79. </li>
  80. </ul>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { FetchLibBookTotal, FetchUsertotal, FetchLibcodeDetails, FetchLibcodeResouceDetails, FetchReadRanking, FetchLendingTotal } from '@/api/library'
  89. import mapJson from '@/assets/json/qy.json'
  90. import libJson from '@/assets/json/lib.json'
  91. import { debounce } from 'lodash' // js工具类,按需加载
  92. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  93. import 'swiper/dist/css/swiper.css'
  94. export default {
  95. name: 'Map',
  96. components: {
  97. swiper, swiperSlide
  98. },
  99. data() {
  100. return {
  101. currentHover: -1,
  102. timeTicket: null,
  103. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
  104. count: 0,
  105. len: 0, // 轮播数组的长度, 通过 count % len 可以得到[0, len-1] 数组下标
  106. libALLNum: [],
  107. libInfoData: [],
  108. libIndex: 0,
  109. libCurrent: null,
  110. swiperKey: 1,
  111. currentIndex: 0,
  112. displayedImages: [],
  113. libImg: [],
  114. swiperOption: null,
  115. seriesData: [],
  116. mapImg: require('../../assets/images/map-bg2.png'),
  117. cardTotal: 0,
  118. rankingData: [],
  119. rankingWithPercentage: [],
  120. rankInterval: null,
  121. timer: null,
  122. position: 0,
  123. speed: 2 // 滚动速度,可根据需要调整
  124. }
  125. },
  126. computed: {
  127. swiper() {
  128. return this.$refs.mySwiper.swiper
  129. }
  130. },
  131. beforeDestroy() {
  132. this.destroy()
  133. },
  134. created() {
  135. this.getLibBookTotal()
  136. this.getReadRanking()
  137. this.getLendingTotal()
  138. },
  139. activated() {
  140. this.getLibBookTotal()
  141. if (this.rankingData.length !== 0) {
  142. this.currentHover = -1
  143. this.rankInterval = setInterval(() => {
  144. this.currentHover = (this.currentHover + 1) % this.rankingData.length
  145. }, 1000)
  146. }
  147. this.$nextTick(() => {
  148. window.addEventListener('resize', debounce(this.resize, 2000))
  149. })
  150. },
  151. deactivated() {
  152. this.destroy()
  153. },
  154. mounted() {
  155. },
  156. methods: {
  157. destroy() {
  158. window.removeEventListener('resize', this.resize)
  159. clearTimeout(this.timeTicket)
  160. clearInterval(this.rankInterval)
  161. clearInterval(this.timer)
  162. // localStorage.setItem('libIndexItem', this.libIndex)
  163. // localStorage.setItem('libCurrentItem', this.libCurrent)
  164. localStorage.setItem('countItem', this.count)
  165. this.rankInterval = null
  166. this.timer = null
  167. this.timeTicket = null
  168. },
  169. startScrolling() {
  170. this.$nextTick(() => {
  171. const containerHeight = this.$refs.scrollInfo.offsetHeight
  172. const contentHeight = this.$refs.marquee.offsetHeight
  173. // 设置 CSS 变量 --container-height,以便在 CSS 中使用
  174. this.$refs.marquee.parentElement.style.setProperty('--container-height', `${contentHeight + 30}px`)
  175. if (contentHeight > containerHeight) {
  176. this.$refs.marquee.classList.add('lib-animation')
  177. } else {
  178. this.$refs.marquee.classList.remove('lib-animation')
  179. }
  180. })
  181. },
  182. getReadRanking() {
  183. const params = {
  184. 'libcode': 'QYTSG,SJLFG,FXLFG,SEDSG,BZHFG',
  185. 'starttime': this.getFormattedDate(new Date(), -1),
  186. 'endtime': this.getFormattedDate(new Date()),
  187. 'rownum': 10,
  188. 'nordtype': 'QYTSG_E'
  189. }
  190. FetchReadRanking(params).then(res => {
  191. const result = JSON.parse(res.data)
  192. if (result.success && result.resultlist.length > 0) {
  193. this.rankingData = result.resultlist.sort((a, b) => b.TOTALNUM - a.TOTALNUM).slice(0, 10)
  194. this.rankingDataComputed()
  195. this.rankInterval = setInterval(() => {
  196. this.currentHover = (this.currentHover + 1) % this.rankingData.length
  197. }, 1000)
  198. } else {
  199. throw new Error('Failed' + libcode)
  200. }
  201. }).catch(error => {
  202. console.error('Error', error)
  203. return null
  204. })
  205. },
  206. rankingDataComputed() {
  207. const firstPlaceNum = this.rankingData[0].TOTALNUM
  208. this.rankingWithPercentage = this.rankingData.map(item => {
  209. if (item.RDNAME.length === 2) {
  210. // 截取name 字符串截取第一个字符,
  211. item.RDNAME = item.RDNAME.substring(0, 1) + ' * '
  212. } else if (item.RDNAME.length === 3) {
  213. // 截取第一个和第三个字符
  214. item.RDNAME = item.RDNAME.substring(0, 1) + ' * ' + item.RDNAME.substring(2, 3)
  215. } else if (item.RDNAME.length > 3) {
  216. // 截取第一个和大于第4个字符
  217. item.RDNAME = item.RDNAME.substring(0, 1) + ' * ' + ' * ' + item.RDNAME.substring(3, item.RDNAME.length)
  218. }
  219. const percentage = (item.TOTALNUM / firstPlaceNum) * 100
  220. return { ...item, percentage }
  221. })
  222. },
  223. getLendingTotal() {
  224. FetchLendingTotal().then(res => {
  225. const result = JSON.parse(res.data)
  226. if (result.success & result.resultlist.length !== 0) {
  227. // BZL_YEAR 本年办证人数
  228. this.cardTotal = result.resultlist.filter(item => item.LIBCODE !== '999').reduce((acc, obj) => acc + obj.BZL_YEAR, 0)
  229. } else {
  230. this.cardTotal = 0
  231. }
  232. }).catch(error => {
  233. console.error('Error', error)
  234. })
  235. },
  236. // 馆藏量
  237. getLibBookTotal() {
  238. const params = {
  239. 'libcode': 'LSJDFG,LJPFG,DCDFG,QYTSG,SJLFG,XMDFG,FXLFG,QLQFG,SEDSG,MZZFG,GYTZFG,KJSKCFG,JBTZFG,SKTZFG,XJZFG,PSZFG,DZQZFG,WXJDFG,CHJDFG,BSZFG,BZHFG',
  240. 'starttime': '2000-01-01',
  241. 'endtime': '2034-01-01'
  242. }
  243. FetchLibBookTotal(params).then(res => {
  244. const result = JSON.parse(res.data)
  245. if (result.success & result.resultlist.length !== 0) {
  246. // 目的拿到馆藏量
  247. this.libALLNum = result.resultlist
  248. } else {
  249. this.libALLNum = []
  250. }
  251. this.getUserTotal()
  252. .then(userTotals => {
  253. userTotals.forEach(userTotal => {
  254. const libCode = Object.keys(userTotal)[0]
  255. const count = userTotal[libCode]
  256. const foundItem = this.libALLNum.find(item => item.LIBCODE === libCode)
  257. if (foundItem) {
  258. foundItem.countCard = count
  259. }
  260. })
  261. this.getLibcodeDetails()
  262. })
  263. .catch(error => {
  264. console.error('Error', error)
  265. this.getLibcodeDetails()
  266. })
  267. }).catch(error => {
  268. console.error('Error', error)
  269. this.libALLNum = []
  270. this.getLibcodeDetails()
  271. })
  272. },
  273. // 左边办证量
  274. getTotalForLibcode(libcode) {
  275. const params = {
  276. 'libcode': libcode,
  277. 'startdate': '2000-01-01',
  278. 'enddate': '2034-01-01',
  279. 'isrdtype': 0
  280. }
  281. return FetchUsertotal(params).then(res => {
  282. const result = JSON.parse(res.data)
  283. if (result.success && result.pagedata.length > 0) {
  284. return { [libcode]: result.pagedata[0].count }
  285. } else {
  286. throw new Error('Failed' + libcode)
  287. }
  288. }).catch(error => {
  289. console.error('Error' + libcode, error)
  290. return { [libcode]: 0 }
  291. })
  292. },
  293. getUserTotal() {
  294. const libraries = ['QYTSG', 'SJLFG', 'FXLFG', 'SEDSG', 'BZHFG']
  295. const getTotalPromises = libraries.map(libcode => this.getTotalForLibcode(libcode))
  296. return Promise.all(getTotalPromises)
  297. .then(results => {
  298. return results
  299. })
  300. .catch(error => {
  301. console.error('Error', error)
  302. return 0
  303. })
  304. },
  305. // 分管显示内容
  306. getLibcodeDetails() {
  307. FetchLibcodeDetails().then(res => {
  308. const result = JSON.parse(res.data)
  309. if (result.length !== 0) {
  310. const libCode = {
  311. 'QYTSG': [111.848657, 26.588519],
  312. 'LSJDFG': [111.86478, 26.599231],
  313. 'LJPFG': [111.823424, 26.693962],
  314. 'DCDFG': [111.77655, 26.663866],
  315. 'SJLFG': [111.856979, 26.59469],
  316. 'XMDFG': [111.895584, 26.611702],
  317. 'FXLFG': [111.843102, 26.57896],
  318. 'QLQFG': [111.902703, 26.571593],
  319. 'SEDSG': [111.842537, 26.58196],
  320. 'MZZFG': [111.796508, 26.510589],
  321. 'GYTZFG': [111.897118, 26.48444],
  322. 'KJSKCFG': [111.851548, 26.550191],
  323. 'JBTZFG': [112.085297, 26.436849],
  324. 'SKTZFG': [111.819018, 26.412155],
  325. 'XJZFG': [112.009764, 26.355137],
  326. 'PSZFG': [112.051186, 26.489878],
  327. 'DZQZFG': [111.873254, 26.369761],
  328. 'WXJDFG': [111.855175, 26.574414],
  329. 'CHJDFG': [111.850902, 26.586461],
  330. 'BSZFG': [111.989802, 26.421353],
  331. 'BZHFG': [111.862001, 26.580311]
  332. }
  333. // console.log('this.libALLNum', this.libALLNum)
  334. const updatedLibraries = result.map(library => {
  335. const matchingData = this.libALLNum.find(item => item.LIBCODE === library.tcId)
  336. if (matchingData) {
  337. return {
  338. ...library,
  339. GCL: matchingData.GCL,
  340. sort: Object.keys(libCode).indexOf(library.tcId) + 1,
  341. coordinate: libCode[library.tcId],
  342. countCard: matchingData.countCard ? matchingData.countCard : 0
  343. }
  344. } else {
  345. return {
  346. ...library,
  347. GCL: 0,
  348. sort: Object.keys(libCode).indexOf(library.tcId) + 1,
  349. coordinate: libCode[library.tcId],
  350. countCard: 0
  351. }
  352. }
  353. }).sort((a, b) => a.sort - b.sort)
  354. this.libInfoData = updatedLibraries
  355. // console.log('this.libInfoData', this.libInfoData)
  356. if (localStorage.getItem('countItem')) {
  357. this.count = parseInt(localStorage.getItem('countItem'))
  358. } else {
  359. this.count = 0
  360. }
  361. if (this.libInfoData.length !== 0) {
  362. this.initChart() // 初始化
  363. setTimeout(() => {
  364. this.updateChart() // 更新数据,散点轮播显示
  365. this.startScrolling()
  366. window.addEventListener('resize', debounce(this.resize, 2000)) // 使用事件捕获,由外层向内
  367. }, 300)
  368. }
  369. } else {
  370. this.libInfoData = []
  371. }
  372. }).catch(error => {
  373. console.error('Error', error)
  374. })
  375. },
  376. initChart() {
  377. this.$echarts.registerMap('qiyang', mapJson) // 注册map
  378. this.myChart = this.$echarts.init(this.$refs.chart) // echarts容器实例化
  379. var mapImg = document.createElement('img')
  380. mapImg.style.height = mapImg.height = mapImg.width = mapImg.style.width = '1px'
  381. mapImg.src = require('../../assets/images/map-bg2.png')
  382. var XAData = this.libInfoData.map(item => {
  383. return [
  384. { name: '陶铸图书馆' },
  385. { name: item.name, value: item.address }
  386. ]
  387. })
  388. var convertData = function(data) {
  389. var res = []
  390. for (var i = 0; i < data.length; i++) {
  391. var dataItem = data[i]
  392. var fromCoord = libJson[dataItem[0].name]
  393. var toCoord = libJson[dataItem[1].name]
  394. if (fromCoord && toCoord) {
  395. res.push({
  396. fromName: dataItem[0].name,
  397. toName: dataItem[1].name,
  398. coords: [fromCoord, toCoord],
  399. value: dataItem[1].value
  400. })
  401. }
  402. }
  403. return res
  404. }
  405. var series = [];
  406. [
  407. ['陶铸图书馆', XAData]
  408. ].forEach(function(item, i) {
  409. series.push(
  410. {
  411. name: item[0],
  412. type: 'effectScatter',
  413. symbol: 'image://' + require('@/assets/images/map_10.png'),
  414. symbolSize: [26, 20],
  415. coordinateSystem: 'geo',
  416. zlevel: 3,
  417. selectedMode: false,
  418. rippleEffect: {
  419. // brushType: 'stroke',
  420. color: 'transparent'
  421. // scale: 1.5
  422. },
  423. label: {
  424. normal: {
  425. show: true,
  426. position: 'right',
  427. formatter: ''
  428. }
  429. },
  430. itemStyle: {
  431. normal: {
  432. color: 'transparent',
  433. areaColor: 'transparent'
  434. },
  435. emphasis: {
  436. areaColor: '#2B91B7'
  437. }
  438. },
  439. tooltip: {
  440. show: true
  441. },
  442. data: item[1].map(function(dataItem) {
  443. return {
  444. name: dataItem[1].name,
  445. value: dataItem[1].name ? libJson[dataItem[1].name].concat([dataItem[1].value]) : '',
  446. place: dataItem[1].value
  447. }
  448. })
  449. },
  450. {
  451. name: item[0],
  452. type: 'lines',
  453. zlevel: 1,
  454. effect: {
  455. show: true,
  456. period: 6,
  457. trailLength: 0.7,
  458. color: 'red', // arrow箭头的颜色
  459. symbolSize: 3
  460. },
  461. lineStyle: {
  462. normal: {
  463. color: '#fff',
  464. width: 0,
  465. curveness: 0.2
  466. }
  467. },
  468. tooltip: {
  469. show: false
  470. },
  471. data: convertData(item[1])
  472. },
  473. {
  474. name: item[0],
  475. type: 'lines',
  476. zlevel: 2,
  477. symbol: ['none', 'arrow'],
  478. symbolSize: 10, // 固定箭头大小
  479. effect: {
  480. show: true,
  481. period: 6,
  482. trailLength: 0,
  483. symbol: 'arrow',
  484. symbolSize: 10 // 动态箭头大小
  485. },
  486. lineStyle: {
  487. normal: {
  488. color: '#fff',
  489. width: 1,
  490. opacity: 0.6,
  491. curveness: 0.2
  492. }
  493. },
  494. tooltip: {
  495. show: false
  496. },
  497. data: convertData(item[1])
  498. }
  499. )
  500. })
  501. this.seriesData = series
  502. const initOption = {
  503. baseOption: {
  504. // 提示框
  505. tooltip: {
  506. trigger: 'item',
  507. triggerOn: 'click',
  508. showContent: true, // 是否显示提示框浮层
  509. alwaysShowContent: true, // 是否一直显示提示框内容
  510. // hideDelay: 100, // 浮层隐藏的延迟
  511. enterable: 'mousemove|click',
  512. padding: [0, 0, 0, 0],
  513. backgroundColor: null,
  514. position: function(point, params, dom, rect, size) {
  515. return [point[0] + 14, point[1] - 164]
  516. },
  517. formatter: (params, ticket, callback) => {
  518. if (params.seriesType === 'effectScatter') {
  519. const addressLine = params.data.place ? `<div class='place'>地址:${params.data.place}</div>` : ''
  520. return `<div class='tooltip-main' >
  521. <div class='tooltip-line'></div>
  522. <div class='tooltip-content'>
  523. <div class='title'>${params.data.name}</div>
  524. ${addressLine}
  525. </div>
  526. </div>`
  527. } else if (params.seriesType === 'lines') {
  528. return (
  529. params.data.fromName +
  530. '>' +
  531. params.data.toName +
  532. '<br />' +
  533. params.data.value
  534. )
  535. } else {
  536. return params.name
  537. }
  538. }
  539. },
  540. // 设置geo坐标系
  541. geo: [
  542. {
  543. map: 'qiyang',
  544. aspectScale: 1,
  545. zoom: 1.1,
  546. top: '6%', // 距离顶部的位置,每层向下一个百分比
  547. left: '11%',
  548. roam: false, // 是否开启平游或缩放
  549. z: 6, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
  550. itemStyle: {
  551. areaColor: {
  552. type: 'linear',
  553. x: 0,
  554. y: 0,
  555. x2: 1,
  556. y2: 1,
  557. colorStops: [{
  558. offset: 0, color: 'rgba(0,0,0,.1)'
  559. }, {
  560. offset: 0.8, color: 'rgba(59,143,248,.6)'
  561. }],
  562. global: false
  563. },
  564. borderColor: '#9ffcff',
  565. borderWidth: 1
  566. },
  567. emphasis: {
  568. itemStyle: {
  569. areaColor: {
  570. type: 'linear',
  571. x: 0,
  572. y: 0,
  573. x2: 1,
  574. y2: 1,
  575. colorStops: [{
  576. offset: 0, color: 'rgba(0,0,0,.1)'
  577. }, {
  578. offset: 0.8, color: 'rgba(59,143,248,.6)'
  579. }],
  580. global: false
  581. } // 鼠标移上去时区域的颜色
  582. }
  583. },
  584. label: {
  585. emphasis: {
  586. show: false,
  587. color: '#fff'
  588. }
  589. },
  590. tooltip: {
  591. show: true
  592. }
  593. },
  594. {
  595. map: 'qiyang',
  596. aspectScale: 1,
  597. zoom: 1.1,
  598. top: '6%', // 距离顶部的位置,每层向下一个百分比
  599. left: '11%',
  600. roam: false, // 是否开启平游或缩放
  601. z: 5, // 可以看成是css的z-index,数字越大图层越高,我这里设置了5个,然后页面有点卡,根据实际需要来添加,3个其实就能看出效果了
  602. itemStyle: {
  603. areaColor: {
  604. type: 'pattern',
  605. image: mapImg,
  606. repeat: 'repeat'
  607. }, // 每个图层的背景色,根据需要来调,由亮变暗,下面的几个颜色也一样
  608. borderColor: '#9ffcff',
  609. borderWidth: 3,
  610. shadowColor: '#4cd4eb',
  611. shadowOffsetX: 0,
  612. shadowOffsetY: 0,
  613. shadowBlur: 0,
  614. emphasis: { // 地图悬停高亮样式
  615. areaColor: {
  616. type: 'pattern',
  617. image: mapImg,
  618. repeat: 'repeat'
  619. }
  620. }
  621. },
  622. emphasis: {
  623. disabled: true,
  624. areaColor: '#01215c'
  625. },
  626. label: {
  627. emphasis: {
  628. show: false,
  629. color: '#fff'
  630. }
  631. },
  632. tooltip: {
  633. show: false
  634. }
  635. },
  636. {
  637. map: 'qiyang',
  638. aspectScale: 1,
  639. zoom: 1.1,
  640. top: '7%', // 根据自己需要来设置
  641. left: '10%',
  642. roam: false, // 是否开启平游或缩放
  643. z: 4, // 变小,也就是被压在下面
  644. itemStyle: {
  645. areaColor: '#05498f', // 记得改颜色
  646. borderColor: '#0296cf',
  647. borderWidth: 2,
  648. shadowColor: '#0296cf',
  649. shadowOffsetX: 0,
  650. shadowOffsetY: 0,
  651. shadowBlur: 0,
  652. emphasis: { // 地图悬停高亮样式
  653. disabled: true,
  654. areaColor: '#05498f'
  655. }
  656. },
  657. tooltip: {
  658. show: false
  659. }
  660. },
  661. {
  662. map: 'qiyang',
  663. aspectScale: 1,
  664. zoom: 1.1,
  665. top: '9%', // 根据自己需要来设置
  666. left: '9%',
  667. roam: false,
  668. z: 3, // 变小,也就是被压在下面
  669. itemStyle: {
  670. areaColor: 'rgba(3,106,183,.5)', // 记得改颜色
  671. borderColor: '#025792',
  672. borderWidth: 2,
  673. shadowColor: '#025792',
  674. shadowOffsetX: 0,
  675. shadowOffsetY: 0,
  676. shadowBlur: 0,
  677. emphasis: { // 地图悬停高亮样式
  678. areaColor: 'rgba(3,106,183,.5)'
  679. }
  680. },
  681. tooltip: {
  682. show: false
  683. }
  684. },
  685. {
  686. map: 'qiyang',
  687. aspectScale: 1,
  688. zoom: 1.1,
  689. top: '11%', // 根据自己需要来设置
  690. left: '8%',
  691. roam: false,
  692. z: 2, // 变小,也就是被压在下面
  693. itemStyle: {
  694. areaColor: 'rgba(3,106,183,.2)', // 记得改颜色
  695. borderColor: '#195175',
  696. borderWidth: 1,
  697. shadowColor: '#0f4c74',
  698. shadowOffsetX: 0,
  699. shadowOffsetY: 4,
  700. shadowBlur: 10,
  701. emphasis: { // 地图悬停高亮样式
  702. areaColor: 'rgba(3,106,183,.2)'
  703. }
  704. },
  705. tooltip: {
  706. show: false
  707. }
  708. },
  709. {
  710. map: 'qiyang',
  711. aspectScale: 1,
  712. zoom: 1.1,
  713. top: '12%', // 根据自己需要来设置
  714. left: '10%',
  715. roam: false,
  716. z: 1, // 变小,也就是被压在下面
  717. itemStyle: {
  718. areaColor: 'rgba(0,0,0,.6)', // 记得改颜色
  719. borderColor: 'rgba(0,0,0,.6)',
  720. borderWidth: 2,
  721. shadowColor: 'rgba(0,0,0,.6)',
  722. shadowOffsetX: 0,
  723. shadowOffsetY: 4,
  724. shadowBlur: 10,
  725. emphasis: { // 地图悬停高亮样式
  726. areaColor: 'rgba(0,0,0,.6)'
  727. }
  728. },
  729. tooltip: {
  730. show: false
  731. }
  732. }
  733. ],
  734. series: series
  735. },
  736. media: [
  737. {
  738. query: {
  739. maxWidth: 666
  740. },
  741. option: {
  742. tooltip: {
  743. position: function(point, params, dom, rect, size) {
  744. return [point[0] + 10, point[1] - 122]
  745. }
  746. }
  747. }
  748. }
  749. ]
  750. }
  751. setTimeout(() => {
  752. this.myChart.setOption(initOption)
  753. }, 200)
  754. },
  755. updateChart() {
  756. // 地图数据
  757. // const mapData = mapJson.features.map((item) => {
  758. // return {
  759. // name: item.properties.name,
  760. // value: Math.round(Math.random() * 100),
  761. // centroid: item.properties.centroid,
  762. // adcode: item.properties.adcode
  763. // }
  764. // })
  765. // 散点数据
  766. // const scatterData = libJsonData
  767. // const scatterData = mapData.map((item) => {
  768. // return {
  769. // name: item.name,
  770. // value: item.centroid
  771. // ? item.centroid.concat(item.value)
  772. // : item.centroid, // [经, 纬度, 值]
  773. // itemStyle: {
  774. // color: 'red'
  775. // }
  776. // // adcode: item.adcode,
  777. // }
  778. // })
  779. // const updateOption = {
  780. // series: [
  781. // {
  782. // data: mapData // type: 'map'
  783. // },
  784. // {
  785. // data: mapData // type: 'map'
  786. // },
  787. // {
  788. // data: scatterData // type: 'effectScatter'
  789. // }
  790. // ]
  791. // }
  792. this.len = this.seriesData[0].data.length // 此处设置的是需要轮播的次数
  793. // this.myChart.setOption(updateOption)
  794. this.libIndex = this.count % this.len
  795. this.libCurrent = this.libInfoData[this.libIndex]
  796. console.log('this.libIndex', this.libIndex)
  797. console.log('this.libCurrent22', this.libCurrent)
  798. this.initSwiper()
  799. this.updatePageWithData()
  800. this.autohover()
  801. },
  802. mouseMove() {
  803. // 当鼠标移入,终止轮播,高亮显示当前区域
  804. this.myChart.on('mouseover', (params) => {
  805. clearInterval(this.timeTicket)
  806. this.myChart.dispatchAction({
  807. type: 'downplay'
  808. // seriesIndex: 0
  809. })
  810. this.myChart.dispatchAction({
  811. type: 'highlight',
  812. seriesIndex: 0,
  813. dataIndex: params.dataIndex
  814. })
  815. this.myChart.dispatchAction({
  816. type: 'showTip',
  817. seriesIndex: 0,
  818. dataIndex: params.dataIndex
  819. })
  820. })
  821. // 当鼠标移出,轮播继续开始
  822. this.myChart.on('mouseout', this.autohover)
  823. },
  824. autohover() {
  825. // clearInterval(this.timeTicket)
  826. // this.timeTicket = setInterval(() => {
  827. // 1. 取消上次的高亮
  828. this.myChart.dispatchAction({
  829. type: 'downplay',
  830. seriesIndex: 0
  831. })
  832. // 2. 显示当前高亮
  833. this.myChart.dispatchAction({
  834. type: 'highlight',
  835. seriesIndex: 0,
  836. dataIndex: this.count % this.len
  837. })
  838. // 3. 显示提示框中的信息
  839. this.myChart.dispatchAction({
  840. type: 'showTip',
  841. seriesIndex: 0,
  842. dataIndex: this.count % this.len
  843. })
  844. // }, 2000)
  845. },
  846. resize() {
  847. this.myChart.resize()
  848. },
  849. updatePageWithData() {
  850. this.displayedImages = []
  851. const linkSrc = process.env.VUE_APP_BASE_API
  852. const params = {
  853. 'branchId': this.libCurrent.id
  854. }
  855. FetchLibcodeResouceDetails(params).then(res => {
  856. const result = JSON.parse(res.data)
  857. this.displayedImages = result.map((item, index) => {
  858. if (item.filePath) {
  859. item.cover = linkSrc + '/downloadFile' + item.filePath
  860. } else {
  861. item.cover = ''
  862. }
  863. return item
  864. })
  865. this.currentIndex = 0
  866. this.swiperKey += 1
  867. if (this.displayedImages.length === 1) {
  868. setTimeout(() => {
  869. this.count++
  870. this.libIndex = this.count % this.len
  871. this.libCurrent = this.libInfoData[this.libIndex]
  872. this.updatePageWithData()
  873. this.autohover()
  874. }, 5000)
  875. }
  876. }).catch(error => {
  877. console.error('Error', error)
  878. })
  879. },
  880. initSwiper() {
  881. const _self = this
  882. this.swiperOption = {
  883. // loop: true,
  884. // initialSlide: 0,
  885. notNextTick: false, // notNextTick是一个组件自有属性,如果notNextTick设置为true,组件则不会通过NextTick来实例化swiper,也就意味着你可以在第一时间获取到swiper对象,假如你需要刚加载遍使用获取swiper对象来做什么事,那么这个属性一定要是true
  886. // slidesPerView: 3, // 数量
  887. // spaceBetween: 30, // 间距
  888. // slidesPerGroup: 1, // 分几组
  889. // 禁止滑动
  890. noSwiping: true,
  891. observer: true, // 开启动态检查器
  892. direction: 'horizontal', // 设置水平还是垂直vertical
  893. // grabCursor: true, //光标样式
  894. // setWrapperSize: true,
  895. // autoHeight: true,
  896. // centeredSlides: true,
  897. // paginationClickable: true,
  898. // keyboard: true, //键盘控制
  899. // mousewheelControl: true, //鼠标轮控制
  900. autoplay: {
  901. delay: 3000, // 自动切换的时间间隔,单位ms
  902. stopOnLastSlide: false, // 当切换到最后一个slide时停止自动切换
  903. disableOnInteraction: false // 用户操作swiper之后,是否禁止autoplay
  904. // reverseDirection: false, //开启反向自动轮播
  905. // waitForTransition: true, //等待过渡完毕。自动切换会在slide过渡完毕后才开始计时
  906. },
  907. // 显示分页
  908. pagination: {
  909. el: '.swiper-pagination',
  910. type: 'progressbar'
  911. // progressbarOpposite: true,
  912. // clickable: true // 允许分页点击跳转
  913. },
  914. on: {
  915. slideChangeTransitionEnd() {
  916. _self.currentIndex = this.activeIndex
  917. if (_self.currentIndex === _self.displayedImages.length - 1) {
  918. setTimeout(() => {
  919. if (_self.count === _self.libInfoData.length - 1) {
  920. _self.count = 0
  921. // _self.$parent.autoPagination(3)
  922. } else {
  923. _self.count++
  924. }
  925. _self.libIndex = _self.count % _self.len
  926. _self.libCurrent = _self.libInfoData[_self.libIndex]
  927. console.log('_self.count', _self.count)
  928. console.log('_self.libIndex', _self.libIndex)
  929. console.log('_self.libCurrent', _self.libCurrent)
  930. _self.updatePageWithData()
  931. _self.autohover()
  932. _self.startScrolling()
  933. _self.currentIndex = 0
  934. }, 3000)
  935. }
  936. }
  937. }
  938. }
  939. }
  940. }
  941. }
  942. </script>
  943. <style lang="scss">
  944. @import "~@/assets/styles/index.scss";
  945. </style>
  946. <!--
  947. {
  948. type: 'map',
  949. map: 'qiyang',
  950. roam: false,
  951. silent: true,
  952. // geoIndex: 0, geoIndex 指定一个 geo 组件。这样的话,map 和 其他 series(例如散点图)就可以共享一个 geo 组件了。
  953. data: null,
  954. label: {
  955. show: false,
  956. fontSize: 0
  957. }
  958. },
  959. {
  960. name: item[0] + ' Top3',
  961. type: 'lines',
  962. zlevel: 1,
  963. effect: {
  964. show: true,
  965. period: 6,
  966. trailLength: 0.7,
  967. color: 'red', // arrow箭头的颜色
  968. symbolSize: 3
  969. },
  970. lineStyle: {
  971. normal: {
  972. color: color[i],
  973. width: 0,
  974. curveness: 0.2
  975. }
  976. },
  977. data: convertData(item[1])
  978. },
  979. {
  980. type: 'effectScatter',
  981. coordinateSystem: 'geo', // 注意坐标系的设置
  982. // symbol: 'image://' + require('../../assets/images/default-img.png'),
  983. data: null,
  984. symbolSize: [8, 4],
  985. showEffectOn: 'render',
  986. rippleEffect: {
  987. brushType: 'stroke',
  988. color: '#9ffcff',
  989. period: 9,
  990. scale: 5
  991. },
  992. label: {
  993. show: true,
  994. color: '#FFF',
  995. formatter: '',
  996. offset: [0, -12]
  997. },
  998. emphasis: {
  999. // 设置高亮显示的状态
  1000. scale: 8,
  1001. itemStyle: {
  1002. color: 'pink'
  1003. }
  1004. }
  1005. } -->