修改支付跳转参数

This commit is contained in:
zhouyanli
2026-07-25 16:30:00 +08:00
parent 9ebe66cacb
commit a3f35f95b5
4 changed files with 72 additions and 22 deletions

View File

@@ -28,6 +28,8 @@
<script setup>
import { ref, reactive } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { getBankMiniProgramParams } from '/pageSubPack/api/apiSub.js'
import { showApiError } from '/pageSubPack/api/request.js'
import { getAppPaymentData, clearAppPaymentData, buildPaymentItemFromApp } from '/pageSubPack/api/appLaunch.js'
const paymentItem = reactive({})
@@ -66,21 +68,36 @@ const loadPaymentItem = () => {
const goBack = () => uni.redirectTo({ url: '/pages/paymentIndex/paymentIndex' })
const handlePay = () => {
navigatedToPayment.value = true
wx.navigateToMiniProgram({
appId: 'wxc0189436c58b59cd',
path: 'pages/pay/pay',
extraData: { ...paymentItem },
envVersion: 'trial',
success: () => console.log('已跳转到日照银行支付小程序'),
fail: (err) => {
navigatedToPayment.value = false
console.error('跳转日照银行支付失败', err)
uni.showToast({ title: '拉起支付失败', icon: 'none' })
const handlePay = async () => {
uni.showLoading({ title: '加载中...', mask: true })
try {
// 调用后端获取日照银行支付参数
const res = await getBankMiniProgramParams({ ...paymentItem })
uni.hideLoading()
if (res.code !== 200 || !res.data) {
uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' })
return
}
console.log('支付参数====', JSON.stringify(res.data))
navigatedToPayment.value = true
wx.navigateToMiniProgram({
appId: 'wxc0189436c58b59cd',
path: 'pages/pay/pay',
extraData: res.data,
envVersion: 'trial',
success: () => console.log('已跳转到日照银行支付小程序'),
fail: (err) => {
navigatedToPayment.value = false
console.error('跳转日照银行支付失败', err)
uni.showToast({ title: '拉起支付失败', icon: 'none' })
}
})
} catch (err) {
uni.hideLoading()
showApiError(err)
console.error('支付失败:', err)
}
})
}
}
const handleBackToList = () => uni.redirectTo({ url: '/pages/paymentIndex/paymentIndex' })
</script>