fix: 收敛模板编辑发布契约并还原餐饮页面视觉
This commit is contained in:
1 parent
20bcb43534
commit
f4061a24bd
102 files changed
+4510
-870
No files matched your search
@@ -31,14 +31,15 @@ Page({
|
||||
// 字段全部来自后台已发布的咨询表单,模板只负责呈现。
|
||||
fields: [],
|
||||
values: {},
|
||||
displayValues: {},
|
||||
formId: "",
|
||||
submitting: false,
|
||||
formError: "",
|
||||
presentation: {},
|
||||
},
|
||||
onLoad(options) {
|
||||
this.offeringId = options.offeringId || "";
|
||||
loadWorkspaceWithFallback()
|
||||
this.offeringId = options?.offeringId || "";
|
||||
return loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
this.forms = workspace.inquiryForms || [];
|
||||
this.setData({ presentation: workspace.brand?.visualPresentation?.inquiry || {} });
|
||||
@@ -54,8 +55,15 @@ Page({
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const formId = form?.key || form?.id || "";
|
||||
if (formId !== this.data.formId)
|
||||
this.setData({ formId, fields: form?.fields || [], values: {} });
|
||||
if (formId !== this.data.formId) {
|
||||
// 原型中的类型选项为按钮网格,人数/日期和预算/配送各占半行;数据与文案仍来自已发布表单。
|
||||
const fields = (form?.fields || []).map((field) => ({
|
||||
...field,
|
||||
useChips: field.key === "type" && (field.type === "select" || field.type === "radio"),
|
||||
halfWidth: ["people", "date", "budget", "delivery"].includes(field.key),
|
||||
}));
|
||||
this.setData({ formId, fields, values: {}, displayValues: {} });
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// 本页是 tabBar 页,从详情页进入时参数经 openPage 暂存,而不是通过 onLoad 传入。
|
||||
@@ -90,10 +98,21 @@ Page({
|
||||
switchToForm() {
|
||||
this.setData({ subView: "form" });
|
||||
},
|
||||
chooseChip(e) {
|
||||
const { key, value } = e.currentTarget.dataset;
|
||||
this.setData({ ["values." + key]: value });
|
||||
},
|
||||
choose(e) {
|
||||
const field = this.data.fields.find((item) => item.key === e.currentTarget.dataset.key);
|
||||
const option = field?.options?.[Number(e.detail.value)];
|
||||
if (option) this.setData({ ["values." + field.key]: option.value });
|
||||
if (option)
|
||||
this.setData({
|
||||
["values." + field.key]: option.value,
|
||||
["displayValues." + field.key]: option.label,
|
||||
});
|
||||
},
|
||||
checkboxChange(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
},
|
||||
input(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
@@ -101,7 +120,11 @@ Page({
|
||||
submit() {
|
||||
const { values, formId, fields } = this.data;
|
||||
const missing = fields.find(
|
||||
(field) => field.required && (values[field.key] === undefined || values[field.key] === ""),
|
||||
(field) =>
|
||||
field.required &&
|
||||
(values[field.key] === undefined ||
|
||||
values[field.key] === "" ||
|
||||
(Array.isArray(values[field.key]) && !values[field.key].length)),
|
||||
);
|
||||
if (missing) return this.setData({ formError: "请填写" + missing.label });
|
||||
if (!formId) return this.setData({ formError: "咨询表单暂不可用,请稍后重试" });
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
<view class="form-card">
|
||||
<text class="form-title">{{presentation.title || '咨询 / 预订'}}</text>
|
||||
<text wx:if="{{presentation.subtitle}}" class="form-desc">{{presentation.subtitle}}</text>
|
||||
<view wx:for="{{fields}}" wx:key="key" class="field">
|
||||
<text class="label">{{item.label}} <b wx:if="{{item.required}}">*</b></text>
|
||||
<picker wx:if="{{item.type === 'select' || item.type === 'radio'}}" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker">{{values[item.key] || '请选择' + item.label}}</view></picker>
|
||||
<view class="form-fields">
|
||||
<view wx:for="{{fields}}" wx:key="key" class="field {{item.halfWidth ? 'field-half' : ''}}">
|
||||
<text class="label">{{item.label}} <text wx:if="{{item.required}}" class="required">*</text></text>
|
||||
<view wx:if="{{item.useChips}}" class="type-grid"><view wx:for="{{item.options}}" wx:for-item="option" wx:key="value" class="type-option {{values[item.key] === option.value ? 'selected' : ''}}" data-key="{{item.key}}" data-value="{{option.value}}" bindtap="chooseChip">{{option.label}}</view></view>
|
||||
<picker wx:elif="{{item.type === 'select' || item.type === 'radio'}}" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker">{{displayValues[item.key] || '请选择' + item.label}}</view></picker>
|
||||
<picker wx:elif="{{item.type === 'date'}}" mode="date" value="{{values[item.key]}}" data-key="{{item.key}}" bindchange="input"><view class="picker">{{values[item.key] || '请选择日期'}}</view></picker>
|
||||
<textarea wx:elif="{{item.type === 'textarea'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
<input wx:else type="{{item.type === 'number' ? 'number' : 'text'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
<checkbox-group wx:elif="{{item.type === 'multi-select' || item.type === 'checkbox'}}" data-key="{{item.key}}" bindchange="checkboxChange"><label wx:for="{{item.options}}" wx:for-item="option" wx:key="value"><checkbox value="{{option.value}}" />{{option.label}}</label></checkbox-group>
|
||||
<input wx:else type="{{item.type === 'number' || item.type === 'phone' || item.type === 'tel' ? 'number' : 'text'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{formError}}" class="error">! {{formError}}</view>
|
||||
<view wx:if="{{presentation.promise}}" class="promise"><text>{{presentation.promise}}</text></view>
|
||||
@@ -23,7 +27,7 @@
|
||||
<view class="history-head"><text class="record-id">单号 #{{item.id}}</text><text class="record-status">{{item.status}}</text></view>
|
||||
<text class="history-title">{{item.title}}</text>
|
||||
<text wx:for="{{item.summary}}" wx:for-item="line" wx:key="key">{{line.label}}:{{line.value}}</text>
|
||||
<view wx:if="{{item.replyNote}}" class="reply"><b>处理回复:</b>{{item.replyNote}}</view>
|
||||
<view wx:if="{{item.replyNote}}" class="reply"><text class="reply-label">处理回复:</text>{{item.replyNote}}</view>
|
||||
<view class="history-foot">提交时间:{{item.createdAt}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 150rpx;
|
||||
padding: 32rpx 32rpx 64rpx;
|
||||
background: #f7f5f1;
|
||||
color: #292725;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
.sub-tab {
|
||||
flex: 1;
|
||||
padding: 18rpx 4rpx;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.sub-tab.active {
|
||||
@@ -27,35 +27,45 @@
|
||||
box-shadow: 0 4rpx 10rpx rgba(60, 45, 30, 0.08);
|
||||
}
|
||||
.form-card {
|
||||
padding: 30rpx 28rpx;
|
||||
padding: 32rpx;
|
||||
border: 1rpx solid #eee9e3;
|
||||
border-radius: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 8rpx 20rpx rgba(60, 45, 30, 0.035);
|
||||
}
|
||||
.form-title {
|
||||
display: block;
|
||||
color: #282522;
|
||||
font-size: 30rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.form-desc {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
color: #8e877f;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.form-fields {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 28rpx 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.field {
|
||||
margin-top: 26rpx;
|
||||
grid-column: span 2;
|
||||
min-width: 0;
|
||||
}
|
||||
.field-half {
|
||||
grid-column: span 1;
|
||||
}
|
||||
.label {
|
||||
display: block;
|
||||
margin-bottom: 12rpx;
|
||||
color: #4b4640;
|
||||
font-size: 21rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.label b {
|
||||
.required {
|
||||
color: #e35237;
|
||||
}
|
||||
.type-grid {
|
||||
@@ -66,10 +76,10 @@
|
||||
.type-option {
|
||||
padding: 17rpx 6rpx;
|
||||
border: 1rpx solid #e5e0da;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fbfaf8;
|
||||
color: #686159;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.type-option.selected {
|
||||
@@ -92,26 +102,28 @@ textarea,
|
||||
min-height: 76rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e6e0d9;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fbfaf8;
|
||||
color: #59534c;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
textarea {
|
||||
min-height: 120rpx;
|
||||
}
|
||||
.picker {
|
||||
white-space: normal;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.error {
|
||||
margin-top: 22rpx;
|
||||
padding: 16rpx;
|
||||
border: 1rpx solid #f4c5bc;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fff2f0;
|
||||
color: #c34131;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.promise {
|
||||
display: flex;
|
||||
@@ -123,7 +135,7 @@ textarea {
|
||||
border-radius: 16rpx;
|
||||
background: #faf9f7;
|
||||
color: #7b746c;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.promise:first-letter {
|
||||
@@ -165,7 +177,7 @@ textarea {
|
||||
border-radius: 16rpx;
|
||||
background: #f18029;
|
||||
color: #fff;
|
||||
font-size: 21rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
.history-card {
|
||||
@@ -178,7 +190,7 @@ textarea {
|
||||
border-radius: 24rpx;
|
||||
background: #fff;
|
||||
color: #716a62;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.history-head {
|
||||
@@ -190,7 +202,7 @@ textarea {
|
||||
.record-id {
|
||||
color: #a39c94;
|
||||
font-family: monospace;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.record-status {
|
||||
padding: 5rpx 12rpx;
|
||||
@@ -207,11 +219,11 @@ textarea {
|
||||
.reply {
|
||||
padding: 16rpx;
|
||||
border: 1rpx solid #f5d8bc;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fff8ef;
|
||||
color: #6f5744;
|
||||
}
|
||||
.reply b {
|
||||
.reply-label {
|
||||
color: #e2762c;
|
||||
}
|
||||
.history-foot {
|
||||
|
||||
Reference in new issue
Block a user