diff --git a/src/pages/detail/index.vue b/src/pages/detail/index.vue index da8c513..1846017 100644 --- a/src/pages/detail/index.vue +++ b/src/pages/detail/index.vue @@ -145,12 +145,14 @@ const backScan = () => { closeWebview(); }; const runTimeEnv = () => { - if (plus) { - const currentWebView = plus.webview.getWebviewById("wv"); - return currentWebView.RunTime === "app"; - } else { - return false; - } + try { + if (plus) { + const currentWebView = plus.webview.getWebviewById("wv"); + return currentWebView.RunTime === "app"; + } else { + return false; + } + } catch (e) {} }; const getBtngetRules = async () => { const res = await getRules({}); diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 1a6ba7a..4769b9d 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -128,7 +128,7 @@ onLoad((options) => { // 已经登录了 if ( uni.getStorageSync("token") || - plus.webview.getWebviewById("wv").tokenScan || + window?.plus?.webview.getWebviewById("wv").tokenScan || uni.getStorageSync("store-token") ) { paintingDetail(); diff --git a/src/pages/painting/index.vue b/src/pages/painting/index.vue index 4e01497..e4ec15b 100644 --- a/src/pages/painting/index.vue +++ b/src/pages/painting/index.vue @@ -111,6 +111,11 @@ const doneSet = async () => { showMessage({ type: "sucess", message: "入库成功" }); isButtonDisabled.value = true; buttonText.value = "已入库"; + if (runTimeEnv()) { + setTimeout(() => { + closeWebview(); + }, 2000); + } } else { showMessage({ type: "error", message: res.msg }); } diff --git a/utils/service/index.js b/utils/service/index.js index 757ce79..0926181 100644 --- a/utils/service/index.js +++ b/utils/service/index.js @@ -7,7 +7,7 @@ console.log( window?.plus?.storage.getItem("token"), uni.getStorageSync("token") ); -console.log("webview", plus.webview.getWebviewById("wv").tokenScan); +console.log("webview", window?.plus?.webview.getWebviewById("wv").tokenScan); const request = new Request({ baseURL: OAorMc() === "MC" @@ -24,7 +24,7 @@ const request = new Request({ const token = uni.getStorageSync("token") || - plus.webview.getWebviewById("wv").tokenScan || + window?.plus?.webview.getWebviewById("wv").tokenScan || uni.getStorageSync("store-token") || ""; if (config.isFormData) {