Commit fe312452 by Lin

优化客户信息展示和同步功能

- 更新了客户侧组件,新增格式化函数以改善客户姓名和电话的显示。
- 调整了客户详情页,支持只读字段的同步功能,并增加了同步按钮。
- 优化了客户群信息的获取逻辑,增强了用户体验。
1 parent 23e6a946
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<view class="customer-item-body" @click="handleGoCustomerDetail(item)"> <view class="customer-item-body" @click="handleGoCustomerDetail(item)">
<view class="customer-item-row customer-item-row--name"> <view class="customer-item-row customer-item-row--name">
<view class="customer-item-name-left"> <view class="customer-item-name-left">
<text class="customer-item-name">{{ item.customerName || '-' }}</text> <text class="customer-item-name">{{ formatName(item.customerName) }}</text>
<view v-if="item.carSeriesName" class="customer-item-car-tag"> <view v-if="item.carSeriesName" class="customer-item-car-tag">
<text class="customer-item-car-text">{{ item.carSeriesName }}</text> <text class="customer-item-car-text">{{ item.carSeriesName }}</text>
</view> </view>
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
</view> </view>
</view> </view>
<view class="customer-item-row customer-item-row--meta"> <view class="customer-item-row customer-item-row--meta">
<text class="customer-item-meta">{{ item.customerPhone || '-' }}</text> <text class="customer-item-meta">{{ formatPhone(item.customerPhone) }}</text>
<view class="customer-item-divider"></view> <view class="customer-item-divider"></view>
<text class="customer-item-meta">交付{{ formatDisplayDate(item.deliveryDate) }}</text> <text class="customer-item-meta">交付{{ formatDisplayDate(item.deliveryDate) }}</text>
<view class="customer-item-divider"></view> <view class="customer-item-divider"></view>
<text class="customer-item-meta">到店{{ formatDisplayDate(item.inviteDate) }}</text> <text class="customer-item-meta">到店{{ formatDisplayDate(item.inviteDate) }}</text>
</view> </view>
<view class="customer-item-row customer-item-row--group"> <view class="customer-item-row customer-item-row--group">
<text class="customer-item-group">客户群:{{ item.qwGroupName || '-' }}</text> <text class="customer-item-group">客户群:{{ item.qwGroupName || '客户群不存在' }}</text>
<view class="customer-item-arrow"> <view class="customer-item-arrow">
<view class="sprite-icon icon-arrow-right"></view> <view class="sprite-icon icon-arrow-right"></view>
</view> </view>
...@@ -109,6 +109,14 @@ export default { ...@@ -109,6 +109,14 @@ export default {
if (!name) return '' if (!name) return ''
return String(name).charAt(0) return String(name).charAt(0)
}, },
formatName(name) {
if (!name) return '-'
return String(name).charAt(0) + '**'
},
formatPhone(phone) {
if (!phone) return '-'
return String(phone).replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
},
getCustomerStatusLabel(status) { getCustomerStatusLabel(status) {
const map = { const map = {
1: '待跟进', 1: '待跟进',
......
...@@ -41,7 +41,10 @@ ...@@ -41,7 +41,10 @@
<view class="label flex"> <view class="label flex">
<view class="required" v-if="i.required">*</view>{{ i.label }} <view class="required" v-if="i.required">*</view>{{ i.label }}
</view> </view>
<template v-if="i.type == 'input'"> <template v-if="i.type == 'readonly'">
<view class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view>
</template>
<template v-else-if="i.type == 'input'">
<input <input
:type="i.inputType" :type="i.inputType"
:maxlength="i.maxlength" :maxlength="i.maxlength"
...@@ -131,12 +134,16 @@ ...@@ -131,12 +134,16 @@
<view class="required" v-if="i.required">*</view>{{ i.label }} <view class="required" v-if="i.required">*</view>{{ i.label }}
</view> </view>
<template v-if="i.type == 'readonly'"> <template v-if="i.type == 'readonly'">
<view class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view> <view v-if="i.showSync" class="readonly-box flex">
<view class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view>
<view class="sync-btn" @click.stop="syncCustomerGroupInfo">同步</view>
</view>
<view v-else class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view>
</template> </template>
<template v-else-if="i.type == 'input'"> <template v-else-if="i.type == 'input'">
<view class="input-box flex"> <view class="input-box flex">
<input <input
:type="i.inputType || 'text'" :type="i.inputType || 'text'"+
:maxlength="i.maxlength" :maxlength="i.maxlength"
v-model="customerInfo[i.valueKey]" v-model="customerInfo[i.valueKey]"
class="input input--count" class="input input--count"
...@@ -228,11 +235,8 @@ ...@@ -228,11 +235,8 @@
label: '手机号', label: '手机号',
valueKey: 'customerPhone', valueKey: 'customerPhone',
key: 'customerPhone', key: 'customerPhone',
type: 'input', type: 'readonly',
inputType: 'tel', required: true
required: true,
maxlength: 11,
error: false
}, },
{ {
label: '车型', label: '车型',
...@@ -261,9 +265,8 @@ ...@@ -261,9 +265,8 @@
label: '流量来源', label: '流量来源',
valueKey: 'employeeName', valueKey: 'employeeName',
key: 'userId', key: 'userId',
type: 'select', type: 'readonly',
required: true, required: true
popKey: 'residentSaleVisible'
}], }],
default_optionalForm = [{ default_optionalForm = [{
label: '车架号', label: '车架号',
...@@ -292,11 +295,12 @@ ...@@ -292,11 +295,12 @@
key: 'createdDate', key: 'createdDate',
type: 'date' type: 'date'
}], }],
default_groupForm = [{ default_groupForm = [ {
label: '客户群', label: '客户群',
valueKey: 'qwGroupName', valueKey: 'qwGroupName',
key: 'qwGroupName', key: 'qwGroupName',
type: 'readonly' type: 'readonly',
showSync: true
}, },
{ {
label: '群成员关联', label: '群成员关联',
...@@ -486,20 +490,58 @@ ...@@ -486,20 +490,58 @@
uni.hideLoading() uni.hideLoading()
} }
}, },
async getCustomerGroupInfo() { async getCustomerGroupInfo(showToast = false) {
if (!this.customerInfo.customerName || !this.customerInfo.customerPhone) { if (!this.customerInfo.customerName || !this.customerInfo.customerPhone) {
return if (showToast) {
uni.showToast({
title: '请先填写客户姓名和手机号',
icon: 'none'
})
}
return false
} }
let customerGroupParam = this.customerInfo.customerName + this.customerInfo.customerPhone.slice(7,11) let customerGroupParam = this.customerInfo.customerName + this.customerInfo.customerPhone.slice(7,11)
console.log('g张三525235*', customerGroupParam) console.log('getCustomerGroupInfo*', customerGroupParam)
const data = await uni.$api.customerApi.getCustomerGroupInfoAPI({ const data = await uni.$api.customerApi.getCustomerGroupInfoAPI({
customerGroupParam: customerGroupParam customerGroupParam: customerGroupParam
}) })
console.log('getCustomerGroupInfoAPI**getCustomerGroupInfo*', data) console.log('getCustomerGroupInfoAPI**getCustomerGroupInfo*', data)
// http 层已在 code=0 时 resolve(data.data),此处 data 即为业务数据,无需再取 data.data // http 层已在 code=0 时 resolve(data.data),此处 data 即为业务数据,无需再取 data.data
const contactId = data.contact_id const contactId = data && data.contact_id
if (contactId) { if (contactId) {
this.customerInfo.qwGroupId = contactId
this.customerInfo.qwGroupName = data.contact_name || data.name || data.qwGroupName || ''
await this.getCustomerGroupMemberInfoAPI(contactId) await this.getCustomerGroupMemberInfoAPI(contactId)
return true
}
if (showToast) {
uni.showToast({
title: '未找到客户群',
icon: 'none'
})
}
return false
},
async syncCustomerGroupInfo() {
uni.showLoading({
mask: true,
title: '同步中...'
})
try {
const success = await this.getCustomerGroupInfo(true)
if (success) {
uni.showToast({
title: '同步成功',
icon: 'success'
})
}
} catch (error) {
uni.showToast({
title: '同步失败',
icon: 'none'
})
} finally {
uni.hideLoading()
} }
}, },
async getCustomerGroupMemberInfoAPI(contactId) { async getCustomerGroupMemberInfoAPI(contactId) {
...@@ -554,7 +596,9 @@ ...@@ -554,7 +596,9 @@
qwGroupName: '', qwGroupName: '',
groupMemberName: '', groupMemberName: '',
groupMemberId: '', groupMemberId: '',
groupRemark: '' groupRemark: '',
wxId: '',
wxName: ''
} }
if (this.customerId) this.findVisitsInfo() if (this.customerId) this.findVisitsInfo()
}, },
...@@ -611,6 +655,8 @@ ...@@ -611,6 +655,8 @@
} else if (popkey == 'groupMemberVisible') { } else if (popkey == 'groupMemberVisible') {
this.customerInfo.groupMemberName = item.contact_name this.customerInfo.groupMemberName = item.contact_name
this.customerInfo.groupMemberId = item.contact_id this.customerInfo.groupMemberId = item.contact_id
this.customerInfo.wxId = item.wxId || item.wx_id || ''
this.customerInfo.wxName = item.wxName || item.wx_name || ''
} else { } else {
this.customerInfo.receptionSceneName = item.receptionSceneName this.customerInfo.receptionSceneName = item.receptionSceneName
this.customerInfo.receptionScene = item.id this.customerInfo.receptionScene = item.id
...@@ -965,6 +1011,32 @@ ...@@ -965,6 +1011,32 @@
background: #f5f7fa; background: #f5f7fa;
} }
.readonly-box {
width: toRpx(738);
align-items: center;
gap: toRpx(16);
.input--readonly {
flex: 1;
width: 0;
}
.sync-btn {
flex-shrink: 0;
min-width: toRpx(112);
height: toRpx(76);
padding: 0 toRpx(24);
background: #dae9ff;
border-radius: toRpx(16);
color: #2c66f7;
font-size: toRpx(28);
font-weight: 500;
line-height: toRpx(76);
text-align: center;
box-sizing: border-box;
}
}
.form-item--full { .form-item--full {
width: 100%; width: 100%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!