From e39204acff67d6cd0afefb02b1f1b44ee07bf71c Mon Sep 17 00:00:00 2001 From: wangxia <779219182@qq.com> Date: Tue, 12 Aug 2025 15:39:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 33 +++++++++++++++++++++++++++++++++ pages/home/index.vue | 3 ++- pages/person/index.vue | 3 ++- pages/workBench/index.vue | 1 + utils/common.js | 3 +++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/App.vue b/App.vue index eb85fd9..e0b5cf6 100644 --- a/App.vue +++ b/App.vue @@ -16,6 +16,38 @@ export default { onLaunch() { let that = this; uni.removeStorageSync("selectedCity"); + // 可能只在小程序生效的监听方法 + // uni.onBeforeAppRoute((res) => { + // console.log("setNavStyle", res); + // try { + // that.G.Post("/common/user/browsing/history/addRecord", { browsingUrl: res.path }, (res) => {}); + // } catch (error) { + // console.log("error", error); + // } + // }); + // 监听路由跳转 + uni.addInterceptor("navigateTo", { + // 跳转前拦截 + invoke(args) { + console.log("navigateTo 跳转前", args); + that.G.watchUserPage(args.url); + }, + }); + uni.addInterceptor("reLaunch", { + // 跳转前拦截 + invoke(args) { + console.log("reLaunch 跳转前", args); + that.G.watchUserPage(args.url); + }, + }); + uni.addInterceptor("redirectTo", { + // 跳转前拦截 + invoke(args) { + console.log("redirectTo 跳转前", args); + that.G.watchUserPage(args.url); + }, + }); + }, onShow: function (options) { let that = this; @@ -77,6 +109,7 @@ export default { } }, methods: { + initWyyx() { let that = this; diff --git a/pages/home/index.vue b/pages/home/index.vue index 086d092..8285bcc 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -350,6 +350,7 @@ export default { this.agencyInfo = uni.getStorageSync("agencyInfo"); this.userInfo = uni.getStorageSync("apply-userinfo"); that.loadSelectedCityFromCache(); + that.G.watchUserPage("pages/home/index"); } }, @@ -440,7 +441,7 @@ export default { // res.recordList = []; // if (res.recordCount == 0) { - that.loading = false; + that.loading = false; // } else { // that.loading = true; // } diff --git a/pages/person/index.vue b/pages/person/index.vue index cafe789..6059066 100644 --- a/pages/person/index.vue +++ b/pages/person/index.vue @@ -352,6 +352,7 @@ export default { this.getCompanyInfo(); } }); + that.G.watchUserPage("pages/person/index"); // that.userInfo = uni.getStorageSync("apply-userinfo"); } else { that.waitNum_ups = 0; @@ -375,7 +376,7 @@ export default { getNewApplyNum() { let that = this; this.G.Get(this.api.order_getNewApplyNumNotViewed, {}, (res) => { - console.log(res, "getNewApplyNum"); + console.log(res, "getNewApplyNum"); that.applyNum = res; }); }, diff --git a/pages/workBench/index.vue b/pages/workBench/index.vue index 149c5a4..34cac64 100644 --- a/pages/workBench/index.vue +++ b/pages/workBench/index.vue @@ -202,6 +202,7 @@ export default { this.getList(); } this.getGZHInfo(); + that.G.watchUserPage("pages/workBench/index"); }, onReachBottom() { let that = this; diff --git a/utils/common.js b/utils/common.js index f6a40ec..2fa735d 100644 --- a/utils/common.js +++ b/utils/common.js @@ -160,6 +160,8 @@ let data = { /* 设置导航条 */ setNavStyle ($form = 'default') { + console.log('into setNavStyle'); + if ($form == 'home') { uni.setNavigationBarColor({ backgroundColor: "#fff", @@ -1572,6 +1574,7 @@ let data = { } return str; }, + } export default data; From 185651ef475779a62f510c26d86152e349fe8e3a Mon Sep 17 00:00:00 2001 From: wangxia <779219182@qq.com> Date: Tue, 12 Aug 2025 15:45:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 12 +++--------- utils/ajax.js | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/App.vue b/App.vue index e0b5cf6..f42a097 100644 --- a/App.vue +++ b/App.vue @@ -47,7 +47,6 @@ export default { that.G.watchUserPage(args.url); }, }); - }, onShow: function (options) { let that = this; @@ -79,14 +78,10 @@ export default { this.G.checkToken(); } if (!that.globalData.timer) { - if (uni.getStorageSync("apply-token")) { - that.checkNum(); - } + that.checkNum(); that.globalData.timer = setInterval(() => { - console.log("inner++++++++++++++++++++ +++++++++++++++++++++++++++"); - if (uni.getStorageSync("apply-token")) { - that.checkNum(); - } + console.log("inner+++++++++++++++++++++++++++++++++++++++++++++++"); + that.checkNum(); }, 30 * 1000); } @@ -109,7 +104,6 @@ export default { } }, methods: { - initWyyx() { let that = this; diff --git a/utils/ajax.js b/utils/ajax.js index aadb6c7..5328da7 100644 --- a/utils/ajax.js +++ b/utils/ajax.js @@ -48,7 +48,7 @@ let data = { } // #endif params = { - 'requestComeFrom':'assistant_miniapp', + 'requestComeFrom': 'assistant_miniapp', // #ifdef APP-PLUS 'g-open-env': 'APP-PLUS', appId: uuid_new, @@ -116,7 +116,7 @@ let data = { // console.log('测试报错123123123123123123',res); // console.log('测试报错123123123123123123$url',$url); let resData = res.data; - + if (resData.status == 200) {// 正常 callback(resData.data, resData.msg); } else if (resData.status == 9999) {// 登录过期或者身份变动等需要登录的场景 @@ -138,14 +138,14 @@ let data = { // } else { uni.showToast({ title: resData.msg, - // title:'系统异常,请稍后', + // title:'系统异常,请稍后', icon: "none" }); failback(resData.msg); // } } else if (resData.status == 2002) { uni.showToast({ - title:'已切换团队,需要重新登录', + title: '已切换团队,需要重新登录', icon: "none" }); setTimeout(() => { @@ -154,23 +154,23 @@ let data = { }); }, 1500); } else {// 其他异常 - if($url == '/yishoudan/user/apply/order/V2/details'){ - - }else{ - uni.showToast({ - title: resData.msg, - icon: "none" - }); - } - - + if ($url == '/yishoudan/user/apply/order/V2/details') { + + } else { + uni.showToast({ + title: resData.msg, + icon: "none" + }); + } + + failback(resData.msg); } }, fail (error) { uni.showToast({ // title: error.errMsg, - title:'系统异常,请稍后', + title: '系统异常,请稍后', icon: "none" }) failback(error); @@ -211,6 +211,17 @@ let data = { }; } }, + //监听用户的页面点击 + watchUserPage (path) { + let that = this; + try { + if (uni.getStorageSync("apply-userinfo")) { + that.Post("/common/user/browsing/history/addRecord", { browsingUrl: path }, (res) => { }); + } + } catch (error) { + console.log("error", error); + } + }, }; export default data; \ No newline at end of file