扫码支付修改

This commit is contained in:
weiwei committed 2025-05-08 11:11:41 +08:00
1 parent ecbdb04a05
commit d9133f2ced
5 files changed
+35 -25

No files matched your search

+26 -16
View File
@@ -1,7 +1,7 @@
<template>
<crud-layout bg="/static/page/blue-bg.png">
<view class="h-screen flex flex-col">
<view class="mx-auto text-34 py-2 h-80rpx">{{ scanData.name }}</view>
<view class="mx-auto text-34 py-2 h-80rpx">{{ scanCodeData.name }}</view>
<tm-sheet class="flex flex-row">
<span class="text-2xl text-[#333] mr-1 line-height-normal">¥</span>
@@ -36,8 +36,8 @@
</template>
<script setup lang="ts">
import { ref, computed } from "vue"
import { onShow } from "@dcloudio/uni-app"
import { ref, computed, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { usePayStore } from "@/sheep/stores/pay"
import payApi from "@@/api/pay"
import { storePrice } from "@/sheep/utils/formatMoney"
@@ -46,23 +46,33 @@ import { merchantApi, walletApi } from "@/sheep/api"
import numberKeyboard from "@/sheep/components/numberKeyboard.vue"
import { filePath } from "@/sheep/utils/file"
import { hooks } from "@@/index"
import { isEmpty } from "radash"
const amount = ref("")
const scanData = ref<{ id?: string; name?: string }>({})
const disabled = ref(false)
const scanCodeData = reactive({
id: "",
name: "",
})
const walletList = ref<any>([])
const curWalletId = ref("")
const disabled = ref(false)
const amount = ref("")
onLoad((options: any) => {
if (!isEmpty(options.id)) {
scanCodeData.id = options.id
} else {
uni.showToast({ title: "参数不存在", icon: "none" })
}
})
onShow(async () => {
uni.showLoading({ title: "加载中...", mask: true })
scanData.value.id = usePayStore().payData.id
if (scanData.value.id) {
const { data } = await merchantApi.detail({ id: scanData.value.id })
scanData.value.name = data.name
usePayStore().setPayData(scanData.value)
if (scanCodeData.id) {
const { data } = await merchantApi.detail({ id: scanCodeData.id })
scanCodeData.name = data.name
disabled.value = false
} else {
uni.showToast({ title: "扫码信息不存在", icon: "none" })
uni.showToast({ title: "参数不存在", icon: "none" })
disabled.value = true
}
@@ -88,7 +98,7 @@ const displayAmount = computed(() => {
// 点击支付
const handlePay = () => {
if (!scanData.value.id || !scanData.value.name) return uni.showToast({ title: "扫码信息不存在", icon: "none" })
if (!scanCodeData.id || !scanCodeData.name) return uni.showToast({ title: "扫码参数不存在", icon: "none" })
if (!amount.value) {
uni.showToast({ title: "请输入金额", icon: "none" })
return
@@ -112,7 +122,7 @@ const pay = async () => {
try {
uni.showLoading({ title: "支付中...", mask: true })
const res = await payApi.createQrCodeOrder({
merchantId: scanData.value.id,
merchantId: scanCodeData.id,
customPrice: storePrice(Number(amount.value)),
walletId: curWalletId.value,
})
@@ -120,11 +130,11 @@ const pay = async () => {
uni.showToast({ title: res.msg || "支付失败", icon: "error" })
} else {
uni.hideLoading()
usePayStore().setPayData({ ...scanData.value, customPrice: Number(amount.value).toFixed(2) })
usePayStore().setPayData({ id: scanCodeData.id, name: scanCodeData.name, customPrice: Number(amount.value).toFixed(2) })
router.jump("/pages/pay/payComplete", {}, 2)
}
} catch (error: any) {
uni.showToast({ title: "错误", icon: "error" })
uni.showToast({ title: "请求错误", icon: "error" })
uni.hideLoading()
}
}
+1 -1
View File
@@ -17,7 +17,7 @@
<view class="h-30rpx" />
<tm-sheet v-if="false" v-for="(item, index) in pageHook.list" :key="index" :margin="[0, 20]">
<view class="text-36 overflow-hidden text-nowrap text-ellipsis">
文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本 TmText文本
文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本TmText文本
</view>
<view class="flex items-center">
<image src="@/static/page/时间.svg" mode="aspectFill" class="w-28rpx h-28rpx mr-1" />
+3 -6
View File
@@ -270,7 +270,6 @@ const login = {
const scanCode = {
// 扫一扫
scan: async () => {
usePayStore().setPayData({})
try {
const decodedString = await scanCode.getScanResult()
if (decodedString) {
@@ -291,9 +290,8 @@ const scanCode = {
if (isDevEnv()) {
// 开发环境模拟扫码
// const testQrCode = "eyJpZCI6IjE4OTYxNTcyMDc2NDQwNTM1MDYiLCJuYW1lIjoi5rWL6K+V5ZWG5oi3In0=" // 线上-测试超市-收款码
// const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 测试环境-邓本地-新县府超市-收款码
// const testQrCode = "eyJpZCI6IjE5MDc2ODQwNTY4NDA4NDMyNjYiLCJuYW1lIjoi5pm66IO95p+c6Ieq6JCl5ZWG5oi3MSJ9" // 测试环境-邓本地-智能柜自营商户1-收款码
const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxMzE1NzA4MDQxODI5NTgwOSIsImNhYmluZXRObyI6IjEifQ==" // 测试智能柜货柜二维码
const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 测试环境-邓本地-新县府超市-收款码
// const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxMzE1NzA4MDQxODI5NTgwOSIsImNhYmluZXRObyI6IjEifQ==" // 测试智能柜货柜二维码
uni.showModal({ content: "开发环境不是浙政钉和诗画环境,扫码仅供测试,收款商家为测试商户超市" })
return scanCode.decodeBase64(testQrCode)
} else if (state.appInfo == "zzd") {
@@ -314,8 +312,7 @@ const scanCode = {
try {
const decodedJson = JSON.parse(decodedString)
if (decodedJson?.id && decodedJson?.name) {
usePayStore().setPayData(decodedJson)
router.jump("/pages/pay/scanPay")
router.jump("/pages/pay/scanPay", { id: decodedJson.id, name: decodedJson.name })
} else if (decodedJson?.hardDoorId && decodedJson?.cabinetNo) {
router.jump("/pages/cabinet/buy", { hardDoorId: decodedJson.hardDoorId, cabinetNo: decodedJson.cabinetNo })
} else {
+1 -1
View File
@@ -31,7 +31,7 @@
class="flex-1 h-[80rpx] flex items-center justify-center bg-white mx-[5px] rounded-lg cursor-pointer select-none active:bg-[#f0f0f0]"
@click="handleDelete"
>
<image class="w-[30rpx] h-[30rpx]" src="@/static/page/keyboardDelete.svg" />
<image class="w-[40rpx] h-[40rpx]" src="@/static/page/keyboardDelete.svg" />
</view>
</view>
</view>
+4 -1
View File
@@ -48,7 +48,10 @@ async function handleZzdLogin(): Promise<boolean> {
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (!token) return false
if (!token) {
uni.showToast({ title: "用户凭证已失效,请重新进入智慧后勤应用", icon: "none", duration: 6000 })
return false
}
const res = await userApi.auth(token)
if (res?.code == 0) {