诗画扫码测试
This commit is contained in:
1 parent
093b0d3ecc
commit
e4f3af4e18
1 file changed
+22
-30
+22
-30
@@ -42,8 +42,6 @@
|
||||
切换角色
|
||||
</view>
|
||||
</view>
|
||||
<view>11{{ JSON.stringify(aaa) }}</view>
|
||||
<view>11{{ JSON.stringify(bbb) }}</view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
@@ -137,10 +135,10 @@ const login = {
|
||||
const zhengdingResult = login.zhengdingLogin()
|
||||
if (zhengdingResult) return
|
||||
|
||||
uni.showToast({ title: "当前登录环境未知" })
|
||||
uni.showToast({ title: "当前登录环境未知", icon: "none" })
|
||||
} catch (error) {
|
||||
console.error("登录失败:", error)
|
||||
uni.showToast({ title: "登录失败" })
|
||||
uni.showToast({ title: "登录失败", icon: "none" })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -151,7 +149,7 @@ const login = {
|
||||
|
||||
const userInfo = await (window as any).CP2.getUserInfo()
|
||||
if (userInfo.code == 0) {
|
||||
uni.showToast({ title: "获取诗画用户信息失败" })
|
||||
uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
|
||||
return false
|
||||
} else {
|
||||
const { accountId, sessionId } = userInfo.data
|
||||
@@ -183,14 +181,14 @@ const login = {
|
||||
if (response.code == 0) {
|
||||
storage.saveToken({ accessToken: response.data.accessToken })
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "登录成功" })
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
|
||||
const { data: userData } = await userApi.userInfo()
|
||||
storage.saveUserInfo(userData)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
storage.clearUserStorage()
|
||||
uni.showToast({ title: "登录失败" })
|
||||
uni.showToast({ title: "登录失败", icon: "none" })
|
||||
}
|
||||
break
|
||||
|
||||
@@ -203,20 +201,20 @@ const login = {
|
||||
if (res.code == 0) {
|
||||
storage.saveToken(res.data)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "登录成功" })
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
|
||||
const { data: userData } = await userApi.userInfo()
|
||||
storage.saveUserInfo(userData)
|
||||
} else {
|
||||
storage.clearUserStorage()
|
||||
if (res.msg == "token已失效") {
|
||||
uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", duration: 6000 })
|
||||
uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 })
|
||||
} else {
|
||||
uni.showToast(res.msg || "登录失败")
|
||||
uni.showToast({ title: res.msg || "登录失败", icon: "none" })
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({ title: "登录错误" })
|
||||
uni.showToast({ title: "登录错误", icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
@@ -224,7 +222,7 @@ const login = {
|
||||
break
|
||||
|
||||
default:
|
||||
uni.showToast({ title: "当前登录环境未知" })
|
||||
uni.showToast({ title: "当前登录环境未知", icon: "none" })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -236,7 +234,7 @@ const login = {
|
||||
uni.showLoading({ title: "退出登录中...", mask: true })
|
||||
storage.clearUserStorage()
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "退出登录成功" })
|
||||
uni.showToast({ title: "退出登录成功", icon: "none" })
|
||||
},
|
||||
|
||||
// 切换角色
|
||||
@@ -246,8 +244,6 @@ const login = {
|
||||
},
|
||||
}
|
||||
|
||||
const aaa = ref("")
|
||||
const bbb = ref("")
|
||||
const scanCode = {
|
||||
// 扫一扫
|
||||
scan: async () => {
|
||||
@@ -255,16 +251,14 @@ const scanCode = {
|
||||
try {
|
||||
const decodedString = await scanCode.getScanResult()
|
||||
|
||||
if (state.appInfo == "dd") {
|
||||
if (decodedString) {
|
||||
scanCode.processScanResult(decodedString)
|
||||
} else {
|
||||
uni.showToast({ title: "无效的二维码" })
|
||||
}
|
||||
if (decodedString) {
|
||||
scanCode.processScanResult(decodedString)
|
||||
} else {
|
||||
uni.showToast({ title: "无效的二维码", icon: "none" })
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error) {
|
||||
uni.showToast({ title: error })
|
||||
uni.showToast({ title: error, icon: "none" })
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -275,7 +269,7 @@ const scanCode = {
|
||||
// 开发环境模拟扫码
|
||||
// const testQrCode = "eyJpZCI6IjE4OTYxNTcyMDc2NDQwNTM1MDYiLCJuYW1lIjoi5rWL6K+V5ZWG5oi3In0=" // 线上-测试超市-收款码
|
||||
const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 测试环境-邓本地-新县府超市-收款码
|
||||
uni.showToast({ title: "开发环境不是浙政钉环境,扫码仅供测试,收款商家为测试商户超市" })
|
||||
uni.showToast({ title: "开发环境不是浙政钉环境,扫码仅供测试,收款商家为测试商户超市", icon: "none" })
|
||||
return scanCode.decodeBase64(testQrCode)
|
||||
} else if (state.appInfo == "dd") {
|
||||
// 浙政钉扫码
|
||||
@@ -284,11 +278,9 @@ const scanCode = {
|
||||
} else if (state.appInfo == "sh") {
|
||||
// 诗画扫码
|
||||
const res = await (window as any).CP2.showScanQr({ needResult: 1 })
|
||||
aaa.value = res.data
|
||||
bbb.value = scanCode.decodeBase64(res.data)
|
||||
// return scanCode.decodeBase64(res.data)
|
||||
if (res.code == 0) return scanCode.decodeBase64(res.data.qrCode)
|
||||
} else {
|
||||
uni.showToast({ title: "当前环境未知" })
|
||||
uni.showToast({ title: "当前环境未知", icon: "none" })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -300,10 +292,10 @@ const scanCode = {
|
||||
usePayStore().setPayData(decodedJson)
|
||||
router.jump("/pages/pay/scanPay")
|
||||
} else {
|
||||
uni.showToast({ title: "无效的二维码" })
|
||||
uni.showToast({ title: "无效的二维码", icon: "none" })
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({ title: "无效的二维码内容" })
|
||||
uni.showToast({ title: "无效的二维码内容", icon: "none" })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -321,7 +313,7 @@ const scanCode = {
|
||||
return decodedString
|
||||
} catch (error) {
|
||||
console.error("Base64 解码失败:", error)
|
||||
uni.showToast({ title: "解码失败,无效的二维码" })
|
||||
uni.showToast({ title: "无效的二维码", icon: "none" })
|
||||
return undefined
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user