修改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

@@ -1,6 +1,10 @@
<script setup> <script setup>
import { onLaunch,onShow,onHide } from '@dcloudio/uni-app' import { onLaunch,onShow,onHide } from '@dcloudio/uni-app'
let cidRetryTimer = null
let cidRetryCount = 0
const MAX_RETRY = 5 // 最多重试 5 次
// 应用启动时执行 // 应用启动时执行
onLaunch(() => { onLaunch(() => {
console.log('App 启动') console.log('App 启动')
@@ -12,29 +16,90 @@
// 只有 App 平台才获取 CID // 只有 App 平台才获取 CID
getPushCID() getPushCID()
// #endif // #endif
// 自动登录:检查本地是否已有 token有则直接跳转首页
const token = uni.getStorageSync('token')
const hasShowGuide = uni.getStorageSync('hasShowGuide')
if (token) {
// 已有登录凭证,直接进入首页
console.log('检测到已登录,跳转首页')
uni.reLaunch({ url: '/pages/index/index' })
} else if (hasShowGuide) {
// 已看过引导页但没有 token直接跳转登录页
console.log('已看过引导页,跳转登录页')
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' })
}
// 否则停留在引导页navigation
}) })
onShow(() =>{ onShow(() =>{
console.log('App Show') console.log('App Show')
}) // #ifdef APP-PLUS
// 每次回到前台时检查 CID 是否有效,没有则重新获取
onHide(() =>{ const savedCid = uni.getStorageSync('push_cid')
console.log('App Hide') if (!savedCid) {
console.log('App Show 检测到 CID 为空,重新获取')
cidRetryCount = 0
getPushCID()
}
// #endif
}) })
// 获取 uniPush 2.0 CID onHide(() =>{
console.log('App Hide')
})
// 获取 uniPush 2.0 CID带重试机制解决离线安装首次启动 CID 为空的问题)
function getPushCID() { function getPushCID() {
// #ifdef APP-PLUS
// 先尝试 plus.push.getClientInfo 获取(兼容老版本)
try {
const clientInfo = plus.push.getClientInfo()
if (clientInfo && clientInfo.clientid) {
console.log('推送 CIDplus.push=', clientInfo.clientid)
uni.setStorageSync('push_cid', clientInfo.clientid)
return
}
} catch (e) {
console.log('plus.push.getClientInfo 失败,改用 uni.getPushClientId')
}
uni.getPushClientId({ uni.getPushClientId({
success: (res) => { success: (res) => {
console.log('推送初始化成功') if (res.cid) {
console.log('CID =', res.cid) console.log('推送初始化成功, CID =', res.cid)
uni.setStorageSync('push_cid', res.cid)
// 存起来备用 cidRetryCount = 0
uni.setStorageSync('push_cid', res.cid) if (cidRetryTimer) {
clearTimeout(cidRetryTimer)
cidRetryTimer = null
}
} else {
// CID 返回为空(常见于离线安装首次启动)
console.warn('获取到 CID 为空,将重试')
scheduleRetry()
}
}, },
fail: (err) => { fail: (err) => {
console.error('获取推送 CID 失败', err) console.error('获取推送 CID 失败', err)
scheduleRetry()
} }
}) })
// #endif
}
// 定时重试获取 CID间隔递增2s → 4s → 8s → 16s → 32s
function scheduleRetry() {
if (cidRetryCount >= MAX_RETRY) {
console.error('CID 获取重试已达上限(' + MAX_RETRY + '次),放弃重试')
return
}
cidRetryCount++
const delay = Math.pow(2, cidRetryCount) * 1000
console.log('将在 ' + delay / 1000 + 's 后第 ' + cidRetryCount + ' 次重试获取 CID')
if (cidRetryTimer) clearTimeout(cidRetryTimer)
cidRetryTimer = setTimeout(() => {
getPushCID()
}, delay)
} }
</script> </script>

View File

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

View File

