修复回归安全问题并补充验证
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const config = require('../../utils/config')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
Page({
|
||||
@@ -6,21 +7,34 @@ Page({
|
||||
id: '',
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: ''
|
||||
timeText: '',
|
||||
loadError: false,
|
||||
errorMessage: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
onLoad(options = {}) {
|
||||
this.setData({ id: options.id || '' })
|
||||
this.loadDetail()
|
||||
},
|
||||
|
||||
async loadDetail() {
|
||||
this.setData({ loadError: false, errorMessage: '' })
|
||||
try {
|
||||
const appointment = await planningApi.appointment(this.data.id)
|
||||
this.applyAppointment(appointment)
|
||||
} catch (error) {
|
||||
const demo = mock.buildCalendar(new Date()).appointments[0]
|
||||
this.applyAppointment(demo)
|
||||
if (config.USE_DEV_MOCK_DATA) {
|
||||
const demo = mock.buildCalendar(new Date()).appointments[0]
|
||||
this.applyAppointment(demo)
|
||||
} else {
|
||||
this.setData({
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: '',
|
||||
loadError: true,
|
||||
errorMessage: error.message || '预约详情加载失败,请检查服务连接后重试'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -28,11 +42,17 @@ Page({
|
||||
this.setData({
|
||||
appointment,
|
||||
avatarText: String(appointment.customerName || '客').slice(0, 1),
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
|
||||
loadError: false,
|
||||
errorMessage: ''
|
||||
})
|
||||
},
|
||||
|
||||
async updateStatus(status) {
|
||||
if (!this.data.appointment.orderId) {
|
||||
wx.showToast({ title: '预约数据未加载', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
await planningApi.updateStatus(this.data.appointment.orderId, status)
|
||||
wx.showToast({ title: '已更新' })
|
||||
|
||||
@@ -1,46 +1,54 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card detail-card">
|
||||
<view class="detail-head">
|
||||
<view class="detail-person">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
<view>
|
||||
<text class="customer">{{appointment.customerName}}</text>
|
||||
<text class="phone">{{appointment.customerPhone}}</text>
|
||||
<view wx:if="{{loadError}}" class="card error-card">
|
||||
<text class="error-title">数据加载失败</text>
|
||||
<text class="error-desc">{{errorMessage}}</text>
|
||||
<button class="compact-btn" bindtap="loadDetail">重试</button>
|
||||
</view>
|
||||
|
||||
<block wx:else>
|
||||
<view class="card detail-card">
|
||||
<view class="detail-head">
|
||||
<view class="detail-person">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
<view>
|
||||
<text class="customer">{{appointment.customerName}}</text>
|
||||
<text class="phone">{{appointment.customerPhone}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-actions">
|
||||
<text class="tag">{{appointment.statusText}}</text>
|
||||
<button class="small-action" bindtap="goTransfer">改派</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-actions">
|
||||
<text class="tag">{{appointment.statusText}}</text>
|
||||
<button class="small-action" bindtap="goTransfer">改派</button>
|
||||
<view class="detail-grid">
|
||||
<view>
|
||||
<text class="label">项目</text>
|
||||
<text class="value">{{appointment.productTitle}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">美甲师</text>
|
||||
<text class="value">{{appointment.artistName}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">时间</text>
|
||||
<text class="value">{{timeText}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">时长</text>
|
||||
<text class="value">{{appointment.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-grid">
|
||||
<view>
|
||||
<text class="label">项目</text>
|
||||
<text class="value">{{appointment.productTitle}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">美甲师</text>
|
||||
<text class="value">{{appointment.artistName}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">时间</text>
|
||||
<text class="value">{{timeText}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">时长</text>
|
||||
<text class="value">{{appointment.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">备注</view>
|
||||
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">备注</view>
|
||||
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom action-row">
|
||||
<button class="secondary-btn" bindtap="confirm">确认</button>
|
||||
<button class="primary-btn" bindtap="complete">完成</button>
|
||||
<button class="danger-btn" bindtap="cancel">取消</button>
|
||||
</view>
|
||||
<view class="fixed-bottom action-row">
|
||||
<button class="secondary-btn" bindtap="confirm">确认</button>
|
||||
<button class="primary-btn" bindtap="complete">完成</button>
|
||||
<button class="danger-btn" bindtap="cancel">取消</button>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user