From 487f7f7e47e8682c9604aa1ff3ab231855e23c69 Mon Sep 17 00:00:00 2001 From: xuminyui <576362016@qq.com> Date: Thu, 24 Oct 2024 13:50:22 +0800 Subject: [PATCH] fix --- src/App.vue | 126 +++++++++++++++++++++-------------------- utils/service/index.js | 10 ++-- 2 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/App.vue b/src/App.vue index b27cd7e..3352c54 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,74 +12,78 @@ const loading = ref(false); export default { onLaunch: function () {}, onShow: function () { - console.log('2222222') + console.log("2222222"); // const token = window?.plus?.storage.getItem("token"); // uni.setStorageSync("token", token); // console.log("App Show", uni.getStorageSync("token")); const params = new URLSearchParams(window.location.search); //属性包含当前 URL 的查询字符串部分 - state.id = params.get("id"); - state.pid = params.get("pid"); - console.log(state) + state.id = params.get("id"); + state.pid = params.get("pid"); + console.log(state); -const paintingDetail = async () => { - loading.value = true; - console.log("state", state); - const res = await pbDetail({ - id: state.id, - pid: state.pid, - }); - if (res.status === 0) { - console.log("成功拉1"); - state.boxRelBucketStatus = res.data.boxRelBucketStatus; - console.log("boxRelBucketStatus", state.boxRelBucketStatus); - if (res.data.pbStatus == 1) { - console.log("成功拉2"); - uni.navigateTo({ - url: "/pages/index/index?id=" + state.id + "&pid=" + state.pid, - success: () => { - loading.value = false; - }, - fail: () => { - loading.value = false; - showMessage({ type: "default", message: "跳转失败" }); - }, + const paintingDetail = async () => { + loading.value = true; + console.log("state", state); + const res = await pbDetail({ + id: state.id, + pid: state.pid, }); - } else { - if ( - res.data.boxRelBucketStatus == 3 && - res.data.locateAddress == "公司内" - ) { - uni.navigateTo({ - url: "/pages/painting/index?id=" + state.id + "&pid=" + state.pid, - success: () => { - loading.value = false; - }, - fail: () => { - loading.value = false; - showMessage({ type: "default", message: "跳转失败" }); - }, - }); - } else { - uni.setStorageSync('data',res.data) - console.log() - uni.navigateTo({ - url: - "/pages/detail/index?id="+ state.id + "&pid=" + state.pid+'&boxRelBucketStatus='+state.boxRelBucketStatus, - - success: () => { - loading.value = false; - }, - fail: () => { - loading.value = false; - showMessage({ type: "default", message: "跳转失败" }); - }, - }); - } - } - } -}; -paintingDetail() + if (res.status === 0) { + console.log("成功拉1"); + state.boxRelBucketStatus = res.data.boxRelBucketStatus; + console.log("boxRelBucketStatus", state.boxRelBucketStatus); + if (res.data.pbStatus == 1) { + console.log("成功拉2"); + uni.navigateTo({ + url: "/pages/index/index?id=" + state.id + "&pid=" + state.pid, + success: () => { + loading.value = false; + }, + fail: () => { + loading.value = false; + showMessage({ type: "default", message: "跳转失败" }); + }, + }); + } else { + if ( + res.data.boxRelBucketStatus == 3 && + res.data.locateAddress == "公司内" + ) { + uni.navigateTo({ + url: "/pages/painting/index?id=" + state.id + "&pid=" + state.pid, + success: () => { + loading.value = false; + }, + fail: () => { + loading.value = false; + showMessage({ type: "default", message: "跳转失败" }); + }, + }); + } else { + uni.setStorageSync("data", res.data); + console.log(); + uni.navigateTo({ + url: + "/pages/detail/index?id=" + + state.id + + "&pid=" + + state.pid + + "&boxRelBucketStatus=" + + state.boxRelBucketStatus, + success: () => { + loading.value = false; + }, + fail: () => { + loading.value = false; + showMessage({ type: "default", message: "跳转失败" }); + }, + }); + } + } + } + }; + paintingDetail(); }, onHide: function () { console.log("App Hide"); diff --git a/utils/service/index.js b/utils/service/index.js index 989ba2b..6f8c23e 100644 --- a/utils/service/index.js +++ b/utils/service/index.js @@ -18,10 +18,12 @@ const request = new Request({ ? "application/x-www-form-urlencoded" : "application/json"; - const token = - window?.plus?.webview.getWebviewById("wv").tokenScan || - uni.getStorageSync("store-token") || - ""; + const token = ""; + try { + token = plus?.webview.getWebviewById("wv").tokenScan; + } catch (e) { + token = uni.getStorageSync("store-token"); + } console.log("tokenServer", token); if (config.isFormData) { config.headers["Content-Type"] = "multipart/form-data";