扫码支付钱包选择
This commit is contained in:
1 parent
2c8e8ff9bd
commit
48e791ea5c
1 file changed
+41
-4
@@ -7,7 +7,31 @@
|
||||
<span class="text-2xl text-[#333] mr-1 line-height-normal">¥</span>
|
||||
<span class="text-3xl font-medium text-[#333]">{{ displayAmount }}</span>
|
||||
</tm-sheet>
|
||||
<tm-button class="mt-40" :block="true" @click="disabled ? '' : handlePay()" :disabled="disabled">支付</tm-button>
|
||||
|
||||
<tm-sheet v-if="walletList.length > 0" class="flex flex-col">
|
||||
<view class="text-gray-700 font-bold text-sm mb-2">选择支付钱包:</view>
|
||||
<tm-radio-group v-model="curWalletId" direction="column">
|
||||
<tm-radio :value="v.id" v-for="(v, index) in walletList" :key="index">
|
||||
<template v-slot:label="{ checked }">
|
||||
<view
|
||||
class="card relative border-4 border-solid border-#efefef flex justify-between items-center p-3"
|
||||
:class="{ 'border-4 border-solid border-blue!': curWalletId == v.id }"
|
||||
>
|
||||
<view class="flex items-center">
|
||||
<image class="w-70 h-70 mr-2" :src="filePath(v.walletTypeIcon)" />
|
||||
<view class="main-text-32">{{ v.walletTypeName }}</view>
|
||||
</view>
|
||||
<view class="main-text-28 flex items-center">
|
||||
<view>余额:{{ hooks.useMoney(v.balance) }}</view>
|
||||
<text>元</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</tm-radio>
|
||||
</tm-radio-group>
|
||||
</tm-sheet>
|
||||
|
||||
<tm-button class="mt-1" :block="true" @click="disabled ? '' : handlePay()" :disabled="disabled">支付</tm-button>
|
||||
|
||||
<numberKeyboard v-model="amount" />
|
||||
</view>
|
||||
@@ -16,19 +40,23 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from "vue"
|
||||
import { onShow } from "@dcloudio/uni-app"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
import { usePayStore } from "@/sheep/stores/pay"
|
||||
import payApi from "@@/api/pay"
|
||||
import { storePrice } from "@/sheep/utils/formatMoney"
|
||||
import { router } from "@/sheep"
|
||||
import { merchantApi } from "@/sheep/api"
|
||||
import { merchantApi, walletApi } from "@/sheep/api"
|
||||
import numberKeyboard from "@/sheep/components/numberKeyboard.vue"
|
||||
import { filePath } from "@/sheep/utils/file"
|
||||
import { hooks } from "@@/index"
|
||||
|
||||
const amount = ref("")
|
||||
const scanData = ref<{ id?: string; name?: string }>({})
|
||||
const disabled = ref(false)
|
||||
const walletList = ref<any>([])
|
||||
const curWalletId = ref("")
|
||||
|
||||
onShow(async () => {
|
||||
onLoad(async () => {
|
||||
uni.showLoading({ title: "加载中...", mask: true })
|
||||
scanData.value.id = usePayStore().payData.id
|
||||
if (scanData.value.id) {
|
||||
@@ -40,6 +68,14 @@ onShow(async () => {
|
||||
uni.showToast({ title: "扫码信息不存在", icon: "none" })
|
||||
disabled.value = true
|
||||
}
|
||||
|
||||
const res = await walletApi.all()
|
||||
if (res.code == 0) {
|
||||
walletList.value = res.data.records
|
||||
if (walletList.value.length > 0) {
|
||||
curWalletId.value = walletList.value.find((v: any) => v.walletTypeUniqueCode == "1").id
|
||||
}
|
||||
}
|
||||
uni.hideLoading()
|
||||
})
|
||||
|
||||
@@ -81,6 +117,7 @@ const pay = async () => {
|
||||
const res = await payApi.createQrCodeOrder({
|
||||
merchantId: scanData.value.id,
|
||||
customPrice: storePrice(Number(amount.value)),
|
||||
walletId: curWalletId.value,
|
||||
})
|
||||
if (res.code != 0) {
|
||||
uni.showToast({ title: res.msg || "支付失败", icon: "error" })
|
||||
|
||||
Reference in new issue
Block a user