@@ -8,10 +8,10 @@ if (process.env.NODE_ENV === 'development') {
export default function request(url, data = {}, method = "GET") { export default function request(url, data = {}, method = "GET") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.showLoading({ // uni.showLoading({
title: '请求中...', // title: '请求中...',
mask: true // mask: true
}); // });
uni.request({ uni.request({
url: baseUrl + url, url: baseUrl + url,
@@ -23,7 +23,7 @@ export default function request(url, data = {}, method = "GET") {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: (res) => { success: (res) => {
uni.hideLoading(); // uni.hideLoading();
// HTTP 失败 // HTTP 失败
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
@@ -54,7 +54,7 @@ export default function request(url, data = {}, method = "GET") {
} }
}, },
fail: (err) => { fail: (err) => {
uni.hideLoading(); // uni.hideLoading();
reject({ msg: '网络异常', code: -1, raw: err }); reject({ msg: '网络异常', code: -1, raw: err });
} }
}); });

View File

@@ -205,7 +205,7 @@ const doLogin = () => {
setTimeout(() =>{ setTimeout(() =>{
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/index/index'
},1000); },2000);
}) })
}else{ }else{
uni.showToast({ title: res.msg, icon: 'error' }); uni.showToast({ title: res.msg, icon: 'error' });

View File

@@ -37,7 +37,7 @@
<view class="line"> <view class="line">
<view class="row"> <view class="row">
<text class="label">车位状态</text> <text class="label">车位状态</text>
<text class="value">{{ item.parkingStatus }}</text> <text class="value">{{ getParkingStatus(item.parkingStatus) }}</text>
</view> </view>
</view> </view>
<view class="line"> <view class="line">
@@ -94,6 +94,18 @@
const pageNum = ref(1) const pageNum = ref(1)
const pageSize = ref(10) const pageSize = ref(10)
// 车位状态映射
const getParkingStatus =(status) =>{
const statusMap = {
'0':'闲置',
'1':'自用',
'2':'租赁',
'3':'借出',
'4':'其他'
}
return statusMap[status]
}
// ==================== 获取列表数据 ==================== // ==================== 获取列表数据 ====================
const getList = async () => { const getList = async () => {
// 防重复请求 // 防重复请求

View File

@@ -70,12 +70,12 @@
title: '注销账号', title: '注销账号',
type: 'arrow' type: 'arrow'
}, },
{ // {
title: '升级版本', // title: '升级版本',
type: 'text', // type: 'text',
value: '当前版本 1.0.0', // value: '当前版本 1.0.0',
valueClass: 'item-version' // valueClass: 'item-version'
} // }
]) ])
// 格式化字节大小 // 格式化字节大小
@@ -165,8 +165,8 @@
const checkVersionUpdate = async () => { const checkVersionUpdate = async () => {
uni.showLoading({ title: '检查中...', mask: true }) uni.showLoading({ title: '检查中...', mask: true })
// #ifdef APP-PLUS // #ifdef APP-PLUS
// const channel = plus.runtime.channel; // 云打包自动写入,自定义包为空 const channel = plus.runtime.channel; // 云打包自动写入,自定义包为空
// const channel = 'xioami' // const channel = 'xiaomi'
// console.log('channel',channel) // console.log('channel',channel)
// #endif // #endif
@@ -174,8 +174,7 @@
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync()
const platform = systemInfo.platform === 'android' ? 'android':'ios' const platform = systemInfo.platform === 'android' ? 'android':'ios'
const appChannel = 'resident' const appChannel = 'resident'
const channel = 'xiaomi' // const channel = 'xiaomi'
// const channel = plus.runtime.channel;
// 1. 查询最新版本 // 1. 查询最新版本
const versionRes = await getAppVersion(platform, channel, appChannel) const versionRes = await getAppVersion(platform, channel, appChannel)
@@ -299,6 +298,10 @@
}); });
authLogout().then(res => { authLogout().then(res => {
if (res.code === 200) { if (res.code === 200) {
// 清除本地登录凭证
uni.removeStorageSync('token');
uni.removeStorageSync('userId');
uni.removeStorageSync('currentVillageId');
uni.hideLoading(); uni.hideLoading();
uni.showToast({ uni.showToast({
title: '退出成功', title: '退出成功',
@@ -306,22 +309,30 @@
}); });
setTimeout(() => { setTimeout(() => {
uni.hideLoading(); uni.hideLoading();
uni.redirectTo({ uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login' url: '/pageSubPack/loginSub/pwd-login'
}); });
}, 1500); }, 1500);
} else { } else {
uni.showToast({ // 即使服务端返回失败,也清除本地数据并跳转登录页
title: `${res.msg}`, uni.removeStorageSync('token');
icon: 'error' uni.removeStorageSync('userId');
uni.removeStorageSync('currentVillageId');
uni.hideLoading();
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
}); });
} }
}).catch(err => { }).catch(err => {
console.log(err); console.log(err);
uni.showToast({ // 网络异常时也清除本地数据并跳转登录页
title: err.msg, uni.removeStorageSync('token');
icon: 'error' uni.removeStorageSync('userId');
uni.removeStorageSync('currentVillageId');
uni.hideLoading();
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
}); });
}) })

