fix: 让订单文案随行业模板切换
This commit is contained in:
1 parent
e807bba1cb
commit
60c2937ee2
4 files changed
+11
-10
No files matched your search
@@ -1,9 +1,10 @@
|
||||
const { customerRequest } = require('../../utils/request');
|
||||
const { request, customerRequest } = require('../../utils/request');
|
||||
const { bookingViewModel } = require('../../utils/labels');
|
||||
const { getTemplate } = require('../../utils/templates');
|
||||
Page({
|
||||
data: { loading: true, error: '', bookings: [], cancellingId: '' },
|
||||
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: '' }); customerRequest('/customer/bookings').then((items) => this.setData({ bookings: (Array.isArray(items) ? items : []).map(bookingViewModel), loading: false })).catch((error) => this.setData({ loading: false, error: error.message || '网络请求失败' })); },
|
||||
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' }); }); } }); }
|
||||
});
|
||||
@@ -8,8 +8,8 @@
|
||||
<view wx:for="{{bookings}}" wx:key="id" class="card">
|
||||
<view class="card-visual"><view class="dish-placeholder"></view><view class="card-main"><text class="name">{{item.serviceName}}</text><text class="summary">{{item.quantityLabel}} · {{item.fulfillmentLabel}} · {{item.requestedTime || '时间待确认'}}</text></view></view>
|
||||
<view class="card-foot"><text class="price">{{item.estimatedAmount ? '¥'+item.estimatedAmount/100 : '人工沟通报价'}}</text><text class="status">{{item.statusLabel}}</text></view>
|
||||
<view class="actions"><button class="contact" size="mini" bindtap="contact">联系品牌方</button><button class="cancel" wx:if="{{item.status === 'received'}}" loading="{{cancellingId === item.id}}" disabled="{{!!cancellingId}}" size="mini" data-id="{{item.id}}" bindtap="cancel">{{cancellingId === item.id ? '取消中...' : '取消申请'}}</button></view>
|
||||
<text class="cancel-note" wx:if="{{item.status === 'received'}}">如需调整,请尽早联系品牌方。</text>
|
||||
<view class="actions"><button class="contact" size="mini" bindtap="contact">{{template.contactLabel}}</button><button class="cancel" wx:if="{{item.status === 'received'}}" loading="{{cancellingId === item.id}}" disabled="{{!!cancellingId}}" size="mini" data-id="{{item.id}}" bindtap="cancel">{{cancellingId === item.id ? '取消中...' : template.cancelLabel}}</button></view>
|
||||
<text class="cancel-note" wx:if="{{item.status === 'received'}}">{{template.cancelNote}}</text>
|
||||
</view>
|
||||
<view class="faq"><view class="faq-title">常见问题 <text>›</text></view><view>○ 怎么确认预约? <text>›</text></view><view>○ 配送范围有多远? <text>›</text></view><view>○ 可以改时间吗? <text>›</text></view></view>
|
||||
</block>
|
||||
|
||||
Reference in new issue
Block a user