修改已知问题
This commit is contained in:
1 parent
73f7f4d8b0
commit
c28b5763a0
4 files changed
+25
-17
No files matched your search
+13
-9
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import isDevEnv from "./sheep/utils/isDevEnv"
|
||||
import { getAppInfo } from "@@/utils/getAppInfo"
|
||||
|
||||
// import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
|
||||
// onLaunch(() => {})
|
||||
@@ -114,9 +115,9 @@ export default {
|
||||
uni.setNavigationBarTitle({ title: "" })
|
||||
|
||||
// 环境判断
|
||||
const res = await (window as any).CP2.getAppInfo()
|
||||
if (res.code == 0) {
|
||||
// 不是诗画环境
|
||||
const appInfo = await getAppInfo()
|
||||
if (appInfo == "zzd") {
|
||||
// 浙政钉环境
|
||||
const launchParam = getLaunchParam()
|
||||
|
||||
console.log("app launch 启动路径参数", launchParam)
|
||||
@@ -131,8 +132,8 @@ export default {
|
||||
default:
|
||||
break
|
||||
}
|
||||
} else {
|
||||
// 是诗画环境
|
||||
} else if (appInfo == "sh") {
|
||||
// 诗画环境
|
||||
const userRole = uni.getStorageSync("userRole")
|
||||
switch (userRole) {
|
||||
case "merchant":
|
||||
@@ -159,24 +160,27 @@ export default {
|
||||
const launchParam = getLaunchParam()
|
||||
console.log("tabbar launch 启动路径参数", launchParam)
|
||||
|
||||
const res = await (window as any).CP2.getAppInfo()
|
||||
if (res.code == 0) {
|
||||
// 不是诗画环境
|
||||
const appInfo = await getAppInfo()
|
||||
if (appInfo == "zzd") {
|
||||
// 浙政钉环境
|
||||
if (launchParam) {
|
||||
setTabbarByLaunchParam(launchParam)
|
||||
uni.hideTabBar()
|
||||
} else {
|
||||
uni.hideTabBar()
|
||||
uni.showToast({ title: "启动参数不合法", icon: "none" })
|
||||
}
|
||||
} else {
|
||||
} else if (appInfo == "sh") {
|
||||
// 是诗画环境
|
||||
const userRole = uni.getStorageSync("userRole")
|
||||
switch (userRole) {
|
||||
case "user":
|
||||
setTabbarByUserRole("user")
|
||||
uni.showTabBar()
|
||||
break
|
||||
case "merchant":
|
||||
setTabbarByUserRole("merchant")
|
||||
uni.showTabBar()
|
||||
break
|
||||
default:
|
||||
uni.hideTabBar()
|
||||
|
||||
@@ -272,7 +272,7 @@ const scanCode = {
|
||||
const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxMTYwNDg5ODQ1NTc4OTU2OSIsImNhYmluZXRObyI6IjEifQ==" // 测试智能柜货柜二维码
|
||||
uni.showModal({ content: "开发环境不是浙政钉和诗画环境,扫码仅供测试,收款商家为测试商户超市" })
|
||||
return scanCode.decodeBase64(testQrCode)
|
||||
} else if (state.appInfo == "dd") {
|
||||
} else if (state.appInfo == "zzd") {
|
||||
// 浙政钉扫码
|
||||
const res: any = await (window as any).dd.scan({ type: "all" })
|
||||
return scanCode.decodeBase64(res.text)
|
||||
|
||||
@@ -4,7 +4,7 @@ export const getAppInfo = async (): Promise<string> => {
|
||||
const res = await (window as any).CP2.getAppInfo()
|
||||
// 浙政钉环境
|
||||
if (res.code === 0) {
|
||||
return "dd"
|
||||
return "zzd"
|
||||
} else {
|
||||
// 诗画环境
|
||||
return "sh"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { isEmpty } from "radash"
|
||||
import isDevEnv from "./isDevEnv"
|
||||
import { router, constant } from "@@/index"
|
||||
import { userApi } from "../api"
|
||||
import { getAppInfo } from "@@/utils/getAppInfo"
|
||||
|
||||
// 常量定义
|
||||
const TOKEN_KEY = constant.storageConstant.TOKEN
|
||||
@@ -84,9 +85,9 @@ async function handleShLogin(): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
|
||||
const { accountId, sessionId } = userInfo.data
|
||||
const { accountId = "", sessionId = "" } = userInfo.data
|
||||
const response = await userApi.authsh({ accountId, sessionId })
|
||||
// const response = await userApi.authsh({ accountId: "67186e49d63fea141aad6772", sessionId: "67186e49d63fea141aad6776" }) // 测试
|
||||
// const response = await userApi.authsh({ accountId: "67e790d6a95d5a7b507e53dd", sessionId: "67fdff553cbc284e352ebb4d" }) // 测试
|
||||
|
||||
if (response.code == 0) {
|
||||
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
|
||||
@@ -114,15 +115,18 @@ async function handleShLogin(): Promise<boolean> {
|
||||
|
||||
// 根据应用环境自动登录 返回登录结果
|
||||
async function autoLogin(): Promise<boolean> {
|
||||
const appInfo = await (window as any).CP2.getAppInfo()
|
||||
const appInfo = await getAppInfo()
|
||||
|
||||
// 浙政钉环境
|
||||
if (appInfo.code == 0) {
|
||||
if (appInfo == "zzd") {
|
||||
return await handleZzdLogin()
|
||||
}
|
||||
// 诗画环境
|
||||
else {
|
||||
else if (appInfo == "sh") {
|
||||
return await handleShLogin()
|
||||
} else {
|
||||
uni.showToast({ title: "app环境错误", icon: "none" })
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +186,7 @@ function handleSuccessMessage(response: any) {
|
||||
// 创建请求实例
|
||||
const http = new Request({
|
||||
baseURL: import.meta.env.VITE_API_URL,
|
||||
timeout: 8000,
|
||||
timeout: 15000,
|
||||
method: "GET",
|
||||
header: {
|
||||
Accept: "*/*",
|
||||
|
||||
Reference in new issue
Block a user