style: 统一全仓代码格式

This commit is contained in:
que01 committed 2026-09-19 18:46:26 +08:00
1 parent d811478d0f
commit 8033cabff9
30 files changed
+1183 -187

No files matched your search

+70 -8
View File
@@ -1,10 +1,72 @@
const { request, customerRequest } = require('../../utils/request');
const { bookingViewModel } = require('../../utils/labels');
const { getTemplate } = require('../../utils/templates');
const { request, customerRequest } = require("../../utils/request");
const { bookingViewModel } = require("../../utils/labels");
const { getTemplate } = require("../../utils/templates");
Page({
data: { loading: true, error: '', bookings: [], cancellingId: '', template: getTemplate('personal') },
onLoad() { this.load(); }, onShow() { this.load(); },
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 || '网络请求失败' })); },
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' }); }); } }); }
data: {
loading: true,
error: "",
bookings: [],
cancellingId: "",
template: getTemplate("personal"),
},
onLoad() {
this.load();
},
onShow() {
this.load();
},
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 || "网络请求失败" }));
},
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" });
});
},
});
},
});
+5 -1
View File
@@ -1 +1,5 @@
{"navigationBarTitleText":"我的订单","navigationBarBackgroundColor":"#FBF7F1","navigationBarTextStyle":"black"}
{
"navigationBarTitleText": "我的订单",
"navigationBarBackgroundColor": "#FBF7F1",
"navigationBarTextStyle": "black"
}
+158 -2
View File
@@ -1,2 +1,158 @@
.page{min-height:100vh;padding:24rpx 32rpx 60rpx;background:#FBF7F1;color:#2B2B2B}.heading-row{display:flex;justify-content:space-between;align-items:center;margin:12rpx 0 32rpx}.heading{font-size:48rpx;font-weight:700}.phone{font-size:48rpx;color:#7A4A2B}.status-banner{position:relative;display:flex;justify-content:space-between;align-items:center;margin-bottom:20rpx;padding:34rpx 32rpx;background:#F4EBD9;border-radius:16rpx}.status-title{display:block;font-size:40rpx;font-weight:700}.status-sub{display:block;margin-top:10rpx;font-size:28rpx}.check{color:#B54A2C;font-size:88rpx;line-height:1}.card{margin-bottom:18rpx;padding:22rpx;background:#F4EBD9;border-radius:16rpx}.card-visual{display:flex;gap:20rpx;align-items:center}.dish-placeholder{width:190rpx;height:190rpx;flex:none;border-radius:12rpx;background:#c79555}.name{display:block;font-size:36rpx;font-weight:700;margin-bottom:14rpx}.summary{font-size:28rpx;line-height:1.6}.card-foot{display:flex;justify-content:space-between;align-items:center;margin-top:24rpx;padding:18rpx 4rpx;border-top:1rpx solid #dfcda9}.status{padding:8rpx 20rpx;border:1rpx solid #B54A2C;border-radius:30rpx;color:#B54A2C}.price{color:#B54A2C;font-size:42rpx}.actions{display:flex;gap:16rpx;margin-top:18rpx}.actions button{flex:1;border-radius:12rpx;font-size:29rpx}.contact{background:#2B2B2B;color:#fff}.cancel{background:#B54A2C;color:#fff}.cancel-note{display:block;margin-top:18rpx;text-align:center;font-size:25rpx}.faq{margin-top:24rpx;padding:28rpx 30rpx;background:#fff;border-radius:16rpx}.faq view{padding:20rpx 0;border-bottom:1rpx solid #eee;font-size:29rpx}.faq view:last-child{border-bottom:0}.faq-title{font-size:36rpx!important;font-weight:700}.faq text{float:right;color:#7A4A2B;font-size:40rpx}.state,.empty{text-align:center;padding:100rpx 20rpx;color:#7A4A2B}
.check{box-sizing:border-box;display:flex;width:108rpx;height:108rpx;align-items:center;justify-content:center;padding:18rpx;border:8rpx solid #B54A2C;border-radius:50%;color:#B54A2C;font-size:56rpx;line-height:1}
.page {
min-height: 100vh;
padding: 24rpx 32rpx 60rpx;
background: #fbf7f1;
color: #2b2b2b;
}
.heading-row {
display: flex;
justify-content: space-between;
align-items: center;
margin: 12rpx 0 32rpx;
}
.heading {
font-size: 48rpx;
font-weight: 700;
}
.phone {
font-size: 48rpx;
color: #7a4a2b;
}
.status-banner {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
padding: 34rpx 32rpx;
background: #f4ebd9;
border-radius: 16rpx;
}
.status-title {
display: block;
font-size: 40rpx;
font-weight: 700;
}
.status-sub {
display: block;
margin-top: 10rpx;
font-size: 28rpx;
}
.check {
color: #b54a2c;
font-size: 88rpx;
line-height: 1;
}
.card {
margin-bottom: 18rpx;
padding: 22rpx;
background: #f4ebd9;
border-radius: 16rpx;
}
.card-visual {
display: flex;
gap: 20rpx;
align-items: center;
}
.dish-placeholder {
width: 190rpx;
height: 190rpx;
flex: none;
border-radius: 12rpx;
background: #c79555;
}
.name {
display: block;
font-size: 36rpx;
font-weight: 700;
margin-bottom: 14rpx;
}
.summary {
font-size: 28rpx;
line-height: 1.6;
}
.card-foot {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 24rpx;
padding: 18rpx 4rpx;
border-top: 1rpx solid #dfcda9;
}
.status {
padding: 8rpx 20rpx;
border: 1rpx solid #b54a2c;
border-radius: 30rpx;
color: #b54a2c;
}
.price {
color: #b54a2c;
font-size: 42rpx;
}
.actions {
display: flex;
gap: 16rpx;
margin-top: 18rpx;
}
.actions button {
flex: 1;
border-radius: 12rpx;
font-size: 29rpx;
}
.contact {
background: #2b2b2b;
color: #fff;
}
.cancel {
background: #b54a2c;
color: #fff;
}
.cancel-note {
display: block;
margin-top: 18rpx;
text-align: center;
font-size: 25rpx;
}
.faq {
margin-top: 24rpx;
padding: 28rpx 30rpx;
background: #fff;
border-radius: 16rpx;
}
.faq view {
padding: 20rpx 0;
border-bottom: 1rpx solid #eee;
font-size: 29rpx;
}
.faq view:last-child {
border-bottom: 0;
}
.faq-title {
font-size: 36rpx !important;
font-weight: 700;
}
.faq text {
float: right;
color: #7a4a2b;
font-size: 40rpx;
}
.state,
.empty {
text-align: center;
padding: 100rpx 20rpx;
color: #7a4a2b;
}
.check {
box-sizing: border-box;
display: flex;
width: 108rpx;
height: 108rpx;
align-items: center;
justify-content: center;
padding: 18rpx;
border: 8rpx solid #b54a2c;
border-radius: 50%;
color: #b54a2c;
font-size: 56rpx;
line-height: 1;
}