hookehuyr

fix(api): 修复登录参数和请求URL配置问题

修正志愿者登录接口参数从username改为uuid
更新兑换相关接口的URL路径和参数配置
添加请求参数合并逻辑确保默认参数被正确应用
1 /* 1 /*
2 * @Date: 2023-08-24 09:42:27 2 * @Date: 2023-08-24 09:42:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-14 20:50:41 4 + * @LastEditTime: 2026-01-20 11:08:06
5 * @FilePath: /xyxBooking-weapp/src/api/index.js 5 * @FilePath: /xyxBooking-weapp/src/api/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -28,9 +28,9 @@ const Api = { ...@@ -28,9 +28,9 @@ const Api = {
28 QUERY_QR_CODE: '/srv/?a=api&t=id_number_query_qr_code', 28 QUERY_QR_CODE: '/srv/?a=api&t=id_number_query_qr_code',
29 ICBC_ORDER_QRY: '/srv/?a=icbc_orderqry', 29 ICBC_ORDER_QRY: '/srv/?a=icbc_orderqry',
30 WX_PAY: '/srv/?a=icbc_pay_wxamp', 30 WX_PAY: '/srv/?a=icbc_pay_wxamp',
31 - REDEEM_LOGIN: '/srv/?a=redeem&t=login', 31 + REDEEM_LOGIN: '/srv/?f=reserve_admin&a=login',
32 - REDEEM_CHECK_AUTH: '/srv/?a=redeem&t=check_auth', 32 + REDEEM_CHECK_AUTH: '/srv/?f=reserve_admin&a=user&t=check_auth',
33 - REDEEM_REDEEM: '/srv/?a=redeem&t=redeem', 33 + REDEEM_REDEEM: '/srv/?f=reserve_admin&a=bill&t=redeem',
34 }; 34 };
35 35
36 /** 36 /**
......
1 <!-- 1 <!--
2 * @Date: 2026-01-08 13:01:56 2 * @Date: 2026-01-08 13:01:56
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-14 20:49:12 4 + * @LastEditTime: 2026-01-20 10:54:19
5 * @FilePath: /xyxBooking-weapp/src/pages/volunteerLogin/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/volunteerLogin/index.vue
6 * @Description: 义工登录页面 6 * @Description: 义工登录页面
7 --> 7 -->
...@@ -68,7 +68,7 @@ const handleLogin = async () => { ...@@ -68,7 +68,7 @@ const handleLogin = async () => {
68 } 68 }
69 69
70 Taro.showLoading({ title: '登录中...' }) 70 Taro.showLoading({ title: '登录中...' })
71 - const login_res = await volunteerLoginAPI({ username: username.value, password: password.value }) 71 + const login_res = await volunteerLoginAPI({ uuid: username.value, password: password.value })
72 Taro.hideLoading() 72 Taro.hideLoading()
73 73
74 if (login_res?.code !== 1) { 74 if (login_res?.code !== 1) {
......
...@@ -51,6 +51,46 @@ service.defaults.params = { ...@@ -51,6 +51,46 @@ service.defaults.params = {
51 let has_shown_timeout_modal = false 51 let has_shown_timeout_modal = false
52 52
53 /** 53 /**
54 + * 合并请求参数,将默认参数与请求参数合并
55 + * @param {Object} config - axios请求配置对象
56 + * @returns {Object} 合并后的请求配置对象
57 + */
58 +
59 +const merge_request_params = (config) => {
60 + const url = config?.url || ''
61 + if (!url || url.indexOf('?') === -1) {
62 + const params = config?.params || {}
63 + return {
64 + ...config,
65 + params: {
66 + ...REQUEST_DEFAULT_PARAMS,
67 + ...params,
68 + },
69 + }
70 + }
71 +
72 + const parts = url.split('?')
73 + const base_url = parts[0]
74 + const search = parts.slice(1).join('?')
75 + const url_params = {}
76 + const search_params = new URLSearchParams(search)
77 + for (const [key, value] of search_params.entries()) {
78 + url_params[key] = value
79 + }
80 + const merged_params = {
81 + ...REQUEST_DEFAULT_PARAMS,
82 + ...url_params,
83 + ...(config?.params || {}),
84 + }
85 +
86 + return {
87 + ...config,
88 + url: base_url,
89 + params: merged_params,
90 + }
91 +}
92 +
93 +/**
54 * 判断是否为超时错误 94 * 判断是否为超时错误
55 * @param {Error} error - 请求错误对象 95 * @param {Error} error - 请求错误对象
56 * @returns {boolean} 是否为超时错误 96 * @returns {boolean} 是否为超时错误
...@@ -147,6 +187,8 @@ service.interceptors.request.use( ...@@ -147,6 +187,8 @@ service.interceptors.request.use(
147 config.headers.cookie = sessionid; 187 config.headers.cookie = sessionid;
148 } 188 }
149 189
190 + config = merge_request_params(config)
191 +
150 // 增加时间戳 192 // 增加时间戳
151 if (config.method === 'get') { 193 if (config.method === 'get') {
152 config.params = { ...config.params, timestamp: (new Date()).valueOf() } 194 config.params = { ...config.params, timestamp: (new Date()).valueOf() }
......
...@@ -125,7 +125,7 @@ const buildApiUrl = (action, params = {}) => { ...@@ -125,7 +125,7 @@ const buildApiUrl = (action, params = {}) => {
125 a: action, 125 a: action,
126 f: REQUEST_DEFAULT_PARAMS.f, 126 f: REQUEST_DEFAULT_PARAMS.f,
127 client_name: REQUEST_DEFAULT_PARAMS.client_name, 127 client_name: REQUEST_DEFAULT_PARAMS.client_name,
128 - ...params 128 + ...params,
129 }) 129 })
130 return `${BASE_URL}/srv/?${queryParams.toString()}` 130 return `${BASE_URL}/srv/?${queryParams.toString()}`
131 } 131 }
......