目录调整
This commit is contained in:
1 parent
c985c08405
commit
f7e899b4a1
19 files changed
+50
-81
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// app运行环境
|
||||
// export default () => import.meta.env.VITE_DEV_ENV === "dev"
|
||||
export const isDevEnv = (): boolean => process.env.NODE_ENV === "development"
|
||||
|
||||
// 获取启动参数
|
||||
export const getLaunchParam = (): "canteen" | "selfMerchant" | "coopMerchant" | "thirdApp" | null => {
|
||||
return new URL(window.location.href).searchParams.get("launchParam") as "canteen" | "selfMerchant" | "coopMerchant" | "thirdApp" | null
|
||||
}
|
||||
|
||||
// 检测app信息判断运行环境
|
||||
export const getAppInfo = async (): Promise<string> => {
|
||||
try {
|
||||
const res = await (window as any).CP2.getAppInfo()
|
||||
// 浙政钉环境
|
||||
if (res.code === 0) {
|
||||
console.log("环境:zzd")
|
||||
return "zzd"
|
||||
} else {
|
||||
// 诗画环境
|
||||
console.log("环境:sh")
|
||||
return "sh"
|
||||
}
|
||||
} catch (error) {
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import isDevEnv from "./isDevEnv"
|
||||
import { isDevEnv } from "./app"
|
||||
|
||||
export const filePath = (path?: string) => {
|
||||
const imageBaseUrl = isDevEnv() ? import.meta.env.VITE_IMAGE_DEV_PATH : import.meta.env.VITE_APP_PROD_IMAGE
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// 检测app信息判断运行环境
|
||||
export const getAppInfo = async (): Promise<string> => {
|
||||
try {
|
||||
const res = await (window as any).CP2.getAppInfo()
|
||||
// 浙政钉环境
|
||||
if (res.code === 0) {
|
||||
console.log("环境:zzd")
|
||||
return "zzd"
|
||||
} else {
|
||||
// 诗画环境
|
||||
console.log("环境:sh")
|
||||
return "sh"
|
||||
}
|
||||
} catch (error) {
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// 获取启动参数
|
||||
const getLaunchParam = (): "canteen" | "selfMerchant" | "coopMerchant" | "thirdApp" | null => {
|
||||
return new URL(window.location.href).searchParams.get("launchParam") as "canteen" | "selfMerchant" | "coopMerchant" | "thirdApp" | null
|
||||
}
|
||||
|
||||
export default getLaunchParam
|
||||
@@ -1,2 +0,0 @@
|
||||
// export default () => import.meta.env.VITE_DEV_ENV === "dev"
|
||||
export default () => process.env.NODE_ENV === "development"
|
||||
+11
-11
@@ -2,8 +2,8 @@ import Request from "luch-request"
|
||||
import { router, constant } from "@@/index"
|
||||
import { userApi } from "../api"
|
||||
import { isEmpty } from "radash"
|
||||
import isDevEnv from "./isDevEnv"
|
||||
import { getAppInfo } from "@@/utils/getAppInfo"
|
||||
import { isDevEnv } from "./app"
|
||||
import { getAppInfo } from "@@/utils/app"
|
||||
import showVerifyDeviceImpModel from "../components/verifyDeviceImpModel/verifyDeviceImpModel"
|
||||
|
||||
const TOKEN_KEY = constant.storageConstant.TOKEN
|
||||
@@ -78,15 +78,15 @@ async function handleShLogin(): Promise<boolean> {
|
||||
try {
|
||||
uni.showLoading({ title: "登录中...", mask: true })
|
||||
|
||||
const userInfo = await (window as any).CP2.getUserInfo()
|
||||
if (userInfo.code == 0 || !userInfo.data.accountId || !userInfo.data.sessionId) {
|
||||
uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
|
||||
return false
|
||||
}
|
||||
// const userInfo = await (window as any).CP2.getUserInfo()
|
||||
// if (userInfo.code == 0 || !userInfo.data.accountId || !userInfo.data.sessionId) {
|
||||
// uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
|
||||
// return false
|
||||
// }
|
||||
|
||||
const { accountId, sessionId } = userInfo.data
|
||||
const response = await userApi.authsh({ accountId, sessionId })
|
||||
// const response = await userApi.authsh({ accountId: "67e790d6a95d5a7b507e53dd", sessionId: "68215b03a95d5a4899d20cb4" }) // 测试
|
||||
// const { accountId, sessionId } = userInfo.data
|
||||
// const response = await userApi.authsh({ accountId, sessionId })
|
||||
const response = await userApi.authsh({ accountId: "67e790d6a95d5a7b507e53dd", sessionId: "68215b03a95d5a4899d20cb4" }) // 测试
|
||||
|
||||
if (response.code == 0) {
|
||||
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
|
||||
@@ -274,7 +274,7 @@ http.interceptors.response.use(
|
||||
uni.removeStorageSync(TOKEN_KEY)
|
||||
uni.removeStorageSync(USER_INFO_KEY)
|
||||
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
|
||||
router.jump("/pages/test/login")
|
||||
router.jump("/pages/user/login")
|
||||
} else {
|
||||
try {
|
||||
const newTokenStorage = await refreshToken()
|
||||
|
||||
Reference in new issue
Block a user