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

+6 -2
View File
@@ -1,6 +1,10 @@
const app = getApp();
module.exports = {
get apiBaseUrl() { return app.globalData.apiBaseUrl; },
get brand() { return app.globalData.brand || {}; },
get apiBaseUrl() {
return app.globalData.apiBaseUrl;
},
get brand() {
return app.globalData.brand || {};
},
};
+14 -5
View File
@@ -1,12 +1,21 @@
const STATUS_LABELS = { received: '待确认', contacting: '沟通中', confirmed: '已确认', completed: '已完成', cancelled: '已取消' };
const FULFILLMENT_LABELS = { pickup: '自取', delivery: '配送' };
const STATUS_LABELS = {
received: "待确认",
contacting: "沟通中",
confirmed: "已确认",
completed: "已完成",
cancelled: "已取消",
};
const FULFILLMENT_LABELS = { pickup: "自取", delivery: "配送" };
function bookingViewModel(item, template) {
return {
...item,
statusLabel: STATUS_LABELS[item.status] || '未知状态',
fulfillmentLabel: template?.modeLabels?.[item.fulfillmentType] || FULFILLMENT_LABELS[item.fulfillmentType] || '待确认',
serviceName: item.service?.name || item.items?.[0]?.serviceNameSnapshot || '未命名服务',
statusLabel: STATUS_LABELS[item.status] || "未知状态",
fulfillmentLabel:
template?.modeLabels?.[item.fulfillmentType] ||
FULFILLMENT_LABELS[item.fulfillmentType] ||
"待确认",
serviceName: item.service?.name || item.items?.[0]?.serviceNameSnapshot || "未命名服务",
quantityLabel: `${item.items?.[0]?.quantity || 1} 份`,
};
}
+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 };
+75 -3
View File
@@ -1,6 +1,78 @@
const TEMPLATES = {
food: { modeLabels: { pickup: '自取', delivery: '配送' }, contactLabel: '联系摊主', cancelLabel: '取消预约', cancelNote: '取消后请及时告知摊主,避免食材浪费。', hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取', serviceSub: '今日可订', first: '普通套餐', firstSub: '日常家常饭', second: '私厨服务', secondSub: '聚餐定制', available: '今日可订', unavailable: '暂不可订', empty: '暂无可订服务', bookingTitle: '预约套餐', requestType: 'package', modeLabel: '取餐方式', modeA: '自取', modeB: '配送', locationLabel: '配送地址', locationPlaceholder: '请输入配送地址', notePlaceholder: '口味、餐具或其他说明', submitNotice: '提交后由摊主人工确认,确认后再安排制作。', submitLabel: '提交预约' },
personal: { modeLabels: { pickup: '线上沟通', delivery: '线下沟通' }, contactLabel: '联系品牌方', cancelLabel: '取消申请', cancelNote: '如需调整,请尽早联系品牌方。', hero: '个人品牌', heroSub: '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系', serviceSub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务', bookingTitle: '合作咨询', requestType: 'inquiry', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' },
food: {
modeLabels: { pickup: "自取", delivery: "配送" },
contactLabel: "联系摊主",
cancelLabel: "取消预约",
cancelNote: "取消后请及时告知摊主,避免食材浪费。",
hero: "今天吃什么",
heroSub: "现做家常饭",
about: "品牌简介",
description: "个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。",
primary: "预约套餐",
secondary: "咨询私厨",
timeLabel: "营业时间",
time: "11:00—20:00",
addressLabel: "摊位地址",
address: "校园路社区便民点 12 号",
noteLabel: "配送说明",
note: "满 30 元周边配送,也可自取",
serviceSub: "今日可订",
first: "普通套餐",
firstSub: "日常家常饭",
second: "私厨服务",
secondSub: "聚餐定制",
available: "今日可订",
unavailable: "暂不可订",
empty: "暂无可订服务",
bookingTitle: "预约套餐",
requestType: "package",
modeLabel: "取餐方式",
modeA: "自取",
modeB: "配送",
locationLabel: "配送地址",
locationPlaceholder: "请输入配送地址",
notePlaceholder: "口味、餐具或其他说明",
submitNotice: "提交后由摊主人工确认,确认后再安排制作。",
submitLabel: "提交预约",
},
personal: {
modeLabels: { pickup: "线上沟通", delivery: "线下沟通" },
contactLabel: "联系品牌方",
cancelLabel: "取消申请",
cancelNote: "如需调整,请尽早联系品牌方。",
hero: "个人品牌",
heroSub: "把专业能力,变成值得信赖的体验",
about: "关于我",
description: "这里展示你的专业背景、工作方式与品牌理念。",
primary: "查看服务",
secondary: "发起咨询",
timeLabel: "服务时间",
time: "工作日 10:00—18:00",
addressLabel: "所在位置",
address: "线上 / 线下均可沟通",
noteLabel: "合作说明",
note: "提交需求后,我会尽快与你联系",
serviceSub: "可咨询",
first: "标准服务",
firstSub: "清晰的服务方案",
second: "定制合作",
secondSub: "按需求沟通",
available: "可咨询",
unavailable: "暂不可用",
empty: "暂无可咨询服务",
bookingTitle: "合作咨询",
requestType: "inquiry",
modeLabel: "沟通方式",
modeA: "线上沟通",
modeB: "线下沟通",
locationLabel: "沟通方式或地点",
locationPlaceholder: "请输入会议方式、地点或链接",
notePlaceholder: "请介绍你的需求、预算或期待结果",
submitNotice: "提交后品牌方会与你确认需求、时间和合作方式。",
submitLabel: "提交需求",
},
};
function getTemplate(key) { return TEMPLATES[key] || TEMPLATES.personal; }
function getTemplate(key) {
return TEMPLATES[key] || TEMPLATES.personal;
}
module.exports = { getTemplate, TEMPLATES };