跳转
This commit is contained in:
1 parent
7517034d24
commit
8fc5b51705
1 file changed
+38
-15
@@ -1,10 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 门户壳「扫一扫」落地页(非 tabBar,进入即调起扫码)
|
||||
* 扫码 / 结果处理与「我的」页同一套 hooks.useScanCode
|
||||
* 扫码 / 结果处理与「我的」页同一套 useScanCode
|
||||
*/
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import hooks from "@/sheep/hooks"
|
||||
import { hooks } from "@@/index"
|
||||
|
||||
const actModalShow = (_payload: { cancelId: string }) => {
|
||||
uni.showToast({ title: "请到「我的」中核销活动码", icon: "none" })
|
||||
@@ -14,25 +14,34 @@ const actModalShow = (_payload: { cancelId: string }) => {
|
||||
const { scanCodeAction, processUrlScanResult, processBase64ScanResult } = hooks.useScanCode(actModalShow)
|
||||
|
||||
const runScan = async () => {
|
||||
const scanResult = await scanCodeAction()
|
||||
if (!scanResult) {
|
||||
uni.showToast({ title: "扫码取消或失败", icon: "none" })
|
||||
try {
|
||||
const scanResult = await scanCodeAction()
|
||||
if (!scanResult) {
|
||||
uni.showToast({ title: "扫码取消或失败", icon: "none" })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
fail: () => uni.switchTab({ url: "/pages/tabbar/my" }),
|
||||
})
|
||||
}, 400)
|
||||
return
|
||||
}
|
||||
if (scanResult.startsWith("http")) {
|
||||
processUrlScanResult(scanResult.replace("/#", ""))
|
||||
} else {
|
||||
processBase64ScanResult(scanResult)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("[portalScan] runScan", e)
|
||||
uni.showToast({ title: "扫码异常", icon: "none" })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
fail: () => uni.switchTab({ url: "/pages/tabbar/my" }),
|
||||
})
|
||||
}, 400)
|
||||
return
|
||||
}
|
||||
if (scanResult.startsWith("http")) {
|
||||
processUrlScanResult(scanResult.replace("/#", ""))
|
||||
} else {
|
||||
processBase64ScanResult(scanResult)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
// 等页面与容器 JSAPI 就绪后再调起,避免只停在中间页
|
||||
setTimeout(() => {
|
||||
void runScan()
|
||||
}, 250)
|
||||
@@ -40,7 +49,21 @@ onLoad(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="page flex-col-center min-h-screen bg-#f5f5f5">
|
||||
<view class="sub-text-28 color-#666">正在打开扫一扫…</view>
|
||||
<view class="wrap">
|
||||
<text class="tip">正在打开扫一扫…</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wrap {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
.tip {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user