feat:生成钱包二维码定时刷新

This commit is contained in:
dzc committed 2024-12-03 17:48:18 +08:00
1 parent 6de8e064a5
commit 1886bc7cfb
5 files changed
+1433 -6

No files matched your search

+43 -5
View File
@@ -2,6 +2,7 @@
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash"
import uqrcode from "@@/utils/uqrcode"
import { hooks, router } from "@@/index"
import { merchantApi, walletApi } from "@@/api"
@@ -9,6 +10,7 @@ import { merchantApi, walletApi } from "@@/api"
const state = reactive<any>({
showBindDialog: false,
showFreezeDialog: false,
showQrCodeDialog: false,
currentCard: {}
})
const bindForm = reactive<any>({
@@ -17,8 +19,8 @@ const bindForm = reactive<any>({
const bindFormRules = reactive<any>({
cardNumber: [
{ required: true, message: '请输入卡号' },
{ required: true, min: 8, message: '饭卡长度在8位' },
{ required: true, max: 8, message: '饭卡长度在8位' },
{ required: true, min: 12, message: '饭卡长度在12位' },
{ required: true, max: 12, message: '饭卡长度在12位' },
]
})
const freezeForm = reactive<any>({
@@ -76,6 +78,31 @@ const openFreezeDialog = (v: any) => {
const closeFreezeDialog = () => {
state.showFreezeDialog = false
}
const doPreviewQrCode = async (v: any) => {
uni.showLoading({ title: '生成中...', mask: false });
const _pa = { walletId: v.id }
try {
const { data, code }: any = await walletApi.getQrCode(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
state.showQrCodeDialog = true
uqrcode.make({
canvasId: 'qrcodeId',
text: data,
size: 200,
margin: 0,
success: res => {
console.log(res, "res");
},
complete: () => {
uni.hideLoading()
}
})
} catch (error) {
console.error(error);
uni.hideLoading()
}
}
const doFreeze = async () => {
try {
uni.showLoading({ title: '申请中...', mask: false });
@@ -105,12 +132,16 @@ const doFreeze = async () => {
<view class="h-30rpx" />
<view class="card flex-col rounded-20rpx p-x-30rpx p-y-20rpx m-b-30rpx" v-for="(v, i) in pageHook.list"
:key="i" @tap="router.jump('/pages/wallet/detail', { id: v.id })">
<view v-if="v.cardNumber" class="flex-col" @tap.stop="hooks.useCopy(v.cardNumber)">
<view class="flex-col">
<view class="flex-row items-center justify-between">
<view class="flex-row-center">
<text class="second-text-28">卡号: {{ v.cardNumber }}</text>
<text v-if="v.cardNumber" class="second-text-28">卡号: {{ v.cardNumber }}</text>
</view>
<view class="second-text-50">
<text v-if="v.cardNumber" class="iconfont icon-fuzhi"
@tap.stop="hooks.useCopy(v.cardNumber)" />
<text class="m-l-20rpx iconfont icon-erweima" @tap.stop="doPreviewQrCode(v)" />
</view>
<text class="second-text-50 iconfont icon-fuzhi" />
</view>
<view class="h-1px m-t-10rpx bg-#999 bg-opacity-5" />
</view>
@@ -178,6 +209,13 @@ const doFreeze = async () => {
冻结
</view>
</tm-drawer>
<tm-drawer z-index="100" v-model:show="state.showQrCodeDialog" :overlayClick="false" title="钱包二维码"
:show-close="true" position="bottom" size="50%">
<view class="flex-col-center">
<view class="h-80rpx" />
<canvas canvas-id="qrcodeId" class="size-200px" />
</view>
</tm-drawer>
</template>
<style lang="scss" scoped></style>
+9
View File
@@ -9,6 +9,15 @@ export default {
showLoading: false,
},
}),
getQrCode: (params: any) =>
request({
url: "pay/wallet/get-qr-code",
method: "GET",
params,
custom: {
showLoading: false,
},
}),
detail: (params: any) =>
request({
url: "pay/wallet/detail",
View File
Whitespace-only changes.
+2 -1
View File
@@ -1 +1,2 @@
export * from './request'
export * from "./request";
export * as uqrcode from "./uqrcode";
File diff suppressed because it is too large. Load diff