诗画扫码测试
This commit is contained in:
1 parent
b8c6a397ff
commit
4002c60297
2 files changed
+23
-9
No files matched your search
+21
-7
@@ -42,11 +42,13 @@
|
||||
切换角色
|
||||
</view>
|
||||
</view>
|
||||
<view>11{{ JSON.stringify(aaa) }}</view>
|
||||
<view>11{{ JSON.stringify(bbb) }}</view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from "vue"
|
||||
import { reactive, ref } from "vue"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
import { isEmpty } from "radash"
|
||||
import { filePath } from "@@/utils/file"
|
||||
@@ -244,6 +246,8 @@ const login = {
|
||||
},
|
||||
}
|
||||
|
||||
const aaa = ref("")
|
||||
const bbb = ref("")
|
||||
const scanCode = {
|
||||
// 扫一扫
|
||||
scan: async () => {
|
||||
@@ -251,10 +255,12 @@ const scanCode = {
|
||||
try {
|
||||
const decodedString = await scanCode.getScanResult()
|
||||
|
||||
if (decodedString) {
|
||||
scanCode.processScanResult(decodedString)
|
||||
} else {
|
||||
uni.showToast({ title: "无效的二维码" })
|
||||
if (state.appInfo == "dd") {
|
||||
if (decodedString) {
|
||||
scanCode.processScanResult(decodedString)
|
||||
} else {
|
||||
uni.showToast({ title: "无效的二维码" })
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error) {
|
||||
@@ -271,10 +277,18 @@ const scanCode = {
|
||||
const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 测试环境-邓本地-新县府超市-收款码
|
||||
uni.showToast({ title: "开发环境不是浙政钉环境,扫码仅供测试,收款商家为测试商户超市" })
|
||||
return scanCode.decodeBase64(testQrCode)
|
||||
} else {
|
||||
// 实际环境扫码
|
||||
} else if (state.appInfo == "dd") {
|
||||
// 浙政钉扫码
|
||||
const res: any = await (window as any).dd.scan({ type: "all" })
|
||||
return scanCode.decodeBase64(res.text)
|
||||
} else if (state.appInfo == "sh") {
|
||||
// 诗画扫码
|
||||
const res = await (window as any).CP2.showScanQr()
|
||||
aaa.value = res.data
|
||||
bbb.value = scanCode.decodeBase64(res.data)
|
||||
// return scanCode.decodeBase64(res.data)
|
||||
} else {
|
||||
uni.showToast({ title: "当前环境未知" })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ const selectRole = (role: "user" | "merchant") => (userRole.value = role)
|
||||
// 确认选择
|
||||
const confirmRole = () => {
|
||||
uni.setStorageSync("userRole", userRole.value)
|
||||
if (userRole.value === "user") uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
|
||||
if (userRole.value === "merchant") uni.reLaunch({ url: "/pages/tabbar/individualOrder" })
|
||||
if (userRole.value === "user") uni.redirectTo({ url: "/pages/tabbar/coopMerchant" })
|
||||
if (userRole.value === "merchant") uni.redirectTo({ url: "/pages/tabbar/individualOrder" })
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user