修改bug

This commit is contained in:
zhouyanli
2026-07-28 11:11:39 +08:00
parent ebc8cfa3cb
commit a9a5afaf26
7 changed files with 145 additions and 230 deletions

View File

@@ -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' })
}
}

View File

@@ -83,9 +83,6 @@
import {
getPushSingle
} from '/pageSubPack/api/api.js'
import {
getBankMiniProgramParams
} from '/pageSubPack/api/apiSub.js'
// 响应式数据
const outstandingPayment = ref(true)
@@ -152,8 +149,9 @@
}
// 立即缴费 — 通过微信拉起日照银行小程序进行支付
const handlePay = async () => {
const handlePay = () => {
const amount = arrearsAmount.value
console.log('saaaaaaa', paymentItem)
try {
uni.showLoading({ title: '加载中...' })
@@ -162,46 +160,25 @@
const deviceTypeMap = { '物业费': '3', '车位费': '4', '垃圾处理费': '5' }
const mappedDeviceType = deviceTypeMap[switchStatus(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)),
deviceCode: paymentItem.deviceCode || '',
deviceType: mappedDeviceType,
billId: paymentItem.billId || '',
billId: paymentItem.id || '',
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)
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
}
// 把 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)
console.log('传入中间小程序的path参数:', queryString)
// #ifdef APP-PLUS
// 原生App通过微信SDK拉起小程序
plus.share.getServices((services) => {
@@ -215,21 +192,11 @@
return
}
weixin.launchMiniProgram({
id: 'gh_a765aef0172c',
// appId: 'wx40625124315d2de1',
type:1, // 0 正式版 / 1测试版 / 2预览版
path: 'pageSubPack/payment-list/arrearsPayment',
extraData: extraData,
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('拉起日照银行小程序失败App', JSON.stringify(err))
@@ -237,27 +204,10 @@
})
})
// #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)
uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' })
console.error('拉起支付小程序异常', err)
uni.showToast({ title: '请求异常,请重试', icon: 'none' })
}
}