48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
|
const { customerRequest, customerTokenKey } = require("../../utils/request");
|
|
|
|
Page({
|
|
data: { brand: {}, records: [], error: "", recordsError: "" },
|
|
onLoad() {
|
|
loadWorkspaceWithFallback()
|
|
.then((workspace) =>
|
|
this.setData({
|
|
brand: workspace.brand || {},
|
|
trustItems: workspace.trustItems || [],
|
|
}),
|
|
)
|
|
.catch((error) => this.setData({ error: error.message }));
|
|
},
|
|
onShow() {
|
|
this.loadRecords();
|
|
},
|
|
loadRecords() {
|
|
if (!wx.getStorageSync(customerTokenKey()))
|
|
return this.setData({ records: [], recordsError: "" });
|
|
customerRequest("/customer/inquiry-submissions")
|
|
.then((records) =>
|
|
this.setData({ records: Array.isArray(records) ? records : [], recordsError: "" }),
|
|
)
|
|
.catch((error) =>
|
|
this.setData({ recordsError: error.message || "记录加载失败,请稍后重试" }),
|
|
);
|
|
},
|
|
call() {
|
|
wx.makePhoneCall({
|
|
phoneNumber: (this.data.brand.phone || this.data.brand.contactPhone || "").replace(
|
|
/[^0-9-]/g,
|
|
"",
|
|
),
|
|
});
|
|
},
|
|
copyWechat() {
|
|
wx.setClipboardData({
|
|
data: this.data.brand.wechat || this.data.brand.contactWechat || "",
|
|
success: () => wx.showToast({ title: "微信号已复制", icon: "none" }),
|
|
});
|
|
},
|
|
recordsPage() {
|
|
wx.navigateTo({ url: "/pages/records/index" });
|
|
},
|
|
});
|