Files
crm-uni/pages/index/customer.vue
T

779 lines
19 KiB
Vue

<template>
<view class="conts">
<z-paging ref="paging" v-model="datalist" @query="queryList" :empty-view-text="$t('Nodata')">
<template #top>
<view class="top">
<!-- <view class="navbar">{{$t('customer.title')}}</view> -->
<uni-nav-bar leftText=" " :fixed="true" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgba(52,113,255,0)" :statusBar="true" :title="$t('customer.title')"></uni-nav-bar>
<view class="topSearch">
<view class="left">
<view @click="showPicker = true" class="searchl">
{{country_name || $t('customer.Country')}}
</view>
<u-search v-model="keyword" bgColor="#fff" search-icon=" " :show-action="false" :placeholder="$t('customer.inputhd')"></u-search>
<view @click="searchCli" class="search">
<image src="/static/image/customer/search1.png" mode=""></image>
</view>
</view>
<view class="right">
<image src="/static/image/customer/search.png" @click="showtagfn()" mode=""></image>
</view>
</view>
</view>
<view class="tabsbg">
<u-tabs :list="list1" :current="current" lineColor="#fff" :scrollable="isey" @click="tabclick" :inactiveStyle="{color: '#fff'}" :activeStyle="{color: '#fff',fontWeight: '500',transform: 'scale(1.05)'}"></u-tabs>
</view>
</template>
<view class="list">
<u-swipe-action>
<u-swipe-action-item :options="options1" v-for="(item, index) in datalist" :key="index" @click="delClick(item)">
<view class="contents" >
<view class="" >
<view class="top" @click="godetile(item)">
<view class="">{{item.created_at}}</view>
<view class="right">
<text class="medal" :style="{color:(item.magnitude == 0 ?'#F5AB00' : item.magnitude == 1 ?'#8495B8': '#9B7200')}">{{item.magnitude_txt}}</text>
<text class="tag" :style="{background:(item.follow == 0 ?'#3471FF' : item.follow == 1 ?'#27C89C': '#FF4040')}">{{item.follow==0?$t('followup'):item.follow==1?$t('deal'):$t('lost')}}</text>
</view>
</view>
<u-line margin="20rpx 0px"></u-line>
<view class="cont">
<view class="title">
<view class="">
<text class="name">{{item.contacts}}</text>
<u-tooltip :text="item.phone" :copyText="item.phone" :showCopy="true">
<text class="phone" @click.stop>{{item.phone}}</text>
</u-tooltip>
</view>
<view class="ststus" @click="godetile(item)">{{item.grade_txt}}</view>
</view>
<view class="info" @click="godetile(item)">
<text class="sex">{{item.sex_txt}}</text> | <text class="addr">{{item.country_name}}</text><text class="type">{{item.car_type_name}}</text>
</view>
</view>
</view>
<view class="desc1">
<view class="userzy" @click="cede(item)"><image src="/static/image/customer/zhuany.png" mode=""></image> {{$t('transfer')}}</view>
<view class="" @click="callPhone(item)"><image src="/static/image/customer/phone.png" mode=""></image> {{$t('call')}}</view>
<view class="" @click="editClick(item)"><image src="/static/image/customer/edit.png" mode=""></image> {{$t('customer.addfollow')}}</view>
<!-- <view class="" @click="delClick(item)"><image src="/static/image/customer/trash.png" mode=""></image> {{$t('delete')}}</view> -->
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</z-paging>
<u-picker closeOnClickOverlay :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="show" :columns="alluserlist" @cancel="cancel" @close="cancel" @confirm="confirm" :title="$t('transfer')" keyName="name"></u-picker>
<!-- <u-picker closeOnClickOverlay :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :show="show" :columns="columns" @cancel="cancel" @close="cancel" @confirm="confirm" :title="$t('customer.CustomerScreening')" keyName="label"></u-picker> -->
<u-popup :show="showts" :closeOnClickOverlay="false" :round="20" mode="center">
<view class="popupcontent">
<view class="title">{{$t('prompt')}}</view>
<view class="text">
{{$t('deletemsg')}}
</view>
</view>
<view class="cent">
<view class="btn1" @click="showts = !showts">{{$t('cancel')}}</view>
<view class="btn" @click="delfn()">{{$t('confirm')}}</view>
</view>
</u-popup>
<movable-area class="movable-area">
<movable-view class="movable-view" :x="x" :y="y" direction="all">
<view class="index" @tap="addcustomer">
<image src="/static/image/customer/add.png" mode="widthFix">
</view>
</movable-view>
</movable-area>
<u-popup closeOnClickOverlay :show="showPicker" mode="bottom" :round="10" @close="close('showPicker')">
<view class="text">
<view class="qx" @click="close('showPicker') ">{{$t('cancel')}}</view>
<view class="qd" @click="arerfn">{{$t('confirm')}}</view>
</view>
<view class="popup-content">
<!-- 搜索框 -->
<u-input
v-model="searchKeyword"
:placeholder="$t('keyword')"
@input="handleSearch"
></u-input>
<!-- 选项列表 -->
<scroll-view scroll-y class="option-list">
<view
v-for="(item, index) in filteredOptions"
:key="index"
class="option-item"
@click="handleSelect(item)"
:class="actives==item.id?'actives':''"
>
{{ item.name }}
</view>
<view v-if="filteredOptions.length === 0" class="no-data">
{{$t('noresults')}}
</view>
</scroll-view>
</view>
</u-popup>
<!-- 客户标签 -->
<u-popup closeOnClickOverlay :show="showtag" mode="bottom" :round="10" @close="closetag('showtag')" :closeable="false" >
<view class="text">
<view class="qx" @click="close('showtag') ">{{$t('cancel')}}</view>
<view class="qd" @click="showtagqd">{{$t('confirm')}}</view>
</view>
<view class="popup-content">
<view>
<view class="name">{{$t('customer.CustomerScreening')}}</view>
<view class="row">
<view class="col4 tagitem" v-for="(items, indexs) in columns" :class="{ 'tagactive': isActivetime(items.id) }" @click="tagSelecttime(items)" :key="indexs">
{{ items.label }}
</view>
</view>
</view>
<scroll-view scroll-y class="tag-list">
<view
v-for="(item, index) in taglist"
:key="index"
class="tags"
>
<view class="name">{{ item.name }}</view>
<view class="row">
<view class="col4 tagitem" v-for="(item1, index1) in item.tags" :class="{ 'tagactive': isActive(item1.group_id, item1.id) }" @click="tagSelect(item1)" :key="index1">
{{ item1.name }}
</view>
</view>
</view>
</scroll-view>
</view>
</u-popup>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
showtag: false,
actives:'',
showPicker: false, // 控制选择器显示
searchKeyword: "", // 搜索关键词
selectedLabel: "", // 选中的值(显示在输入框中)
filteredOptions: [], // 过滤后的数据
country_name:'',
country_id:'',
tag_id:[],
current:0,
options1: [],
x: 300, //x坐标
y: 550, //y坐标
keyword:'',
follow_last:'',
follow:'',
show:false,
showts:false,
del_id:'',
columns:[],
list1: [],
datalist:[],
isey:false,
activeMap: {}, // 存储每个父级下选中的子项 { 父ID: 子ID }
taglist:[],
alluserlist:[],
customer_id:''
}
},
onLoad(e) {
if(e.tab){
this.follow=e.tab - 1
this.current = e.tab
this.datalist=[]
// this.queryList(1, 10)
}
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
this.x = windowWidth-70
this.y = windowHeight-55
uni.removeStorageSync('location')
this.area()
},
onShow() {
// var location = uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):uni.getLocale()
// if(location=='ru'){
// this.isey=true
// }else{
// this.isey=false
// }
this.queryList(1, 10)
this.options1=[{
text: this.$t('delete'),
style: {
backgroundColor: '#f56c6c'
}
}]
this.list1=[{
name: this.$t('all'),
id:'all'
}, {
name: this.$t('followup'),
id:'followup'
}, {
name: this.$t('deal'),
id:'deal'
}, {
name: this.$t('lost'),
id:'lost'
}]
this.columns=[{
label: this.$t('all'),
id:''
},{
label:this.$t('tday'),
id: 0
}, {
label: this.$t('threeday'),
id: 1
}, {
label: this.$t('sevenday'),
id: 2
}]
uni.setTabBarItem({
index: 0,
text: this.$t('tabbar.home')
})
uni.setTabBarItem({
index: 1,
text: this.$t('tabbar.highseas')
})
uni.setTabBarItem({
index: 2,
text: this.$t('tabbar.customer')
})
uni.setTabBarItem({
index: 3,
text: this.$t('tabbar.mine')
})
},
methods: {
//获取转移用户
getalluser(){
request({
url:'user/getUsers?abbr=xinyouhe',
method:'get',
}).then(res => {
var list = res.data.data
this.alluserlist = [list]
})
},
// 搜索处理函数
handleSearch() {
var that = this
if (this.searchKeyword) {
this.filteredOptions = this.areaList1.filter((item) => item.name.includes(this.searchKeyword));
} else {
// 如果搜索框为空,显示全部数据
this.filteredOptions = this.areaList1;
}
},
// 选择选项
handleSelect(item) {
this.selectedLabel = item.name; // 回显选中的值
// this.searchKeyword = item.name
this.actives = item.id
// this.showPicker = false; // 关闭弹窗
},
arerfn(){
this.showPicker = false; // 关闭弹窗
this.country_name = this.selectedLabel
this.country_id = this.actives
this.queryList(1, 10)
},
//国家
area(){
request({
url:'area/getCountry',
method:'get',
}).then(res => {
var list = res.data.data
this.areaList1 = list
this.filteredOptions = list;
})
},
//标签
tagGroup(){
request({
url:'tagGroup/list',
method:'get',
}).then(res => {
this.taglist = res.data.data
})
},
//标签点击
tagSelect(item) {
// 如果已选中则取消,否则设置选中
this.$set(this.activeMap, item.group_id, this.activeMap[item.group_id] === item.id ? '' : item.id);
},
isActive(parentId, childId) {
return this.activeMap[parentId] === childId;
},
tagSelecttime(item) {
this.follow_last = item.id;
},
isActivetime(id) {
return this.follow_last === id;
},
showtagqd(){
const selectedIds = Object.values(this.activeMap).filter(id => id !== '')
this.tag_id = selectedIds
this.queryList(1, 10)
this.showtag = false
},
showtagfn(){
console.log(this.columns)
this.tagGroup()
this.showtag = true
},
searchCli(){
this.queryList(1, 10)
},
close(val){
this[val] = false
},
//转移客户
confirm(e) {
this.show = false
request({
url:'customer/cede',
method:'post',
data: {
user_id: e.value[0].id,
customer_id:this.customer_id
}
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code ==0){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/customer',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
},
cancel() {
this.show = false
},
//tab标签切换
tabclick(e){
if(e.id=='all'){
this.follow=''
}else{
this.follow=e.index - 1
}
this.datalist=[]
this.queryList(1, 10)
},
//客户列表数据
queryList(pageNo, pageSize) {
var that = this;
request({
url:'customer/list',
method:'get',
data: {
follow:this.follow,
page:pageNo,
per_page:10,
keyword:this.keyword,
follow_last:this.follow_last,
country_id:this.country_id,
tag_id:this.tag_id,
}
}).then(res => {
if(res.data.code ==0){
var datas = res.data.data.list;
this.$refs.paging.complete(datas);
}else{
// this.$refs.paging.complete(null);
// that.listlength=0
}
uni.stopPullDownRefresh();
})
},
godetile(item){
uni.navigateTo({
url: '/pages/customer/detile?id='+item.id
});
},
// 拨打电话
callPhone(item) {
var phoneNumber= item.phone
if (!phoneNumber) {
uni.showToast({
title: this.$t('callPhonemsg'),
icon: 'none',
});
return;
}
uni.showModal ({
title: this.$t('prompt'),
content: this.$t('callmsg'),
cancelText: this.$t('cancel'),
confirmText: this.$t('confirm'),
success: function (res) {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: phoneNumber,
success: () => {
// console.log('拨打电话成功');
},
fail: (err) => {
// console.log('拨打电话失败', err);
},
});
} else if (res.cancel) {
// console.log('用户点击取消');
}
}
});
},
editClick(item){
uni.navigateTo({
url: '/pages/customer/followup?id='+item.id
});
},
delClick(item){
this.del_id = item.id
},
delfn(){
this.showts=false
request({
url:'customer/delete',
method:'get',
data: {
id:this.del_id,
}
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code ==0){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/customer',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
},
addcustomer(){
uni.navigateTo({
url: '/pages/customer/add'
});
},
//转移客户
cede(item){
this.customer_id = item.id
this.getalluser()
this.show = true
}
}
}
</script>
<style lang="scss">
uni-page-body {
background-color: #F6F6F6 !important;
}
::v-deep .u-search__content{
padding: 0 56px 0px 70px;
}
::v-deep .u-search__content__input{
font-size: 24rpx !important;
}
::v-deep .u-tabs__wrapper__nav__item__text{
font-size: 28rpx !important;
}
.u-swipe-action-item {
margin-bottom: 10px;
border-radius: 10px;
}
.conts{
background-image: url("/static/image/customer/bg.png");
background-size: 100%;
background-repeat: no-repeat;
height: calc(100vh - 50px);
}
.navbar{
/* #ifdef APP-PLUS */
// padding-top: 20px;
/* #endif */
height: 44px;
line-height: 44px;
text-align: center;
color: #fff;
font-size: 32rpx;
}
.topSearch {
display: flex;
align-items: center;
padding: 10px 15px 5px;
.left {
position: relative;
flex: 1;
}
.right {
text-align: right;
margin-left: 5px;
image{
width: 24px;
height: 20px;
margin-top: 5px;
}
}
.searchl{
background: linear-gradient(to right, #3471FF, #6776FF);
color: white;
border-radius: 20px;
padding: 4px 12px;
text-align: center;
position: absolute;
/* #ifdef APP-PLUS */
top: 3px;
/* #endif */
top: 2px;
left:5px;
font-size: 12px;
width: 46px; /* 你可以根据需要调整宽度 */
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: inline-block;
image{
width: 16px;
height: 16px;
}
}
.search{
background: linear-gradient(to right, #3471FF, #6776FF);
color: white;
border-radius: 20px;
padding: 6px 16px 2px;
text-align: center;
position: absolute;
/* #ifdef APP-PLUS */
top: 3px;
/* #endif */
top: 2px;
right: 5px;
font-size: 12px;
image{
width: 16px;
height: 16px;
}
}
}
.list{
padding: 15px;
overflow: auto;
// height: calc(100vh - 350rpx);
.contents{
background-color: #FFFFFF;
border-radius: 10px;
margin-bottom: 10px;
.top{
padding: 10px 15px 0px;
display: flex;
align-items: center;
justify-content: space-between;
.tag{
color: white;
border-radius: 20px 0px 0px 20px;
padding: 3px 10px;
margin-right: -15px;
text-align: right;
}
.right{
display: flex;
align-items: center;
.medal{
margin-right: 10px;
}
}
}
.cont{
padding: 0px 15px 10px;
font-size: 24rpx;
.title{
display: flex;
align-items: center;
justify-content: space-between;
color: #222222;
.name{
font-size: 30rpx;
font-weight: bold;
margin-right: 10px;
}
.phone{
font-size: 28rpx;
}
}
.ststus{
color: #666666;
text-align: right;
}
.info,.desc{
color: #78758E;
line-height: 26px;
}
.sex{
margin-right: 5px;
}
.addr{
margin-left: 5px;
}
.type{
margin-left: 5px;
color: #3471FF;
}
}
}
.desc1{
padding: 0px 15px 10px;
color: #3471FF;
display: flex;
justify-content: flex-end;
align-items: center;
view{
margin-left:15px;
}
image{
width: 14px;
height: 14px;
vertical-align: sub;
margin-right: 5px;
}
.userzy image{
width: 18px;
height: 18px;
}
}
}
.popupcontent{
text-align: center;
padding: 10px 40px 20px;
.title{
font-size: 18px;
color: #333333;
line-height: 60px;
}
.text{
color: #666666;
font-size: 16px;
}
}
.cent{
display: flex;
align-items: center;
justify-content: space-around;
padding: 0px 10px 20px;
text-align: center;
.btn1{
background-color: #F6F6F6;
border: 1px solid #F6F6F6;
color: #333333;
border-radius: 50px;
width: 46%;
margin: 10px 0px 20px;
height: 40px;
line-height: 40px;
}
.btn{
background-color: #3471FF;
color: white;
border-radius: 50px;
width: 46%;
margin: 10px 0px 20px;
height: 40px;
line-height: 40px;
}
}
.actives{
background-color: #dfdfdf;
}
.text{
display: flex;
align-items: center;
justify-content: space-between;
line-height: 30px;
padding: 10px 15px 0px;
.qd{
color: #3471FF;
}
}
.popup-content {
padding: 20px;
background-color: #fff;
}
.option-list {
max-height: 400rpx;
margin-top: 20rpx;
}
.option-item {
padding: 20rpx;
border-bottom: 1rpx solid #eee;
}
.option-item:last-child {
border-bottom: none;
}
.no-data {
text-align: center;
padding: 20rpx;
color: #999;
}
//标签
.tag-list{
max-height: 900rpx;
margin-top: 20rpx;
}
.tags{
margin-top: 10px;
}
.name{
margin: 10px 0px;
}
.tagitem{
background: #ECF2FF;
border-radius: 8px;
color: #3471FF;
text-align: center;
padding: 5px 13px;
}
.row{
width: 100%;
}
.col4{
display: inline-block;
margin: 4px 3px;
// width: 30%;
}
.tagactive{
background: #3471FF !important;
color: #fff !important;
}
</style>