View File

@@ -135,9 +135,14 @@
// 检查是否有从日照银行小程序返回的支付结果 // 检查是否有从日照银行小程序返回的支付结果
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.payResult === 'success') { if (extraData.retCode === 'SUCCESS') {
currentStep.value = 2
sendPaySuccessPush() sendPaySuccessPush()
uni.redirectTo({
url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay'
})
return
} else if (extraData.retCode === 'FAIL') {
uni.showToast({ title: extraData.retMsg || '支付失败', icon: 'none' })
return return
} }
} }
@@ -145,7 +150,9 @@
const paySuccess = uni.getStorageSync('paySuccess') const paySuccess = uni.getStorageSync('paySuccess')
if (paySuccess) { if (paySuccess) {
uni.removeStorageSync('paySuccess') uni.removeStorageSync('paySuccess')
currentStep.value = 2 uni.redirectTo({
url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay'
})
} }
}) })
@@ -174,65 +181,122 @@
} }
// 立即缴费 — 通过微信拉起日照银行小程序进行支付 // 立即缴费 — 通过微信拉起日照银行小程序进行支付
const handlePay = async () => { const handlePay = async () => {
if (!payNum.value || Number(payNum.value) <= 0) { if (!payNum.value || Number(payNum.value) <= 0) {
uni.showToast({ uni.showToast({
title: '请输入正确的缴费金额', title: '请输入正确的缴费金额',
icon: 'none' icon: 'none'
}) })
return
}
try {
uni.showLoading({ title: '加载中...' })
// 设备类型映射电费→1(电表)水费→2(水表)
const deviceTypeMap = { '电费': '1', '水费': '2' }
const mappedDeviceType = deviceTypeMap[paymentItem.type] || paymentItem.deviceType || ''
const res = await getBankMiniProgramParams({
acct: uni.getStorageSync('userId'), // 用户userId
orderType: '20', // 水电费等手输金额
orderAmount: String(Math.round(Number(payNum.value) * 100)), // 金额,单位:分
deviceCode: paymentItem.deviceCode || '',
deviceType: mappedDeviceType, // 1-电表2-水表
billId: paymentItem.billId || '', // 账单明细ID
residentUserId: uni.getStorageSync('userId'),
goodName: paymentItem.name || '' // 商品名称
})
uni.hideLoading()
if (res.code !== 200 || !res.data) {
uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' })
return return
} }
console.log('resres返回数据',res)
console.log('resres',res.data)
const { appId, path, extraData } = res.data try {
uni.showLoading({ title: '加载中...' })
uni.navigateToMiniProgram({ // 设备类型映射电费→1(电表)水费→2(水表)
appId: appId, const deviceTypeMap = { '电费': '1', '水费': '2' }
path: path || '', const mappedDeviceType = deviceTypeMap[paymentItem.type] || paymentItem.deviceType || ''
extraData: extraData || {},
envVersion: 'release', const res = await getBankMiniProgramParams({
success: () => { acct: uni.getStorageSync('userId'),
console.log('成功拉起日照银行小程序') orderType: '20',
}, orderAmount: String(Math.round(Number(payNum.value) * 100)),
fail: (err) => { deviceCode: paymentItem.deviceCode || '',
console.error('拉起日照银行小程序失败', err) deviceType: mappedDeviceType,
uni.showToast({ title: err.msg ||'拉起支付小程序失败', icon: 'none' }) 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)
} catch (err) { console.log('resres', res.data)
uni.hideLoading()
console.error('获取支付参数异常', err)
uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' })
}
}
// 缴费成功推送通知 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: 1, // 0=正式版 1=测试版 2=预览版
path: path || '',
extraData: extraData
}, (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' })
})
})
// #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' })
}
}
// 缴费成功推送通知
const sendPaySuccessPush = () => { const sendPaySuccessPush = () => {
const userId = uni.getStorageSync('userId') const userId = uni.getStorageSync('userId')
if (userId) { if (userId) {
@@ -709,4 +773,4 @@
width: 100vw; width: 100vw;
height: 46px; height: 46px;
} }
</style> </style>

View File

@@ -151,13 +151,13 @@
// iconClass: "gas" // iconClass: "gas"
// }, // },
{ {
name: "水", name: "水",
type: "water", type: "water",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png",
iconClass: "water" iconClass: "water"
}, },
{ {
name: "电", name: "电",
type: "electric", type: "electric",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
iconClass: "electric" iconClass: "electric"
@@ -213,7 +213,7 @@
onReady(() => {}) onReady(() => {})
onLoad(() => { onLoad(() => {
postOpenId() // postOpenId()
uni.hideTabBar({ uni.hideTabBar({
animation: false // 关闭动画,更稳定 animation: false // 关闭动画,更稳定
}); });
@@ -269,7 +269,7 @@
uni.redirectTo({ uni.redirectTo({
url: '/pageSubPack/payment-list/selectPaymentEntity' url: '/pageSubPack/payment-list/selectPaymentEntity'
}) })
} else if (type.name == '水' || type.name == '电') { } else if (type.name == '水' || type.name == '电') {
uni.redirectTo({ uni.redirectTo({
url: '/pageSubPack/payment-list/addHydropower' url: '/pageSubPack/payment-list/addHydropower'
}) })

View File

@@ -83,6 +83,9 @@
import { import {
getPushSingle getPushSingle
} from '/pageSubPack/api/api.js' } from '/pageSubPack/api/api.js'
import {
getBankMiniProgramParams
} from '/pageSubPack/api/apiSub.js'
// 响应式数据 // 响应式数据
const outstandingPayment = ref(true) 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') const paySuccess = uni.getStorageSync('paySuccess')
if (paySuccess) { if (paySuccess) {
uni.removeStorageSync('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 handlePay = async () => {
// 优先使用用户输入金额,否则使用页面展示的应缴金额
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' })
}
// 缴费成功推送通知 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 sendPaySuccessPush = () => {
const userId = uni.getStorageSync('userId') const userId = uni.getStorageSync('userId')
if (userId) { if (userId) {
@@ -631,4 +742,4 @@
width: 100vw; width: 100vw;
height: 46px; height: 46px;
} }
</style> </style>

View File

@@ -95,13 +95,19 @@ const handleBtnClick = () => {
// 防重复跳转:已触发过跳转则直接返回 // 防重复跳转:已触发过跳转则直接返回
if (isNavigating.value) return; if (isNavigating.value) return;
isNavigating.value = true; isNavigating.value = true;
// 立即体验,跳转登录页 // 记录引导已完成
// 1. 记录引导已完成
uni.setStorageSync('hasShowGuide', true); uni.setStorageSync('hasShowGuide', true);
// 2. 跳转登录页 // 检查是否已有登录 token有则直接进首页否则跳转登录页
uni.redirectTo({ const token = uni.getStorageSync('token');
url: "/pageSubPack/loginSub/pwd-login" if (token) {
}) uni.switchTab({
url: '/pages/index/index'
})
} else {
uni.redirectTo({
url: "/pageSubPack/loginSub/pwd-login"
})
}
} }
}; };
</script> </script>