hengmei-two/pagesB/customerList/customerList.vue

441 lines
15 KiB
Vue
Raw Normal View History

2021-08-19 06:40:59 +00:00
<template>
<view>
<!-- 状态栏 -->
<status-nav :titleVal="'客户列表'" :statusTitle="true"></status-nav>
<!-- 自定义二级分类 -->
<!-- 列表 -->
<view :style="{paddingTop: statusHeight+'px'}" class="pad-zy30 pad-x20">
2021-08-19 06:40:59 +00:00
<view class="radius20 fon28 col3 mar-sx20">
<view class="disac">
<view @tap="openXial" class="disjbac width100 radius10 pad-zy20 xialak posir">
<view class="" style="color: #B3B3B3;">{{category}}</view>
<image :class="isZhuan?'zhuan':'nozhuan'" src="/static/public/sanj.png" mode="aspectFill"></image>
<!-- 下拉列表 -->
<view v-if="isZhuan" class="posia bacf radius10 xial-box">
<input @tap.stop="entryEv" @confirm="searchEv" type="text" class="pad20" v-model="searchVal" placeholder="请输入昵称/姓名/手机" />
2021-08-19 06:40:59 +00:00
<view class="pad-zy20 xial-item-box">
<view @tap="chooseXia(indexl)" :class="xialCurrent==indexl?'pcol':''" v-for="(iteml,indexl) in xialone" :key="indexl">{{iteml.title}}</view>
2021-08-19 06:40:59 +00:00
</view>
</view>
</view>
<view @tap="searchEv" class="flexs tc mar-z30 colf radius10 customer-btn" :style="{background:publicColor}">搜索</view>
2021-08-19 06:40:59 +00:00
</view>
</view>
<!-- 列表 -->
<view v-if="dataList.length!=0" class="dis bacf radius10 pad20 mar-x20 posir" v-for="(item,index) in dataList" :key="index">
<image @tap="goDetail(item.id)" lazy-load class="mar-y20 flexs" :src="item.imgSrc" style="width: 98rpx;height: 98rpx;" mode="aspectFill"></image>
2022-01-24 05:53:00 +00:00
<view class="fon24 col3 width100 mar-x40" style="margin-bottom: 120rpx;">
2021-08-19 06:40:59 +00:00
<view class="bold disjbac">
<view class="fon28 clips1">{{item.name}}</view>
<view class="flexs">来源{{item.come}}</view>
</view>
2022-01-24 05:53:00 +00:00
<view style="margin: 15rpx 0;" @tap="copyPhone(item.phone)">{{item.phone || ''}}</view>
2022-01-18 02:43:26 +00:00
<view>客服{{item.service || '暂无'}}</view>
2021-08-19 06:40:59 +00:00
<view class="col80 disjbac" style="margin: 15rpx 0 0 0;">
<view>{{item.time}}</view>
<view class="col3">{{item.qudao}}</view>
</view>
</view>
2022-01-24 05:53:00 +00:00
<!-- 真实姓名 -->
2022-03-04 08:48:40 +00:00
<view class="posia col3 fon24 radius10 tc disac" style="left: 20rpx;bottom: 100rpx;">
姓名
<input v-if="item.allow" :auto-focus="item.allow" type="text" v-model="realName" style="width: 100rpx;text-align: left;" />
<text v-else>{{item.real_name || ''}}</text>
<text @tap="updateName(item.id,item.real_name,index)" class="mar-z10 mar-y20 pcol flexs">{{item.updateText}}</text>
</view>
2022-01-18 02:43:26 +00:00
<!-- 分配客服 -->
2022-01-28 09:04:37 +00:00
<!-- <view @tap="fenCustomer(index)" class="posia colf fon24 radius10 tc customer-btn" style="right: 20rpx;top: 80rpx;z-index: 1;" v-if="item.customer=='' || item.customer==null" :style="{background:publicColor}"></view> -->
2022-02-15 08:02:16 +00:00
<view @tap="fenCustomer(index)" class="posia colf fon24 radius10 tc customer-btn" style="right: 20rpx;top: 80rpx;z-index: 1;" v-if="isFen" :style="{background:publicColor}"></view>
2022-01-18 02:43:26 +00:00
<!-- 设置标签 -->
<view @tap="tuneUpTag(index)" v-if="item.isTag" class="posia colf fon24 radius10 tc customer-btn" style="right: 20rpx;bottom: 20rpx;z-index: 1;" :style="{background:publicColor}"></view>
<view class="fon24 col3 posia bold disac" style="bottom: 60rpx;left: 20rpx;right: 20rpx;"><text class="flexs">标签</text>
<block v-if="item.tags.length">
2022-01-18 02:43:26 +00:00
<scroll-view scroll-x style="max-width: 60%;">
<view class="disac"><view v-for="(item1,tagIndex) in item.tags" :key="tagIndex" class="pcol pad-zy10 flexs">{{item1}}</view></view>
</scroll-view>
</block>
<block v-else class="col9"></block>
</view>
2022-01-18 02:43:26 +00:00
<view class="fon24 col3 posia clips1 bold" style="bottom: 20rpx;left: 20rpx;right: 20rpx;max-width: 70%;">详细来源{{item.source_detail}}</view>
</view>
<view v-if="dataList.length==0" class="disjcac fc" style="margin-top: 50%;">
<image class="zanw-img" src="/static/public/nothing.png" mode="aspectFill"></image>
<view class="fon24 col3">您搜索的内容暂无结果换个关键词试试吧</view>
2021-08-19 06:40:59 +00:00
</view>
<!-- 分配客服弹框 -->
<pu-po :category="xialtList" @chooseXiaT="chooseXiaT" :isXiala="true" :isShowT="isShowT" :clearVal="'暂不分配'" :comfrimVal="'立即分配'" @comfirmev="comfirmev" @cancleev="cancleev"></pu-po>
<!-- 设置标签弹框 -->
2022-01-18 02:43:26 +00:00
<!-- <pu-po :category="tagList" @chooseXiaT="chooseTag" :isXiala="true" :isTag="true" :isShowT="isShowTag" :clearVal="'暂不设置'" :comfrimVal="'立即设置'" @comfirmev="comfirmevTag" @cancleev="cancleevTag"></pu-po> -->
2021-08-19 06:40:59 +00:00
<!-- 返回顶部 -->
<!-- <back-top :showTop="showTop" @backTop="backTop"></back-top> -->
</view>
2021-08-26 09:57:04 +00:00
<!-- 底部客服 -->
<public-customer :nbottom="100"></public-customer>
2022-01-18 02:43:26 +00:00
<view v-if="isShowTag" class="disjcac posAll" @tap="closeXial">
<view class="bacf radius20 width100 tank-box">
<view class="pad-x20">
<view class="mar-s30 mar-x40 tc">请选择标签</view>
<view @tap.stop="openXia" class="disjbac radius10 pad-zy20 mar-zy20 xialak mar-x50 posir">
2022-08-24 05:54:29 +00:00
<view class="col3 disac fon28 width100"><input class="width100 mar-y20" disabled v-model="tagStr"></view>
2022-01-18 02:43:26 +00:00
<image :class="isZhuan1?'zhuan':'nozhuan'" src="/static/public/sanj.png" mode="aspectFill"></image>
<!-- 下拉列表 -->
<view v-if="isZhuan1" class="posia bacf radius10 xial-box">
<!-- 标签下拉 -->
<view class="pad-zy20 xial-item-box">
2022-08-24 05:54:29 +00:00
<view @tap.stop="chooseXiaTag(index)" class="disac fon28 mar-sx10" :class="item.checked?'pcol':''" v-for="(item,index) in tagList" :key="index">
<view v-if="" class="disac" style="transform: scale(.8);">
2022-01-18 02:43:26 +00:00
<checkbox style="width: 60rpx;height: 60rpx;display: inherit;" color="#3875F6" :data-id="item.id" :checked="item.checked" />
</view>
{{item.title}}
</view>
</view>
</view>
</view>
</view>
<view class="disjb fon28 colf pad-x30 pad-zy30 tc">
<view @tap="cancleevTag" class="pad-sx20 radius10 tank-btn" style="background-color: rgba(230, 230, 230,1);color: #000000;">暂不设置</view>
<view @tap="comfirmevTag" :style="{background:publicColor}" class="pad-sx20 radius10 tank-btn">立即设置</view>
</view>
</view>
</view>
2022-03-04 08:48:40 +00:00
<!-- 用户信息授权手机号授权 -->
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
2021-08-19 06:40:59 +00:00
</view>
</template>
<script>
export default {
data() {
return {
category:'',
dataList:[],
2021-08-19 06:40:59 +00:00
showTop:false,
isShowT:false,
isXiala:true,
isZhuan:false,
2022-01-18 02:43:26 +00:00
isZhuan1:false,
2021-08-19 06:40:59 +00:00
xialCurrent:0,
xialone:['全部'],
xialtList:[],
staff_id:'',//员工ID
customer_id:'',//客户ID
page:1,
size:10,
total:'',
isZanw:true,
ntype:'all',
tagList:[],
tag_id:'',
isShowTag:false,
tagId:'',
2022-01-18 02:43:26 +00:00
searchVal:'',
tagIds:[],
tagVal:[],
tagStr:'',
2022-03-04 08:48:40 +00:00
isFen:uni.getStorageSync('isFen'),
realName:'',//姓名
2021-08-19 06:40:59 +00:00
}
},
computed: {
// 主题颜色
publicColor() {
return this.$store.state.publicColor
},
statusHeight() {
return this.$store.state.statusHeight
}
},
2021-08-19 06:40:59 +00:00
onPageScroll(e) {
e.scrollTop > 360 ? this.showTop = true : this.showTop = false
},
onReachBottom() {//触底事件
// for (let i = 0; i < 4; i++) {
// let obj = {imgSrc:'/static/public/like.png',name:'USER',come:'顾客分享',phone:'18888888888',customer:'恒美植发客服-01',time:'2021-07-15 14:25',qudao:'第二渠道'}
// this.dataList.push(obj)
// }
if(this.total!=this.dataList.length){
this.page++
2021-11-02 10:23:53 +00:00
this.checkCL(this.ntype)
} else {
if(this.isZanw) this.$toolAll.tools.showToast('暂无更多列表数据')
this.isZanw = false
2021-08-19 06:40:59 +00:00
}
},
onLoad() {
2022-03-21 01:44:07 +00:00
if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
2022-03-04 08:48:40 +00:00
this.checkKF()//查询客服列表
this.checkCL()//客户列表
this.checkLY()//渠道来源
this.obtainTag();//获取标签列表
}
2021-08-19 06:40:59 +00:00
},
methods: {
// 查看客户详情事件
goDetail(id){
uni.navigateTo({
url:`/pagesB/customDetail/customDetail?id=${id}`
})
},
2022-03-04 08:48:40 +00:00
// 修改客户昵称
updateName(id,name,index){
if(this.dataList[index].updateText=='修改'){
this.dataList.forEach(item=>item.allow=false)
this.dataList[index].allow = true;
this.dataList[index].updateText = '确认修改';
this.realName = name;
} else {
if(this.dataList[index].real_name != this.realName) {
this.$requst.post('user/update-info',{customer_id:id,field:'real_name',value:this.realName}).then(res=>{
this.$toolAll.tools.showToast('修改成功');
this.dataList.forEach(item=>item.allow=false)
this.dataList[index].updateText = '修改';
this.checkCL();
})
} else {
this.dataList.forEach(item=>item.allow=false)
this.dataList[index].updateText = '修改';
}
}
},
2022-01-24 05:53:00 +00:00
// 复制电话号码
copyPhone(e){
uni.setClipboardData({
data: e,//要被复制的内容
success:(res) => {
uni.showToast({title:'复制成功' })
}
});
},
2022-01-18 02:43:26 +00:00
// 关闭下拉
closeXial(){
// this.isShowTag = false;
this.isZhuan1 = false;
},
openXia(){
this.isZhuan1 = !this.isZhuan1
},
// 标签单选
chooseXiaTag(index){
let isexistence = this.tagIds.indexOf(this.tagList[index].id);
this.tagList[index].checked = !this.tagList[index].checked;
if(isexistence!=-1){
this.tagIds.splice(isexistence,1);
this.tagVal.splice(isexistence,1)
} else {
this.tagIds.push(this.tagList[index].id)
this.tagVal.push(this.tagList[index].title)
}
this.tagStr = this.tagVal.join(',');
this.tagId = this.tagIds.join(',');
// 单选时,控制全选按钮是否选中
if(this.tagIds.length==this.tagList.length){
this.isAll = true;
} else this.isAll = false;
if(!this.tagIds.length) {
this.tagStr = '请选择'
}
},
obtainTag(){//获取标签列表
this.$requst.post('user/tag-list').then(res=>{
// console.log('查询客户列表:',res);
if(res.code==0){
2022-01-18 02:43:26 +00:00
this.tagList = [];
if(res.data.length!=0){
res.data.forEach(item=>{
2022-01-18 02:43:26 +00:00
let xuan = false;
let obj = {
title:item.name,
id:item.id,
2022-01-18 02:43:26 +00:00
checked:xuan
}
this.tagList.push(obj)
})
}
}
},error=>{})
},
// 调起设置标签弹框
tuneUpTag(index){
2022-08-24 05:54:29 +00:00
// console.log('设置标签调起弹框');
// 查询已有标签
this.getTagsCur(this.dataList[index].id);
this.isShowTag = true
2022-01-18 02:43:26 +00:00
this.tagStr = '';
this.tagId = '';
this.tagList.forEach((item,v)=>{
item.checked = false;
if(this.dataList[index].tags.length) {
this.dataList[index].tags.forEach(item1=>{
if(item.title == item1){
this.tagList[v].checked = true;
}
})
if(item.checked){
this.tagIds.push(item.id);
this.tagVal.push(item.title)
}
}
})
this.tagStr = this.tagVal.join(',');
this.tagId = this.tagIds.join(',');
// 客服列表
this.customer_id = this.dataList[index].id//客户ID
if(this.tagList.length==0) this.tagList = ['暂无可设置的标签']
},
2022-08-24 05:54:29 +00:00
// 查询已有标签
getTagsCur(id){
this.tagVal = [];
this.$requst.get('user/customer-tags',{customer_id:id}).then(res=>{
if(res.code==0){
console.log('已有标签:',res);
this.tagIds = res.data.ids;
let tagsArr = [];
res.data.list.forEach(item=>{
tagsArr.push(item.name);
})
this.tagVal = tagsArr;
}
},error=>{})
},
checkKF(){//查看客户列表
this.$requst.post('user/servicer-list').then(res=>{
// console.log('查询客户列表:',res);
if(res.code==0){
if(res.data.length!=0){
res.data.forEach(item=>{
let obj = {
title:item.name,
id:item.id
}
this.xialtList.push(obj)
})
this.staff_id = this.xialtList[0].id
}
}
},error=>{})
},
searchEv(){//搜索事件
2021-11-02 10:23:53 +00:00
this.page = 1;
this.isZanw = true;
this.checkCL(this.ntype)
},
checkLY(){//查询来源渠道事件
this.$requst.post('user/channel').then(res=>{
// console.log('来源渠道:',res);
if(res.code==0){
for (let key in res.data) {
let lyObj = {
title:res.data[key],
name:key
}
this.xialone.push(lyObj)
}
this.xialone.unshift({title:"全部",name:'all'})
this.category = this.xialone[0].title
}
},error=>{})
},
checkCL(ntype){//查询客户列表事件
this.$requst.post('user/customer',{page:this.page,size:this.size,type:ntype,keyword:this.searchVal}).then(res=>{
// console.log('客户列表:',res);
if(res.code==0){
if(this.page==1) this.dataList = []
this.total = res.data.total
if(res.data.list.length!=0){
res.data.list.forEach(item=>{
let cuObj = {
id:item.id,
imgSrc:item.headimgurl,
name:item.nickname,
come:item.channel_text,
phone:item.mobile,
customer:item.service[0],
time:item.created_at,
qudao:item.tag[0],
2021-11-02 10:23:53 +00:00
service:item.service,
source_detail:item.source_detail,
2022-01-18 02:43:26 +00:00
tags:item.tag,
2022-01-24 05:53:00 +00:00
isTag:!item.tag.includes('员工'),
2022-03-04 08:48:40 +00:00
real_name:item.real_name,
allow:false,
updateText:'修改'
}
2022-01-18 02:43:26 +00:00
this.dataList.push(cuObj);
})
}
this.isZhuan = false;
} else this.$toolAll.tools.showToast(res.msg)
},error=>{})
},
fenCustomer(index){//分配弹框调起事件
// console.log('分配客服调起弹框');
2021-08-19 06:40:59 +00:00
this.isShowT = true
// 客服列表
this.customer_id = this.dataList[index].id//客户ID
if(this.xialtList.length==0) this.xialtList = ['暂无可分配客服']
2021-08-19 06:40:59 +00:00
},
backTop(){//回到顶部事件
uni.pageScrollTo({
scrollTop: 0,
duration: 300
});
},
comfirmev(){//立即分配执行事件
// console.log('立即分配');
this.isShowT = false
this.$requst.post('user/customer-allot',{staff_id:this.staff_id,customer_id:this.customer_id}).then(res=>{
// console.log('分配客服:',res);
if(res.code==0){
this.page = 1
this.$toolAll.tools.showToast('分配成功')
this.checkCL(this.ntype)//客户列表
2022-01-18 02:43:26 +00:00
} else this.$toolAll.tools.showToast(res.msg)
},error=>{})
},
// 立即设置标签
comfirmevTag(){
this.$toolAll.tools.showToast('设置中...')
// console.log('立即分配');
this.$requst.post('user/set-tags',{tag_ids:this.tagId,ids:this.customer_id}).then(res=>{
// console.log('分配客服:',res);
if(res.code==0){
this.page = 1
this.$toolAll.tools.showToast('设置成功')
2022-01-18 02:43:26 +00:00
this.obtainTag();
this.isShowTag = false
this.checkCL(this.ntype)//客户列表
} else this.$toolAll.tools.showToast(res.msg)
},error=>{})
},
cancleev(){
2021-08-19 06:40:59 +00:00
this.isShowT = false
},
// 暂不设置标签
cancleevTag(){
this.isShowTag = false
},
2021-08-19 06:40:59 +00:00
openXial(){
this.isZhuan = !this.isZhuan
this.searchVal = '';
// console.log('开启下拉');
2021-08-19 06:40:59 +00:00
},
chooseXia(index){
2021-11-02 10:23:53 +00:00
this.xialCurrent = index;
this.ntype = this.xialone[index].name;
this.category = this.xialone[index].title;
2021-08-19 06:40:59 +00:00
},
chooseXiaT(e){
this.staff_id = e.id
},
entryEv(){
this.isXiala = true;
2021-08-19 06:40:59 +00:00
}
}
}
</script>
<style>
</style>