修改cid无效、登录缓存问题,正在对接支付功能

This commit is contained in:
zhouyanli
2026-07-14 14:35:54 +08:00
parent 3124f95cb3
commit 173f1c4585
10 changed files with 391 additions and 121 deletions

View File

@@ -83,6 +83,9 @@
import {
getPushSingle
} from '/pageSubPack/api/api.js'
import {
getBankMiniProgramParams
} from '/pageSubPack/api/apiSub.js'
// 响应式数据
const outstandingPayment = ref(true)
@@ -106,11 +109,30 @@
})
// 从支付收银台返回时检查支付结果
onShow(() => {
onShow((options) => {
// 检查是否有从日照银行小程序返回的支付结果
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'
})
return
} else if (extraData.retCode === 'FAIL') {
uni.showToast({ title: extraData.retMsg || '支付失败', icon: 'none' })
return
}
}
const paySuccess = uni.getStorageSync('paySuccess')
if (paySuccess) {
uni.removeStorageSync('paySuccess')
currentStep.value = 2
uni.redirectTo({
url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay'
})
// currentStep.value = 2
}
})
@@ -130,21 +152,110 @@
});
}
// 立即缴费 — 跳转到支付收银台选择支付方式
const handlePay = () => {
// 优先使用用户输入金额,否则使用页面展示的应缴金额
const amount = payAmount.value
uni.setStorageSync('payData', {
amount: String(amount),
deviceCode: paymentItem.deviceCode,
type: paymentItem.type,
name: paymentItem.name,
fullAddress: paymentItem.fullAddress
})
// uni.navigateTo({ url: '/pageSubPack/payment-list/yinlianPayTn' })
}
// 立即缴费 — 通过微信拉起日照银行小程序进行支付
const handlePay = async () => {
// 缴费成功推送通知
try {
uni.showLoading({ title: '加载中...' })
// 设备类型映射物业费→3车位费→4垃圾处理费→5
const deviceTypeMap = { '物业费': '3', '车位费': '4', '垃圾处理费': '5' }
const mappedDeviceType = deviceTypeMap[switchStatus(paymentItem.type)] || ''
const res = await getBankMiniProgramParams({
acct: uni.getStorageSync('userId'),
orderType: '20',
orderAmount: String(Math.round(Number(payAmount.value) * 100)),
deviceCode: paymentItem.deviceCode || '',
deviceType: mappedDeviceType,
billId: paymentItem.billId || '',
residentUserId: uni.getStorageSync('userId'),
goodName: paymentItem.name || ''
})
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
}
// 解析 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 = {}
}
// #ifdef APP-PLUS
// 原生App通过微信SDK拉起小程序
plus.share.getServices((services) => {
const weixin = services.find(s => s.id === 'weixin')
if (!weixin) {
uni.showToast({ title: '未检测到微信客户端', icon: 'none' })
return
}
if (!weixin.launchMiniProgram) {
uni.showToast({ title: '当前微信版本太低,不支持拉起小程序', icon: 'none' })
return
}
weixin.launchMiniProgram({
id: appId,
type: 0, // 0=正式版 1=测试版 2=预览版
path: path || '',
extraData: extraDataObj
}, () => {
console.log('成功拉起日照银行小程序App')
}, (err) => {
console.error('拉起日照银行小程序失败App', JSON.stringify(err))
uni.showToast({ title: '拉起支付小程序失败', icon: 'none' })
})
})
// #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
} catch (err) {
uni.hideLoading()
console.error('获取支付参数异常', err)
uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' })
}
}
// 缴费成功推送通知
const sendPaySuccessPush = () => {
const userId = uni.getStorageSync('userId')
if (userId) {
@@ -631,4 +742,4 @@
width: 100vw;
height: 46px;
}
</style>
</style>