diff --git a/src/api/library.js b/src/api/library.js index 57d374c..68f945a 100644 --- a/src/api/library.js +++ b/src/api/library.js @@ -154,6 +154,15 @@ export function FetchTotalResource(params) { }) } +// page4 获取视频 +export function FetchVideo(params) { + return request({ + url: '/api/fileRelevant/getVideo' + '?' + qs.stringify(params, { indices: false }), + method: 'get', + urlType: 'local' + }) +} + // 获取当日每小时借还信息 export function FetchTodayJH(params) { return request({ @@ -189,6 +198,7 @@ export default { FetchNoticeList, FetchSync36, FetchTotalResource, + FetchVideo, FetchTodayJH, FetchWeekJH } diff --git a/src/main.js b/src/main.js index ad36a9c..022317a 100644 --- a/src/main.js +++ b/src/main.js @@ -71,26 +71,21 @@ const app = new Vue({ // 处理路由参数并挂载应用 router.onReady(() => { try { - // 获取路由参数(query或params) const route = router.currentRoute const libcode = route.query.libcode || route.params.libcode - // 更新Vuex状态 if (libcode) { store.commit('SET_LIBCODE', libcode) } else { - // 使用默认值(可选) - store.commit('SET_LIBCODE', '1501') + store.commit('SET_LIBCODE', '1201') } } catch (error) { console.error('处理路由参数时出错:', error) } finally { - // 确保应用最终会挂载 app.$mount('#app') } }) -// 路由切换时更新libcode router.beforeEach((to, from, next) => { try { const newLibcode = to.query.libcode || to.params.libcode @@ -100,5 +95,5 @@ router.beforeEach((to, from, next) => { } catch (error) { console.error('路由切换时更新libcode出错:', error) } - next() // 必须调用next(),否则路由会被阻塞 + next() }) diff --git a/src/views/map/index.vue b/src/views/map/index.vue index 7114376..4cd5560 100644 --- a/src/views/map/index.vue +++ b/src/views/map/index.vue @@ -133,19 +133,25 @@ export default { return this.$refs.mySwiper.swiper } }, + watch: { + baseSetting: { + handler(result) { + if (!result) return + + this.activatedBaseSetting = result + if (result.open_lib_appId && result.open_lib_secret && result.open_lib_http) { + this.getLibBookTotal(this.activatedBaseSetting) + this.getReadRanking(this.activatedBaseSetting) + this.getLendingTotal(this.activatedBaseSetting) + } + }, + immediate: true + } + }, beforeDestroy() { this.destroy() }, created() { - this.$watch('baseSetting', (newVal, oldVal) => { - console.log('baseSetting 变化:', newVal) - if (newVal && Object.keys(newVal).length > 0) { - this.activatedBaseSetting = newVal - this.getLibBookTotal(this.activatedBaseSetting) - this.getReadRanking(this.activatedBaseSetting) - this.getLendingTotal(this.activatedBaseSetting) - } - }, { immediate: true }) }, activated() { // this.getLibBookTotal(this.activatedBaseSetting) diff --git a/src/views/mixins/index.js b/src/views/mixins/index.js index 7dac441..4f3bc26 100644 --- a/src/views/mixins/index.js +++ b/src/views/mixins/index.js @@ -20,7 +20,8 @@ export const pageCrud = { orderIds: [], updateTime: '', oldUpdateTime: JSON.parse(localStorage.getItem('updateTime')) || '', - welcomeData: [] + welcomeData: [], + videoData: [] } }, computed: { @@ -65,7 +66,6 @@ export const pageCrud = { }, // 组件挂载时的共用方法 mounted() { - // this.useLibcode() }, // 组件共用方法 methods: { @@ -80,6 +80,7 @@ export const pageCrud = { const result = res.data.settings this.baseSetting = res.data.settings this.welcomeData = res.data.screenWelcomePromotions + this.videoData = res.data.screenPromotionVideos // this.wecharQrCodeSrc = linkSrc + '/downloadFile' + result.wecharQrCode this.wecharQrCodeSrc = result.wechar_qr_code.context localStorage.setItem('wecharQrCodeSrc', this.wecharQrCodeSrc) diff --git a/src/views/pageFive/index.vue b/src/views/pageFive/index.vue index 44f7b34..9556893 100644 --- a/src/views/pageFive/index.vue +++ b/src/views/pageFive/index.vue @@ -55,15 +55,12 @@ export default { }, baseSetting: { handler(newVal) { - // 从baseSetting中获取welcome_play配置并转换为毫秒 if (newVal && newVal.welcome_play) { - // 将字符串转换为数字,乘以1000转换为毫秒,确保是有效数字 const seconds = parseInt(newVal.welcome_play.context, 10) - // 确保数值合理(1-60秒之间),否则使用默认值 if (!isNaN(seconds) && seconds > 0 && seconds <= 60) { this.carouselInterval = seconds * 1000 } else { - this.carouselInterval = 5000 // 无效值时使用默认5秒 + this.carouselInterval = 5000 } console.log('this.carouselInterval', this.carouselInterval) } diff --git a/src/views/pageFour/index.vue b/src/views/pageFour/index.vue index 0024f4a..fddccb4 100644 --- a/src/views/pageFour/index.vue +++ b/src/views/pageFour/index.vue @@ -88,7 +88,7 @@