统一甲屿云命名体系
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
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() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const customer = this.data.customer || {}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?customerName=${encodeURIComponent(customer.name || '')}&phone=${encodeURIComponent(customer.phone || '')}`
|
||||
})
|
||||
},
|
||||
|
||||
back() {
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "客户详情"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<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>
|
||||
<view>
|
||||
<text class="customer-name">{{customer.name}}</text>
|
||||
<text class="customer-phone">{{customer.phone}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button wx:if="{{canCreateAppointment}}" class="small-action" bindtap="createAppointment">新预约</button>
|
||||
</view>
|
||||
|
||||
<view class="stats">
|
||||
<view class="card stat">
|
||||
<text class="stat-value">{{stats.orderCount}}</text>
|
||||
<text class="stat-label">累计订单</text>
|
||||
</view>
|
||||
<view class="card stat">
|
||||
<text class="stat-value">¥{{stats.amount}}</text>
|
||||
<text class="stat-label">累计消费</text>
|
||||
</view>
|
||||
<view class="card stat">
|
||||
<text class="stat-value">{{stats.lastTime}}</text>
|
||||
<text class="stat-label">最近消费</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<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 || item.productTitle || '预约作品'}}</text>
|
||||
<text class="meta">{{item.date || item.appointmentDate || '-'}} · {{item.artist || item.artistName || '-'}}</text>
|
||||
</view>
|
||||
<text class="amount">¥{{item.amount || item.payAmount || 0}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -0,0 +1,96 @@
|
||||
.customer-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 18rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.customer-identity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
border-radius: 50%;
|
||||
background: #e5eee9;
|
||||
color: #5b7f73;
|
||||
font-size: 32rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.customer-name,
|
||||
.customer-phone {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.customer-phone {
|
||||
margin-top: 8rpx;
|
||||
color: #928a81;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 14rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.stat {
|
||||
padding: 16rpx 12rpx;
|
||||
}
|
||||
|
||||
.stat-value,
|
||||
.stat-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
color: #26231f;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
margin-top: 8rpx;
|
||||
color: #91897f;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.order-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.amount {
|
||||
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