feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

@@ -0,0 +1,148 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { request, customerRequest, customerTokenKey } = require("../../utils/request");
const typeOptions = [
"日常留餐",
"宿舍开黑餐",
"社团 / 班级活动",
"生日聚会",
"考试周加餐",
"其他需求",
];
const peopleOptions = [
"1 人(单点)",
"2-4 人(寝室小聚)",
"5-10 人(部门小聚)",
"10-30 人(社团活动)",
"30 人以上(大型活动)",
];
const budgetOptions = [
"15 元左右 / 人(实惠)",
"18-22 元 / 人(荤素双拼)",
"25 元以上 / 人(高规格定制)",
];
const deliveryOptions = [
"摊位自取(报手机尾号即拿)",
"送至宿舍楼下(满 3 份)",
"送至指定教室 / 场地",
];
const labels = {
new: "待处理",
reviewing: "沟通中",
replied: "已回复",
qualified: "已确认",
converted: "已转化",
closed: "已关闭",
};
Page({
data: {
subView: "form",
records: [],
typeOptions,
peopleOptions,
budgetOptions,
deliveryOptions,
peopleIndex: 1,
budgetIndex: 1,
deliveryIndex: 0,
values: {
type: "日常留餐",
people: peopleOptions[1],
budget: budgetOptions[1],
delivery: deliveryOptions[0],
},
formId: "",
submitting: false,
formError: "",
},
onLoad(options) {
loadWorkspaceWithFallback()
.then((workspace) => {
const form =
(workspace.inquiryForms || []).find((item) => item.targetId === options.offeringId) ||
(workspace.inquiryForms || []).find((item) => item.target === "brand") ||
workspace.inquiryForms?.[0];
this.setData({ formId: form?.key || form?.id || "" });
})
.catch(() => {});
},
onShow() {
if (!wx.getStorageSync(customerTokenKey())) return;
customerRequest("/customer/inquiry-submissions")
.then((items) =>
this.setData({
records: (items || []).map((item) => ({
...item,
type: item.inquiryForm?.name || item.values?.type || "品牌咨询",
people: item.values?.people || "",
time: item.values?.date || "",
delivery: item.values?.delivery || "",
remark: item.values?.remark || "",
status: labels[item.status] || item.status,
replyNote: item.replyNote,
createdAt: new Date(item.createdAt).toLocaleDateString("zh-CN"),
})),
}),
)
.catch(() => {});
},
switchView(e) {
this.setData({ subView: e.currentTarget.dataset.view });
},
switchToForm() {
this.setData({ subView: "form" });
},
chooseType(e) {
this.setData({ "values.type": e.currentTarget.dataset.value });
},
choosePeople(e) {
const index = Number(e.detail.value);
this.setData({ peopleIndex: index, "values.people": peopleOptions[index] });
},
chooseBudget(e) {
const index = Number(e.detail.value);
this.setData({ budgetIndex: index, "values.budget": budgetOptions[index] });
},
chooseDelivery(e) {
const index = Number(e.detail.value);
this.setData({ deliveryIndex: index, "values.delivery": deliveryOptions[index] });
},
chooseDate(e) {
this.setData({ "values.date": e.detail.value });
},
input(e) {
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
},
submit() {
const { values, formId } = this.data;
if (!values.phone)
return this.setData({ formError: "请填写手机号或微信号,以便阿成加您发排菜菜单" });
if (!values.date) return this.setData({ formError: "请选择期望用餐日期" });
if (!formId) return this.setData({ formError: "咨询表单暂不可用,请稍后重试" });
this.setData({ submitting: true, formError: "" });
const send = () =>
customerRequest("/customer/inquiry-submissions", {
method: "POST",
data: { formId, values },
}).then((result) => {
wx.setStorageSync("latestInquirySubmission", result);
this.setData({ submitting: false, subView: "history" });
this.onShow();
wx.showToast({ title: "已提交,阿成会尽快联系你", icon: "none" });
});
const fail = (error) =>
this.setData({ submitting: false, formError: error.message || "提交失败,请重试" });
if (wx.getStorageSync(customerTokenKey())) return send().catch(fail);
wx.login({
success: (login) =>
request("/customer/session/wechat", { method: "POST", data: { code: login.code } })
.then((result) => {
wx.setStorageSync(customerTokenKey(), result.token);
return send();
})
.catch(fail),
fail,
});
},
});
@@ -0,0 +1,12 @@
{
"navigationBarTitleText": "提交咨询",
"navigationBarBackgroundColor": "#FBF7F1",
"navigationBarTextStyle": "black",
"usingComponents": {
"brand-button": "/components/ui/brand-button/brand-button",
"brand-field": "/components/ui/brand-field/brand-field",
"brand-loading": "/components/ui/brand-loading/brand-loading",
"brand-empty": "/components/ui/brand-empty/brand-empty",
"inquiry-form": "/components/modules/inquiry-form/inquiry-form"
}
}
@@ -0,0 +1,5 @@
<view class="page booking-page">
<view class="sub-tabs"><view class="sub-tab {{subView === 'form' ? 'active' : ''}}" data-view="form" bindtap="switchView">▤ 新建咨询 / 预订</view><view class="sub-tab {{subView === 'history' ? 'active' : ''}}" data-view="history" bindtap="switchView">▣ 我的咨询记录 ({{records.length}})</view></view>
<block wx:if="{{subView === 'form'}}"><view class="form-card"><text class="form-title">定制 / 预留需求登记</text><text class="form-desc">告诉阿成时间与人数,阿成量身帮你们排菜(免收预约定金)</text><view class="field"><text class="label">1. 咨询类型 <b>*</b></text><view class="type-grid"><view wx:for="{{typeOptions}}" wx:key="*this" class="type-option {{values.type === item ? 'selected' : ''}}" data-value="{{item}}" bindtap="chooseType">{{item}}</view></view></view><view class="two-col"><view class="field"><text class="label">预计用餐人数 <b>*</b></text><picker range="{{peopleOptions}}" value="{{peopleIndex}}" bindchange="choosePeople"><view class="picker">{{values.people || '请选择人数'}}</view></picker></view><view class="field"><text class="label">期望用餐时间 <b>*</b></text><picker mode="date" value="{{values.date}}" bindchange="chooseDate"><view class="picker">{{values.date || '请选择日期'}}</view></picker></view></view><view class="two-col"><view class="field"><text class="label">人均预算期望</text><picker range="{{budgetOptions}}" value="{{budgetIndex}}" bindchange="chooseBudget"><view class="picker">{{values.budget || '请选择预算'}}</view></picker></view><view class="field"><text class="label">取餐 / 配送偏好</text><picker range="{{deliveryOptions}}" value="{{deliveryIndex}}" bindchange="chooseDelivery"><view class="picker">{{values.delivery || '请选择方式'}}</view></picker></view></view><view class="field"><text class="label">预留餐品 / 口味偏好 / 忌口备注</text><textarea value="{{values.remark}}" data-key="remark" bindinput="input" placeholder="例:现炒牛肉饭 1 份,微辣多浇卤汁,不要香菜;或活动特殊要求" /></view><view class="field"><text class="label">联系手机或微信号 <b>*</b></text><input value="{{values.phone}}" data-key="phone" bindinput="input" placeholder="阿成将第一时间加微信发排菜明细与确认" /></view><view wx:if="{{formError}}" class="error">! {{formError}}</view><view class="promise">◷ <text>承诺:阿成将在 15~30 分钟内主动加微信沟通,未成单绝不骚扰。</text></view><button class="submit" loading="{{submitting}}" bindtap="submit">➤ 立即提交咨询(免收定金)</button></view></block>
<block wx:else><view wx:if="{{!records.length}}" class="empty"><text class="empty-icon">▣</text><text class="empty-title">暂无咨询记录</text><text>快向阿成提交一份预订需求吧~</text><button bindtap="switchToForm">新建咨询</button></view><view wx:else class="history-list"><view wx:for="{{records}}" wx:key="id" class="history-card"><view class="history-head"><text class="record-id">单号 #{{item.id}}</text><text class="record-status">{{item.status}}</text></view><text class="history-title">{{item.type}}({{item.people}})</text><text>◷ 时间:{{item.time || item.createdAt}}</text><text>⌖ 配送 / 取餐:{{item.delivery || '待确认'}}</text><text>备注:{{item.remark || item.flavor || '无'}}</text><view wx:if="{{item.replyNote}}" class="reply"><b>阿成微信留言:</b>{{item.replyNote}}</view><view class="history-foot">提交时间:{{item.createdAt}}<text>如有修改可随时微信留言</text></view></view><text class="history-note">仅展示近 30 天内的微信预约咨询历史</text></view></block>
</view>
@@ -0,0 +1,234 @@
.page {
min-height: 100vh;
padding: 28rpx 32rpx 150rpx;
background: #f7f5f1;
color: #292725;
}
.sub-tabs {
display: flex;
gap: 6rpx;
margin-bottom: 24rpx;
padding: 6rpx;
border-radius: 18rpx;
background: #e9e6e1;
color: #655f58;
font-size: 20rpx;
font-weight: 600;
}
.sub-tab {
flex: 1;
padding: 18rpx 4rpx;
border-radius: 14rpx;
text-align: center;
}
.sub-tab.active {
background: #fff;
color: #2c2925;
box-shadow: 0 4rpx 10rpx rgba(60, 45, 30, 0.08);
}
.form-card {
padding: 30rpx 28rpx;
border: 1rpx solid #eee9e3;
border-radius: 28rpx;
background: #fff;
box-shadow: 0 8rpx 20rpx rgba(60, 45, 30, 0.035);
}
.form-title {
display: block;
color: #282522;
font-size: 30rpx;
font-weight: 700;
}
.form-desc {
display: block;
margin-top: 8rpx;
color: #8e877f;
font-size: 19rpx;
}
.field {
margin-top: 26rpx;
}
.label {
display: block;
margin-bottom: 12rpx;
color: #4b4640;
font-size: 21rpx;
font-weight: 700;
}
.label b {
color: #e35237;
}
.type-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10rpx;
}
.type-option {
padding: 17rpx 6rpx;
border: 1rpx solid #e5e0da;
border-radius: 14rpx;
background: #fbfaf8;
color: #686159;
font-size: 18rpx;
text-align: center;
}
.type-option.selected {
border-color: #ef812d;
background: #fff2e7;
color: #d5661e;
font-weight: 700;
}
.two-col {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 18rpx;
}
.picker,
input,
textarea,
.picker {
box-sizing: border-box;
width: 100%;
min-height: 76rpx;
padding: 20rpx;
border: 1rpx solid #e6e0d9;
border-radius: 14rpx;
background: #fbfaf8;
color: #59534c;
font-size: 19rpx;
line-height: 1.5;
}
textarea {
min-height: 120rpx;
}
.picker {
white-space: normal;
}
.error {
margin-top: 22rpx;
padding: 16rpx;
border: 1rpx solid #f4c5bc;
border-radius: 14rpx;
background: #fff2f0;
color: #c34131;
font-size: 19rpx;
}
.promise {
display: flex;
gap: 10rpx;
align-items: flex-start;
margin-top: 22rpx;
padding: 18rpx;
border: 1rpx solid #eee9e3;
border-radius: 16rpx;
background: #faf9f7;
color: #7b746c;
font-size: 18rpx;
line-height: 1.5;
}
.promise:first-letter {
color: #ed7d25;
}
.submit {
width: 100%;
height: 78rpx;
margin-top: 24rpx;
border-radius: 18rpx;
background: #f18029;
color: #fff;
font-size: 22rpx;
font-weight: 700;
line-height: 78rpx;
}
.empty {
display: flex;
flex-direction: column;
align-items: center;
padding: 130rpx 28rpx;
color: #aaa39b;
font-size: 20rpx;
}
.empty-icon {
font-size: 60rpx;
color: #d8d1c8;
}
.empty-title {
margin: 18rpx 0 8rpx;
color: #655e56;
font-size: 27rpx;
font-weight: 700;
}
.empty button {
height: 70rpx;
margin-top: 28rpx;
padding: 0 34rpx;
border-radius: 16rpx;
background: #f18029;
color: #fff;
font-size: 21rpx;
line-height: 70rpx;
}
.history-card {
display: flex;
flex-direction: column;
gap: 12rpx;
margin-bottom: 18rpx;
padding: 24rpx;
border: 1rpx solid #eee9e3;
border-radius: 24rpx;
background: #fff;
color: #716a62;
font-size: 19rpx;
line-height: 1.5;
}
.history-head {
display: flex;
justify-content: space-between;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f0ece7;
}
.record-id {
color: #a39c94;
font-family: monospace;
font-size: 18rpx;
}
.record-status {
padding: 5rpx 12rpx;
border-radius: 999rpx;
background: #fff1e5;
color: #d36b20;
font-size: 17rpx;
}
.history-title {
color: #292622;
font-size: 24rpx;
font-weight: 700;
}
.reply {
padding: 16rpx;
border: 1rpx solid #f5d8bc;
border-radius: 14rpx;
background: #fff8ef;
color: #6f5744;
}
.reply b {
color: #e2762c;
}
.history-foot {
display: flex;
justify-content: space-between;
padding-top: 14rpx;
border-top: 1rpx solid #f3efea;
color: #aaa39b;
font-size: 17rpx;
}
.history-foot text {
color: #e2762c;
}
.history-note {
display: block;
padding: 10rpx;
text-align: center;
color: #aaa39b;
font-size: 17rpx;
}