修复客户默认头像入库与回填SQL
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
const DEFAULT_CUSTOMER_AVATAR = '/assets/images/default-avatar-1.png'
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
@@ -11,6 +13,7 @@ Page({
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
avatar: DEFAULT_CUSTOMER_AVATAR,
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
@@ -49,6 +52,7 @@ Page({
|
||||
const customer = {
|
||||
id: detail.id,
|
||||
name: detail.nickname || detail.name || detail.account || '客户',
|
||||
avatar: detail.avatar || detail.avatarUrl || detail.customerAvatar || DEFAULT_CUSTOMER_AVATAR,
|
||||
phone: detail.contactPhone || detail.phone || '未填写',
|
||||
contactPhone: detail.contactPhone || '',
|
||||
remark: detail.signature || ''
|
||||
@@ -60,6 +64,7 @@ Page({
|
||||
remark: customer.remark
|
||||
},
|
||||
avatarText: String(customer.name || '客').slice(-1),
|
||||
avatar: customer.avatar,
|
||||
stats: {
|
||||
orderCount: detail.orderCount || detail.totalOrderCount || 0,
|
||||
amount: detail.totalAmount || detail.consumeAmount || 0,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<block wx:else>
|
||||
<view class="card customer-head">
|
||||
<view class="customer-identity">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
<image class="avatar avatar-image" src="{{avatar}}" mode="aspectFill"></image>
|
||||
<view>
|
||||
<text class="customer-name">{{customer.name}}</text>
|
||||
<text class="customer-phone">{{customer.phone}}</text>
|
||||
|
||||
@@ -21,12 +21,17 @@
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
background: #e5eee9;
|
||||
color: #5b7f73;
|
||||
font-size: 32rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.avatar-image {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.customer-name,
|
||||
.customer-phone {
|
||||
display: block;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
const DEFAULT_CUSTOMER_AVATARS = [
|
||||
'/assets/images/default-avatar-1.png',
|
||||
'/assets/images/default-avatar-2.png',
|
||||
'/assets/images/default-avatar-3.png',
|
||||
'/assets/images/default-avatar-4.png'
|
||||
]
|
||||
const DEFAULT_CUSTOMER_AVATAR = '/assets/images/default-avatar-1.png'
|
||||
|
||||
function formatCustomerAmount(value) {
|
||||
const amount = Number(value || 0)
|
||||
@@ -49,12 +44,12 @@ function isToday(value) {
|
||||
return formatCustomerDate(value) === new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
function mapCustomer(item, index) {
|
||||
function mapCustomer(item) {
|
||||
const name = item.nickname || item.name || item.account || '客户'
|
||||
return {
|
||||
id: item.id,
|
||||
name,
|
||||
avatar: item.avatar || item.avatarUrl || item.customerAvatar || DEFAULT_CUSTOMER_AVATARS[index % DEFAULT_CUSTOMER_AVATARS.length],
|
||||
avatar: item.avatar || item.avatarUrl || item.customerAvatar || DEFAULT_CUSTOMER_AVATAR,
|
||||
tagText: resolveCustomerTag(item),
|
||||
amountText: formatCustomerAmount(resolveCustomerAmount(item)),
|
||||
lastDateText: formatCustomerDate(item.lastOrderTime || item.lastConsumeTime),
|
||||
|
||||
Reference in New Issue
Block a user