Files
crm-uni/pages/customer/detile.vue
T
2025-03-27 16:54:52 +08:00

636 lines
15 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" :title="$t('navbar.customerinfo')"></uni-nav-bar>
<view class="content">
<view class="contents" >
<view class="top">
<view class="name">{{datas.contacts}}</view>
<view class="right">
<text class="medal" :style="{color:(datas.magnitude == 0 ?'#F5AB00' : datas.magnitude == 1 ?'#8495B8': '#9B7200')}">{{datas.magnitude_txt}}</text>
<text class="tag" :style="{background:(datas.follow == 0 ?'#3471FF' : datas.follow == 1 ?'#27C89C': '#FF4040')}">{{datas.follow_txt}}</text>
</view>
</view>
<u-line margin="20rpx 0px" color="#fff" :hairline="false"></u-line>
<view class="cont">
<view class="title">
<view class=""><text class="name">{{datas.phone}}</text></view>
<view class="ststus" v-if="datas.channel_name!=''">{{$t('channel')}}:{{datas.channel_name}}</view>
</view>
<view class="info"><text class="sex">{{datas.sex_txt}}</text> | <text class="addr">{{datas.country_name}}</text><text class="type">{{datas.car_type_name}}</text>
</view>
<view v-if="datas.email!=''">Email: {{datas.email}}</view>
<view v-if="datas.WhatsApp!=''">WhatsAPP: {{datas.WhatsApp}}</view>
<view v-if="datas.address!=''">{{$t('customer.Company')}}: {{datas.address}}</view>
<view v-if="datas.describe!=''">{{$t('remarks')}}: {{datas.describe}}</view>
</view>
<view class="edt">
<!-- <view class="btn" @click="showtag = true"><image src="/static/image/customer/tagadd.png" mode=""></image><text> {{$t('addtag')}}</text></view> -->
<view class="btn" @click="editFn"><image src="/static/image/customer/edit.png" mode=""></image><text> {{$t('edtbtn')}}</text></view>
</view>
</view>
<view class="cells">
<view class="top">
<view class="item">{{$t('CustomerProfile')}}</view>
<view class="right">
<view class="btn"@click="showtag = true"><image src="/static/image/customer/tagadd.png" mode=""></image><text> {{$t('addtag')}}</text></view>
</view>
</view>
<view v-if="datas.tags.length>0">
<view class="conts" :class="{'expandeds':!expanded}">
<view class="tags" v-for="(item, index) in datas.tags" :key="index">{{item.name}}</view>
</view>
<view class="toggle" @click="expanded = !expanded">
<text >
{{ expanded ? $t('retract') : $t('expand') }}
</text>
<u-icon v-if="expanded" class="arrowright" name="arrow-up" size="16" color="#999999"></u-icon>
<u-icon v-else class="arrowright" name="arrow-down" size="16" color="#999999"></u-icon>
</view>
</view>
<view v-else class="nones">
{{$t('CustomerProfilemag')}}
</view>
</view>
<view class="cell">
<view class="item">{{$t('customer.Cstomerfj')}}</view>
<view class="right select" @click="showgrade = true">
<!-- <input :placeholder="$t('customer.Cstomerfjinput')" disabled v-model="grade_name" /> -->
<view class="" :class="['content2', { placeholder: !grade_name }]">{{grade_name || $t('customer.Cstomerfjinput')}}</view>
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
</view>
</view>
</view>
<u-gap height="10" bgColor="#F6F6F6"></u-gap>
<view class="steps">
<view class="title">
<view class="">
{{$t('customer.followrecord')}} <text class="status" :style="{color:(datas.follow == 0 ?'#3471FF' : datas.follow == 1 ?'#27C89C': '#FF4040')}">{{datas.follow_txt}}</text>
</view>
<view class="btnjl" @click="followupFn">
{{$t('navbar.addfollowup')}}
</view>
</view>
<u-steps v-if="followList.length>0" :current="followList.length" direction="column" dot>
<u-steps-item :title="item.type==1? $t('customer.Online') : $t('customer.Visit') " v-for="(item, index) in followList" :key="index">
<view slot="desc" class="desc">
<view class="flex" v-if="item.type==0">
<view class="">
<view class="lingh">
{{$t('times')}} :{{item.created_at}}
</view>
<view class="">{{$t('address')}}:{{item.address}}</view>
<view class="lingh">{{$t('customer.Visitcontent')}}:{{item.audio_text}}</view>
</view>
<view class="">
<!-- <image :src="item.oss_picture" mode=""></image> -->
<u-album
:urls="isurls(item.oss_picture)"
:singleSize="80"
keyName="src"
></u-album>
</view>
</view>
<view class="" v-else>
<view class="lingh">
{{$t('times')}}:{{item.created_at}}
</view>
<view class="">
<u-album
:urls="isurls(item.oss_picture)"
keyName="src"
:singleSize="80"
></u-album>
<!-- <image :src="item.oss_picture" mode=""></image> -->
</view>
</view>
</view>
</u-steps-item>
</u-steps>
<empty :list="followList"></empty>
</view>
<view class="zw"></view>
<u-picker closeOnClickOverlay :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" :defaultIndex="defaultIndexfj" :show="showgrade" @cancel="cancel('showgrade')" @close="close('showgrade')" :columns="getGradeList" keyName="name" @confirm="gradeHandler"></u-picker>
<!-- 客户标签 -->
<u-popup closeOnClickOverlay :show="showtag" mode="bottom" :round="10" @close="closetag('showtag')" :closeable="true" >
<view class="popup-content">
<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 {
id:'',
expanded:false,
followList:[],
showtag: false,
showmap: false,
showmagnitude: false,
showgrade: false,
showcartype: false,
showchannel: false,
showarea: false,
getGradeList1:[],
getGradeList:[],
grade_name:'',
defaultIndexfj:[0],
form: {
grade:'',
},
datas:'',
activeMap: {}, // 存储每个父级下选中的子项 { 父ID: 子ID }
taglist:[]
}
},
onLoad(options) {
console.log(options);
this.id = options.id;
var that = this
this.getGrade()
this.customerdetailfn()
this.tagGroup()
},
onShow() {
if(uni.getStorageSync('location')){
this.location = JSON.parse(uni.getStorageSync('location'))
this.form.address = this.location.address
this.form.lng = this.location.lng
this.form.lat = this.location.lat
console.log(this.location)
}
this.followlistfn()
},
methods: {
leftClick(){
uni.navigateBack({})
},
isurls(url){
var urls=[]
var obj={}
obj.src = url
urls.push(obj)
return urls
},
gomap(){
uni.navigateTo({
url: '/pages/customer/map'
});
},
select(){
var that=this;
that.getGradeList1.forEach((item,index) => {
if(item.id == that.form.grade){
that.grade_name = item.name
that.defaultIndexfj=[index]
}
})
},
//客户详情
customerdetailfn(){
var that=this;
request({
url:'customer/detail',
method:'get',
data: {
id:this.id,
}
}).then(res => {
that.datas = res.data.data
that.datas.tags.forEach((item,index) => {
that.$set(that.activeMap, item.group_id,item.id);
})
that.form = res.data.data
that.select()
})
},
// 跟进记录
followlistfn(){
request({
url:'follow/list',
method:'get',
data: {
customer_id:this.id,
}
}).then(res => {
this.followList = res.data.data
console.log(res.data.data)
})
},
//添加跟进
followupFn(){
uni.navigateTo({
url: '/pages/customer/followup?id='+this.id
});
},
mapclose(){
this.showmap = false
},
mapconfirm(){
this.showmap = false
},
//客户等级
getGrade(){
request({
url:'customer/getGrade',
method:'get',
}).then(res => {
var list = res.data.data
this.getGradeList = [list]
this.getGradeList1 = list
})
},
//客户等级切换事件
gradeHandler(val){
this.form.grade = val.value[0].id
this.grade_name = val.value[0].name
this.showgrade = false
request({
url:'customer/grade',
method:'post',
data:{
id:this.id,
grade:this.form.grade
}
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
// if(res.data.code ==0){
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/index/customer',// 替换为你要跳转的页面路径
// });
// }, 1000);
// }
})
},
cancel(val){
this[val] = false
},
close(val){
this[val] = false
},
closetag(val){
this[val] = false
this.customerdetailfn()
},
editFn(){
uni.navigateTo({
url: '/pages/customer/editdetile?id='+this.id
});
},
//标签
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);
console.log(this.activeMap)
request({
url:'tagGroup/updatePivot',
method:'post',
data:{
customer_id: this.id,
group_id:item.group_id,
tag_id:this.activeMap[item.group_id]
}
}).then(res => {
if(res.data.code!=0){
uni.showToast({
title: res.data.message,
icon: 'none'
});
}
})
},
isActive(parentId, childId) {
return this.activeMap[parentId] === childId;
},
nextFn(){
request({
url:'customer/save',
method:'post',
data:this.form
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code ==0){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/customer',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
}
}
}
</script>
<style lang="scss">
::v-deep .u-cell__body{
padding: 0px !important;
}
::v-deep .u-collapse-item__content__text{
padding: 10px 0px!important;
}
::v-deep .u-cell__title-text{
font-size: 14px;
}
.u-m-lr-10{
margin: 0px 10px;
}
.placeholder {
color: #999; /* 占位符颜色 */
}
textarea {
min-height: 200rpx;// 设置默认高度 ,解决设置自适应高度之后高度无效问题
margin-top: 15px;
background-color: #F6F6F6;
padding: 15px;
border-radius: 10px;
}
.red{
color: red;
}
.zw{
height: 120px;
}
.uniui-right{
position: absolute;
top: 2px;
}
.expandeds{
height: 33px;
overflow: hidden;
}
.cells{
margin-bottom: 10px;
background: #f6f6f6;
padding:13px 15px;
border-radius: 10px;
.top{
display: flex;
align-items: center;
justify-content: space-between;
color: #666666;
}
.btn{
color: #3471FF;
text-align: right;
display: flex;
align-items: center;
}
image{
width: 14px;
height: 14px;
margin-right: 5px;
}
.conts{
padding: 10px 0px;
}
.tags{
display: inline-block;
margin: 4px 3px;
// width: 31%;
background: #ECF2FF;
border-radius: 15px;
color: #3471FF;
text-align: center;
padding: 5px 15px;
}
.toggle{
display: flex;
align-items: center;
justify-content: center;
color: #999999;
font-size: 12px;
margin-top: 5px;
text{
margin-right: 5px;
}
}
.nones{
text-align: center;
color: #999999;
line-height: 30px;
font-size: 12px;
}
}
.cell{
position: relative;
display: flex;
justify-content:space-between;
padding: 13px 20px;
align-items: center;
font-weight: 500;
.item{
width: 90px;
color: #666666;
}
background: #f6f6f6;
border-radius: 10px;
}
.arrowright{
margin-right: -15px;
}
.right{
text-align: right;
}
.select{
display: flex;
position: relative;
margin-right: 10px;
}
.tagname{
color: #726CFF;
font-size: 12px;
}
.content{
padding: 10px 15px;
background: #FFFFFF;
.contents{
background-color:#F6F6F6;
border-radius: 10px;
margin-bottom: 10px;
.edt{
display: flex;
justify-content: flex-end;
padding-bottom: 10px;
text-align: center;
image{
width: 14px;
height: 14px;
margin-right: 5px;
vertical-align: middle;
}
}
.btn{
color: #3471FF;
text-align: right;
padding: 0px 15px 0px;
}
.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;
}
.right{
display: flex;
align-items: center;
.medal{
margin-right: 10px;
}
}
}
.name{
font-size: 32rpx;
font-weight: bold;
margin-right: 10px;
}
.cont{
padding: 0px 15px 10px;
font-size: 24rpx;
.title{
display: flex;
align-items: center;
justify-content: space-between;
color: #222222;
}
.ststus{
color: #666666;
}
.info,.desc{
color: #78758E;
line-height: 26px;
}
.sex{
margin-right: 5px;
}
.addr{
margin-left: 5px;
}
.type{
margin-left: 5px;
color: #3471FF;
}
}
}
}
.steps{
padding: 15px;
background: #fff;
image{
width: 44px;
height:44px;
}
.desc{
align-items: center;
color: #999999;
.lingh{
line-height: 40px;
}
.flex{
display: flex;
justify-content: space-between;
align-items: center;
}
}
.title{
display: flex;
align-items: center;
justify-content: space-between;
color: #666666;
font-size: 32rpx;
margin-bottom: 15px;
.status{
font-size: 28rpx;
margin-left: 10px;
}
.btnjl{
background: linear-gradient(to right, #3471FF, #6776FF);
color: white;
padding: 4px 10px;
border-radius: 20px;
font-size: 28rpx;
}
}
}
// 标签弹框
.popup-content {
padding: 20px;
}
.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 0px;
}
.row{
width: 100%;
}
.col4{
display: inline-block;
margin: 4px 3px;
width: 30%;
}
}
.tagactive{
background: #3471FF !important;
color: #fff !important;
}
</style>