修改支付页跳转

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

@@ -2,8 +2,8 @@
"name" : "花开物业", "name" : "花开物业",
"appid" : "__UNI__29C3D60", "appid" : "__UNI__29C3D60",
"description" : "智慧社区居民端面向小区业主使用,支持注册、验证码、账号密码多种登录方式,提供密码找回功能,账号使用安全便捷。支持多小区切换,首页设有轮播 banner、社区公告集成远程开门、生活缴费、在线报修、访客邀请、社区活动常用服务。全服务板块统一涵盖门禁开门、线上缴费、报修申报、访客预约、投诉反馈、问卷调研、活动报名、社区公示、一键联系物业功能。个人中心可管理房屋、住户、车位、车辆信息支持更换手机号、修改密码、消息通知设置、版本更新及账号退出一站式满足业主居家生活、社区服务、房产车辆管理需求实现社区生活数字化、便捷化。", "description" : "智慧社区居民端面向小区业主使用,支持注册、验证码、账号密码多种登录方式,提供密码找回功能,账号使用安全便捷。支持多小区切换,首页设有轮播 banner、社区公告集成远程开门、生活缴费、在线报修、访客邀请、社区活动常用服务。全服务板块统一涵盖门禁开门、线上缴费、报修申报、访客预约、投诉反馈、问卷调研、活动报名、社区公示、一键联系物业功能。个人中心可管理房屋、住户、车位、车辆信息支持更换手机号、修改密码、消息通知设置、版本更新及账号退出一站式满足业主居家生活、社区服务、房产车辆管理需求实现社区生活数字化、便捷化。",
"versionName" : "1.0.1", "versionName" : "1.0.2",
"versionCode" : 114, "versionCode" : 115,
"transformPx" : false, "transformPx" : false,
"uniCloud" : { "uniCloud" : {
"provider" : "aliyun", "provider" : "aliyun",

View File

@@ -1,6 +1,6 @@
let baseUrl = ''; let baseUrl = '';
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.1.6:8080'; // 开发环境 baseUrl = 'http://192.168.1.222:8085'; // 开发环境
// baseUrl = 'http://wuyeapi.ckdzkj.com'; // baseUrl = 'http://wuyeapi.ckdzkj.com';
} else { } else {
baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境 baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境

View File

@@ -191,14 +191,15 @@
const res = await getBankMiniProgramParams({ const res = await getBankMiniProgramParams({
acct: uni.getStorageSync('userId'), acct: uni.getStorageSync('userId'),
orderType: '20', orderType: '10',
orderAmount: String(Math.round(Number(amount) * 100)), orderAmount: String(Math.round(Number(amount) * 100)),
// orderAmount: String(Math.round(Number(arrearsAmount.value) * 100)), // orderAmount: String(Math.round(Number(arrearsAmount.value) * 100)),
deviceCode: paymentItem.deviceCode || '', deviceCode: paymentItem.deviceCode || '',
deviceType: mappedDeviceType, deviceType: mappedDeviceType,
billId: paymentItem.billId || '', billId: paymentItem.billId || '',
residentUserId: uni.getStorageSync('userId'), residentUserId: uni.getStorageSync('userId'),
goodName: paymentItem.name || '' goodName: paymentItem.name || switchStatus(paymentItem.type) || '',
remark:'服务费'
}) })
uni.hideLoading() uni.hideLoading()
@@ -220,20 +221,13 @@
return return
} }
// 解析 extraData后端返回可能是字符串或对象 // 把支付金额和token拼接到 extraData 查询字符串中传入中间小程序,实现免登录
/* let extraDataObj = extraData const token = uni.getStorageSync('token') || ''
if (typeof extraData === 'string') { const payAmountStr = String(payAmount.value)
try { const orderAmountStr = String(Math.round(Number(amount) * 100))
extraDataObj = JSON.parse(extraData) const custId = uni.getStorageSync('custId') || ''
} catch (e) { const extraDataWithAmount = extraData + '&payAmount=' + encodeURIComponent(payAmountStr) + '&orderAmount=' + encodeURIComponent(orderAmountStr) + '&token=' + encodeURIComponent(token) + '&custId=' + encodeURIComponent(custId)
console.error('extraData JSON解析失败使用空对象', e) console.log('传入中间小程序的extraData:', extraDataWithAmount)
extraDataObj = {}
}
}
if (!extraDataObj || typeof extraDataObj !== 'object') {
extraDataObj = {}
}
console.log('解析-----extraDataObj', extraDataObj) */
// #ifdef APP-PLUS // #ifdef APP-PLUS
// 原生App通过微信SDK拉起小程序 // 原生App通过微信SDK拉起小程序
plus.share.getServices((services) => { plus.share.getServices((services) => {
@@ -247,25 +241,24 @@
return return
} }
weixin.launchMiniProgram({ weixin.launchMiniProgram({
id: 'gh_4ba5e4fdaa83', id: 'gh_a765aef0172c',
// appId:'00004951', // appId: 'wx40625124315d2de1',
type: 1, // 0=正式版 1=测试版 2=预览版 type:1, // 0 正式版 / 1测试版 / 2预览版
path: path, path: 'pageSubPack/payment-list/arrearsPayment',
// extMsg: JSON.stringify({ extraData: extraData }) extraData: extraDataWithAmount,
extraData: extraData
}, (res) => { }, (res) => {
console.log('ress-------------',res) console.log('ress-------------',res)
if (res.retCode === 'SUCCESS') { // if (res.retCode === 'SUCCESS') {
console.log('成功拉起日照银行小程序App', res.retCode) // console.log('成功拉起日照银行小程序App', res.retCode)
} else { // } else {
console.log('拉起日照银行小程序返回失败App======)', res.retMsg) // console.log('拉起日照银行小程序返回失败App======)', res.retMsg)
} // }
console.log('回调---日照银行小程序回调结果App', JSON.stringify(res)) console.log('回调---回调结果App', JSON.stringify(res))
}, (err) => { }, (err) => {
console.error('拉起日照银行小程序失败App', JSON.stringify(err)) console.error('err---拉起失败App', JSON.stringify(err))
uni.showToast({ title: '拉起支付小程序失败', icon: 'none' }) uni.showToast({ title: '拉起支付小程序失败', icon: 'none' })
}) })
}) })

View File

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