feat:适配支付,第三方app
This commit is contained in:
1 parent
196ed0285a
commit
7ec67acded
22 files changed
+173
-119
No files matched your search
@@ -1,19 +1,19 @@
|
||||
<template>
|
||||
<view class="bg-[#f5f5f5] px-8rpx py-16rpx rounded-4 fixed bottom-0 left-0 right-0 w-full">
|
||||
<view class="flex justify-end">
|
||||
<image v-show="show" class="w-[50rpx] h-[50rpx] mx-16rpx mb-8rpx" src="@/static/page/fold.svg"
|
||||
<image v-if="show" class="w-[50rpx] h-[50rpx] mx-16rpx mb-8rpx" src="@/static/page/fold.svg"
|
||||
@click="show = !show" />
|
||||
<image v-show="!show" class="w-[50rpx] h-[50rpx] mx-16rpx mb-8rpx" src="@/static/page/unfold.svg"
|
||||
<image v-if="!show" class="w-[50rpx] h-[50rpx] mx-16rpx mb-8rpx" src="@/static/page/unfold.svg"
|
||||
@click="show = !show" />
|
||||
</view>
|
||||
<view v-show="show" class="flex mb-20rpx" v-for="(row, rowIndex) in keyboardLayout" :key="rowIndex">
|
||||
<view v-if="show" class="flex mb-20rpx" v-for="(row, rowIndex) in keyboardLayout" :key="rowIndex">
|
||||
<view
|
||||
class="flex-1 h-[90rpx] flex items-center justify-center bg-white text-2xl text-[#333] mx-[5px] rounded-lg cursor-pointer select-none active:bg-[#f0f0f0]"
|
||||
v-for="(key, keyIndex) in row" :key="keyIndex" @click="handleKeyPress(key.toString())">
|
||||
{{ key }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-show="show" class="flex mb-0rpx">
|
||||
<view v-if="show" class="flex mb-0rpx">
|
||||
<view
|
||||
class="flex-1 h-[90rpx] flex items-center justify-center bg-white text-2xl text-[#333] mx-[5px] rounded-lg cursor-pointer select-none active:bg-[#f0f0f0]"
|
||||
@click="handleKeyPress('.')">
|
||||
|
||||
@@ -1,59 +1,28 @@
|
||||
import { router } from ".."
|
||||
import { APPENV } from "../constant"
|
||||
import { getAppInfo, isDevEnv } from "../utils/app"
|
||||
import { getUrlParamsObj } from "../utils/app"
|
||||
|
||||
export function useScanCode(actModalShow) {
|
||||
async function scanCodeAction(): Promise<string | undefined> {
|
||||
const appInfo = await getAppInfo()
|
||||
if (isDevEnv() && appInfo != APPENV.APP) {
|
||||
// 开发环境模拟扫码
|
||||
// const testQrCode = "eyJpZCI6IjE5MDU4ODg4NjQ0NTQ1MzMxMjEiLCJuYW1lIjoi6ICB5Y6/5bqc6aOf5aCCIn0=" // 测试线上-老县府食堂-收款二维码
|
||||
// const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxNDIxNTYwODQzNzQxMTg0MSIsImNhYmluZXRObyI6IjEifQ==" // 测试线上-智能柜-收款二维码
|
||||
// const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 邓本地-测试环境-新县府超市收款二维码
|
||||
// const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxMzE1NzA4MDQxODI5NTgwOSIsImNhYmluZXRObyI6IjEifQ==" // 邓本地-测试单门智能柜柜门二维码
|
||||
// const testQrCode = "http://192.168.101.45:8889/h5/#/pages/pay/scanPay?id=1905816751043452930&name=测试新县府超市" // 邓本地-测试环境-新县府超市收款二维码
|
||||
// const testQrCode = "http://192.168.101.45:8889/h5/#/pages/pay/scanPay?hardDoorId=1913157080418295809&cabinetNo=1" // 测试智能柜柜门二维码
|
||||
const testQrCode = "eyJjYW5jZWxJZCI6IjE5ODQyNDA4MzM5NDMyMDc5MzcifQ==" // 测试商户活动核销
|
||||
uni.showModal({ content: "开发环境不是浙政钉和诗画环境,扫码仅供测试" })
|
||||
return Promise.resolve(testQrCode)
|
||||
}
|
||||
if (appInfo == APPENV.APP) {
|
||||
const scanResult = await new Promise<string>((resolve, reject) => {
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
console.log("APP扫码成功:", JSON.stringify(res))
|
||||
resolve(res.result || "")
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("APP扫码失败", JSON.stringify(err))
|
||||
resolve("")
|
||||
},
|
||||
})
|
||||
const scanResult = await new Promise<string>((resolve, reject) => {
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
console.log("uniapp扫码成功:", JSON.stringify(res))
|
||||
resolve(res.result || "")
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("uniapp扫码失败", JSON.stringify(err))
|
||||
resolve("")
|
||||
},
|
||||
})
|
||||
return scanResult
|
||||
}
|
||||
if (appInfo == APPENV.ZZD) {
|
||||
// 浙政钉扫码
|
||||
const res: any = await (window as any).dd.scan({ type: "all" })
|
||||
return res.text || ""
|
||||
}
|
||||
if (appInfo == APPENV.SH) {
|
||||
// 诗画扫码
|
||||
const res = await (window as any).CP2.showScanQr({ needResult: 1 })
|
||||
if (res.code == 1) return res.data.qrCode || ""
|
||||
return ""
|
||||
}
|
||||
uni.showToast({ title: "当前环境未知", icon: "none" })
|
||||
})
|
||||
return scanResult
|
||||
}
|
||||
|
||||
// 处理url扫码结果
|
||||
function processUrlScanResult(url: string) {
|
||||
if (!url) return
|
||||
const searchParams = new URL(url).searchParams
|
||||
const paramsObj: Record<string, string> = {}
|
||||
searchParams.forEach((value, key) => (paramsObj[key] = value))
|
||||
const { hardDoorId, cabinetNo, action, id, name } = paramsObj
|
||||
|
||||
const searchParams = getUrlParamsObj(url)
|
||||
const { hardDoorId, cabinetNo, action, id, name } = searchParams
|
||||
// 智能柜扫码
|
||||
if (hardDoorId && cabinetNo) {
|
||||
router.jump("/pages/cabinet/buy", { hardDoorId, cabinetNo })
|
||||
@@ -61,7 +30,7 @@ export function useScanCode(actModalShow) {
|
||||
}
|
||||
// 扫收款机上生成的码支付
|
||||
if (action === "harQrCodeScanPay") {
|
||||
const { mchId, orderId } = paramsObj
|
||||
const { mchId, orderId } = searchParams
|
||||
router.jump("/pages/pay/scanPay", { action, mchId, orderId })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ const TABBAR_CONSTANT: Array<TabbarItem> = [
|
||||
},
|
||||
{
|
||||
pagePath: "/pages/tabbar/prosperityShopMchList",
|
||||
text: "共富商城",
|
||||
text: "共富商家",
|
||||
iconPath: "/static/tabbar/prosperity-shop.png",
|
||||
selectedIconPath: "/static/tabbar/prosperity-shop-select.png",
|
||||
launchParam: ["prosperityShopMchList"],
|
||||
|
||||
@@ -38,3 +38,13 @@ export const getLaunchParam = (url?: string) => {
|
||||
const params = getUrlParams(url)
|
||||
return params?.launchParam
|
||||
}
|
||||
|
||||
export const getUrlParamsObj = (url?: string): Record<string, any> => {
|
||||
if (!url) {
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
url = currentPage?.route ?? ""
|
||||
}
|
||||
const params = getUrlParams(url)
|
||||
return params
|
||||
}
|
||||
Reference in new issue
Block a user