1286 lines
31 KiB
JavaScript
1286 lines
31 KiB
JavaScript
import _ from '../../../commons/js/commons'
|
|
const app = getApp()
|
|
const innerAudioContext = wx.createInnerAudioContext();
|
|
let interval = null
|
|
Page({
|
|
data: {
|
|
imgUrl:_.config.imgUrl,
|
|
tabid:1,
|
|
tab:[
|
|
{"id":1,"title":"跟进记录",is_show_all:true},
|
|
{"id":2,"title":"客户画像",is_show_all:false},
|
|
],
|
|
logslist: [],//日志列表
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
statistics:[],//统计数据
|
|
isShowMessage:false,//是否显示短信弹窗
|
|
currentIndex:'-1',//日志播放录音
|
|
play: false,//日志播放录音
|
|
isShowNote:false,//新增日志弹窗
|
|
a_num:'',//到店次数
|
|
t_num:'',//试驾次数
|
|
statuskey:-10,//状态值
|
|
note:'',//日志
|
|
photos:[],
|
|
defeat_reason:'',//战败理由
|
|
submitFlag:false,
|
|
|
|
currentime:0,
|
|
currentx:'00:00',
|
|
|
|
isShowOrder:false,//是否显示订单弹窗
|
|
v2OrderId:_.config.v2OrderId,//订单id临界切换版本
|
|
order:[],//客户订单
|
|
|
|
levelIndex:-1,
|
|
level: [],//等级
|
|
|
|
followIndex:-1,
|
|
follow: [],//跟进渠道
|
|
isShowTimePicker:false,
|
|
weekList:['日','一','二','三','四','五','六'],
|
|
dateList:[],
|
|
nextIndex:-1,//计划回访时间
|
|
|
|
comment:'',//评论内容
|
|
isShowComment:false,//是否显示用户评论弹窗
|
|
|
|
wxgr:0,//是否添加个微
|
|
defeatIndex:-1,
|
|
defeatTag: [],
|
|
|
|
wxgrimg:'',//个微
|
|
wxgrimg_url:'',//个微
|
|
|
|
isShowCall:false,//是否显示拨打电话确认弹框
|
|
phoneNumber:'',//拨打的电话号码
|
|
|
|
userInfo:'',
|
|
optDefeat: false
|
|
},
|
|
onLoad(options) {
|
|
for (let key in options) {
|
|
this.setData({
|
|
[key]: options[key]
|
|
})
|
|
}
|
|
|
|
this.getAppCustomersDetails()
|
|
this.getAppCustomerData()
|
|
this.getAppCustomerlogs()
|
|
this.getAppCustomersTag()
|
|
//战败标签数据
|
|
this.getAppDefeatTag()
|
|
//意向标签-到店
|
|
this.getAppDaoDianTag()
|
|
//意向标签-购买
|
|
this.getAppGouMaiTag()
|
|
|
|
this.getAppCustomersFilter()
|
|
|
|
innerAudioContext.onEnded(() => {
|
|
this.offaudio()
|
|
})
|
|
|
|
this.getTimePicker()
|
|
|
|
this.getUserInfo()
|
|
|
|
},
|
|
onshow() {
|
|
|
|
},
|
|
|
|
//生命周期函数--监听页面隐藏
|
|
onHide: function () {
|
|
this.offaudio()
|
|
},
|
|
|
|
//生命周期函数--监听页面卸载
|
|
onUnload: function () {
|
|
this.offaudio()
|
|
},
|
|
|
|
//获取用户信息
|
|
getUserInfo(){
|
|
_.apiQuery.getUserInfo().then(res => {
|
|
this.setData({
|
|
userInfo: res,
|
|
})
|
|
});
|
|
},
|
|
|
|
//候取当前月日历
|
|
getTimePicker(){
|
|
let date = new Date();
|
|
let cYear = date.getFullYear(); //年份
|
|
let cMonth = date.getMonth()+1; //当前月份
|
|
let cDay = date.getDate();//当前日期
|
|
let fweek = new Date(cYear,cMonth-1,1).getDay();//本月第一天星期几
|
|
let days = new Date(cYear,cMonth,-1)
|
|
let cn = days.getDate()+1 //当月天数
|
|
let rn = ''//上个月天数
|
|
if (cMonth === 1) {
|
|
rn = 31
|
|
} else {
|
|
rn = new Date(cYear,cMonth-1,-1).getDate()+1
|
|
}
|
|
|
|
let dateList = []
|
|
for(let i=0;i<fweek;i++){
|
|
dateList.push({
|
|
isopt:false,
|
|
checked:false,
|
|
year:cMonth == 1?cYear-1:cYear,
|
|
month:cMonth == 1?12:cMonth-1,
|
|
day:rn-i,
|
|
})
|
|
}
|
|
for(let i=1;i<=cn;i++){
|
|
dateList.push({
|
|
isopt:false,
|
|
checked:false,
|
|
year:cYear,
|
|
month:cMonth,
|
|
day:i
|
|
})
|
|
}
|
|
|
|
if((cn-cDay)>29){//相差15天以上不用特意补下个月
|
|
let lweek = new Date(cYear,cMonth-1,cn).getDay();//本月最后天星期几
|
|
let sbu = 6 - lweek //最后一周补齐
|
|
for(let i=1;i<=sbu;i++){
|
|
dateList.push({
|
|
isopt:false,
|
|
checked:false,
|
|
year:cMonth == 12?cYear+1:cYear,
|
|
month:cMonth == 12?1:cMonth+1,
|
|
day:i
|
|
})
|
|
}
|
|
}else{
|
|
let zbu = 30 - (cn-cDay) //至少要补多少天
|
|
let bweek = ''//至少要补的最后一天星期几
|
|
if(cMonth==12){
|
|
bweek = new Date(cYear+1,1,zbu).getDay()
|
|
}else{
|
|
bweek = new Date(cYear,cMonth,zbu).getDay()
|
|
}
|
|
let sbu = zbu + 6 - bweek //最后一周补齐
|
|
for(let i=1;i<=sbu;i++){
|
|
dateList.push({
|
|
isopt:false,
|
|
checked:false,
|
|
year:cMonth == 12?cYear+1:cYear,
|
|
month:cMonth == 12?1:cMonth+1,
|
|
day:i
|
|
})
|
|
}
|
|
}
|
|
|
|
this.setData({
|
|
cYear,
|
|
cMonth,
|
|
cDay,
|
|
dateList,
|
|
})
|
|
|
|
},
|
|
|
|
//获取客户详情
|
|
getAppCustomersDetails(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCustomersDetails(params).then(res=>{
|
|
this.setData({
|
|
detailinfo:res.data,
|
|
statuskey:res.data.status!=3?res.data.status:-10,
|
|
})
|
|
|
|
if(res.data.level){
|
|
_.apiQuery.getAppCustomersFilter().then(res2 => {
|
|
let level = res2.data.level
|
|
this.setData({
|
|
level:res2.data.level,
|
|
})
|
|
level.forEach((item,index) => {
|
|
if(item == res.data.level){
|
|
this.setData({
|
|
levelIndex:index,
|
|
})
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
if(res.data.status==2){
|
|
this.getAppCusorderV2Customer()
|
|
|
|
}
|
|
|
|
if(res.data.status==3&this.data.tab.length<3){
|
|
let tab = this.data.tab
|
|
tab.push({"id":3,"title":"战败分析"},)
|
|
this.setData({
|
|
tab,
|
|
})
|
|
}
|
|
if(res.data.status!=3&this.data.tab.length==3){
|
|
let tab = this.data.tab
|
|
tab.splice(2, 1)
|
|
this.setData({
|
|
tab,
|
|
})
|
|
}
|
|
wx.stopPullDownRefresh()
|
|
|
|
})
|
|
},
|
|
|
|
//获取客户详细信息
|
|
getAppCustomerData(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCustomerData(params).then(res=>{
|
|
this.setData({
|
|
baseinfo:res.data.baseinfo,
|
|
wxgr:res.data.baseinfo.wxgr,
|
|
wxgrimg:res.data.baseinfo.wxgrimg,
|
|
wxgrimg_url:res.data.baseinfo.wxgrimg_url,
|
|
})
|
|
})
|
|
},
|
|
|
|
//获取客户订单
|
|
getAppCusorderV2Customer(){
|
|
let params = {};
|
|
params['customer_id'] = this.data.id;
|
|
_.apiQuery.getAppCusorderV2Customer(params).then(res=>{
|
|
this.setData({
|
|
order:res.data.list,
|
|
})
|
|
})
|
|
},
|
|
|
|
//获取日志
|
|
getAppCustomerlogs(){
|
|
this.setData({
|
|
load: false,
|
|
loading: true,
|
|
})
|
|
let params = {};
|
|
params['page'] = this.data.pageNo;
|
|
params['size'] = 10;
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCustomerlogs(params).then(res => {
|
|
|
|
let list = res.data.list
|
|
list.forEach(item => {
|
|
if(item.record_url){
|
|
item.alltime=this.format(item.second)
|
|
}
|
|
})
|
|
this.setData({
|
|
statistics:res.data.statistics?res.data.statistics:this.data.statistics,
|
|
pageNo: this.data.pageNo + 1,
|
|
logslist: this.data.logslist.concat(list),
|
|
load: true,
|
|
loading: false,
|
|
})
|
|
if (res.data.total == 0) {
|
|
this.setData({
|
|
noData: true
|
|
})
|
|
} else if (this.data.logslist.length == res.data.total) {
|
|
this.setData({
|
|
end: true
|
|
})
|
|
}
|
|
wx.stopPullDownRefresh()
|
|
});
|
|
},
|
|
|
|
//更新获取日志
|
|
getAppCustomerlogsRefresh(){
|
|
this.setData({
|
|
load: false,
|
|
loading: true,
|
|
})
|
|
let params = {};
|
|
params['page'] = 1;
|
|
params['size'] = (this.data.pageNo-1)*10;
|
|
params['id'] = this.data.id;
|
|
_.apiQuery.getAppCustomerlogs(params).then(res => {
|
|
|
|
let list = res.data.list
|
|
list.forEach(item => {
|
|
if(item.record_url){
|
|
item.alltime=this.format(item.second)
|
|
}
|
|
})
|
|
this.setData({
|
|
logslist:list,
|
|
load: true,
|
|
loading: false,
|
|
})
|
|
if (res.data.total == 0) {
|
|
this.setData({
|
|
noData: true
|
|
})
|
|
} else if (this.data.logslist.length == res.data.total) {
|
|
this.setData({
|
|
end: true
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//切换tab
|
|
changeTab(e){
|
|
this.setData({
|
|
tabid: this.data.tab[e.currentTarget.dataset.index].id,
|
|
})
|
|
},
|
|
|
|
//显示短信弹框
|
|
showMessage(e){
|
|
this.setData({
|
|
isShowMessage:true,
|
|
content:'',
|
|
})
|
|
},
|
|
|
|
//关闭短信弹框
|
|
hideMessage(e){
|
|
this.setData({
|
|
isShowMessage:false,
|
|
})
|
|
},
|
|
|
|
//输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
submitFlag: false,
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//发短信
|
|
postAppSmsCustomer(){
|
|
if (this.data.submitFlag) return;
|
|
if (this.data.content == '') {
|
|
wx.showToast({
|
|
title: '请填写短信内容',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
this.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['content'] = this.data.content;
|
|
_.apiQuery.postAppSmsCustomer(params).then(res=>{
|
|
this.setData({
|
|
isShowMessage:false,
|
|
submitFlag:false,
|
|
content:'',
|
|
})
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
|
|
this.onPullDownRefresh()
|
|
|
|
})
|
|
}
|
|
},
|
|
|
|
//选择状态
|
|
radioPicker(e){
|
|
if(e.currentTarget.dataset.key != this.data.statuskey){
|
|
this.setData({
|
|
statuskey:e.currentTarget.dataset.key,
|
|
levelIndex:-1,
|
|
followIndex:-1,
|
|
})
|
|
if(e.currentTarget.dataset.key == 0){
|
|
this.setData({
|
|
a_num:'',//到店次数
|
|
t_num:'',//试驾次数
|
|
defeat_reason:'',//战败理由
|
|
})
|
|
}else if(e.currentTarget.dataset.key == 1){
|
|
this.setData({
|
|
defeat_reason:'',//战败理由
|
|
})
|
|
if(this.data.detailinfo.status==0){
|
|
this.data.level.forEach((item,index) => {
|
|
if(item == 'H'){
|
|
this.setData({
|
|
levelIndex:index,
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}else if(e.currentTarget.dataset.key == 3){
|
|
this.setData({
|
|
a_num:'',//到店次数
|
|
t_num:'',//试驾次数
|
|
note:'',//日志
|
|
photos:[],
|
|
nextIndex:-1,
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
//到店试驾
|
|
checkPicker(e){
|
|
if(e.currentTarget.dataset.pointer == 'daodian'){
|
|
this.setData({
|
|
a_num:this.data.a_num == 1?'':1,
|
|
})
|
|
}
|
|
if(e.currentTarget.dataset.pointer == 'shijia'){
|
|
this.setData({
|
|
t_num:this.data.t_num == 1?'':1,
|
|
})
|
|
}
|
|
if(e.currentTarget.dataset.pointer == 'gewei'){
|
|
this.setData({
|
|
wxgr:this.data.wxgr == 1?'0':1,
|
|
})
|
|
}
|
|
},
|
|
|
|
//取消变更状态
|
|
optShowOrder(){
|
|
this.setData({
|
|
isShowOrder:!this.data.isShowOrder,
|
|
})
|
|
},
|
|
|
|
//修改状态和到店次数、试驾次数
|
|
putAppCustomers(e){
|
|
if(this.data.statuskey == -10){
|
|
wx.showToast({
|
|
title: '请选择状态',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if((this.data.statuskey==0||this.data.statuskey==1)&&this.data.followIndex == -1){
|
|
wx.showToast({
|
|
title: '请选择跟进渠道',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if((this.data.statuskey==0||this.data.statuskey==1)&&this.data.followIndex == -1){
|
|
wx.showToast({
|
|
title: '请选择客户等级',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if((this.data.statuskey==0||this.data.statuskey==1)&&this.data.nextIndex == -1){
|
|
wx.showToast({
|
|
title: '请选择计划回访时间',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.statuskey != 3&&this.data.note == ''){
|
|
wx.showToast({
|
|
title: '请填写小记',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if(this.data.statuskey == 3&&this.data.defeat_reason == ''){
|
|
wx.showToast({
|
|
title: '请填写战败理由',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else if((this.data.statuskey == 0||this.data.statuskey == 1)&&this.data.wxgr==1&&this.data.wxgrimg==''){
|
|
wx.showToast({
|
|
title: '请上传个微截图',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
else{
|
|
let credentials = []
|
|
let photos = this.data.photos
|
|
photos.forEach(item => {
|
|
credentials.push(item.img)
|
|
})
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
if(this.data.t_num != ''){
|
|
params['t_num'] = this.data.t_num;
|
|
}
|
|
if(this.data.a_num != ''){
|
|
params['a_num'] = this.data.a_num;
|
|
}
|
|
if(this.data.note != ''){
|
|
params['content'] = this.data.note;
|
|
}
|
|
if(credentials.length>0){
|
|
params['imgs'] = credentials;
|
|
}
|
|
if(this.data.statuskey != -10){
|
|
params['status'] = this.data.statuskey;
|
|
}
|
|
if(this.data.defeat_reason != ''){
|
|
params['defeat_reason'] = this.data.defeat_reason;
|
|
}
|
|
if(this.data.levelIndex>-1){
|
|
params['level'] = this.data.level[this.data.levelIndex];
|
|
}
|
|
if(this.data.followIndex>-1){
|
|
params['follow_channel'] = this.data.follow[this.data.followIndex];
|
|
}
|
|
if(this.data.nextIndex>-1){
|
|
params['visit_time'] = this.data.dateList[this.data.nextIndex].year +'-'+ this.data.dateList[this.data.nextIndex].month +'-'+ this.data.dateList[this.data.nextIndex].day;
|
|
}
|
|
if(this.data.statuskey == 0){
|
|
params['daodian_tag'] = this.data.daoDianTag;
|
|
}
|
|
if(this.data.statuskey == 1){
|
|
params['goumai_tag'] = this.data.gouMaiTag;
|
|
}
|
|
if(this.data.statuskey == 3){
|
|
params['invalid_tag'] = this.data.defeatTag;
|
|
}
|
|
if((this.data.statuskey == 0||this.data.statuskey == 1)&&this.data.wxgr==1){
|
|
params['wxgr'] = this.data.wxgr;
|
|
params['wxgrimg'] = this.data.wxgrimg;
|
|
}
|
|
console.log(this.data.daodianTag)
|
|
console.log(params)
|
|
_.apiQuery.putAppCustomers(params).then(res=>{
|
|
this.setData({
|
|
isShowNote:false,//新增日志弹窗
|
|
a_num:'',//到店次数
|
|
t_num:'',//试驾次数
|
|
note:'',//日志
|
|
photos:[],
|
|
defeat_reason:'',//战败理由
|
|
submitFlag:false,
|
|
nextIndex:-1,
|
|
})
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
|
|
this.onPullDownRefresh()
|
|
|
|
})
|
|
}
|
|
},
|
|
|
|
//推送链接
|
|
pushLink(e){
|
|
if(e.currentTarget.dataset.url){
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
},
|
|
|
|
//拨打客户电话xz
|
|
call(e) {
|
|
let params = {};
|
|
params['id'] = e.currentTarget.dataset.id;
|
|
params['type'] = 0;
|
|
_.apiQuery.getAppXz(params).then(res=>{
|
|
this.setData({
|
|
isShowCall:true,
|
|
phoneNumber:res.data.mobile,
|
|
})
|
|
})
|
|
},
|
|
|
|
//时间格式话
|
|
format(t) {
|
|
let time = Math.floor(t / 60) >= 10 ? Math.floor(t / 60) : '0' + Math.floor(t / 60)
|
|
t = time + ':' + ((t % 60) / 100).toFixed(2).slice(-2)
|
|
return t
|
|
},
|
|
|
|
//点击
|
|
handle_slider_move_start(e){
|
|
clearTimeout(interval)
|
|
innerAudioContext.stop()
|
|
this.setData({
|
|
currentIndex:e.currentTarget.dataset.index,
|
|
play:false,
|
|
})
|
|
},
|
|
|
|
//拖动中
|
|
hanle_slider_changing(e){
|
|
clearTimeout(interval)
|
|
innerAudioContext.stop()
|
|
this.setData({
|
|
currentime:e.detail.value,
|
|
currentx:this.format(parseInt(e.detail.value))
|
|
})
|
|
innerAudioContext.src = this.data.logslist[e.currentTarget.dataset.index].record_url
|
|
},
|
|
|
|
//拖动结束
|
|
hanle_slider_change(e){
|
|
clearTimeout(interval)
|
|
innerAudioContext.stop()
|
|
this.setData({
|
|
currentime:e.detail.value,
|
|
currentx:this.format(parseInt(e.detail.value))
|
|
})
|
|
innerAudioContext.src = this.data.logslist[e.currentTarget.dataset.index].record_url
|
|
innerAudioContext.seek(parseInt(this.data.currentime))
|
|
},
|
|
|
|
//离开页面
|
|
offaudio() {
|
|
this.setData({
|
|
currentIndex:'-1',
|
|
play: false,
|
|
currentime:0,
|
|
currentx:'00:00'
|
|
})
|
|
innerAudioContext.stop()
|
|
clearTimeout(interval)
|
|
},
|
|
|
|
//操作录音
|
|
audioPlay: function (e) {
|
|
clearTimeout(interval)
|
|
if(this.data.currentIndex != e.currentTarget.dataset.index){
|
|
innerAudioContext.stop()
|
|
this.setData({
|
|
currentIndex:e.currentTarget.dataset.index,
|
|
currentime:0,
|
|
play:true,
|
|
})
|
|
innerAudioContext.src = this.data.logslist[e.currentTarget.dataset.index].record_url
|
|
innerAudioContext.play()
|
|
this.countDown()
|
|
}else{
|
|
if(this.data.play){
|
|
this.setData({
|
|
play:false,
|
|
})
|
|
innerAudioContext.pause()
|
|
}else{
|
|
this.setData({
|
|
play:true,
|
|
})
|
|
innerAudioContext.play()
|
|
this.countDown()
|
|
}
|
|
}
|
|
},
|
|
|
|
//播放录音时间
|
|
countDown:function () {
|
|
interval = setInterval(res => {
|
|
this.setData({
|
|
currentime:this.data.currentime + 1,
|
|
currentx:this.format(this.data.currentime + 1)
|
|
})
|
|
}, 1000)
|
|
},
|
|
|
|
//新增小记显示隐藏
|
|
optShowNote(){
|
|
this.setData({
|
|
isShowNote:!this.data.isShowNote,
|
|
a_num:'',//到店次数
|
|
t_num:'',//试驾次数
|
|
note:'',//日志
|
|
photos:[],
|
|
defeat_reason:'',//战败理由
|
|
})
|
|
},
|
|
|
|
//选择图片
|
|
chooseImg(e) {
|
|
let that = this
|
|
//上传小记图片
|
|
if(e.currentTarget.dataset.type=='note_img'){
|
|
wx.chooseImage({
|
|
count: 2 - this.data.photos.length, // 默认6
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success(res1) {
|
|
let currentLength = that.data.photos.length
|
|
for (let i = 0; i < res1.tempFilePaths.length; i++) {
|
|
//上传图片
|
|
that.uploadImg(res1.tempFilePaths[i])
|
|
}
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
//上传个微截图
|
|
if(e.currentTarget.dataset.type=='gw_img'){
|
|
wx.chooseImage({
|
|
count: 1, // 默认9
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success(res) {
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
})
|
|
wx.uploadFile({
|
|
url:_.config.api.upImg,
|
|
filePath:res.tempFilePaths[0],
|
|
name: 'img',
|
|
formData: {
|
|
'app': 'liche'
|
|
},
|
|
success: (resp) => {
|
|
resp.data = JSON.parse(resp.data);
|
|
if (resp.data.code == 200) {
|
|
wx.hideLoading();
|
|
that.setData({
|
|
wxgrimg:resp.data.data.url,
|
|
wxgrimg_url:resp.data.data.full_url,
|
|
})
|
|
}else{
|
|
wx.hideLoading();
|
|
wx.showToast({
|
|
title: '上传失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
},
|
|
})
|
|
},
|
|
fail: res => {
|
|
wx.showToast({
|
|
title: '文件选择失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
//上传图片
|
|
uploadImg(img){
|
|
let that = this
|
|
setTimeout(function () {
|
|
wx.showLoading({
|
|
title: '图片上传中',
|
|
})
|
|
}, 500);
|
|
wx.uploadFile({
|
|
url: _.config.api.upImg,
|
|
filePath: img,
|
|
name: 'img',
|
|
formData: {
|
|
'app': 'liche'
|
|
},
|
|
success(res) {
|
|
setTimeout(function () {
|
|
wx.hideLoading()
|
|
}, 500);
|
|
let imgdata = JSON.parse(res.data)
|
|
let list = []
|
|
list.push({
|
|
img:imgdata.data.url,
|
|
img_url:imgdata.data.full_url,
|
|
})
|
|
that.setData({
|
|
photos: that.data.photos.concat(list),
|
|
})
|
|
},
|
|
fail(res) {
|
|
wx.hideLoading()
|
|
wx.showToast({
|
|
title: res.data.msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 编辑页面删除图片
|
|
delPic(e){
|
|
let photos = this.data.photos
|
|
photos.splice(e.currentTarget.dataset.index, 1)
|
|
this.setData({
|
|
photos: photos,
|
|
})
|
|
},
|
|
|
|
//查看图片
|
|
previewImage(e){
|
|
if(e.currentTarget.dataset.type=='logs'){
|
|
wx.previewImage({
|
|
current:e.currentTarget.dataset.current,
|
|
urls:this.data.logslist[e.currentTarget.dataset.index].imgs,
|
|
})
|
|
}
|
|
else if(e.currentTarget.dataset.type=='gw_img'){
|
|
wx.previewImage({
|
|
current:this.data.wxgrimg_url,
|
|
urls:[this.data.wxgrimg_url],
|
|
})
|
|
}
|
|
},
|
|
|
|
//战败/再战申请
|
|
putAppCustomersDefeats(e){
|
|
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['type'] = e.currentTarget.dataset.type;
|
|
_.apiQuery.putAppCustomersDefeats(params).then(res => {
|
|
wx.showModal({
|
|
title: '',
|
|
content: '操作成功',
|
|
confirmText: "知道了",
|
|
showCancel:false,
|
|
success(resm) {
|
|
if (resm.confirm) {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
},
|
|
|
|
//客户标签
|
|
getAppCustomersTag(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['type'] = 'detail';
|
|
_.apiQuery.getAppCustomersTag(params).then(res => {
|
|
if(res.data.tags&&res.data.tags.length>0){
|
|
let taglList = res.data.tags
|
|
taglList.forEach(itemA => {
|
|
itemA.list.forEach(itemB => {
|
|
if(itemB.checked){
|
|
itemA.have=true
|
|
}
|
|
})
|
|
})
|
|
this.setData({
|
|
taglList,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//置顶操作
|
|
optTop(e){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['is_top'] = this.data.detailinfo.is_top==1?0:1;
|
|
_.apiQuery.putAppCustomers(params).then(res=>{
|
|
|
|
//刷新列表页
|
|
let pages = getCurrentPages();
|
|
let prevPage = null; //上一个页面
|
|
if (pages.length >= 2) {
|
|
prevPage = pages[pages.length - 2]; //上一个页面
|
|
if(prevPage.route == 'pages/customer/index'||prevPage.route == 'pages/customer/filterList/index'){
|
|
prevPage.onPullDownRefresh()
|
|
}
|
|
}
|
|
|
|
this.getAppCustomersDetails()
|
|
})
|
|
},
|
|
|
|
//客户等级
|
|
changeLevel(e) {
|
|
if(this.data.levelIndex != e.detail.value && e.detail.value >= 0){
|
|
if(this.data.detailinfo.level == 'H'&&e.detail.value==2){
|
|
wx.showToast({
|
|
title: 'H级客户不可直接降为B级',
|
|
icon: 'none'
|
|
})
|
|
}else{
|
|
this.setData({
|
|
levelIndex:e.detail.value,
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
//跟进渠道
|
|
changeFollow(e) {
|
|
if(this.data.followIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
followIndex:e.detail.value,
|
|
})
|
|
}
|
|
},
|
|
|
|
//获取跟进渠道、客户等级
|
|
getAppCustomersFilter(){
|
|
_.apiQuery.getAppCustomersFilter().then(res => {
|
|
this.setData({
|
|
follow:res.data.follow_channel,
|
|
level:res.data.level,
|
|
})
|
|
});
|
|
},
|
|
|
|
|
|
//显示隐藏时间选择器
|
|
optShowTimePicker(){
|
|
this.setData({
|
|
isShowTimePicker:!this.data.isShowTimePicker,
|
|
})
|
|
|
|
let kd = '' //可操作天数
|
|
if(this.data.level[this.data.levelIndex]=='H'){
|
|
kd = 3
|
|
}else if(this.data.level[this.data.levelIndex]=='A'){
|
|
kd = 7
|
|
}else if(this.data.level[this.data.levelIndex]=='B'){
|
|
kd = 15
|
|
}
|
|
else if(this.data.level[this.data.levelIndex]=='C'){
|
|
kd = 30
|
|
}
|
|
let cindex = ''
|
|
let dateList = this.data.dateList
|
|
dateList.forEach((item,index) => {
|
|
if(item.year == this.data.cYear&&item.month == this.data.cMonth&&item.day == this.data.cDay){
|
|
cindex = index
|
|
}
|
|
})
|
|
dateList.forEach((item,index) => {
|
|
item.isopt = false
|
|
if(cindex<index&&index<cindex+kd+1){
|
|
item.isopt = true
|
|
}
|
|
})
|
|
this.setData({
|
|
dateList,
|
|
})
|
|
|
|
},
|
|
|
|
//选择计划回访时间
|
|
optday(e){
|
|
if(this.data.nextIndex != e.currentTarget.dataset.index){
|
|
this.setData({
|
|
nextIndex:e.currentTarget.dataset.index,
|
|
})
|
|
}
|
|
},
|
|
|
|
//显示隐藏用户评论
|
|
optShowComment(e){
|
|
this.setData({
|
|
commentId:e.currentTarget.dataset.id?e.currentTarget.dataset.id:'',
|
|
isShowComment:!this.data.isShowComment,
|
|
comment:'',
|
|
})
|
|
},
|
|
|
|
//用户评论
|
|
postAppCustomersComments(){
|
|
if (this.data.submitFlag) return;
|
|
if (this.data.comment == '') {
|
|
wx.showToast({
|
|
title: '请填写评论内容',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
this.setData({
|
|
submitFlag: true,
|
|
})
|
|
let params = {};
|
|
params['id'] = this.data.commentId;
|
|
params['content'] = this.data.comment;
|
|
_.apiQuery.postAppCustomersComments(params).then(res=>{
|
|
this.setData({
|
|
submitFlag:false,
|
|
isShowComment:false,
|
|
comment:'',
|
|
})
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
|
|
this.getAppCustomerlogsRefresh()()
|
|
|
|
})
|
|
}
|
|
},
|
|
|
|
//战败理由标签
|
|
getAppDefeatTag(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['tag_type'] = '1';
|
|
_.apiQuery.getAppCustomersTag(params).then(res => {
|
|
// this.setData({
|
|
// defeatTag:res.data.tags&&res.data.tags.length>0?res.data.tags:[],
|
|
// })
|
|
let that = this
|
|
if(res.data.tags&&res.data.tags.length>0){
|
|
let defeatList = res.data.tags
|
|
let defeatTitleList = []
|
|
defeatList.forEach((itemA,index) => {
|
|
// if(itemA.type=='radio'){
|
|
// defeatTitleList.push(itemA.name+'单选')
|
|
// }
|
|
// if(itemA.type=='checkbox'){
|
|
// defeatTitleList.push(itemA.name+'多选')
|
|
// }
|
|
defeatTitleList.push(itemA.name)
|
|
itemA.list.forEach(itemB => {
|
|
if(itemB.checked){
|
|
itemA.have=true
|
|
}
|
|
})
|
|
})
|
|
that.setData({
|
|
defeatList,
|
|
defeatTitleList,
|
|
})
|
|
|
|
let defeatTag = res.data.tags
|
|
setTimeout(function () {
|
|
if(res.data.tag_id == 0){
|
|
defeatTag.forEach((itemA,index) => {
|
|
itemA.list.forEach(itemB => {
|
|
itemB.checked = false
|
|
})
|
|
})
|
|
}
|
|
else{
|
|
defeatTag.forEach((itemA,index) => {
|
|
itemA.list.forEach(itemB => {
|
|
if(itemB.checked){
|
|
that.setData({
|
|
defeatIndex:index,
|
|
})
|
|
}
|
|
})
|
|
})
|
|
}
|
|
that.setData({
|
|
defeatTag,
|
|
})
|
|
}, 10)
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
//战败理由单选
|
|
defeatRadioPicker(e){
|
|
let defeatTag = this.data.defeatTag
|
|
defeatTag[e.currentTarget.dataset.i].list.forEach(item => {
|
|
item.checked=false
|
|
})
|
|
defeatTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked=true
|
|
this.setData({
|
|
defeatTag,
|
|
})
|
|
},
|
|
|
|
//战败理由多选
|
|
defeatCheckPicker(e){
|
|
this.setData({
|
|
['defeatTag['+e.currentTarget.dataset.i+'].list['+e.currentTarget.dataset.j+'].checked']:!this.data.defeatTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked,
|
|
})
|
|
},
|
|
|
|
//战败理由标签选择
|
|
changeDefeat(e) {
|
|
if(this.data.defeatIndex != e.detail.value && e.detail.value >= 0){
|
|
this.setData({
|
|
defeatIndex:e.detail.value,
|
|
})
|
|
|
|
let defeatTag = this.data.defeatTag
|
|
defeatTag.forEach(itemA => {
|
|
itemA.list.forEach(itemB => {
|
|
itemB.checked=false
|
|
})
|
|
})
|
|
this.setData({
|
|
defeatTag,
|
|
})
|
|
|
|
}
|
|
},
|
|
|
|
//意向标签-到店
|
|
getAppDaoDianTag(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['tag_type'] = '2';
|
|
params['tag_type2'] = '1';
|
|
_.apiQuery.getAppCustomersTag(params).then(res => {
|
|
this.setData({
|
|
daoDianTag:res.data.tags&&res.data.tags.length>0?res.data.tags:[],
|
|
})
|
|
let that = this
|
|
if(res.data.tags&&res.data.tags.length>0){
|
|
let daoDianList = res.data.tags
|
|
daoDianList.forEach((itemA,index) => {
|
|
itemA.list.forEach(itemB => {
|
|
if(itemB.checked){
|
|
itemA.have=true
|
|
}
|
|
})
|
|
})
|
|
that.setData({
|
|
daoDianList,
|
|
})
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
//意向标签-到店-单选
|
|
daoDianRadioPicker(e){
|
|
let daoDianTag = this.data.daoDianTag
|
|
daoDianTag[e.currentTarget.dataset.i].list.forEach(item => {
|
|
item.checked=false
|
|
})
|
|
daoDianTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked=true
|
|
this.setData({
|
|
daoDianTag,
|
|
})
|
|
},
|
|
|
|
//意向标签-到店-多选
|
|
daoDianCheckPicker(e){
|
|
this.setData({
|
|
['daoDianTag['+e.currentTarget.dataset.i+'].list['+e.currentTarget.dataset.j+'].checked']:!this.data.daoDianTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked,
|
|
})
|
|
},
|
|
|
|
//意向标签-购买
|
|
getAppGouMaiTag(){
|
|
let params = {};
|
|
params['id'] = this.data.id;
|
|
params['tag_type'] = '2';
|
|
params['tag_type2'] = '2';
|
|
_.apiQuery.getAppCustomersTag(params).then(res => {
|
|
this.setData({
|
|
gouMaiTag:res.data.tags&&res.data.tags.length>0?res.data.tags:[],
|
|
})
|
|
let that = this
|
|
if(res.data.tags&&res.data.tags.length>0){
|
|
let gouMaiList = res.data.tags
|
|
gouMaiList.forEach((itemA,index) => {
|
|
itemA.list.forEach(itemB => {
|
|
if(itemB.checked){
|
|
itemA.have=true
|
|
}
|
|
})
|
|
})
|
|
that.setData({
|
|
gouMaiList,
|
|
})
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
//意向标签-购买-单选
|
|
gouMaiRadioPicker(e){
|
|
let gouMaiTag = this.data.gouMaiTag
|
|
gouMaiTag[e.currentTarget.dataset.i].list.forEach(item => {
|
|
item.checked=false
|
|
})
|
|
gouMaiTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked=true
|
|
this.setData({
|
|
gouMaiTag,
|
|
})
|
|
},
|
|
|
|
//意向标签-购买-多选
|
|
gouMaiCheckPicker(e){
|
|
this.setData({
|
|
['gouMaiTag['+e.currentTarget.dataset.i+'].list['+e.currentTarget.dataset.j+'].checked']:!this.data.gouMaiTag[e.currentTarget.dataset.i].list[e.currentTarget.dataset.j].checked,
|
|
})
|
|
},
|
|
|
|
//隐藏电话弹框
|
|
hideCall(){
|
|
this.setData({
|
|
isShowCall:false,
|
|
})
|
|
},
|
|
|
|
//拨打电话
|
|
makePhoneCall(){
|
|
wx.makePhoneCall({
|
|
phoneNumber: this.data.phoneNumber,
|
|
})
|
|
},
|
|
|
|
//复制
|
|
copyWord(){
|
|
if(this.data.detailinfo.mobile){
|
|
wx.setClipboardData({
|
|
data: this.data.detailinfo.mobile,
|
|
success (res) {
|
|
_.utils.$toast('复制成功')
|
|
}
|
|
})
|
|
}else{
|
|
_.utils.$toast('无手机号')
|
|
}
|
|
},
|
|
|
|
//页面相关事件处理函数--监听用户下拉动作
|
|
onPullDownRefresh(){
|
|
this.setData({
|
|
logslist: [],
|
|
pageNo: 1,
|
|
noData: false,
|
|
end: false,
|
|
load: true,
|
|
loading: false,
|
|
})
|
|
this.getAppCustomersDetails()
|
|
this.getAppCustomerData()
|
|
this.getAppCustomerlogs()
|
|
this.getAppCustomersTag()
|
|
//战败标签数据
|
|
this.getAppDefeatTag()
|
|
//意向标签-到店
|
|
this.getAppDaoDianTag()
|
|
//意向标签-购买
|
|
this.getAppGouMaiTag()
|
|
},
|
|
|
|
//页面上拉触底事件的处理函数
|
|
onReachBottom(){
|
|
if (this.data.noData || this.data.end||!this.data.load) return;
|
|
this.getAppCustomerlogs()
|
|
},
|
|
|
|
}) |