feat: 按林境门作原型完善静态小程序

This commit is contained in:
que01 committed 2026-09-22 16:43:29 +08:00
1 parent 4afb6bbbe8
commit 8489c8ca79
26 files changed
+92 -964

No files matched your search

+10 -62
View File
@@ -1,72 +1,20 @@
const { request, customerRequest } = require("../../utils/request");
const { bookingViewModel } = require("../../utils/labels");
const { getTemplate } = require("../../utils/templates");
const { brand, trustContent } = require("../../utils/linjing-data");
Page({
data: {
loading: true,
error: "",
bookings: [],
cancellingId: "",
template: getTemplate("personal"),
brand, trustContent, records: [],
},
onLoad() {
this.load();
this.setData({ records: wx.getStorageSync("linjingInquiryRecords") || [] });
},
onShow() {
this.load();
this.setData({ records: wx.getStorageSync("linjingInquiryRecords") || [] });
},
load() {
const token = wx.getStorageSync("customerToken");
if (!token) return this.setData({ loading: false, bookings: [], error: "" });
this.setData({ loading: true, error: "" });
Promise.all([customerRequest("/customer/bookings"), request("/public/brand")])
.then(([items, brand]) => {
getApp().globalData.brand = brand;
const template = getTemplate(brand.templateKey);
this.setData({
template,
bookings: (Array.isArray(items) ? items : []).map((item) =>
bookingViewModel(item, template),
),
loading: false,
});
})
.catch((error) => this.setData({ loading: false, error: error.message || "网络请求失败" }));
call() {
wx.makePhoneCall({ phoneNumber: brand.phone.replace(/[^0-9-]/g, "") });
},
retry() {
this.load();
},
contact() {
const brand = getApp().globalData.brand || {};
if (brand.contactPhone) return wx.makePhoneCall({ phoneNumber: brand.contactPhone });
if (brand.contactWechat)
return wx.showModal({
title: "联系品牌方",
content: "微信号:" + brand.contactWechat,
showCancel: false,
});
wx.showToast({ title: "暂未配置联系方式", icon: "none" });
},
cancel(e) {
const id = e.currentTarget.dataset.id;
if (this.data.cancellingId) return;
wx.showModal({
title: "取消预约",
content: "确定取消这笔预约吗?",
success: (result) => {
if (!result.confirm) return;
this.setData({ cancellingId: id });
customerRequest("/customer/bookings/" + id + "/cancel", { method: "POST", data: {} })
.then(() => {
this.setData({ cancellingId: "" });
wx.showToast({ title: "已取消预约", icon: "success" });
this.load();
})
.catch((error) => {
this.setData({ cancellingId: "" });
wx.showToast({ title: error.message || "取消失败", icon: "none" });
});
},
});
copyWechat() { wx.setClipboardData({ data: brand.wechat, success: () => wx.showToast({ title: "微信号已复制", icon: "none" }) }); },
recordsPage() { wx.navigateTo({ url: "/pages/records/index" }); },
inquire() {
wx.navigateTo({ url: "/pages/inquiry/index" });
},
});