10/14
This commit is contained in:
@@ -92,14 +92,14 @@ export const upDateMyHouse = (data) => {
|
||||
// =========问卷调查=========
|
||||
// 问卷列表
|
||||
export const getQuestionnaireList = (data) => {
|
||||
return get('/api/resident/questionnaire/list',data)
|
||||
return get('/api/resident/questionnaire/list', data)
|
||||
}
|
||||
// 问卷详情
|
||||
export const getQuestionnaireDetail = (data) => {
|
||||
return get('/api/resident/questionnaire/myAnswers',data)
|
||||
return get('/api/resident/questionnaire/myAnswers', data)
|
||||
}
|
||||
// 提交问卷
|
||||
export const submitQuestionnair = (id,data) => {
|
||||
export const submitQuestionnair = (id, data) => {
|
||||
return post(`/api/resident/questionnaire/${id}/submit`, data)
|
||||
}
|
||||
// =====投诉意见=======
|
||||
@@ -109,19 +109,19 @@ export const getComplainType = () => {
|
||||
}
|
||||
// 获取投诉列表
|
||||
export const getComplainList = (data) => {
|
||||
return get('/complain/getComplainList',data)
|
||||
return get('/complain/getComplainList', data)
|
||||
}
|
||||
// 提交投诉建议
|
||||
export const addComplain = (data) => {
|
||||
return post('/complain/add',data)
|
||||
return post('/complain/add', data)
|
||||
}
|
||||
// 投诉详情
|
||||
export const getComplainDetail = (data) => {
|
||||
return get('/complain/detail',data)
|
||||
return get('/complain/detail', data)
|
||||
}
|
||||
// 联系物业
|
||||
export const getManagePhoneData = (data) => {
|
||||
return get('/api/manage/banner/getManagePhone',data)
|
||||
return get('/api/manage/banner/getManagePhone', data)
|
||||
}
|
||||
|
||||
// 修改身份证照片
|
||||
@@ -223,3 +223,187 @@ export const getParkingDetail = (data) => {
|
||||
export const rebindCar = (data) => {
|
||||
return post(`/ResidentCarAreaManage/rebind`, data)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// RZbank
|
||||
/**
|
||||
* 归一化 billId/billIds:单个 id 用 billId,多个用 billIds,统一转为 billIds 数组
|
||||
*/
|
||||
function normalizeBillParams(obj) {
|
||||
if (!obj) return
|
||||
// 先解码再拆分为数组
|
||||
if (typeof obj.billIds === 'string') {
|
||||
const decoded = decodeURIComponent(obj.billIds)
|
||||
obj.billIds = decoded.includes(',') ?
|
||||
decoded.split(',').map(v => v.trim()).filter(Boolean) : [decoded]
|
||||
}
|
||||
// billId 存在且 billIds 不存在时,包装为数组
|
||||
if (obj.billId && !obj.billIds) {
|
||||
const decoded = decodeURIComponent(
|
||||
typeof obj.billId === 'string' ? obj.billId : String(obj.billId)
|
||||
)
|
||||
obj.billIds = decoded.includes(',') ?
|
||||
decoded.split(',').map(v => v.trim()).filter(Boolean) : [decoded]
|
||||
delete obj.billId
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 从启动参数中获取 App 传入的全部数据(支付参数 + token + userId)
|
||||
*/
|
||||
export function captureAppLaunchData(onShowOptions) {
|
||||
let data = null
|
||||
let queryData = null
|
||||
|
||||
const tryGetData = (options, label) => {
|
||||
if (!options) return null
|
||||
console.log(label, JSON.stringify(options))
|
||||
|
||||
// 保存 path query 参数(供接口调用)
|
||||
if (options.query && Object.keys(options.query).length > 0) {
|
||||
queryData = options.query
|
||||
console.log(label + ' path query 参数:', JSON.stringify(queryData))
|
||||
}
|
||||
|
||||
// 优先从 query 获取
|
||||
if (options.query && Object.keys(options.query).length > 0) {
|
||||
return options.query
|
||||
}
|
||||
|
||||
// referrerInfo.extraData:可能是对象也可能是查询字符串
|
||||
const extraData = options?.referrerInfo?.extraData
|
||||
if (extraData) {
|
||||
if (typeof extraData === 'string') {
|
||||
console.log(label + ' extraData 是查询字符串,解析中...')
|
||||
return parseQueryString(extraData)
|
||||
}
|
||||
return extraData
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// 冷启动
|
||||
try {
|
||||
data = tryGetData(wx.getLaunchOptionsSync?.() || {}, '冷启动')
|
||||
} catch (e) {
|
||||
console.error('getLaunchOptionsSync 失败:', e)
|
||||
}
|
||||
|
||||
// 热启动
|
||||
if (!data) {
|
||||
data = tryGetData(onShowOptions, '热启动')
|
||||
}
|
||||
|
||||
if (data && (data.payAmount || data.acct || data.custId || data.billId || data.billIds)) {
|
||||
// 归一化 billId/billIds:单个 id 用 billId,多个用 billIds,统一转为 billIds 数组
|
||||
normalizeBillParams(data)
|
||||
|
||||
// 恢复登录态
|
||||
if (data.token) {
|
||||
uni.setStorageSync('token', data.token)
|
||||
console.log('已恢复 token')
|
||||
}
|
||||
if (data.userId) {
|
||||
uni.setStorageSync('userId', data.userId)
|
||||
console.log('已恢复 userId')
|
||||
}
|
||||
|
||||
uni.setStorageSync(STORAGE_KEY, data)
|
||||
console.log('已存储 App 支付数据:', JSON.stringify(data))
|
||||
}
|
||||
|
||||
// 归一化 queryData 中的 billId/billIds
|
||||
normalizeBillParams(queryData)
|
||||
|
||||
// 单独保存参数供接口使用(优先 queryData,fallback 到 data,即 extraData 来源)
|
||||
const queryParams = queryData || data
|
||||
if (queryParams) {
|
||||
uni.setStorageSync(APP_QUERY_KEY, queryParams)
|
||||
console.log('已存储 App 接口参数:', JSON.stringify(queryParams))
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// 获取日照银行小程序拉起参数
|
||||
export const getBankMiniProgramParams = (data) => {
|
||||
return post('/api/pay/yidang/create', data)
|
||||
}
|
||||
/**
|
||||
* 支付返回结果
|
||||
* 日照银行支付小程序完成支付后,通过 navigateBackMiniProgram 携带 extraData 返回,
|
||||
* 本小程序在 App.onShow 中通过 referrerInfo.extraData 接收(场景值 1038)。
|
||||
* 这里只负责捕获/读取/清除原始返回数据,成功/失败判定见 resolvePaymentResult。
|
||||
*/
|
||||
const PAYMENT_RESULT_KEY = 'payment_return_result'
|
||||
/**
|
||||
* 捕获支付返回结果(在 App.onShow 中调用)
|
||||
* 注意:App 冷/热启动进入时 extraData 是支付参数(payAmount/billIds 等),
|
||||
* 并非支付返回,需跳过,避免覆盖真实结果。
|
||||
*/
|
||||
export function capturePaymentResult(onShowOptions) {
|
||||
console.log(onShowOptions)
|
||||
if (!onShowOptions) return
|
||||
const extraData = onShowOptions?.referrerInfo?.extraData
|
||||
if (!extraData) return
|
||||
|
||||
// 含支付参数字段说明是 App 跳转进入(冷/热启动),不是支付返回,跳过
|
||||
if (typeof extraData === 'object' && (extraData.payAmount || extraData.billId || extraData.billIds || extraData
|
||||
.acct || extraData.custId)) {
|
||||
return
|
||||
}
|
||||
|
||||
let parsed = extraData
|
||||
if (typeof extraData === 'string') {
|
||||
try {
|
||||
parsed = JSON.parse(extraData)
|
||||
} catch (e) {
|
||||
parsed = parseQueryString(extraData)
|
||||
}
|
||||
}
|
||||
console.log('捕获到支付返回结果:', JSON.stringify(parsed))
|
||||
uni.setStorageSync(PAYMENT_RESULT_KEY, parsed)
|
||||
}
|
||||
|
||||
/** 读取支付返回结果(读取后建议调用 clearPaymentReturnResult 清除) */
|
||||
export function getPaymentReturnResult() {
|
||||
try {
|
||||
return uni.getStorageSync(PAYMENT_RESULT_KEY) || null
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 清除支付返回结果 */
|
||||
export function clearPaymentReturnResult() {
|
||||
uni.removeStorageSync(PAYMENT_RESULT_KEY)
|
||||
}
|
||||
|
||||
// 失败/成功信号值(大小写不敏感),字段名与取值以日照银行实际返回为准,如不一致只需调整下方映射
|
||||
const FAIL_SIGNALS = ['fail', 'failed', 'cancel', 'cancelled', 'error', 'closed', 'notpay', 'payerror', '2', 'false',
|
||||
'no', '01'
|
||||
]
|
||||
const SUCCESS_SIGNALS = ['success', 'ok', 'paid', 'finish', 'finished', '1', '0000', '0', '200', 'true', 'yes', '00']
|
||||
const RESULT_FIELDS = ['payResult', 'result', 'status', 'payStatus', 'tradeState', 'returnCode', 'code', 'errCode',
|
||||
'orderState'
|
||||
]
|
||||
|
||||
/**
|
||||
* 判定日照银行返回的支付结果:'success' | 'fail' | null(无法判定)
|
||||
*/
|
||||
export function resolvePaymentResult(data) {
|
||||
console.log("日照银行返回数据:", data)
|
||||
if (!data || typeof data !== 'object') return null
|
||||
// 布尔字段优先
|
||||
if (typeof data.success === 'boolean') return data.success ? 'success' : 'fail'
|
||||
if (typeof data.isSuccess === 'boolean') return data.isSuccess ? 'success' : 'fail'
|
||||
for (const key of RESULT_FIELDS) {
|
||||
const v = data[key]
|
||||
if (v === undefined || v === null || v === '') continue
|
||||
const s = String(v).trim().toLowerCase()
|
||||
if (FAIL_SIGNALS.includes(s)) return 'fail'
|
||||
if (SUCCESS_SIGNALS.includes(s)) return 'success'
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user