祁阳图书馆智慧大屏
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.

328 lines
10 KiB

1 year 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
12 months ago
1 year ago
11 months ago
12 months 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
1 year 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
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
11 months ago
12 months 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. <template>
  2. <div id="screen-container">
  3. <div v-if="isLoading" class="loading">
  4. <dv-loading>Loading...</dv-loading>
  5. </div>
  6. <!-- Header -->
  7. <Header :header-title="headerTitle" :current-index="currentIndex" :page-data="pageData" />
  8. <!-- <div class="header-page">{{ (currentIndex+1) +' / '+ pageData.length }}</div> -->
  9. <!-- 内容部分 -->
  10. <!-- <keep-alive>
  11. <PageOne v-if="currentIndex === 0" ref="pageOneRefs" />
  12. </keep-alive>
  13. <PageTwo v-if="currentIndex === 1" />
  14. <PageThree v-if="currentIndex=== 2" />
  15. <PageFour v-if="currentIndex === 3" /> -->
  16. <keep-alive>
  17. <component :is="currentPage && currentPage.title" />
  18. </keep-alive>
  19. <!-- bottom -->
  20. <div class="bottom-bg">
  21. <div class="bottom-content">
  22. <div class="dot-container left-dots">
  23. <div class="dot" />
  24. <div class="dot" />
  25. <div class="dot" />
  26. </div>
  27. <div class="dot-container right-dots">
  28. <div class="dot" />
  29. <div class="dot" />
  30. <div class="dot" />
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { FetchInitToken, FetchInitSetting } from '@/api/library'
  38. import Header from '@/views/header/index.vue'
  39. import PageOne from '@/views/pageOne/index.vue'
  40. import PageTwo from '@/views/map/index.vue'
  41. import PageThree from '@/views/pageThree/index.vue'
  42. import PageFour from '@/views/pageFour/index.vue'
  43. export default {
  44. name: 'Home',
  45. components: {
  46. Header,
  47. PageOne,
  48. PageTwo,
  49. PageThree,
  50. PageFour
  51. },
  52. inject: ['reload'],
  53. data() {
  54. return {
  55. currentIndex: 0, // 当前显示的页面索引
  56. currentPage: null, // 当前显示的页面数据
  57. isLoading: false,
  58. height: '',
  59. headerTitle: '祁阳陶铸图书馆智慧大屏馆情数据总览',
  60. pageData: [
  61. { id: 1, title: 'PageOne', delayed: 20, isShow: false },
  62. { id: 2, title: 'PageTwo', delayed: 20, isShow: false },
  63. { id: 3, title: 'PageThree', delayed: 20, isShow: false },
  64. { id: 4, title: 'PageFour', delayed: 20, isShow: false }
  65. ],
  66. swiperOption: null,
  67. loadingTtimer: null,
  68. timer2: null,
  69. leftTimer: null,
  70. middleTimer: null,
  71. deviceTimer: null,
  72. todayTimer: null,
  73. yearTimer: null,
  74. intervalId: null,
  75. orderIds: [],
  76. wecharQrCodeSrc: null
  77. }
  78. },
  79. computed: {
  80. shouldCacheComponent() {
  81. if (this.currentPage) {
  82. switch (this.currentPage.title) {
  83. case 'PageOne':
  84. return 'PageOne'
  85. case 'PageFour':
  86. return 'PageFour'
  87. default:
  88. return null
  89. }
  90. }
  91. return null
  92. },
  93. currentPageComponent() {
  94. if (this.currentPage) {
  95. switch (this.currentPage.title) {
  96. case 'PageTwo':
  97. return 'PageTwo'
  98. case 'PageThree':
  99. return 'PageThree'
  100. default:
  101. return null
  102. }
  103. }
  104. return null
  105. }
  106. },
  107. created() {
  108. // const METAWA = require('../assets/js/META.common.min.js')
  109. // const meta = new METAWA('665e845538d68')
  110. // meta.callback = (r) => {
  111. // console.log(r, '回调')
  112. // }
  113. this.getInitSetting()
  114. },
  115. beforeDestroy() {
  116. this.stopAutoSwitch()
  117. clearInterval(this.timer2)
  118. clearInterval(this.leftTimer)
  119. clearInterval(this.middleTimer)
  120. clearInterval(this.deviceTimer)
  121. clearInterval(this.todayTimer)
  122. clearInterval(this.yearTimer)
  123. this.middleTimer = null
  124. this.leftTimer = null
  125. this.deviceTimer = null
  126. this.todayTimer = null
  127. this.yearTimer = null
  128. },
  129. mounted() {
  130. // this.getToken()
  131. this.showLoading()
  132. },
  133. methods: {
  134. getToken() {
  135. const params = {
  136. 'appid': 'whfeitian',
  137. 'secret': '1f4unqcgg9j0pvx54cwvillch5xto9e5'
  138. }
  139. FetchInitToken(params).then(res => {
  140. console.log(res)
  141. })
  142. },
  143. startPageSwitch() {
  144. const delay = parseInt(this.pageData[this.currentIndex].delayed) * 1000
  145. this.intervalId = setInterval(() => {
  146. this.currentIndex++
  147. if (this.currentIndex >= this.pageData.length) {
  148. this.currentIndex = 0
  149. }
  150. const index = this.currentIndex % this.pageData.length
  151. this.currentPage = this.pageData[index]
  152. }, delay)
  153. },
  154. getInitSetting() {
  155. // selectorder 显示的屏和顺序 1第一屏 2第二屏
  156. // show1 第一屏显示时间
  157. // show2 第二屏显示时间
  158. const linkSrc = process.env.VUE_APP_BASE_API
  159. FetchInitSetting().then(res => {
  160. const result = JSON.parse(res.data)
  161. this.wecharQrCodeSrc = linkSrc + '/downloadFile' + result.wecharQrCode
  162. localStorage.setItem('wecharQrCodeSrc', this.wecharQrCodeSrc)
  163. const selectorder = result.selectorder
  164. const showDurations = { 1: result.show1, 2: result.show2, 3: result.show3, 4: result.show4 }
  165. this.orderIds = selectorder.split(',').map(id => parseInt(id.trim()))
  166. const updatedPageData = this.orderIds.map((id, index) => {
  167. const pageIndex = this.pageData.findIndex(item => item.id === id)
  168. if (pageIndex !== -1) {
  169. const updatedPage = {
  170. ...this.pageData[pageIndex],
  171. isShow: true,
  172. delayed: showDurations[id]
  173. }
  174. return updatedPage
  175. } else {
  176. console.log(`ID 为 ${id} 的页面未找到。`)
  177. return null
  178. }
  179. }).filter(item => item !== null)
  180. this.pageData = updatedPageData
  181. if (this.pageData) {
  182. this.currentPage = this.pageData[this.currentIndex]
  183. this.startPageSwitch()
  184. }
  185. }).catch(error => {
  186. console.error('Error', error)
  187. setTimeout(() => {
  188. this.reload()
  189. }, 5000)
  190. })
  191. },
  192. stopAutoSwitch() {
  193. clearInterval(this.intervalId)
  194. this.intervalId = null
  195. },
  196. goToNextPage() {
  197. this.currentPage = (this.currentPage + 1) % 4
  198. this.stopAutoSwitch() // 停止自动切换,以免与手动切换冲突
  199. // 设置定时器,恢复自动切换
  200. // setTimeout(() => {
  201. // this.startAutoSwitch()
  202. // }, 200000)
  203. },
  204. showLoading() {
  205. this.isLoading = true
  206. this.loadingTtimer = setTimeout(() => {
  207. this.isLoading = false
  208. window.clearTimeout(this.loadingTtimer)
  209. }, 1500)
  210. },
  211. // 数字3位数加分隔符
  212. formatter(str) {
  213. const reg = /(?=(?!\b)(\d{3})+$)/g
  214. return str.toString().replace(reg, ',')
  215. },
  216. // 设置文字滚动
  217. setNumberTransform(item) {
  218. const numberItems = document.querySelectorAll(`.${item.id} i`)
  219. // const numberItems = this.$refs[`${item.id}`]
  220. const numberArr = item.valueArr.filter(item => !isNaN(item))
  221. numberItems.forEach((t) => {
  222. t.style.transition = 'transform 0s ease-in-out'
  223. t.style.transform = `translateY(-0%)`
  224. })
  225. setTimeout(() => {
  226. numberItems.forEach((ls, index) => {
  227. ls.style.transition = 'transform 1s ease-in-out'
  228. ls.style.transform = `translateY(-${numberArr[index] * 10}%)`
  229. })
  230. }, 15)
  231. },
  232. // 定时
  233. initInterval(targetList, time) {
  234. const { setNumberTransform } = this
  235. return setInterval((function fn() {
  236. targetList.forEach(t => {
  237. setTimeout(() => {
  238. setNumberTransform(t)
  239. }, 50)
  240. })
  241. return fn
  242. })(), time)
  243. },
  244. // 定时刷新数字翻牌器
  245. timedRefresh(targetList, type) {
  246. if (type === 'middle') {
  247. this.middleTimer = this.initInterval2(targetList, 8000)
  248. } else if (type === 'left') {
  249. this.leftTimer = this.initInterval(targetList, 10000)
  250. } else if (type === 'device') {
  251. this.deviceTimer = this.initInterval(targetList, 8000)
  252. } else if (type === 'todayTotal') {
  253. this.todayTimer = this.initInterval(targetList, 8000)
  254. } else if (type === 'yearTotal') {
  255. this.yearTimer = this.initInterval(targetList, 10000)
  256. }
  257. this.$once('hook:beforeDestroy', () => {
  258. clearInterval(this.leftTimer)
  259. clearInterval(this.middleTimer)
  260. clearInterval(this.deviceTimer)
  261. clearInterval(this.todayTimer)
  262. clearInterval(this.yearTimer)
  263. this.middleTimer = null
  264. this.leftTimer = null
  265. this.deviceTimer = null
  266. this.todayTimer = null
  267. this.yearTimer = null
  268. })
  269. },
  270. setNumberTransform2(item) {
  271. var numberItems = document.querySelectorAll(`.${item.id} i`)
  272. const numberArr = item.valueArr.filter(item => !isNaN(item))
  273. for (var index = 0; index < numberItems.length; index++) {
  274. const elem = numberItems[index]
  275. elem.style.transition = 'transform 0s ease-in-out'
  276. elem.style.transform = `translate(-50%,-0%)`
  277. }
  278. setTimeout(() => {
  279. for (var index = 0; index < numberItems.length; index++) {
  280. const elem = numberItems[index]
  281. elem.style.transition = 'transform 1s ease-in-out'
  282. elem.style.transform = 'translate(-50%, -' + numberArr[index] * 10 + '%)'
  283. }
  284. }, 15)
  285. },
  286. // 定时
  287. initInterval2(targetList, time) {
  288. const { setNumberTransform2 } = this
  289. return setInterval((function fn() {
  290. targetList.forEach(t => {
  291. setTimeout(() => {
  292. setNumberTransform2(t)
  293. }, 50)
  294. })
  295. return fn
  296. })(), time)
  297. }
  298. }
  299. }
  300. </script>
  301. <style lang="scss">
  302. @import "~@/assets/styles/index.scss";
  303. .swiper-home{
  304. .swiper-wrapper{
  305. transition-timing-function: ease-in-out !important;
  306. }
  307. .swiper-slide{
  308. position: relative;
  309. width: 100%;
  310. overflow: hidden;
  311. }
  312. .swiper-pagination-home{
  313. position: fixed;
  314. top: .2rem;
  315. left: calc( 100% - 2rem);
  316. font-size: .4rem;
  317. }
  318. }
  319. </style>