123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497 |
- // miniprogram/addtrack/addtrack.js
- const utils=require("../../utils/http");
- const util = require("../../utils/util");
- const app=getApp();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- trackflag:{
- type: Boolean,
- value:false
- },
- nowcid:{
- type: String,
- value:''
- },
- addwxarr:Array,
- columns:Array,
- activitylist:Array,
- nextvisitflag:{
- type: Boolean,
- value:false//true是必填,false不必传 下次回访时间
- },
- amountarr:Array
- },
- /**
- * 组件的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- aid: '',
- activityobj: {},
- titype: 1,
- trackflag: false,
- tracktype: '1',
- trackimgarr: [],
- nowimagearr: [],
- nowcid: '',
- recordtext: '',
- visitcount: 0,
- visitlogarr: [],
- statype: '1',
- activityname: '',
- invitecrm: [],
- showUpcrm: [],
- datashow: true,
- start: "",
- end: '',
- nowaid: '',
- personobj: app.globalData.personMsg,
- typeflag: false,
- type: 1,
- tacktype: 3,
- tackarr: [
- { id: 1, text: '自定义' },
- { id: 3, text: '已装修' },
- { id: 4, text: '无需求' },
- { id: 5, text: '有需求' },
- { id: 6, text: '超地域' },
- { id: 7, text: '未交房' },
- { id: 8, text: '在外地' },
- { id: 9, text: '无购买力' },
- { id: 10, text: '未接通电话' },
- ],
- nowtext1: '自定义',
- tacktext: '',
- amountdate: '',
- nowtext: false,
- amountime: 1,
- amountime1: 1,
- visitdate: '',
- apointobj: {},
- customerobj: {},
- nowidx: 0,
- scoleval: 0,
- nowdate: '',
- cluestate: 1,
- activityType: '',
- addwxarr:[],
- addwxtypeflag:false,
- measurenum:'',
- measuretime:'',
- showPicker:false,
- storenum:1,
- loglist:[],
- orderactivitydate:'',
- activityvalue:'',
- subscribelist:[],
- amountext: [],
- amountshow:false,
- trackimgarr1:[],
- nowimagearr1:[],
- depositproductlist:[],
- depositproductnum:'',
- deposit_mode: '1',
- appointype:'',//1是预约活动,2是预约到店
- storeactivityvalue:'',
- storeactivityid:'',
- extarr:[
- {
- keyname: '',
- value: '',
- keytext: '',
- select: '',
- id:''
- }
- ],
- },
- /**
- * 组件的方法列表
- */
- methods: {
- setcrmfun(cid){
- const that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/get_portrait_field',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id:this.data.nowcid
- },
- success: function (res) {
- if(res.data.code==0){
- let extarr=[];
- for (let i in res.data.data) {
- for (let j in res.data.data[i].child) {
- if (res.data.data[i].child[j].keyname =='add_wechat_type') {
- let obj = {
- keyname: res.data.data[i].child[j].keyname,
- value: res.data.data[i].child[j].value?res.data.data[i].child[j].value:'',
- keytext: res.data.data[i].child[j].valname,
- select: res.data.data[i].child[j].select,
- id:res.data.data[i].child[j].id
- };
- extarr[0]=obj;
- }
- }
- }
- that.setData({
- extarr:extarr
- })
- }
- }
- })
- },
- amounthouseimgtap(){
- if(this.data.amountarr.length==1){
- this.uploadimg();
- }else{
- this.setData({
- amountshow:true,
- })
- }
- },
- onClose(){
- this.setData({
- amountshow:false
- })
- },
- onSelect(event) {
- let amountext=this.data.amountext;
- amountext.push(event.detail.name.slice(2, event.detail.name.length));
- this.setData({
- amountext:amountext,
- amountshow:false,
- })
- this.uploadimg();
- },
- prelooktap(e) {
- wx.previewImage({
- current: this.data.loglist[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.loglist[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
- fail(res) {
- console.log(res)
- }
- })
- },
- previewImg(e) {
- wx.previewImage({
- current: this.data.visitlogarr[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.visitlogarr[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
- fail(res) {
- console.log(res)
- }
- })
- },
- preview1Img(e) {
- wx.previewImage({
- current: this.data.visitlogarr[e.currentTarget.dataset.src].img1[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.visitlogarr[e.currentTarget.dataset.src].img1, // 需要预览的图片http链接列表
- fail(res) {
- console.log(res)
- }
- })
- },
- cancleappointap(e){
- let that=this;
- let obj=this.data.subscribelist[e.currentTarget.dataset.idx];
- if (obj.order_type > 0) {
- if (obj.type == "预约量房") {
- wx.showLoading()
- this.addrecord(4, obj.subscribe_date);
- }
- if (obj.type == "预约到店") {
- wx.showLoading()
- this.addrecord(5, obj.subscribe_date);
- }
- if (obj.type == "预约活动") {
- wx.showLoading()
- this.addrecord(6, obj.subscribe_date);
- }
- }
- },
- crmsgfun(){
- let date = new Date();
- let m = date.getMonth() * 1 + 1;
- let d = date.getDate();
- let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
- this.setData({
- amountdate: str,
- start: str,
- nowdate: str,
- visitdate:str
- })
- this.crmmsgfun();
- this.tracklog();
- },
- dothis(){},
- closetracktap: function () {
- this.setData({
- trackflag: false
- })
- },
- setstorenumtap(e){
- this.setData({
- storenum:e.detail.value
- })
- },
- jdHandleClick(e) {
- this.setData({
- deposit_mode: e.currentTarget.dataset.text
- })
- },
- amountimetap1(e) {
- let num = e.currentTarget.dataset.text;
- let date = new Date();
- let nowTime = date.getTime();
- let oneDayTime = 24 * 60 * 60 * 1000;
- var day = date.getDay();
- //显示周日
- var sun = nowTime - (day - 7) * oneDayTime;
- //显示周六
- var wen = nowTime - (day - 6) * oneDayTime;
-
-
- let str = num == 1 ? 0 : num == 2 ? 1 : '';
- let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
-
-
- let year = new Date(timenum).getFullYear();
- let month = new Date(timenum).getMonth();
- let daystr = new Date(timenum).getDate();
-
- this.setData({
- amountime1: num,
- visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- if (this.data.tacktype == 3) {
- this.setData({
- amountime1: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 4) {
- this.setData({
- amountime1: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 5) {
- this.setData({
- amountime1: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- }
- },
- uptracklogtap:function(){
- const that = this;
- wx.chooseMedia({
- count: 9,
- mediaType: ['image'],
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- // tempFilePath可以作为img标签的src属性显示图片
- if (res.errMsg == "chooseMedia:ok") {
- that.createImagePayment1(res.tempFiles);
- }
- },
- fail(res) {
- wx.showToast({
- title: '上传失败请重试!',
- icon: 'error',
- duration: 2000
- })
- }
- })
- },
- createImagePayment1: function (imgUrl) {
- var that = this;
- if (imgUrl.length == 0) return;
- var lent = that.data.trackimgarr1.length + imgUrl.length;
- if (lent > 9) {
- lent = 9
- } else {
- lent = lent;
- }
- let trackimgarr1 = that.data.trackimgarr1;
- let len = imgUrl.length;
- if ((trackimgarr1.length + len) > 9) {
- for (let j = 0; j < len; j++) {
- if (trackimgarr1.length < 9) {
- trackimgarr1.push(imgUrl[j]);
- }
- }
- } else {
- trackimgarr1 = trackimgarr1.concat(imgUrl);
- }
- that.setData({
- trackimgarr1: trackimgarr1
- })
- },
- uploadimg: function () {
- const that = this;
- wx.chooseMedia({
- count: 9,
- mediaType: ['image'],
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- // tempFilePath可以作为img标签的src属性显示图片 res.tempFilePaths
- // console.log(res)
- // var trackimgarr=that.data.trackimgarr;
- if (res.errMsg == "chooseMedia:ok") {
- // let len=res.tempFilePaths.length;
- that.createImagePayment(res.tempFiles);
- // if((trackimgarr.length+len)>9){
- // for(let j=0;j<len;j++){
- // if(trackimgarr.length<9){
- // trackimgarr.push(res.tempFilePaths[j]);
- // }
- // }
- // }else{
- // trackimgarr=trackimgarr.concat(res.tempFilePaths);
- // }
- // that.setData({
- // trackimgarr:trackimgarr
- // })
- }
- },
- fail(res) {
- wx.showToast({
- title: '上传失败请重试!',
- icon: 'error',
- duration: 2000
- })
- }
- })
- },
- createImagePayment: function (imgUrl) {
- var that = this;
- if (imgUrl.length == 0) return;
- var lent = that.data.trackimgarr.length + imgUrl.length;
- if (lent > 9) {
- lent = 9
- } else {
- lent = lent;
- }
- let trackimgarr = that.data.trackimgarr;
- let len = imgUrl.length;
- if ((trackimgarr.length + len) > 9) {
- for (let j = 0; j < len; j++) {
- if (trackimgarr.length < 9) {
- trackimgarr.push(imgUrl[j]);
- }
- }
- } else {
- trackimgarr = trackimgarr.concat(imgUrl);
- }
- that.setData({
- trackimgarr: trackimgarr
- })
- },
- delimgtap: function (e) {
- const that = this;
- wx.showModal({
- title: '确认删除',
- content: '是否删除这张图片?',
- success(res) {
- if (res.confirm) {
- let trackimgarr = that.data.trackimgarr,amountext=that.data.amountext;
- trackimgarr.splice(e.currentTarget.dataset.idx, 1)
- amountext.splice(e.currentTarget.dataset.idx, 1)
- that.setData({
- trackimgarr: trackimgarr,
- amountext:amountext
- })
- }
- }
- })
- },
- deltracktap: function (e) {
- const that = this;
- wx.showModal({
- title: '确认删除',
- content: '是否删除这张图片?',
- success(res) {
- if (res.confirm) {
- let trackimgarr1 = that.data.trackimgarr1;
- trackimgarr1.splice(e.currentTarget.dataset.idx, 1)
- that.setData({
- trackimgarr1: trackimgarr1
- })
- }
- }
- })
- },
- ossuploadimg: function (e) {
- let that = this;
- let trackimgarr = that.data.trackimgarr;
- var arr = [];
- for (let i = 0; i < trackimgarr.length; i++) {
- //获取文件后缀
- // 随机生成文件名称
- let rstr = trackimgarr[i].tempFilePath.split('.');
- var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
- var imgName = fileRandName + '.' + 'png';
- // var fileName = that.data.;
-
- var date = new Date();
- var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
-
- var imgstr = 'crm/' + time + '/' + imgName;
- var nowimagearr = that.data.nowimagearr;
- nowimagearr.push(imgstr);
- that.setData({
- nowimagearr: nowimagearr
- })
- wx.uploadFile({
- url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
- filePath: trackimgarr[i].tempFilePath,
- name: 'file',
- formData: {
- // name: that.data.imgSrc[0],
- key: 'crm/' + time + '/' + imgName,
- policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
- OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
- success_action_status: "200",
- signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
- },
- header: {
- "Content-Type": "multipart/form-data",
- 'accept': 'application/json',
- },
- success: function (rs) {
- if (rs.errMsg == 'uploadFile:ok') {
- arr.push('0');
-
- if (arr.length == trackimgarr.length) {
- that.addrecord();
- }
- }
- },
- fail(res) {
- wx.hideLoading()
- }
- })
- }
- },
- setmoney: function (e) {
- this.setData({
- money: e.detail.value
- })
- },
- setwxtypetap(e){
- let text='',extarr=this.data.extarr;
- for(let i in this.data.extarr[0].select){
- if(this.data.extarr[0].select[i].id == e.currentTarget.dataset.text){
- text=this.data.extarr[0].select[i].name;
- }
- }
- if (extarr[0].keytext != text) {
- extarr[0].keytext = text;
- extarr[0].value = e.currentTarget.dataset.text;
- } else {
- extarr[0].keytext = text;
- extarr[0].value = e.currentTarget.dataset.text;
- }
- this.setData({
- extarr: extarr,
- addwxtypeflag:false
- })
- this.editwxtap();
- },
- setoptap() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crmCustomer/customer_top',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: 2,
- id: that.data.nowcid,
- },
- success: function (res) {
- if (res.data.code == '0') {
- let customerobj = that.data.customerobj;
- if (customerobj.addtoptime) {
- customerobj.addtoptime = '';
- }else{
- customerobj.addtoptime = '2022';
- }
- that.setData({
- customerobj:customerobj
- })
- that.triggerEvent('myevent', that.data.customerobj)
- }
- }
- })
- },
- addwxtap() {
- let extarr=this.data.extarr;
- if (this.data.extarr[0].select.length == 2) {
- this.setData({
- addwxtypeflag:true
- })
- } else {
- extarr[0].keytext = this.data.extarr[0].select[0].name;
- extarr[0].value = this.data.extarr[0].select[0].id;
- this.setData({
- addwxtypeflag:false,
- extarr: extarr
- })
- this.editwxtap();
- }
-
- },
- inputap() {
- this.setData({
- nowtext: !this.data.nowtext
- })
- },
- onChange(event) {
- this.setData({
- scoleval: event.detail,
- });
- },
- measurehousetap(e) {
- let num=e.currentTarget.dataset.type;
- // 量房预约
- let date = new Date();
- let nowTime = date.getTime();
- let oneDayTime = 24 * 60 * 60 * 1000;
- var day = date.getDay();
- //显示周日
- var sun = nowTime - (day - 7) * oneDayTime;
- //显示周六
- var wen = nowTime - (day - 6) * oneDayTime;
-
- let str = num == 1 ? 0 : num == 2 ? 1 : "";
- let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
-
- let year = new Date(timenum).getFullYear();
- let month = new Date(timenum).getMonth();
- let daystr = new Date(timenum).getDate();
-
- this.setData({
- measurenum:num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- measuretime:year + "-" + (month * 1 + 1) + "-" + daystr
- })
- if (!!this.data.reachstorenum) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.measuretime.split("-").join("/"))
- );
-
- if (num == 0) {
- this.setData({
- measuretime:'',
- measurenum:this.data.measurenum != 5 ? "" : this.data.measurenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- }
- if (!!this.data.activityvalue) {
- let num = util.dayDiff(
- new Date(this.data.measuretime.split("-").join("/")),
- new Date(this.data.orderactivitydate.split("-").join("/"))
- );
-
- if (num == 0) {
- this.setData({
- measuretime:'',
- measurenum:this.data.measurenum != 5 ? "" : this.data.measurenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- }
- }
- },
- // 到店
- reachstoretap(e){
- let num=e.currentTarget.dataset.type;
- let date = new Date();
- let nowTime = date.getTime();
- let oneDayTime = 24 * 60 * 60 * 1000;
- var day = date.getDay();
- //显示周日
- var sun = nowTime - (day - 7) * oneDayTime;
- //显示周六
- var wen = nowTime - (day - 6) * oneDayTime;
-
- let str = num == 1 ? 0 : num == 2 ? 1 : "";
- let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
-
- let year = new Date(timenum).getFullYear();
- let month = new Date(timenum).getMonth();
- let daystr = new Date(timenum).getDate();
-
- this.setData({
- reachstorenum:num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- reachstoretime:year + "-" + (month * 1 + 1) + "-" + daystr
- })
- if (!!this.data.measurenum) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.measuretime.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- reachstoretime: "",
- reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- }
- if (!!this.data.activityvalue) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.orderactivitydate.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- reachstoretime: "",
- reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- }
- }
- },
- setitypetap(e) {
- this.setData({
- titype: e.currentTarget.dataset.text,
- })
- if(e.currentTarget.dataset.text==2){
- let amountext=this.data.amountext;
- amountext=[];
- if(this.data.amountarr.length==1){
- amountext[0]=this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
- }
-
- this.setData({
- tacktype: 3,
- amountext:amountext,
- trackimgarr:[]
- })
- this.visitlogfun('量房');
- this.packagefun();
- } else if(e.currentTarget.dataset.text==3){
- this.subscribefun();
- }else{
- this.setData({
- trackimgarr1:[],
- nowimagearr1:[],
- })
- this.tracklog();
- }
- this.depositinitfun();
- },
- packagefun(){
- const that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/customerPackage/list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- depositproductlist:res.data.data
- })
- if(!!that.data.customerobj.package_id){
- for(let i in that.data.depositproductlist){
- if(that.data.depositproductlist[i].id==that.data.customerobj.package_id){
- that.setData({
- depositproductnum:i
- })
- }
- }
- }else{
- that.setData({
- depositproductnum:'',
- })
- }
- }
- }
- })
- },
- bindsigndate: function (e) {
- this.setData({
- addtime: e.detail.value
- })
- },
- bindproductap(e){
- this.setData({
- depositproductnum:e.detail.value
- })
- },
- settacktap(e) {
- this.setData({
- tacktype: e.currentTarget.dataset.text,
- trackimgarr: [],
- nowimagearr: [],
- tacktext: '',
- nowtext1: '自定义',
- amountdate:this.data.nowdate
- })
- let customerobj=this.data.customerobj;
- if(e.currentTarget.dataset.text == 3){
- let amountext=this.data.amountext;
- amountext=[];
- if(this.data.amountarr.length==1){
- amountext[0]=this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
- }
- this.setData({
- amountext:amountext
- })
- this.visitlogfun('量房');
- }else if(e.currentTarget.dataset.text == 4){
- this.visitlogfun('到店');
- }else if(e.currentTarget.dataset.text == 5){
- this.visitlogfun('到场');
- let arr = customerobj.subscirbe;
- for (let i in arr) {
- if(arr[i].type=='预约活动'){
- this.setData({
- activityname:arr[i].activity.title,
- nowaid:arr[i].aid
- })
- }
- }
- }else if (e.currentTarget.dataset.text == 6) {
- this.depositinitfun();
- } else if (e.currentTarget.dataset.text == 7) {
- this.signinitfun();
- }
- },
- setextap(e) {
- this.setData({
- nowtext1: e.currentTarget.dataset.text,
- tacktext: e.currentTarget.dataset.text == '自定义' ? '' : e.currentTarget.dataset.text
- })
- },
- setcluestatetap(e) {
- const that = this;
- if (e.currentTarget.dataset.text == 1) {
- if (this.data.customerobj.state == "待确认" || !this.data.customerobj.state) {
- this.setData({
- cluestate: e.currentTarget.dataset.text,
- })
- }
- } else {
- this.setData({
- cluestate: e.currentTarget.dataset.text,
- })
- }
-
- },
- amountypetap(e) {
- if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5 && this.data.activitylist.length == 0) {
- wx.showToast({
- title: '公司暂无活动不能预约活动',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
-
- const that = this;
- let day = new Date();
- let month = day.getMonth() * 1 + 1;
- let date = day.getDate();
- let year = day.getFullYear();
-
- let str = year + '-' + month + '-' + date;
- if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5) {
- this.setData({
- amountdate: this.data.activitylist[0].start_date,
- nowaid: this.data.activitylist[0].id,
- start: this.data.activitylist[0].start_date,
- end: this.data.activitylist[0].end_date,
- activityname: this.data.activitylist[0].title,
- })
- } else {
- this.setData({
- amountdate: str,
- amountime: 1
- })
- }
- },
- bindwChange: function (e) {
- this.setData({
- amountdate: e.detail.value
- })
- },
- bindvisitChange: function (e) {
- this.setData({
- visitdate: e.detail.value
- })
- },
- setactivitytap() {
- this.setData({
- showPicker: true,
- nowaid:'',
- appointype:1
- })
- },
- setactivitytap1() {
- this.setData({
- showPicker: true,
- nowaid:'',
- appointype:2
- })
- },
- onCancel() {
- this.setData({
- showPicker: false,
- })
- },
- // 量房预约
- clearmeasuretap(){
- this.setData({
- measurenum:'',
- measuretime:''
- })
- },
- showmeasuretap(){
- this.setData({
- ordertimeshow:true,
- ordertype:1
- })
- },
- cleareachstoretap(){
- this.setData({
- reachstorenum:'',
- reachstoretime:''
- })
- },
- showreachstoretap(){
- this.setData({
- ordertimeshow:true,
- ordertype:2
- })
- },
- bindactivityChange: function (e) {
- if(this.data.titype==2){
- this.setData({
- showPicker: false,
- start: this.data.activitylist[e.detail.index].start_date,
- end: this.data.activitylist[e.detail.index].end_date,
- activityname: e.detail.value,
- nowaid: this.data.activitylist[e.detail.index].id
- })
- }else if(this.data.titype==3){
- this.setData({
- showPicker: false,
- start: this.data.activitylist[e.detail.index].start_date,
- end: this.data.activitylist[e.detail.index].end_date,
- activityvalue: this.data.appointype==1?e.detail.value:this.data.activityvalue,
- nowaid: this.data.activitylist[e.detail.index].id,
- storeactivityvalue:this.data.appointype==2?e.detail.value:this.data.storeactivityvalue,
- storeactivityid:this.data.appointype==2?this.data.activitylist[e.detail.index].id:this.data.storeactivityid,
- })
- }
-
- },
- bindstoretap:function (e) {
- this.setData({
- reachstoretime: e.detail.value,
- reachstorenum:3
- })
- if (!!this.data.measurenum) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.measuretime.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- reachstoretime: "",
- reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- }
- if (!!this.data.activityvalue) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.orderactivitydate.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- reachstoretime: "",
- reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- }
- }
- },
- bindactivitytap:function (e) {
- this.setData({
- orderactivitydate: e.detail.value
- })
- if (!!this.data.measurenum) {
- let num = util.dayDiff(
- new Date(this.data.orderactivitydate.split("-").join("/")),
- new Date(this.data.measuretime.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- orderactivitydate:''
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- }
- if (!!this.data.reachstorenum) {
- let num = util.dayDiff(
- new Date(this.data.reachstoretime.split("-").join("/")),
- new Date(this.data.orderactivitydate.split("-").join("/"))
- );
- if (num == 0) {
- this.setData({
- orderactivitydate:''
- })
- wx.showToast({
- title: '同一时间只能预约一个提醒,请重新预约!',
- icon: 'none',
- duration: 2000
- })
- }
- }
- },
- depositinitfun() {
- let date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth();
- month = month * 1 + 1;
- let day = date.getDate();
- let str = year + "-" + month + "-" + day;
-
- if (!!this.data.customerobj.deposit) {
- this.setData({
- money: this.data.customerobj.deposit_money1 ? this.data.customerobj.deposit_money1 : '',
- addtime: this.data.customerobj.deposit ? this.data.customerobj.deposit.split(' ')[0] : ''
- })
- } else {
- this.setData({
- addtime: str,
- money:''
- })
- }
- },
- signinitfun() {
- let date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth();
- month = month * 1 + 1;
- let day = date.getDate();
- let str = year + "-" + month + "-" + day;
- if (!!this.data.customerobj.sign) {
- this.setData({
- money: this.data.customerobj.signed_money ? this.data.customerobj.signed_money : '',
- addtime: this.data.customerobj.sign ? this.data.customerobj.sign.split(' ')[0] : ''
- })
- } else {
- this.setData({
- addtime: str,
- money:''
- })
- }
- },
- typeinitfun() {
- const that = this;
- let day = new Date();
- let month = day.getMonth() * 1 + 1;
- let date = day.getDate();
- let year = day.getFullYear();
-
- let str = year + '-' + month + '-' + date;
-
- this.setData({
- visitdate: str,
- amountdate: str,
- nowtext1: '自定义',
- tacktext: ''
- })
- },
- closeaddwxtap(){
- this.setData({
- addwxtypeflag:false
- })
- },
- crmmsgfun() {
- const that = this;
- if(!this.data.nextvisitflag){
- this.setData({
- visitdate:'',
- amountime1:''
- })
- }else{
- let date = new Date();
- let m = date.getMonth() * 1 + 1;
- let d = date.getDate();
- let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
- this.setData({
- visitdate:str,
- amountime1:1
- })
- }
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/detail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.nowcid
- },
- success: function (res) {
- if (res.data.code == "0") {
- let apointobj = that.data.apointobj;
- that.setData({
- customerobj: res.data.data
- })
- let arr = res.data.data.subscirbe;
- apointobj = {};
- for (let i in arr) {
- if(arr[i].type=='预约活动'){
- that.setData({
- activityname:arr[i].activity.title,
- nowaid:arr[i].aid
- })
- }
- apointobj[arr[i].type] = arr[i].subscribe_date;
- }
- that.setData({
- apointobj: apointobj,
- cluestate: that.data.customerobj.state == "待确认" ? 1 : 2
- })
- }
- }
- })
- },
- editwxtap() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/add_customer_extfield',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowcid,
- alertshow: '1',
- ext: [
- {
- id:this.data.extarr[0].id,
- keyname: this.data.extarr[0].keyname,
- value: this.data.extarr[0].value
- }
- ]
- },
- success: function (res) {
- if (res.data.code == "0") {
- }
-
- }
- })
- },
- tracklog: function (e) {
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/visitlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowcid
- },
- success: function (res) {
- setTimeout(() => {
- wx.hideLoading()
- }, 1000)
- if (res.data.code == "0") {
- let t = 0;
- var str = "red";
- for (let i = 0; i < res.data.data.length; i++) {
- res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
- if (i == 0) {
- res.data.data[0].color = str;
- t = t * 1 + 1;
- } else if (res.data.data[i].addtime.split(' ')[0] != res.data.data[i - 1].addtime.split(' ')[0]) {
- t = t * 1 + 1;
- if (t % 3 == 0) {
- str = 'red';
- } else if (t % 3 == 1) {
- str = 'blue';
- } else if (t % 3 == 2) {
- str = 'cyan';
- }
- res.data.data[i].color = str;
- } else {
- res.data.data[i].color = str;
- }
- }
- that.setData({
- visitlogarr: res.data.data,
- visitcount: res.data.count,
- })
- }
-
- }
- })
- },
- visitlogfun:function(text){
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crmCustomer/visitlogDetails',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowcid,
- state: text == "活动" ? "到场" : text,
- },
- success: function (res) {
- setTimeout(() => {
- wx.hideLoading()
- }, 1000)
- if (res.data.code == "0") {
- for (let i = 0; i < res.data.data.length; i++) {
- res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
- }
- that.setData({
- loglist: res.data.data
- })
- }
- }
- })
- },
- subscribefun(){
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crmCustomer/subscribe',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowcid,
- },
- success: function (res) {
- setTimeout(() => {
- wx.hideLoading()
- }, 1000)
- if (res.data.code == "0") {
- let date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth();
- month = month * 1 + 1;
- let day = date.getDate();
- let date1 = year + "/" + month + "/" + day;
- for (let i = 0; i < res.data.data.length; i++) {
- let num = util.dayDiff(
- new Date(res.data.data[i].subscribe_date.split('-').join('/')),
- new Date(date1)
- );
- res.data.data[i].order_type = num >= 0 ? 1 : 0;
- res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
- }
- that.setData({
- subscribelist: res.data.data
- })
- }
- }
- })
- },
- getstate:function(num){
- const that = this;
- switch (this.data.titype*1) {
- case 1:
- let str = "";
- str = this.data.cluestate == 1 ? "待确认" : this.data.cluestate == 2 ? "未到访" : "无效";
- return str;
- case 2:
- let str1 = "";
- str1 =
- that.data.tacktype == 3
- ? "已量房"
- : this.data.tacktype == 4
- ? "已到店"
- : this.data.tacktype == 5
- ? "已到场"
- : this.data.tacktype == 6
- ? "已交定"
- : this.data.tacktype == 7
- ? "已签单"
- : "预约回访";
- return str1;
- case 3:
-
- let str2 = "";
- str2 =
- num == 1
- ? "预约量房"
- : num == 2
- ? "预约到店"
- : num == 3
- ? "预约活动"
- : num == 4
- ? "未量房"
- : num == 5
- ? "未到店"
- : num == 6
- ? "未到场"
- : "";
- return str2;
- default:
- break;
- }
- },
- addappointap() {
- const that = this;
- if (!!this.data.measuretime) {
- this.addrecord(1);
- }
- if (!!this.data.reachstoretime) {
- this.addrecord(2);
- }
- if (!!this.data.nowaid && !!this.data.orderactivitydate) {
- this.addrecord(3);
- }
- },
- ossuploadimg1: function (e) {
- let that = this;
- let trackimgarr = that.data.trackimgarr1;
- var arr = [];
- for (let i = 0; i < trackimgarr.length; i++) {
- //获取文件后缀
- // 随机生成文件名称
- let rstr = trackimgarr[i].tempFilePath.split('.');
- var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
- var imgName = fileRandName + '.' + 'png';
- // var fileName = that.data.;
-
- var date = new Date();
- var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
-
- var imgstr = 'crm/' + time + '/' + imgName;
- var nowimagearr = that.data.nowimagearr1;
- nowimagearr.push(imgstr);
- that.setData({
- nowimagearr1: nowimagearr
- })
- wx.uploadFile({
- url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
- filePath: trackimgarr[i].tempFilePath,
- name: 'file',
- formData: {
- // name: that.data.imgSrc[0],
- key: 'crm/' + time + '/' + imgName,
- policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
- OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
- success_action_status: "200",
- signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
- },
- header: {
- "Content-Type": "multipart/form-data",
- 'accept': 'application/json',
- },
- success: function (rs) {
- if (rs.errMsg == 'uploadFile:ok') {
- arr.push('0');
-
- if (arr.length == trackimgarr.length) {
- that.addrecord();
- }
- }
- },
- fail(res) {
- wx.hideLoading()
- }
- })
- }
- },
- addrecord: function (num,time) {
- let that = this;
- wx.showLoading({
- title: '加载中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/addvisitlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- customer_id: that.data.nowcid,
- img: that.data.titype == 2?that.data.nowimagearr.join(','):'',
- img1: that.data.titype == 1?that.data.nowimagearr1.join(','):'',
- type: '',
- next_contact_date: that.data.visitdate,
- remark: that.data.tacktext,
- starts: that.data.scoleval * 2,
- state: that.getstate(num),
- aid: num==3?that.data.nowaid: num==2?this.data.storeactivityid:that.data.titype == 2&&this.data.tacktype==5?that.data.nowaid:'',
- money: this.data.money,
- deposit_mode: this.data.deposit_mode,
- confirm_date: num >= 4 ? time:num==1?this.data.measuretime:num==2?this.data.reachstoretime:num==3?this.data.orderactivitydate:that.data.tacktype == 3 ? this.data.amountdate : that.data.tacktype == 4 ? this.data.amountdate : this.data.tacktype == 5 ? this.data.amountdate : '' ,
- number_of_visitors: that.data.titype == 2&&that.data.tacktype == 4?that.data.storenum:'',
- measure_room_img_type:that.data.titype == 2&&that.data.tacktype == 3?that.data.amountext.length>0?that.data.amountext.join(','):'':'',
- package:this.data.titype == 2 &&this.data.tacktype == 6?this.data.depositproductlist.length>0&&this.data.depositproductnum!==''?this.data.depositproductlist[this.data.depositproductnum].id:'':'',
- },
- success: function (res) {
- wx.hideLoading()
- if (res.data.code == "0") {
- // trackflag:false,
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- that.crmmsgfun();
- that.typeinitfun();
- if(that.data.titype == 1){
- that.setData({
- trackimgarr1:[],
- nowimagearr1:[],
- })
- that.tracklog();
- }else if(that.data.titype == 2){
- let amountext=that.data.amountext;
- amountext=[];
- if(that.data.amountarr.length==1){
- amountext[0]=that.data.amountarr[0].name.slice(2, that.data.amountarr[0].name.length)
- }
- that.setData({
- tacktype:3,
- amountext:amountext,
- })
- that.visitlogfun('量房');
- that.tracklog();
- }else if(that.data.titype == 3){
- that.setData({
- nowaid:'',
- activityvalue:'',
- orderactivitydate:'',
- reachstoretime:'',
- reachstorenum:'',
- measurenum:'',
- measuretime:'',
- appointype:'',
- storeactivityid:'',
- storeactivityvalue:''
- })
- that.subscribefun();
- }
- that.setData({
- trackimgarr: [],
- nowimagearr: [],
- tacktext: '',
- money: '',
- })
- that.triggerEvent("run", '')
- }
-
- }
- })
- },
- saverecordtap: function (e) {
- const that = this;
- if (that.data.tacktype == 1 || that.data.tacktype == 3 || that.data.tacktype == 4 || that.data.tacktype == 5 || that.data.tacktype == 6 || that.data.tacktype == 7) {
- if(this.data.nextvisitflag&&!that.data.visitdate){
- wx.showToast({
- title: "下次回访时间不能为空",
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- }
- if(that.data.titype == 2&&that.data.tacktype == 3){
- if (that.data.trackimgarr.length > 0) {
- that.ossuploadimg();
- } else {
- wx.showToast({
- title: "确定量房必须传照片!",
- icon: 'none',
- duration: 2000
- })
- }
- } else {
- if(that.data.titype == 1){
- if (that.data.trackimgarr1.length > 0) {
- that.ossuploadimg1();
- }else{
- that.addrecord();
- }
- }else{
- that.addrecord();
- }
- }
- },
- }
- })
|