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

304 lines
9.1 KiB

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
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
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 :header-title="headerTitle" />
  7. <div class="header-page" @click="goToNextPage">{{ (currentPage+1) +' / '+ pageData.length }}</div>
  8. <section ref="sectionRef">
  9. <keep-alive>
  10. <PageOne v-if="currentPage === 0" ref="user" />
  11. </keep-alive>
  12. <Map v-if="currentPage === 1" />
  13. <PageThree v-if="currentPage === 2" />
  14. <PageFour v-if="currentPage === 3" />
  15. </section>
  16. <div class="bottom-bg">
  17. <div class="bottom-content">
  18. <div class="dot-container left-dots">
  19. <div class="dot" />
  20. <div class="dot" />
  21. <div class="dot" />
  22. </div>
  23. <div class="dot-container right-dots">
  24. <div class="dot" />
  25. <div class="dot" />
  26. <div class="dot" />
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import Header from '@/views/header/index.vue'
  34. import PageOne from '@/views/pageOne/index.vue'
  35. import Map from '@/views/map/index.vue'
  36. import PageThree from '@/views/pageThree/index.vue'
  37. import PageFour from '@/views/pageFour/index.vue'
  38. export default {
  39. name: 'Home',
  40. components: {
  41. Header,
  42. PageOne,
  43. Map,
  44. PageThree,
  45. PageFour
  46. },
  47. data() {
  48. return {
  49. currentPage: 0,
  50. isLoading: false,
  51. height: '',
  52. headerTitle: '祁阳陶铸图书馆智慧大屏馆情数据总览',
  53. pageData: [
  54. {
  55. id: 1, title: 'page1', delayed: 10
  56. },
  57. {
  58. id: 2, title: 'page2', delayed: 0
  59. },
  60. {
  61. id: 3, title: 'page3', delayed: 10
  62. },
  63. {
  64. id: 4, title: 'page4', delayed: 0
  65. }
  66. ],
  67. swiperOption: null,
  68. loadingTtimer: null,
  69. timer2: null,
  70. leftTimer: null,
  71. middleTimer: null,
  72. deviceTimer: null,
  73. todayTimer: null,
  74. yearTimer: null,
  75. intervalId: null // 用于存储定时器的ID
  76. }
  77. },
  78. computed: {
  79. },
  80. created() {
  81. // const METAWA = require('../assets/js/META.common.min.js')
  82. // const meta = new METAWA('665e845538d68')
  83. // meta.callback = (r) => {
  84. // console.log(r, '回调')
  85. // }
  86. this.startAutoSwitch()
  87. },
  88. beforeDestroy() {
  89. clearInterval(this.timer2)
  90. this.stopAutoSwitch()
  91. // window.removeEventListener('resize', this.setElementHeight)
  92. },
  93. mounted() {
  94. this.showLoading()
  95. // this.setElementHeight()
  96. // window.addEventListener('resize', this.setElementHeight)
  97. this.$once('hook:beforeDestroy', () => {
  98. clearInterval(this.timer2)
  99. // window.removeEventListener('resize', this.setElementHeight)
  100. })
  101. },
  102. methods: {
  103. startAutoSwitch() {
  104. this.intervalId = setInterval(() => {
  105. this.currentPage = (this.currentPage + 1) % 4
  106. }, 20000)
  107. },
  108. stopAutoSwitch() {
  109. clearInterval(this.intervalId)
  110. },
  111. goToNextPage() {
  112. this.currentPage = (this.currentPage + 1) % 4
  113. this.stopAutoSwitch() // 停止自动切换,以免与手动切换冲突
  114. if (this.currentPageIndex === 3) {
  115. this.autoplayVideo = false // 切换到视频页面时停止自动播放视频
  116. } else {
  117. this.autoplayVideo = true // 切换到其他页面时继续自动播放视频
  118. }
  119. // 设置定时器,恢复自动切换
  120. // setTimeout(() => {
  121. // this.startAutoSwitch()
  122. // }, 200000)
  123. },
  124. autoPagination(page) {
  125. // this.currentPage = page
  126. console.log('page:', page)
  127. if (page > this.pageData.length) {
  128. page = 1
  129. }
  130. this.currentPage = page
  131. console.log('当前页:', this.currentPage)
  132. // if (this.currentPage === 1 || this.currentPage === 3) {
  133. // clearInterval(this.timer2)
  134. // this.timer2 = setInterval(() => {
  135. // setTimeout(() => {
  136. // this.autoPagination(this.currentPage + 1)
  137. // }, 0)
  138. // }, 8000)
  139. // }
  140. // if (this.currentPage >= this.pageData.length) {
  141. // this.currentPage = 1
  142. // } else {
  143. // this.currentPage = active + 1
  144. // }
  145. // console.log('changePage', this.active)
  146. // if (this.currentPage < this.pageData.length) {
  147. // if (this.currentPage === 1 || this.currentPage === 3) {
  148. // clearInterval(this.timer2)
  149. // this.timer2 = setInterval(() => {
  150. // setTimeout(() => {
  151. // this.active = this.currentPage + 1
  152. // }, 0)
  153. // }, 10000)
  154. // } else {
  155. // this.active = this.currentPage + 1
  156. // }
  157. // } else {
  158. // this.active = 1
  159. // }
  160. this.$once('hook:beforeDestroy', () => {
  161. clearInterval(this.timer2)
  162. clearInterval(this.leftTimer)
  163. clearInterval(this.middleTimer)
  164. clearInterval(this.deviceTimer)
  165. clearInterval(this.todayTimer)
  166. clearInterval(this.yearTimer)
  167. this.middleTimer = null
  168. this.leftTimer = null
  169. this.deviceTimer = null
  170. this.todayTimer = null
  171. this.yearTimer = null
  172. })
  173. },
  174. showLoading() {
  175. this.isLoading = true
  176. this.loadingTtimer = setTimeout(() => {
  177. this.isLoading = false
  178. window.clearTimeout(this.loadingTtimer)
  179. }, 1500)
  180. },
  181. // 设置DOM高度
  182. setElementHeight() {
  183. clearTimeout(this.loadingTtimer)
  184. this.loadingTtimer = setTimeout(() => {
  185. this.showLoading()
  186. this.height = `${(this.$refs.sectionRef.offsetHeight - 30) / 3}px`
  187. }, 100)
  188. },
  189. // 数字3位数加分隔符
  190. formatter(str) {
  191. const reg = /(?=(?!\b)(\d{3})+$)/g
  192. return str.toString().replace(reg, ',')
  193. },
  194. // 设置文字滚动
  195. setNumberTransform(item) {
  196. const numberItems = document.querySelectorAll(`.${item.id} i`)
  197. // const numberItems = this.$refs[`${item.id}`]
  198. const numberArr = item.valueArr.filter(item => !isNaN(item))
  199. numberItems.forEach((t) => {
  200. t.style.transition = 'transform 0s ease-in-out'
  201. t.style.transform = `translateY(-0%)`
  202. })
  203. setTimeout(() => {
  204. numberItems.forEach((ls, index) => {
  205. ls.style.transition = 'transform 0.8s ease-in-out'
  206. ls.style.transform = `translateY(-${numberArr[index] * 10}%)`
  207. })
  208. }, 15)
  209. },
  210. // 定时
  211. initInterval(targetList, time) {
  212. const { setNumberTransform } = this
  213. return setInterval((function fn() {
  214. targetList.forEach(t => {
  215. setTimeout(() => {
  216. setNumberTransform(t)
  217. }, 50)
  218. })
  219. return fn
  220. })(), time)
  221. },
  222. // 定时刷新数字翻牌器
  223. timedRefresh(targetList, type) {
  224. if (type === 'middle') {
  225. this.middleTimer = this.initInterval2(targetList, 8000)
  226. } else if (type === 'left') {
  227. this.leftTimer = this.initInterval(targetList, 10000)
  228. } else if (type === 'device') {
  229. this.deviceTimer = this.initInterval(targetList, 8000)
  230. } else if (type === 'todayTotal') {
  231. this.todayTimer = this.initInterval(targetList, 8000)
  232. } else if (type === 'yearTotal') {
  233. this.yearTimer = this.initInterval(targetList, 10000)
  234. }
  235. this.$once('hook:beforeDestroy', () => {
  236. clearInterval(this.leftTimer)
  237. clearInterval(this.middleTimer)
  238. clearInterval(this.deviceTimer)
  239. clearInterval(this.todayTimer)
  240. clearInterval(this.yearTimer)
  241. this.middleTimer = null
  242. this.leftTimer = null
  243. this.deviceTimer = null
  244. this.todayTimer = null
  245. this.yearTimer = null
  246. })
  247. },
  248. setNumberTransform2(item) {
  249. var numberItems = document.querySelectorAll(`.${item.id} i`)
  250. const numberArr = item.valueArr.filter(item => !isNaN(item))
  251. for (var index = 0; index < numberItems.length; index++) {
  252. const elem = numberItems[index]
  253. elem.style.transition = 'transform 0s ease-in-out'
  254. elem.style.transform = `translate(-50%,-0%)`
  255. }
  256. setTimeout(() => {
  257. for (var index = 0; index < numberItems.length; index++) {
  258. const elem = numberItems[index]
  259. elem.style.transition = 'transform 1s ease-in-out'
  260. elem.style.transform = 'translate(-50%, -' + numberArr[index] * 10 + '%)'
  261. }
  262. }, 15)
  263. },
  264. // 定时
  265. initInterval2(targetList, time) {
  266. const { setNumberTransform2 } = this
  267. return setInterval((function fn() {
  268. targetList.forEach(t => {
  269. setTimeout(() => {
  270. setNumberTransform2(t)
  271. }, 50)
  272. })
  273. return fn
  274. })(), time)
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss">
  280. @import "~@/assets/styles/index.scss";
  281. .swiper-home{
  282. .swiper-wrapper{
  283. transition-timing-function: ease-in-out !important;
  284. }
  285. .swiper-slide{
  286. position: relative;
  287. width: 100%;
  288. overflow: hidden;
  289. }
  290. .swiper-pagination-home{
  291. position: fixed;
  292. top: .2rem;
  293. left: calc( 100% - 2rem);
  294. font-size: .4rem;
  295. }
  296. }
  297. </style>