diff --git a/.env b/.env index f0a2ee4..0638fa6 100644 --- a/.env +++ b/.env @@ -18,7 +18,7 @@ VITE_OAUTH2_APP_CLIENT='mini:mini' # 图片访问基础地址 #VITE_IMAGE_BASE_PATH = http://localhost:9999 -# VITE_IMAGE_BASE_PATH = http://192.168.101.64:9999 # 邓-本地 +# VITE_IMAGE_BASE_PATH = http://192.168.101.81:9999 # 邓-本地 # VITE_IMAGE_BASE_PATH = https://123.156.230.15:8089/api # 线上 # VITE_IMAGE_BASE_PATH = http://220.191.229.171:8090/api # 线上 # VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc # 张 @@ -28,7 +28,7 @@ VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/api # 域名线上 # ******************** start 开发环境 start **************** #VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上 VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api # 域名线上 -# VITE_APP_DEV_SERVICE = http://192.168.101.64:9999 # 邓-本地 +# VITE_APP_DEV_SERVICE = http://192.168.101.81:9999 # 邓-本地 # VITE_APP_DEV_SERVICE = http://127.0.0.1:9999 # VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 线上 # VITE_APP_DEV_SERVICE = http://220.191.229.171:8090/api # 线上 diff --git a/src/App.vue b/src/App.vue index e214667..9e72797 100644 --- a/src/App.vue +++ b/src/App.vue @@ -67,7 +67,28 @@ const tabbar = [ ] export default { - onLaunch() {}, + onLaunch() { + console.log("环境判断") + // ;(window as any).CP2.getUserInfo().then((res) => { + // console.log(res) + // if (res.code == 0) { + // uni.showToast({ title: res.msg || "当前环境不支持", icon: "none" }) + // } + // }) + + const launchParam = new URL(window.location.href).searchParams.get("launchParam") + console.log("app launch 启动路径参数", launchParam) + switch (launchParam) { + case "canteen": + uni.switchTab({ url: "/pages/tabbar/canteen" }) + break + case "selfMerchant": + uni.switchTab({ url: "/pages/tabbar/selfMerchant" }) + break + default: + break + } + }, onShow() {}, onHide() {}, @@ -76,12 +97,15 @@ export default { // console.log("环境判断") // let appEnv = 1 // 1:浙政钉 2:诗画 - const launchPath = uni.getLaunchOptionsSync().path - console.log("启动路径", launchPath) + // const launchPath = uni.getLaunchOptionsSync().path + // console.log("启动路径", launchPath) + + const launchParam = new URL(window.location.href).searchParams.get("launchParam") + console.log("tabbar launch 启动路径参数", launchParam) if (isDevEnv()) { - switch (launchPath) { - case "pages/tabbar/canteen": + switch (launchParam) { + case "canteen": tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { if (authPath.includes("pages/tabbar/canteen")) { uni.setTabBarItem({ @@ -104,7 +128,7 @@ export default { } }) break - case "pages/tabbar/selfMerchant": + case "selfMerchant": tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { if (authPath.includes("pages/tabbar/selfMerchant")) { uni.setTabBarItem({ diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts index c4abbe6..2ebeba6 100644 --- a/src/sheep/utils/request.ts +++ b/src/sheep/utils/request.ts @@ -47,7 +47,7 @@ const http = new Request({ }, }) -// 处理请求头 Authorization +// 读取token 处理Authorization请求头 const getAuthHeader = (tokenStorage: any) => { if (isDevEnv()) { return tokenStorage?.access_token ? `Bearer ${tokenStorage.access_token}` : null @@ -64,31 +64,6 @@ const checkAndRefreshToken = async (tokenStorage: any) => { // console.log("现在的时间大于过期时间吗:", new Date().getTime() >= expiresDate) if (new Date().getTime() >= expiresDate) { - // try { - // const refreshData: any = await request({ - // url: "/auth/oauth2/token", - // method: "POST", - // params: { grant_type: "refresh_token" }, - // data: JSON.stringify({ - // scope: "server", - // refresh_token: tokenStorage.refreshToken.tokenValue, - // }), - // header: { - // skipToken: true, - // Authorization: "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT), - // "content-type": "application/x-www-form-urlencoded", - // }, - // }) - - // if (refreshData.code === 0 && !isEmpty(refreshData.data)) { - // console.log("refreshData.data", refreshData.data) - - // // 刷新成功,更新token并重试请求 - // uni.setStorageSync(TOKEN_KEY, refreshData.data) - // } - // } catch (refreshError) { - // console.error("Token refresh failed:", refreshError) - // } try { uni.showLoading({ title: "加载中...", mask: true }) const params = new URL(window.location.href).searchParams