34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
const { request } = require("../../utils/request");
|
|
Page({
|
|
data: { loading: true, error: "", item: null },
|
|
onLoad(options) {
|
|
request("/public/offerings/" + encodeURIComponent(options.id))
|
|
.then((item) => this.setData({ item, loading: false }))
|
|
.catch(() => this.setData({ loading: false, error: "详情加载失败" }));
|
|
},
|
|
submit() {
|
|
const cta = this.data.item?.cta || {};
|
|
const form = this.data.item?.inquiryForms?.[0];
|
|
if (cta.type === "inquiry" || form?.submissionAction === "create-inquiry") {
|
|
const formId = form?.id || cta.config?.formId;
|
|
return wx.navigateTo({
|
|
url: "/pages/inquiry/index" + (formId ? "?formId=" + encodeURIComponent(formId) : ""),
|
|
});
|
|
}
|
|
if (form?.submissionAction === "create-booking" || cta.type === "booking") {
|
|
return wx.navigateTo({
|
|
url: "/pages/booking/index?offeringId=" + encodeURIComponent(this.data.item?.id || ""),
|
|
});
|
|
}
|
|
if (cta.type === "external-link") {
|
|
return wx.showToast({ title: "请在支持外链的环境打开", icon: "none" });
|
|
}
|
|
if (cta.type === "contact") {
|
|
return wx.showToast({ title: "请从品牌主页查看联系方式", icon: "none" });
|
|
}
|
|
wx.navigateTo({
|
|
url: "/pages/booking/index?offeringId=" + encodeURIComponent(this.data.item?.id || ""),
|
|
});
|
|
},
|
|
});
|