From 84c5ede7259be4a1edfcff0254b3e617f0eb1f46 Mon Sep 17 00:00:00 2001 From: lifizer <913626195@qq.com> Date: Thu, 16 May 2024 17:23:07 +0800 Subject: [PATCH] =?UTF-8?q?Feat(=E9=A1=B5=E9=9D=A2):=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=89=93=E5=BC=80=E6=AC=A1=E6=95=B0=E5=92=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=81=9C=E7=95=99=E6=97=B6=E9=95=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/page.js | 6 ++ main.js | 4 +- mixins/pageListenMixins.js | 33 ++++++++ pages/home/index.vue | 11 ++- pages/home/landMark.vue | 153 +++++++++++++++++++----------------- pages/user/Points/index.vue | 4 +- utils/util.js | 35 +++++++++ 7 files changed, 167 insertions(+), 79 deletions(-) create mode 100644 config/page.js create mode 100644 mixins/pageListenMixins.js diff --git a/config/page.js b/config/page.js new file mode 100644 index 0000000..7f1f01d --- /dev/null +++ b/config/page.js @@ -0,0 +1,6 @@ +export const pageToWatchData = { + 'home_index': { + count: 0, + timer: 0 + } +} diff --git a/main.js b/main.js index 1c18df1..6fa3b48 100644 --- a/main.js +++ b/main.js @@ -16,6 +16,7 @@ import { } from "@/config"; import uView from "uview-ui"; import GooSkeleton from '@/components/GooSkeleton/index.vue' +import { pageToWatchData } from '@/config/page' Vue.use(uView) Vue.component('GooSkeleton', GooSkeleton) @@ -32,7 +33,8 @@ Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL Vue.prototype.$STATIC_RESOURCE_URL = STATIC_RESOURCE_URL Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL Vue.prototype.$WX_LIVE_APPID = WX_LIVE_APPID -Vue.prototype.$global = global; +Vue.prototype.$global = global +Vue.prototype.$pageToWatchData = pageToWatchData Vue.prototype.$validator = function (rule) { return new schema(rule); diff --git a/mixins/pageListenMixins.js b/mixins/pageListenMixins.js new file mode 100644 index 0000000..c811663 --- /dev/null +++ b/mixins/pageListenMixins.js @@ -0,0 +1,33 @@ +import { + pageToWatchShowCount, + pageToWatchShowTimer +} from '@/utils/util' +export const pageListenMixins = { + data(){ + return { + pageTimer: null + } + }, + onShow() { + this.pageToWatchShowCount(this.pageKeyId, this.pageShowTimerFn()) + }, + onHide() { + this.clearPageTimerFn() + }, + methods: { + pageToWatchShowCount, + pageToWatchShowTimer, + pageShowTimerFn() { + this.pageTimer = setInterval(() => { + console.log('----页面监听----%s', this.pageKeyId) + this.pageToWatchShowTimer(this.pageKeyId) + }, 1000) + }, + clearPageTimerFn() { + if (this.pageTimer) { + console.log('清除页面监听-----%s', this.pageKeyId) + clearInterval(this.pageTimer) + } + } + } +} \ No newline at end of file diff --git a/pages/home/index.vue b/pages/home/index.vue index 261b33f..92e5382 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -250,6 +250,8 @@ import {getProducts} from "@/api/store"; import {sharpBannar} from "@/api/goods"; import NP from "number-precision"; +import { pageListenMixins } from '@/mixins/pageListenMixins' + var that; export default { name: 'Index', @@ -260,8 +262,7 @@ export default { CountDown, hxNavbar }, - computed: mapGetters(["userInfo", 'isLogin']), - props: {}, + mixins: [pageListenMixins], data: function () { return { currentIndex: 0, @@ -378,9 +379,11 @@ export default { contentHomestay: {}, contentFestival: {}, countyFamous: {}, - seasonalFood: {} - }; + seasonalFood: {}, + pageKeyId: Object.freeze('home_index') + } }, + computed: mapGetters(["userInfo", 'isLogin']), onLoad: function (options) { that = this; this.init(); diff --git a/pages/home/landMark.vue b/pages/home/landMark.vue index cbec412..b9d80fe 100644 --- a/pages/home/landMark.vue +++ b/pages/home/landMark.vue @@ -1,8 +1,87 @@ + + - -