From f4c8df1950726a962d42edc55d966e5356616f6a Mon Sep 17 00:00:00 2001 From: zoujiandong <10130823232@qq.com> Date: Wed, 3 Dec 2025 10:20:33 +0800 Subject: [PATCH] 111 --- App.vue | 58 ++++++++++++----------------- pages_app/hot/hot.vue | 32 ++++++++++------ pages_app/zhinanList/zhinanList.vue | 15 +++----- 3 files changed, 49 insertions(+), 56 deletions(-) diff --git a/App.vue b/App.vue index fb95f65..24113cd 100644 --- a/App.vue +++ b/App.vue @@ -22,32 +22,32 @@ export default { uni.setStorageSync("userInfo", options.referrerInfo.extraData.userInfo); //getApp({allowDefault: true}).globalData.apiHost = options.referrerInfo.extraData.apiHost; } - // if ( - // options && - // options.referrerInfo.extraData && - // options.referrerInfo.extraData.targetPath - // ) { - // uni.navigateTo({ - // url: options.referrerInfo.extraData.targetPath, - // }); - // } + if ( + options && + options.referrerInfo.extraData && + options.referrerInfo.extraData.targetPath + ) { + uni.navigateTo({ + url: options.referrerInfo.extraData.targetPath, + }); + } console.log("app传递登录信息onLaunch-------------------"); try { // #ifdef APP - // uni.onNativeEventReceive((event, data) => { - // console.log("app传递登录信息-------------------"); - // console.log("event数据"); - // console.log(event); - // console.log("data数据"); - // console.log(data); - // if (event.indexOf("loginInfo") > -1) { - // uni.setStorageSync("DEV_AUTH_TOKEN_App", data.token); - // uni.setStorageSync("userInfo", data.userInfo); - // console.log("获取token数据"); - // console.log(uni.getStorageSync("DEV_AUTH_TOKEN_App")); - // } - // }); + uni.onNativeEventReceive((event, data) => { + console.log("event", event); + console.log("data", data); + if (event.indexOf("clearToken") > -1) { + uni.setStorageSync("AUTH_TOKEN_App", ""); + plus.runtime.quit(); + } + if(event.indexOf("goPage") > -1){ + uni.navigateTo({ + url: data, + }); + } + }); // #endif } catch (error) { console.log("app传递登录信息error-------------------"); @@ -117,19 +117,7 @@ export default { // } // }, 1000) - uni.onNativeEventReceive((event, data) => { - console.log("event", event); - console.log("data", data); - if (event.indexOf("clearToken") > -1) { - uni.setStorageSync("AUTH_TOKEN_App", ""); - plus.runtime.quit(); - } - if(event.indexOf("goPage") > -1){ - uni.navigateTo({ - url: data, - }); - } - }); + let main = plus.android.runtimeMainActivity(); //为了防止快速点按返回键导致程序退出重写quit方法改为隐藏至后台 plus.runtime.quit = function () { diff --git a/pages_app/hot/hot.vue b/pages_app/hot/hot.vue index 926042c..3c5b9fe 100644 --- a/pages_app/hot/hot.vue +++ b/pages_app/hot/hot.vue @@ -398,17 +398,27 @@ const viewGuideline = (cell) => { console.log(downloadTasks.value); downloadTasks.value.forEach(item => { if(item.id == cell.uuid) { - uni.openDocument({ - filePath: item.localPath, - fileType: 'pdf', - success: () => console.log('打开成功'), - fail: (err) => { - uni.showToast({ - title: err, - icon: "none", - }); - } - }); + plus.runtime.openFile(item.localPath, function(e) { + console.log('打开成功'); + }, function(e) { + uni.showToast({ + title: '打开失败:' + e.message, + icon: "none", + duration: 2000, + }); + console.log('打开失败:' + e.message); + }); + // uni.openDocument({ + // filePath: item.localPath, + // fileType: 'pdf', + // success: () => console.log('打开成功'), + // fail: (err) => { + // uni.showToast({ + // title: err, + // icon: "none", + // }); + // } + // }); } }); diff --git a/pages_app/zhinanList/zhinanList.vue b/pages_app/zhinanList/zhinanList.vue index c22a25e..3422be1 100644 --- a/pages_app/zhinanList/zhinanList.vue +++ b/pages_app/zhinanList/zhinanList.vue @@ -458,16 +458,11 @@ const viewGuideline = (cell) => { plus.runtime.openFile(item.localPath, function(e) { console.log('打开成功'); }, function(e) { - uni.showModal({ - title: '提示', - content: JSON.stringify(e), - showCancel: false, - confirmText: '确定', - success: (res) => { - if(res.confirm){ - } - } - }); + uni.showToast({ + title: '打开失败:' + e.message, + icon: "none", + duration: 2000, + }); console.log('打开失败:' + e.message); }); // uni.openDocument({