feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -1,5 +1,5 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const { request, customerRequest } = require("../../utils/request");
|
||||
const { request, customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
Page({
|
||||
data: {
|
||||
offering: null,
|
||||
@@ -8,31 +8,42 @@ Page({
|
||||
title: "需求咨询",
|
||||
subtitle: "提交信息后由主理人与你联系",
|
||||
submitLabel: "提交需求",
|
||||
presentation: {},
|
||||
values: {},
|
||||
fields: [],
|
||||
formId: "",
|
||||
error: "",
|
||||
templateKey: "",
|
||||
navigation: [],
|
||||
},
|
||||
onLoad(options) {
|
||||
loadWorkspaceWithFallback().then((workspace) => {
|
||||
const offering =
|
||||
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
|
||||
const forms = workspace.inquiryForms || [];
|
||||
const form =
|
||||
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const isQuote =
|
||||
form?.purpose === "quote-request" ||
|
||||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
|
||||
this.setData({
|
||||
offering,
|
||||
fields: form?.fields || workspace.fields || [],
|
||||
formId: form?.key || form?.id || "",
|
||||
title: isQuote ? "获取报价方案" : "需求咨询",
|
||||
eyebrow: isQuote ? "QUOTE REQUEST" : "CONSULTATION",
|
||||
submitLabel: isQuote ? "提交报价需求" : "提交需求",
|
||||
});
|
||||
});
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
const offering =
|
||||
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
|
||||
const forms = workspace.inquiryForms || [];
|
||||
const form =
|
||||
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const isQuote =
|
||||
form?.purpose === "quote-request" ||
|
||||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
|
||||
const presentation = workspace.brand?.visualPresentation?.inquiry || {};
|
||||
this.setData({
|
||||
offering,
|
||||
fields: form?.fields || workspace.fields || [],
|
||||
formId: form?.key || form?.id || "",
|
||||
title: isQuote ? "获取报价方案" : presentation.title || "需求咨询",
|
||||
eyebrow: isQuote ? "QUOTE REQUEST" : presentation.eyebrow || "CONSULTATION",
|
||||
subtitle: presentation.subtitle || "提交信息后由主理人与你联系",
|
||||
submitLabel: isQuote ? "提交报价需求" : presentation.submitLabel || "提交需求",
|
||||
presentation,
|
||||
templateKey: workspace.visualTemplate?.key || "",
|
||||
navigation: workspace.navigation || [],
|
||||
});
|
||||
})
|
||||
.catch((error) => this.setData({ error: error.message }));
|
||||
},
|
||||
onInput(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
@@ -69,12 +80,12 @@ Page({
|
||||
this.setData({ submitting: false });
|
||||
wx.showToast({ title: error.message || "提交失败,请重试", icon: "none" });
|
||||
};
|
||||
if (wx.getStorageSync("customerToken")) return send().catch(fail);
|
||||
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("customerToken", result.token);
|
||||
wx.setStorageSync(customerTokenKey(), result.token);
|
||||
return send();
|
||||
})
|
||||
.catch(fail),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"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"
|
||||
"inquiry-form": "/components/modules/inquiry-form/inquiry-form",
|
||||
"runtime-tab-bar": "/components/runtime-tab-bar/runtime-tab-bar"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<view class="page"><view class="head"><text class="eyebrow">{{eyebrow}}</text><text class="title">{{title}}</text><text class="sub">{{offering ? offering.name : subtitle}}</text></view><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" submit-label="{{submitLabel}}" bind:input="onComponentInput" bind:submit="submit" /></view>
|
||||
<view class="page"><view wx:if="{{error}}" class="runtime-error">{{error}}</view><block wx:else><view class="head"><text class="eyebrow">{{eyebrow}}</text><text class="title">{{title}}</text><text class="sub">{{offering ? offering.name : subtitle}}</text></view><view wx:if="{{presentation.note}}" class="booking-note"><text>{{presentation.note}}</text></view><view class="form-panel"><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" submit-label="{{submitLabel}}" bind:input="onComponentInput" bind:submit="submit" /></view></block></view>
|
||||
@@ -3,6 +3,91 @@
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.booking-hero {
|
||||
padding: 52rpx 32rpx 30rpx;
|
||||
background: linear-gradient(180deg, #fff1df, #fff8f0);
|
||||
}
|
||||
.booking-hero .eyebrow {
|
||||
display: block;
|
||||
color: #c65c28;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.booking-hero .title {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
font-size: 44rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.booking-hero .sub {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
color: #7a6a60;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.booking-note {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 0 32rpx 20rpx;
|
||||
padding: 20rpx 22rpx;
|
||||
border: 1rpx solid #f3d1b2;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
color: #a4562d;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.form-panel {
|
||||
margin: 0 24rpx;
|
||||
padding: 10rpx 8rpx 24rpx;
|
||||
border: 1rpx solid #f1e1d5;
|
||||
border-radius: 28rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 12rpx 28rpx rgba(145, 75, 33, 0.06);
|
||||
}
|
||||
.form-panel .form {
|
||||
padding: 20rpx;
|
||||
}
|
||||
.form-panel .field {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.form-panel .label {
|
||||
color: #4f3020;
|
||||
font-weight: 700;
|
||||
}
|
||||
.form-panel input,
|
||||
.form-panel textarea,
|
||||
.form-panel .picker-value {
|
||||
border: 1rpx solid #eaded5;
|
||||
border-radius: 16rpx;
|
||||
background: #fffaf6;
|
||||
}
|
||||
.form-panel .submit {
|
||||
height: 82rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
line-height: 82rpx;
|
||||
}
|
||||
.runtime-error {
|
||||
margin: 48rpx 32rpx;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
color: #8a6846;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.head {
|
||||
background: #252827;
|
||||
color: #fff;
|
||||
@@ -65,3 +150,6 @@
|
||||
font-size: 20rpx;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
Reference in new issue
Block a user