从 xghmall(云闪付版湘工游)迁移民票模块,改造为微信公众号 H5: - 技术栈沿用 uni-app + Vue2 + uView(含定制版日历组件) - 登录/支付独立成层(common/auth.js、common/pay.js): 一期假登录(测试手机号)+ 模拟支付,后端微信接口就绪后只换这两处 - 登录页重写:短信验证码 + 公众号网页授权(code 换用户信息)预留 - 门票列表页为入口页(进页必须登录),加订单悬浮按钮 - 支付成功页接通:查看订单/继续逛逛 + 订单状态轮询 - 详情页定位导航改用 uni.openLocation + 高德网页兜底 - 出行人页:身份证 18 位格式校验,删除死的删除按钮,修正证件类型回显笔误 - 清理云闪付 SDK、支付宝授权、死页面引用等残留 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
/**
|
|
* 对象转url参数
|
|
* @param {*} data,对象
|
|
* @param {*} isPrefix,是否自动加上"?"
|
|
*/
|
|
function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
|
|
let prefix = isPrefix ? '?' : ''
|
|
let _result = []
|
|
if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets';
|
|
for (let key in data) {
|
|
let value = data[key]
|
|
// 去掉为空的参数
|
|
if (['', undefined, null].indexOf(value) >= 0) {
|
|
continue;
|
|
}
|
|
// 如果值为数组,另行处理
|
|
if (value.constructor === Array) {
|
|
// e.g. {ids: [1, 2, 3]}
|
|
switch (arrayFormat) {
|
|
case 'indices':
|
|
// 结果: ids[0]=1&ids[1]=2&ids[2]=3
|
|
for (let i = 0; i < value.length; i++) {
|
|
_result.push(key + '[' + i + ']=' + value[i])
|
|
}
|
|
break;
|
|
case 'brackets':
|
|
// 结果: ids[]=1&ids[]=2&ids[]=3
|
|
value.forEach(_value => {
|
|
_result.push(key + '[]=' + _value)
|
|
})
|
|
break;
|
|
case 'repeat':
|
|
// 结果: ids=1&ids=2&ids=3
|
|
value.forEach(_value => {
|
|
_result.push(key + '=' + _value)
|
|
})
|
|
break;
|
|
case 'comma':
|
|
// 结果: ids=1,2,3
|
|
let commaStr = "";
|
|
value.forEach(_value => {
|
|
commaStr += (commaStr ? "," : "") + _value;
|
|
})
|
|
_result.push(key + '=' + commaStr)
|
|
break;
|
|
default:
|
|
value.forEach(_value => {
|
|
_result.push(key + '[]=' + _value)
|
|
})
|
|
}
|
|
} else {
|
|
_result.push(key + '=' + value)
|
|
}
|
|
}
|
|
return _result.length ? prefix + _result.join('&') : ''
|
|
}
|
|
|
|
export default queryParams;
|