feat(pay): 支付二维码展示使用组件替换

This commit is contained in:
appleyou 2025-04-17 13:28:24 +08:00
parent 6a831d8c3e
commit 0d5c16eaa2
3 changed files with 50 additions and 137 deletions

View File

@ -5,6 +5,7 @@
mode="center" mode="center"
closeable closeable
:round="10" :round="10"
@close="closeHandler"
> >
<view class="qr-code-container-content"> <view class="qr-code-container-content">
<view class="qr-code-container-title">{{ title }}</view> <view class="qr-code-container-title">{{ title }}</view>
@ -55,6 +56,9 @@ export default {
} }
}, },
methods: { methods: {
closeHandler() {
this.$emit('update:show', false)
},
initQRCode() { initQRCode() {
if (!this.qrData) return if (!this.qrData) return
this.$nextTick(() => { this.$nextTick(() => {
@ -64,11 +68,6 @@ export default {
qrCode.make() qrCode.make()
const canvasContext = uni.createCanvasContext('QRCodeCanvas', this) const canvasContext = uni.createCanvasContext('QRCodeCanvas', this)
qrCode.canvasContext = canvasContext qrCode.canvasContext = canvasContext
console.log(
'%c [ qrCode ]-58',
'font-size:13px; background:#777244; color:#bbb688;',
qrCode
)
qrCode.drawCanvas() qrCode.drawCanvas()
}) })
} }

View File

@ -8,7 +8,7 @@ import { getToken, removeToken } from '@/config/auth.js'
module.exports = (vm) => { module.exports = (vm) => {
// 初始化请求配置 // 初始化请求配置
uni.$u.http.setConfig((config) => { uni.$u.http.setConfig((config) => {
config.baseURL = 'http://t-app.beida413.com/prod-api' config.baseURL = 'http://192.168.0.104:8080'
// 192.168.0.100:8080 // 192.168.0.100:8080
//#ifdef DEV_SERVER //#ifdef DEV_SERVER

View File

@ -10,17 +10,17 @@
<view class="contxt"> <view class="contxt">
<!-- 充值 --> <!-- 充值 -->
<template v-if="ifcz"> <template v-if="ifcz">
<div class="tit4">{{ '充值金额' }}</div> <div class="tit4">充值金额</div>
<u-input class="czinputbox" v-model="czJe"></u-input> <u-input class="czinputbox" v-model="czJe"></u-input>
</template> </template>
<template v-else> <template v-else>
<view class="tit">{{ '待支付金额' }}</view> <view class="tit">待支付金额</view>
<view class="tit1"> <view class="tit1">
{{ userInfo.currencyIcon {{ userInfo.currencyIcon
}}{{ orderData.orderAmount | numberToCurrency }} }}{{ orderData.orderAmount | numberToCurrency }}
</view> </view>
<view class="tit2" <view class="tit2"
>{{ '请在' }} <view class="tit3">{{ countDown }}</view >请在 <view class="tit3">{{ countDown }}</view
>{{ '内完成支付,否则订单将会被自动取消' }} >{{ '内完成支付,否则订单将会被自动取消' }}
</view> </view>
</template> </template>
@ -642,7 +642,7 @@
@tap="quickPay(ifcz)" @tap="quickPay(ifcz)"
color="linear-gradient(to right, #fb3024, #fb3024 )" color="linear-gradient(to right, #fb3024, #fb3024 )"
> >
{{ '立即支付' }} 立即支付
</u-button> </u-button>
</view> </view>
</view> </view>
@ -658,19 +658,12 @@
:asyncClose="true" :asyncClose="true"
></u-modal> ></u-modal>
<!-- 二维码 --> <!-- 二维码 -->
<u-popup :show="wxPopup" mode="center" closeable @close="closewxPopup"> <!-- <u-popup :show="wxPopup" mode="center" closeable @close="closewxPopup">
<view class="t_tit">{{ '微信支付' }}</view> <view class="t_tit">{{ '微信支付' }}</view>
<view class="pay_code"> <view class="pay_code">
<canvas canvas-id="qrcodeCanvasWx" style="width: 280px; height: 280px;"></canvas> <canvas canvas-id="qrcodeCanvasWx" style="width: 280px; height: 280px;"></canvas>
</view> </view>
</u-popup> </u-popup> -->
<!-- 支付宝二维码 -->
<u-popup :show="wxPopup1" mode="center" closeable @close="closewxPopup">
<view class="t_tit">{{ '支付宝支付' }}</view>
<view class="pay_code">
<canvas canvas-id="qrcodeCanvasAlipay" style="width: 280px; height: 280px;"></canvas>
</view>
</u-popup>
<successDialog <successDialog
@successClose="successClose" @successClose="successClose"
ref="successDialog" ref="successDialog"
@ -684,7 +677,7 @@
:showCancelButton="true" :showCancelButton="true"
content="是否确定解绑该银行卡" content="是否确定解绑该银行卡"
></u-modal> ></u-modal>
<QRCode :qrData="qrData" :show="qrCodeVisible" /> <QRCode :qrData="qrData" :show.sync="qrCodeVisible" />
</view> </view>
</template> </template>
@ -732,8 +725,6 @@ export default {
showSucce: false, // showSucce: false, //
sucPay: 0, sucPay: 0,
content: '支付成功', content: '支付成功',
wxPopup: false,
wxPopup1: false,
luckydrawData: {}, luckydrawData: {},
ifcz: false, ifcz: false,
czJe: '', czJe: '',
@ -803,6 +794,10 @@ export default {
// //
// this.getBankList() // this.getBankList()
}, },
onUnload() {
clearInterval(this.clockTime)
clearInterval(this.payStatus)
},
methods: { methods: {
showQRCode(text) { showQRCode(text) {
this.qrCodeVisible = true this.qrCodeVisible = true
@ -849,11 +844,6 @@ export default {
} }
}) })
}, },
closewxPopup() {
this.wxPopup = false
this.wxPopup1 = false
clearInterval(payStatus)
},
// //
bindBank(val) { bindBank(val) {
uni.navigateTo({ uni.navigateTo({
@ -1174,115 +1164,51 @@ export default {
} }
}, },
scanPayBfWx(val) { scanPayBfWx(val) {
let params const params = {
if (this.ifcz) { businessType: this.ifcz ? 3 : this.businessType, //
params = { businessCode: this.orderCode,
businessType: 3, // payChannel: val,
businessCode: this.orderCode, payType: 2,
payChannel: val,
payType: 2,
}
} else {
params = {
businessType: this.businessType, //
businessCode: this.orderCode,
payChannel: val,
payType: 2,
}
} }
api.unifiedorder(params).then(res => { api.unifiedorder(params).then(res => {
this.wxPopup = true this.showQRCode(res.data)
this.$nextTick(() => {
const ctx = uni.createCanvasContext('qrcodeCanvasWx', this)
const uqrcode = new UQRCode(ctx, { width: 280, height: 280 })
uqrcode.make(res.data).then(() => {
uqrcode.drawCanvas()
})
})
}) })
this.checkPayStatus(params) this.checkPayStatus(params)
}, },
// //
scanPayWx(val) { scanPayWx(val) {
let params const params = {
if (this.ifcz) { businessType: this.ifcz ? 3 : this.businessType, //
params = { businessCode: this.orderCode,
businessType: 3, // payChannel: val,
businessCode: this.orderCode, payType: 2,
payChannel: val,
payType: 2,
}
}
else {
params = {
businessType: this.businessType, //
businessCode: this.orderCode,
payChannel: val,
payType: 2,
}
api.unifiedorder(params).then(res => {
this.wxPopup = true
this.$nextTick(() => {
const ctx = uni.createCanvasContext('qrcodeCanvasWx', this)
const uqrcode = new UQRCode(ctx, { width: 280, height: 280 })
uqrcode.make(res.data).then(() => {
uqrcode.drawCanvas()
})
})
})
this.checkPayStatus(params)
} }
api.unifiedorder(params).then(res => {
this.showQRCode(res.data)
})
this.checkPayStatus(params)
}, },
// //
scanPayAl(val) { scanPayAl(val) {
let params const params = {
if (this.ifcz) { businessType: this.ifcz ? 3 : this.businessType, //
params = { businessCode: this.orderCode,
businessType: 3, // payChannel: val,
businessCode: this.orderCode, payType: 1,
payChannel: val,
payType: 1,
}
} else {
params = {
businessType: this.businessType, //
businessCode: this.orderCode,
payChannel: val,
payType: 1,
}
} }
api.unifiedorder(params).then(res => { api.unifiedorder(params).then(res => {
this.wxPopup1 = true this.showQRCode(res.data)
this.$nextTick(() => {
const ctx = uni.createCanvasContext('qrcodeCanvasAlipay', this)
const uqrcode = new UQRCode(ctx, { width: 280, height: 280 })
uqrcode.make(res.data).then(() => {
uqrcode.drawCanvas()
})
})
}) })
this.checkPayStatus(params) this.checkPayStatus(params)
}, },
// //
scanPayBfWxJump(val) { scanPayBfWxJump(val) {
let params const params = {
if (this.ifcz) { businessType: this.ifcz ? 3 : this.businessType, //
params = { businessCode: this.orderCode,
businessType: 3, // payChannel: val,
businessCode: this.orderCode, payType: 2,
payChannel: val, appletFlag: 0,
payType: 2,
appletFlag: 0,
}
} else {
params = {
businessType: this.businessType, //
businessCode: this.orderCode,
payChannel: val,
payType: 2,
appletFlag: 0,
}
} }
api.unifiedorder(params).then(res => { api.unifiedorder(params).then(res => {
let url = let url =
@ -1297,23 +1223,12 @@ export default {
}, },
// //
scanPayTlWxJump(val) { scanPayTlWxJump(val) {
let params const params = {
if (this.ifcz) { businessType: this.ifcz ? 3 : this.businessType, //
params = { businessCode: this.orderCode,
businessType: 3, // payChannel: val,
businessCode: this.orderCode, payType: 2,
payChannel: val, appletFlag: 0,
payType: 2,
appletFlag: 0,
}
} else {
params = {
businessType: this.businessType, //
businessCode: this.orderCode,
payChannel: val,
payType: 2,
appletFlag: 0,
}
} }
api.unifiedorder(params).then(res => { api.unifiedorder(params).then(res => {
let url = let url =
@ -1418,8 +1333,7 @@ export default {
this.$refs.successDialog.showSuccess(res.data) this.$refs.successDialog.showSuccess(res.data)
}) })
} else { } else {
this.wxPopup = false this.qrCodeVisible = false
this.wxPopup1 = false
this.showSucce = true this.showSucce = true
} }
} else { } else {