style: 统一全仓代码格式

This commit is contained in:
que01 committed 2026-09-19 18:46:26 +08:00
1 parent d811478d0f
commit 8033cabff9
30 files changed
+1183 -187

No files matched your search

+9 -6
View File
@@ -1,15 +1,15 @@
const config = require('./config');
const config = require("./config");
function request(path, options = {}) {
return new Promise((resolve, reject) => {
wx.request({
url: config.apiBaseUrl + path,
method: options.method || 'GET',
header: { accept: 'application/json', ...(options.header || {}) },
method: options.method || "GET",
header: { accept: "application/json", ...(options.header || {}) },
...(options.data === undefined ? {} : { data: options.data }),
success: (response) => {
if (response.statusCode >= 200 && response.statusCode < 300) return resolve(response.data);
const error = response.data?.error?.message || '请求失败';
const error = response.data?.error?.message || "请求失败";
reject(Object.assign(new Error(error), { statusCode: response.statusCode, response }));
},
fail: reject,
@@ -18,8 +18,11 @@ function request(path, options = {}) {
}
function customerRequest(path, options = {}) {
const token = wx.getStorageSync('customerToken');
return request(path, { ...options, header: { ...(options.header || {}), Authorization: 'Bearer ' + token } });
const token = wx.getStorageSync("customerToken");
return request(path, {
...options,
header: { ...(options.header || {}), Authorization: "Bearer " + token },
});
}
module.exports = { request, customerRequest };