1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029 |
- // miniprogram/xqaddtrack/xqaddtrack.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,
- wactivitylist: Array,
- wcolumns: Array,
- nextvisitflag: {
- type: Boolean,
- value: false//true是必填,false不必传 下次回访时间
- },
- amountarr: Array,
- activityobj: Object
- },
- /**
- * 组件的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- clientype: app.globalData.clientype,
- aid: '',
- aType: "2",
- storeIndex: null,
- activityobj: {},
- titype: 1,
- trackflag: false,
- showWPicker: false,
- subscribeAbled: false,
- tracktype: '1',
- clueType: "1",
- trackimgarr: [],
- nowimagearr: [],
- visitField: [],
- nowcid: '',
- recordtext: '',
- visitcount: 0,
- firstmoney: '',
- staylength: '',
- visitlogarr: [],
- statype: '1',
- activityname: '',
- invitecrm: [],
- showUpcrm: [],
- datashow: true,
- showSelect: true,
- start: "",
- end: '',
- nowaid: '',
- personobj: app.globalData.personMsg,
- typeflag: false,
- type: 1,
- tacktype: 3,
- tackarr: [],
- subscribeTitle: "提交预约",
- nowtext1: '自定义',
- tacktext: '',
- amountdate: '',
- nowtext: false,
- amountime: 1,
- amountime1: 1,
- visitdate: '',
- apointobj: {},
- customerobj: {},
- changeModuleObj: {},
- subscribeObj: {},
- moduleSwitchObj: {},
- nowidx: 0,
- scoleval: 0,
- orderTime: '',
- nowdate: '',
- cluestate: 1,
- activityType: '',
- nextdate: "1",
- addwxarr: [],
- addwxtypeflag: false,
- measurenum: '',
- measuretime: '',
- showPicker: false,
- storenum: 1,
- loglist: [],
- orderactivitydate: '',
- activityvalue: '',
- subscribelist: [],
- amountext: [],
- storeArr: [],
- amountshow: false,
- trackimgarr1: [],
- nowimagearr1: [],
- depositproductlist: [],
- depositproductnum: '',
- deposit_mode: '1',
- appointype: '',//1是预约活动,2是预约到店
- storeactivityvalue: '',
- storeactivityid: '',
- reachstoretime: "",
- subType: "1",
- signOrderTagText: "转单",
- deliveryTagText: "签单",
- contractTagText: "合同",
- extarr: [
- {
- keyname: '',
- value: '',
- keytext: '',
- select: '',
- id: ''
- }
- ],
- },
- /**
- * 组件的方法列表
- */
- methods: {
- getChangeModule() {
- if (this.data.clientype == 'vL0CQQ') {
- this.setData({
- signOrderTagText: "签单",
- deliveryTagText: "交定",
- contractTagText: "签单"
- })
- }
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/changeModule',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.nowcid
- },
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- changeModuleObj: res.data.data
- })
- }
- }
- })
- },
- getSubscribeModule() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/subscribeModule',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.nowcid
- },
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- subscribeObj: res.data.data
- })
- }
- }
- })
- },
- getModuleSwitch() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/moduleSwitch',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- moduleSwitchObj: res.data.data
- })
- }
- }
- })
- },
- getClueTag() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/clueTag',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == 0) {
- let clueTagArr = res.data.data;
- clueTagArr.unshift('自定义');
- clueTagArr = clueTagArr.map((v,i) => {
- return {id: i+1, text: v};
- })
- that.setData({
- tackarr: clueTagArr
- })
- }
- }
- })
- },
- getVisitField() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/visitField',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.nowcid
- },
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- visitField: res.data.data
- })
- that.selectComponent('#customfield').getField();
- }
- }
- })
- },
- getShoplistApi() {
- if (this.data.storeArr.length) {
- return;
- }
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/shop_list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- storeArr: res.data.data
- })
- }
- }
- })
- },
- 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)
- }
- })
- },
- preview2Img(e) {
- wx.previewImage({
- current: this.data.visitlogarr[e.currentTarget.dataset.src].delivery_img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.visitlogarr[e.currentTarget.dataset.src].delivery_img, // 需要预览的图片http链接列表
- fail(res) {
- console.log(res)
- }
- })
- },
- preview3Img(e) {
- wx.previewImage({
- current: this.data.visitlogarr[e.currentTarget.dataset.src].sign_img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.visitlogarr[e.currentTarget.dataset.src].sign_img, // 需要预览的图片http链接列表
- fail(res) {
- console.log(res)
- }
- })
- },
- preview4Img(e){
- wx.previewImage({
- current: this.data.visitlogarr[e.currentTarget.dataset.src].portraitarr[e.currentTarget.dataset.field].valname[e.currentTarget.dataset.idx], // 当前显示图片的http链接
- urls: this.data.visitlogarr[e.currentTarget.dataset.src].portraitarr[e.currentTarget.dataset.field].valname, // 需要预览的图片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() { },
- bindPickerChange: function(e) {
- this.setData({
- storeIndex: e.detail.value
- })
- },
- closetracktap: function () {
- this.setData({
- trackflag: false
- })
- },
- setstorenumtap(e) {
- this.setData({
- storenum: e.detail.value
- })
- },
- setorderTimenumtap() {
- this.setData({
- orderTime: e.detail.value
- })
- },
- getOrderTimeInput(e) {
- this.setData({
- orderTime: e.detail.value
- })
- },
- setstaylengthnumtap() {
- this.setData({
- staylength: 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
- })
- }
- },
- setSubscriteDate(e) {
- let num = e.detail;
- 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({
- nextdate: num,
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- if (this.data.tacktype == 3) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 4) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 5) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- }
- },
- setlfyyDate(e) {
- let num = e.detail;
- 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({
- nextdate: num,
- measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- if (this.data.tacktype == 3) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 4) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
- })
- } else if (this.data.tacktype == 5) {
- this.setData({
- nextdate: num
- })
- if (num == 5) {
- return false;
- }
- this.setData({
- measuretime: 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
- })
- },
- setfirstmoney(e) {
- this.setData({
- firstmoney: 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 curIndex = "";
- 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)
- }
- if (this.data.changeModuleObj.lf.show == 1) {
- curIndex = "3";
- } else if (this.data.changeModuleObj.dd.show == 1) {
- curIndex = "4";
- } else if (this.data.changeModuleObj.hd.show == 1) {
- curIndex = "5";
- } else if (this.data.changeModuleObj.jd.show == 1) {
- curIndex = "6";
- } else if (this.data.changeModuleObj.zd.show == 1) {
- curIndex = "7";
- } else {
- curIndex = "8";
- }
- this.setData({
- tacktype: curIndex,
- amountext: amountext,
- trackimgarr: [],
- trackimgarr1: [],
- nowimagearr1: [],
- })
- this.visitlogfun('量房');
- this.packagefun();
- setTimeout(() => {
- this.selectComponent('#customfield').getField();
- },300)
- } else if (e.currentTarget.dataset.text == 3) {
- this.subscribefun();
- if (this.data.subscribeObj.hd.show == 1) {
- if (!this.data.wactivitylist.length) {
- this.setData({
- subType: 1,
- subscribeAbled: true,
- subscribeTitle: "~暂无外场活动-无法预约~"
- })
- } else {
- this.setData({
- subType: 1,
- subscribeAbled: false,
- subscribeTitle: "提交预约"
- })
- }
- } else if (this.data.subscribeObj.dd.show == 1) {
- this.setData({
- subType: 2,
- subscribeAbled: false,
- subscribeTitle: "提交预约"
- })
- } else if (this.data.subscribeObj.lf.show == 1) {
- this.setData({
- subType: 3,
- subscribeAbled: false,
- subscribeTitle: "提交预约"
- })
- }
- setTimeout(() => {
- this.selectComponent('#customfield').getField();
- },300)
- } else {
- setTimeout(() => {
- this.selectComponent('#customfield').getField();
- },300)
- 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: [],
- trackimgarr1: [],
- nowimagearr1: [],
- 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('到店');
- this.getShoplistApi();
- if (this.data.changeModuleObj.ddhd.show == 1) {
- this.setData({
- activityname: this.data.activityobj.title,
- nowaid: this.data.activityobj.id
- })
- }
- } else if (e.currentTarget.dataset.text == 5) {
- this.visitlogfun('到场');
- let arr = customerobj.subscirbe;
- this.setData({
- activityname: this.data.activityobj.title,
- nowaid: this.data.activityobj.id
- })
- } else if (e.currentTarget.dataset.text == 6) {
- this.depositinitfun();
- } else if (e.currentTarget.dataset.text == 7) {
- this.setData({
- firstmoney: this.data.customerobj.down_payment
- })
- this.signinitfun();
- }
- setTimeout(() => {
- this.selectComponent('#customfield').getField();
- },300)
- },
- setsubtypetap(e) {
- let year = new Date().getFullYear();
- let month = new Date().getMonth();
- let daystr = new Date().getDate();
- if (!this.data.wactivitylist.length && e.currentTarget.dataset.text == 1) {
- this.setData({
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr,
- measuretime: year + '-' + (month * 1 + 1) + '-' + daystr,
- subType: e.currentTarget.dataset.text,
- subscribeAbled: true,
- subscribeTitle: "~暂无外场活动-无法预约~"
- })
- } else {
- this.setData({
- reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr,
- measuretime: year + '-' + (month * 1 + 1) + '-' + daystr,
- subType: e.currentTarget.dataset.text,
- subscribeAbled: false,
- subscribeTitle: "提交预约"
- })
- }
- setTimeout(() => {
- this.selectComponent('#customfield').getField();
- },300)
- },
- 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,
- })
- }
- },
- setcluetypetap(e) {
- this.setData({
- clueType: 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() {
- if (this.data.activityobj.cate == 1) {
- this.setData({
- showWPicker: true,
- nowaid: '',
- appointype: 1
- })
- } else {
- this.setData({
- showPicker: true,
- nowaid: '',
- appointype: 1
- })
- }
- },
- setactivitytap1() {
- this.setData({
- showPicker: true,
- nowaid: '',
- appointype: 2
- })
- },
- setactivitytap2() {
- if (this.data.aType == 1) {
- this.setData({
- showPicker: true,
- nowaid: '',
- appointype: 1
- })
- } else {
- this.setData({
- showWPicker: true,
- nowaid: '',
- appointype: 1
- })
- }
- },
- onCancel() {
- this.setData({
- showPicker: false,
- showWPicker: false,
- showSelect: true,
- })
- },
- showDesignerDialog() {
- this.setData({
- showSelect: false,
- })
- },
- submitDesigner(e) {
- let itemArr = e.detail;
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/crm_customer/reserveDesigner',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.nowcid,
- designerId: itemArr.map(v => v.id).join(',')
- },
- success: function (res) {
- if (res.data.code == 0) {
- wx.showToast({
- title: '指派成功',
- icon: "success",
- duration: 1500,
- success: function() {
- setTimeout(() => {
- that.setData({
- showSelect: true
- })
- },1500)
- that.crmmsgfun();
- }
- })
- }
- }
- })
- },
- // 量房预约
- clearmeasuretap() {
- this.setData({
- measurenum: '',
- measuretime: ''
- })
- },
- showmeasuretap() {
- this.setData({
- ordertimeshow: true,
- ordertype: 1
- })
- },
- bindlfDate(e) {
- this.setData({
- measuretime: e.detail.value
- })
- },
- 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,
- })
- }
- },
- onRadioChange(e) {
- this.setData({
- aType: e.detail,
- activityvalue: "",
- nowaid: ""
- })
- },
- bindWactivityChange(e) {
- if (this.data.titype == 2) {
- this.setData({
- showWPicker: 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({
- showWPicker: 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.money ? this.data.customerobj.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
- })
- }
- this.getChangeModule();
- this.getSubscribeModule();
- this.getModuleSwitch();
- this.getClueTag();
- this.getVisitField();
- 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].portraitarr=JSON.parse(res.data.data[i].save_portrait_field);
- 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;
- }
- if(res.data.data[i].portraitarr){
- for(let j=0;j<res.data.data[i].portraitarr.length;j++){
- if(res.data.data[i].portraitarr[j].type==6){
- res.data.data[i].portraitarr[j].valname=res.data.data[i].portraitarr[j].valname.split(',');
- }
- }
- }
- }
- 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) {
- this.selectComponent('#customfield').addCustomer();
- 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.tacktype == 3 ? that.data.nowimagearr.join(',') : '',
- img1: that.data.titype == 1 ? that.data.nowimagearr1.join(',') : '',
- delivery_img: that.data.titype == 2 && that.data.tacktype == 6 ? that.data.nowimagearr1.join(',') : '',
- sign_img: that.data.titype == 2 && that.data.tacktype == 7 ? that.data.nowimagearr1.join(',') : '',
- type: this.data.clueType,
- 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 : that.data.titype == 2 && this.data.tacktype == 4 && this.data.changeModuleObj.ddhd.show == 1 ? 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 : '' : '',
- talking_order_time: this.data.titype == 2 && this.data.tacktype == 4 ? this.data.orderTime : "",
- stay_length: this.data.titype == 2 && this.data.tacktype == 5 ? this.data.staylength : "",
- down_payment: this.data.titype == 2 && this.data.tacktype == 7 ? this.data.firstmoney : "",
- shop_id: this.data.titype == 2 && this.data.tacktype == 4 && (this.data.storeIndex || this.data.storeIndex == 0) ? this.data.storeArr[this.data.storeIndex].id : ''
- },
- success: function (res) {
- wx.hideLoading()
- if (res.data.code == "0") {
- 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,
- orderTime: "",
- staylength: "",
- firstmoney: "",
- trackimgarr1: [],
- nowimagearr1: [],
- })
- 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: '',
- storeIndex: null
- })
- 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 == 2 && that.data.tacktype == 6) {
- if (that.data.trackimgarr1.length > 0) {
- that.ossuploadimg1();
- } else {
- wx.showToast({
- title: `请上传${that.data.deliveryTagText}依据!`,
- icon: 'none',
- duration: 2000
- })
- return;
- }
- } else if (that.data.titype == 2 && that.data.tacktype == 7) {
- if (that.data.trackimgarr1.length > 0) {
- that.ossuploadimg1();
- } else {
- wx.showToast({
- title: `请上传${that.data.contractTagText}依据!`,
- icon: 'none',
- duration: 2000
- })
- return;
- }
- } else {
- if (that.data.titype == 1) {
- if (that.data.trackimgarr1.length > 0) {
- that.ossuploadimg1();
- } else {
- that.addrecord();
- }
- } else {
- that.addrecord();
- }
- }
- },
- }
- })
|