修改token
This commit is contained in:
@@ -102,32 +102,43 @@ export function captureAppLaunchData(onShowOptions) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// 冷启动
|
// 优先使用本次进入(onLaunch/onShow 传入的 options)的最新参数。
|
||||||
try {
|
// 热启动再次从 App 进入时,getLaunchOptionsSync 仍返回首次冷启动的旧值,
|
||||||
data = tryGetData(wx.getLaunchOptionsSync?.() || {}, '冷启动')
|
// 若先读它会导致新 token 被旧 token 覆盖,因此这里以本次 options 为准。
|
||||||
} catch (e) { console.error('getLaunchOptionsSync 失败:', e) }
|
data = tryGetData(onShowOptions, '本次进入')
|
||||||
|
|
||||||
// 热启动
|
// 兜底:本次 options 未取到数据时,依次尝试当前进入参数、冷启动参数。
|
||||||
|
// 注意:不能以 !onShowOptions 判断,onLaunch/onShow 始终会传入 options 对象,
|
||||||
|
// 那样会误判导致兜底永远不执行,token 无法恢复。
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = tryGetData(onShowOptions, '热启动')
|
try {
|
||||||
|
data = tryGetData(wx.getEnterOptionsSync?.() || {}, '当前进入(getEnterOptionsSync)')
|
||||||
|
} catch (e) { console.error('getEnterOptionsSync 失败:', e) }
|
||||||
|
}
|
||||||
|
if (!data) {
|
||||||
|
try {
|
||||||
|
data = tryGetData(wx.getLaunchOptionsSync?.() || {}, '冷启动(getLaunchOptionsSync)')
|
||||||
|
} catch (e) { console.error('getLaunchOptionsSync 失败:', e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && (data.payAmount || data.acct || data.custId || data.billId || data.billIds)) {
|
if (data) {
|
||||||
// 归一化 billId/billIds:单个 id 用 billId,多个用 billIds,统一转为 billIds 数组
|
// 恢复登录态:只要 App 传入了 token/userId 就恢复,不依赖支付字段名
|
||||||
normalizeBillParams(data)
|
|
||||||
|
|
||||||
// 恢复登录态
|
|
||||||
if (data.token) {
|
if (data.token) {
|
||||||
uni.setStorageSync('token', data.token)
|
uni.setStorageSync('token', data.token)
|
||||||
console.log('已恢复 token')
|
console.log('已恢复 token:', String(data.token).slice(0, 16) + '...')
|
||||||
}
|
}
|
||||||
if (data.userId) {
|
if (data.userId) {
|
||||||
uni.setStorageSync('userId', data.userId)
|
uni.setStorageSync('userId', data.userId)
|
||||||
console.log('已恢复 userId')
|
console.log('已恢复 userId')
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.setStorageSync(STORAGE_KEY, data)
|
// 存在支付参数时才作为 App 支付进入处理
|
||||||
console.log('已存储 App 支付数据:', JSON.stringify(data))
|
if (data.payAmount || data.acct || data.custId || data.billId || data.billIds) {
|
||||||
|
// 归一化 billId/billIds:单个 id 用 billId,多个用 billIds,统一转为 billIds 数组
|
||||||
|
normalizeBillParams(data)
|
||||||
|
uni.setStorageSync(STORAGE_KEY, data)
|
||||||
|
console.log('已存储 App 支付数据:', JSON.stringify(data))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 归一化 queryData 中的 billId/billIds
|
// 归一化 queryData 中的 billId/billIds
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
let baseUrl = '';
|
let baseUrl = '';
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// baseUrl = 'https://wuyeapi.ckdzkj.com'; // 开发环境
|
// baseUrl = 'https://wuyeapi.ckdzkj.com'; // 开发环境
|
||||||
baseUrl = "http://192.168.1.222:8080"
|
// baseUrl = "http://192.168.1.222:8080"
|
||||||
|
baseUrl = "https://apitest.ckdzkj.com";
|
||||||
} else {
|
} else {
|
||||||
baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境
|
// baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境
|
||||||
|
baseUrl = "https://apitest.ckdzkj.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ onShow(() => {
|
|||||||
loadRecords()
|
loadRecords()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// const gotoPayment =()=>{
|
const gotoPayment =()=>{
|
||||||
// uni.navigateTo({ url: '/pages/arrearsPayment/arrearsPayment' })
|
uni.navigateTo({ url: '/pages/arrearsPayment/arrearsPayment' })
|
||||||
// }
|
}
|
||||||
|
|
||||||
const goLogin = () => {
|
const goLogin = () => {
|
||||||
uni.navigateTo({ url: '/pageSubPack/loginSub/pwd-login' })
|
uni.navigateTo({ url: '/pageSubPack/loginSub/pwd-login' })
|
||||||
|
|||||||
Reference in New Issue
Block a user