修改bug
This commit is contained in:
@@ -108,12 +108,6 @@
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
|
||||
import {
|
||||
getPushSingle
|
||||
} from '/pageSubPack/api/api.js'
|
||||
import {
|
||||
getBankMiniProgramParams
|
||||
} from '/pageSubPack/api/apiSub.js'
|
||||
|
||||
// 响应式数据
|
||||
const outstandingPayment = ref(true)
|
||||
@@ -172,14 +166,7 @@
|
||||
}
|
||||
|
||||
// 立即缴费 — 通过微信拉起日照银行小程序进行支付
|
||||
const handlePay = async () => {
|
||||
// if (!payNum.value || Number(payNum.value) <= 0) {
|
||||
// uni.showToast({
|
||||
// title: '请输入正确的缴费金额',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
const handlePay = () => {
|
||||
const amount = arrearsAmount.value
|
||||
|
||||
try {
|
||||
@@ -189,45 +176,25 @@
|
||||
const deviceTypeMap = { '电费': '1', '水费': '2' }
|
||||
const mappedDeviceType = deviceTypeMap[paymentItem.type] || paymentItem.deviceType || ''
|
||||
|
||||
const res = await getBankMiniProgramParams({
|
||||
// 直接从本地参数拼 path 查询字符串传给支付小程序,不走接口
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
const params = {
|
||||
acct: uni.getStorageSync('userId'),
|
||||
orderType: '10',
|
||||
orderAmount: String(Math.round(Number(amount) * 100)),
|
||||
// orderAmount: String(Math.round(Number(arrearsAmount.value) * 100)),
|
||||
orderType: '20',
|
||||
deviceCode: paymentItem.deviceCode || '',
|
||||
deviceType: mappedDeviceType,
|
||||
billId: paymentItem.billId || '',
|
||||
residentUserId: uni.getStorageSync('userId'),
|
||||
goodName: paymentItem.name || switchStatus(paymentItem.type) || '',
|
||||
remark:'服务费'
|
||||
})
|
||||
// goodName: paymentItem.name || switchStatus(paymentItem.type) || '',
|
||||
// remark: '服务费',
|
||||
token: token
|
||||
}
|
||||
const queryString = Object.keys(params).map(k =>
|
||||
encodeURIComponent(k) + '=' + encodeURIComponent(params[k])
|
||||
).join('&')
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.code !== 200 || !res.data) {
|
||||
uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
console.log('resres返回数据', res)
|
||||
// console.log('resres', res.data)
|
||||
|
||||
const { appId, path, extraData } = res.data
|
||||
console.log('navigateToMiniProgram参数:', { appId, path, extraData })
|
||||
|
||||
// 校验必要参数
|
||||
if (!appId) {
|
||||
console.error('缺少appId,无法拉起支付小程序', res.data)
|
||||
uni.showToast({ title: '获取支付参数失败:缺少appId', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 把支付金额和token拼接到 extraData 查询字符串中传入中间小程序,实现免登录
|
||||
const token = uni.getStorageSync('token') || ''
|
||||
const payAmountStr = String(payAmount.value)
|
||||
const orderAmountStr = String(Math.round(Number(amount) * 100))
|
||||
const custId = uni.getStorageSync('custId') || ''
|
||||
const extraDataWithAmount = extraData + '&payAmount=' + encodeURIComponent(payAmountStr) + '&orderAmount=' + encodeURIComponent(orderAmountStr) + '&token=' + encodeURIComponent(token) + '&custId=' + encodeURIComponent(custId)
|
||||
console.log('传入中间小程序的extraData:', extraDataWithAmount)
|
||||
console.log('传入中间小程序的path参数:', queryString)
|
||||
// #ifdef APP-PLUS
|
||||
// 原生App:通过微信SDK拉起小程序
|
||||
plus.share.getServices((services) => {
|
||||
@@ -241,49 +208,22 @@
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
weixin.launchMiniProgram({
|
||||
id: 'gh_a765aef0172c',
|
||||
// appId: 'wx40625124315d2de1',
|
||||
type:1, // 0 正式版 / 1测试版 / 2预览版
|
||||
path: 'pageSubPack/payment-list/arrearsPayment',
|
||||
extraData: extraDataWithAmount,
|
||||
type: 1, // 0 正式版 / 1测试版 / 2预览版
|
||||
path: 'pages/arrearsPayment/arrearsPayment?' + queryString,
|
||||
}, (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('err---拉起失败(App)', JSON.stringify(err))
|
||||
uni.showToast({ title: '拉起支付小程序失败', 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
|
||||
// #endif
|
||||
} catch (err) {
|
||||
uni.hideLoading()
|
||||
console.error('获取支付参数异常', err)
|
||||
uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' })
|
||||
console.error('拉起支付小程序异常', err)
|
||||
uni.showToast({ title: '请求异常,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user