修复管理师端预约与登录体验
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
@@ -9,13 +11,10 @@ Page({
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
customer: { name: '王女士', phone: '138****1201' },
|
||||
stats: { orderCount: 12, amount: 2860, lastTime: '06-01' },
|
||||
orders: [
|
||||
{ id: 1, date: '2026-06-01', project: '纯色美甲', amount: 168, artist: '小王' },
|
||||
{ id: 2, date: '2026-05-18', project: '猫眼延长', amount: 268, artist: '小李' },
|
||||
{ id: 3, date: '2026-05-02', project: '手部护理', amount: 98, artist: '小张' }
|
||||
]
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -23,6 +22,48 @@ Page({
|
||||
id: options.id || '',
|
||||
canCreateAppointment: canCreateAppointment()
|
||||
})
|
||||
this.loadCustomer()
|
||||
},
|
||||
|
||||
async loadCustomer() {
|
||||
if (!this.data.id) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: '缺少客户 ID'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
const detail = await customersApi.detail(this.data.id)
|
||||
if (!detail) {
|
||||
throw new Error('客户详情不存在')
|
||||
}
|
||||
const customer = {
|
||||
id: detail.id,
|
||||
name: detail.nickname || detail.name || detail.account || '客户',
|
||||
phone: detail.contactPhone || detail.phone || '未填写'
|
||||
}
|
||||
this.setData({
|
||||
customer,
|
||||
avatarText: String(customer.name || '客').slice(-1),
|
||||
stats: {
|
||||
orderCount: detail.orderCount || detail.totalOrderCount || 0,
|
||||
amount: detail.totalAmount || detail.consumeAmount || 0,
|
||||
lastTime: detail.lastOrderTime || detail.lastConsumeTime || '-'
|
||||
},
|
||||
orders: Array.isArray(detail.orders) ? detail.orders : [],
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: error.message || '客户详情加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
@@ -30,7 +71,10 @@ Page({
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/appointment-form/index' })
|
||||
const customer = this.data.customer || {}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?customerName=${encodeURIComponent(customer.name || '')}&phone=${encodeURIComponent(customer.phone || '')}`
|
||||
})
|
||||
},
|
||||
|
||||
back() {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<view class="page no-tab">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadCustomer">重试</button>
|
||||
</view>
|
||||
|
||||
<block wx:else>
|
||||
<view class="card customer-head">
|
||||
<view class="customer-identity">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
@@ -28,13 +34,15 @@
|
||||
<view class="section">
|
||||
<view class="section-title">历史订单</view>
|
||||
<view class="list">
|
||||
<view wx:if="{{orders.length === 0}}" class="empty card">暂无历史订单</view>
|
||||
<view wx:for="{{orders}}" wx:key="id" class="card list-card order-card">
|
||||
<view>
|
||||
<text class="order-title">{{item.project}}</text>
|
||||
<text class="meta">{{item.date}} · {{item.artist}}</text>
|
||||
<text class="order-title">{{item.project || item.productTitle || '预约作品'}}</text>
|
||||
<text class="meta">{{item.date || item.appointmentDate || '-'}} · {{item.artist || item.artistName || '-'}}</text>
|
||||
</view>
|
||||
<text class="amount">¥{{item.amount}}</text>
|
||||
<text class="amount">¥{{item.amount || item.payAmount || 0}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -87,3 +87,10 @@
|
||||
color: #6f8f83;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user