修改支付页跳转

This commit is contained in:
zhouyanli
2026-07-25 16:30:50 +08:00
parent 6cb10fee08
commit ebc8cfa3cb
4 changed files with 74 additions and 75 deletions

View File

@@ -114,7 +114,6 @@
if (options && options.referrerInfo && options.referrerInfo.extraData) {
const extraData = options.referrerInfo.extraData
if (extraData.retCode === 'SUCCESS') {
currentStep.value = 2
sendPaySuccessPush()
uni.redirectTo({
url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay'
@@ -154,23 +153,25 @@
// 立即缴费 — 通过微信拉起日照银行小程序进行支付
const handlePay = async () => {
const amount = arrearsAmount.value
try {
uni.showLoading({ title: '加载中...' })
// 设备类型映射物业费→3车位费→4垃圾处理费→5
const deviceTypeMap = { '物业费': '3', '车位费': '4', '垃圾处理费': '5' }
const mappedDeviceType = deviceTypeMap[switchStatus(paymentItem.type)] || ''
const mappedDeviceType = deviceTypeMap[switchStatus(paymentItem.type)] || paymentItem.deviceType || ''
const res = await getBankMiniProgramParams({
acct: uni.getStorageSync('userId'),
orderType: '20',
orderAmount: String(Math.round(Number(payAmount.value) * 100)),
orderType: '10',
orderAmount: String(Math.round(Number(amount) * 100)),
deviceCode: paymentItem.deviceCode || '',
deviceType: mappedDeviceType,
billId: paymentItem.billId || '',
residentUserId: uni.getStorageSync('userId'),
goodName: paymentItem.name || ''
goodName: paymentItem.name || switchStatus(paymentItem.type) || '',
remark:'服务费'
})
uni.hideLoading()
@@ -180,7 +181,6 @@
return
}
console.log('resres返回数据', res)
console.log('resres', res.data)
const { appId, path, extraData } = res.data
console.log('navigateToMiniProgram参数:', { appId, path, extraData })
@@ -192,20 +192,16 @@
return
}
// 解析 extraData(后端返回可能是字符串或对象)
let extraDataObj = extraData
if (typeof extraData === 'string') {
try {
extraDataObj = JSON.parse(extraData)
} catch (e) {
console.error('extraData JSON解析失败使用空对象', e)
extraDataObj = {}
}
}
if (!extraDataObj || typeof extraDataObj !== 'object') {
extraDataObj = {}
}
// extraData 对象和支付金额、token拼成查询字符串传入中间小程序实现免登录
const token = uni.getStorageSync('token') || ''
const payAmountStr = String(payAmount.value)
const orderAmountStr = String(Math.round(Number(amount) * 100))
// extraData 是对象,先转为 query string 再拼接额外参数
const extraDataStr = typeof extraData === 'object' && extraData !== null
? Object.keys(extraData).map(k => encodeURIComponent(k) + '=' + encodeURIComponent(extraData[k])).join('&')
: (extraData || '')
const extraDataWithAmount = extraDataStr + '&payAmount=' + encodeURIComponent(payAmountStr) + '&orderAmount=' + encodeURIComponent(orderAmountStr) + '&token=' + encodeURIComponent(token)
console.log('传入中间小程序的extraData:', extraDataWithAmount)
// #ifdef APP-PLUS
// 原生App通过微信SDK拉起小程序
plus.share.getServices((services) => {
@@ -218,13 +214,23 @@
uni.showToast({ title: '当前微信版本太低,不支持拉起小程序', icon: 'none' })
return
}
weixin.launchMiniProgram({
id: appId,
type: 0, // 0=正式版 1=测试版 2=预览版
path: path || '',
extraData: extraDataObj
}, () => {
console.log('成功拉起日照银行小程序App')
id: 'gh_a765aef0172c',
// appId: 'wx40625124315d2de1',
type:1, // 0 正式版 / 1测试版 / 2预览版
path: 'pageSubPack/payment-list/arrearsPayment',
extraData: extraData,
}, (res) => {
console.log('ress-------------',res)
// if (res.retCode === 'SUCCESS') {
// console.log('成功拉起日照银行小程序App', res.retCode)
// } else {
// console.log('拉起日照银行小程序返回失败App======)', res.retMsg)
// }
console.log('回调---日照银行小程序回调结果App', JSON.stringify(res))
}, (err) => {
console.error('拉起日照银行小程序失败App', JSON.stringify(err))
uni.showToast({ title: '拉起支付小程序失败', icon: 'none' })
@@ -232,22 +238,22 @@
})
// #endif
// #ifdef MP-WEIXIN
// 微信小程序直接navigateToMiniProgram
uni.navigateToMiniProgram({
appId: appId,
path: path || '',
extraData: extraDataObj,
envVersion: 'develop',
success: () => {
console.log('成功拉起日照银行小程序(微信)')
},
fail: (err) => {
console.error('拉起日照银行小程序失败(微信)', JSON.stringify(err))
uni.showToast({ title: err.errMsg || err.msg || '拉起支付小程序失败', icon: 'none' })
}
})
// #endif
// // #ifdef MP-WEIXIN
// // 微信小程序直接navigateToMiniProgram
// uni.navigateToMiniProgram({
// appId: appId,
// path: path || '',
// extraData: extraData,
// envVersion: 'develop',
// success: () => {
// console.log('成功拉起日照银行小程序(微信)')
// },
// fail: (err) => {
// console.error('拉起日照银行小程序失败(微信)', JSON.stringify(err))
// uni.showToast({ title: err.errMsg || err.msg || '拉起支付小程序失败', icon: 'none' })
// }
// })
// // #endif
} catch (err) {
uni.hideLoading()
console.error('获取支付参数异常', err)