addtrack.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497
  1. // miniprogram/addtrack/addtrack.js
  2. const utils=require("../../utils/http");
  3. const util = require("../../utils/util");
  4. const app=getApp();
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. trackflag:{
  11. type: Boolean,
  12. value:false
  13. },
  14. nowcid:{
  15. type: String,
  16. value:''
  17. },
  18. addwxarr:Array,
  19. columns:Array,
  20. activitylist:Array,
  21. nextvisitflag:{
  22. type: Boolean,
  23. value:false//true是必填,false不必传 下次回访时间
  24. },
  25. amountarr:Array
  26. },
  27. /**
  28. * 组件的初始数据
  29. */
  30. data: {
  31. imgUrl: app.globalData.imgUrl,
  32. aid: '',
  33. activityobj: {},
  34. titype: 1,
  35. trackflag: false,
  36. tracktype: '1',
  37. trackimgarr: [],
  38. nowimagearr: [],
  39. nowcid: '',
  40. recordtext: '',
  41. visitcount: 0,
  42. visitlogarr: [],
  43. statype: '1',
  44. activityname: '',
  45. invitecrm: [],
  46. showUpcrm: [],
  47. datashow: true,
  48. start: "",
  49. end: '',
  50. nowaid: '',
  51. personobj: app.globalData.personMsg,
  52. typeflag: false,
  53. type: 1,
  54. tacktype: 3,
  55. tackarr: [
  56. { id: 1, text: '自定义' },
  57. { id: 3, text: '已装修' },
  58. { id: 4, text: '无需求' },
  59. { id: 5, text: '有需求' },
  60. { id: 6, text: '超地域' },
  61. { id: 7, text: '未交房' },
  62. { id: 8, text: '在外地' },
  63. { id: 9, text: '无购买力' },
  64. { id: 10, text: '未接通电话' },
  65. ],
  66. nowtext1: '自定义',
  67. tacktext: '',
  68. amountdate: '',
  69. nowtext: false,
  70. amountime: 1,
  71. amountime1: 1,
  72. visitdate: '',
  73. apointobj: {},
  74. customerobj: {},
  75. nowidx: 0,
  76. scoleval: 0,
  77. nowdate: '',
  78. cluestate: 1,
  79. activityType: '',
  80. addwxarr:[],
  81. addwxtypeflag:false,
  82. measurenum:'',
  83. measuretime:'',
  84. showPicker:false,
  85. storenum:1,
  86. loglist:[],
  87. orderactivitydate:'',
  88. activityvalue:'',
  89. subscribelist:[],
  90. amountext: [],
  91. amountshow:false,
  92. trackimgarr1:[],
  93. nowimagearr1:[],
  94. depositproductlist:[],
  95. depositproductnum:'',
  96. deposit_mode: '1',
  97. appointype:'',//1是预约活动,2是预约到店
  98. storeactivityvalue:'',
  99. storeactivityid:'',
  100. extarr:[
  101. {
  102. keyname: '',
  103. value: '',
  104. keytext: '',
  105. select: '',
  106. id:''
  107. }
  108. ],
  109. },
  110. /**
  111. * 组件的方法列表
  112. */
  113. methods: {
  114. setcrmfun(cid){
  115. const that=this;
  116. utils.$post({
  117. url: app.globalData.webUrl + 'api/crm_customer/get_portrait_field',
  118. header: {
  119. 'Authorization': 'bearer ' + app.globalData.token
  120. },
  121. data: {
  122. id:this.data.nowcid
  123. },
  124. success: function (res) {
  125. if(res.data.code==0){
  126. let extarr=[];
  127. for (let i in res.data.data) {
  128. for (let j in res.data.data[i].child) {
  129. if (res.data.data[i].child[j].keyname =='add_wechat_type') {
  130. let obj = {
  131. keyname: res.data.data[i].child[j].keyname,
  132. value: res.data.data[i].child[j].value?res.data.data[i].child[j].value:'',
  133. keytext: res.data.data[i].child[j].valname,
  134. select: res.data.data[i].child[j].select,
  135. id:res.data.data[i].child[j].id
  136. };
  137. extarr[0]=obj;
  138. }
  139. }
  140. }
  141. that.setData({
  142. extarr:extarr
  143. })
  144. }
  145. }
  146. })
  147. },
  148. amounthouseimgtap(){
  149. if(this.data.amountarr.length==1){
  150. this.uploadimg();
  151. }else{
  152. this.setData({
  153. amountshow:true,
  154. })
  155. }
  156. },
  157. onClose(){
  158. this.setData({
  159. amountshow:false
  160. })
  161. },
  162. onSelect(event) {
  163. let amountext=this.data.amountext;
  164. amountext.push(event.detail.name.slice(2, event.detail.name.length));
  165. this.setData({
  166. amountext:amountext,
  167. amountshow:false,
  168. })
  169. this.uploadimg();
  170. },
  171. prelooktap(e) {
  172. wx.previewImage({
  173. current: this.data.loglist[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  174. urls: this.data.loglist[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
  175. fail(res) {
  176. console.log(res)
  177. }
  178. })
  179. },
  180. previewImg(e) {
  181. wx.previewImage({
  182. current: this.data.visitlogarr[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  183. urls: this.data.visitlogarr[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
  184. fail(res) {
  185. console.log(res)
  186. }
  187. })
  188. },
  189. preview1Img(e) {
  190. wx.previewImage({
  191. current: this.data.visitlogarr[e.currentTarget.dataset.src].img1[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  192. urls: this.data.visitlogarr[e.currentTarget.dataset.src].img1, // 需要预览的图片http链接列表
  193. fail(res) {
  194. console.log(res)
  195. }
  196. })
  197. },
  198. cancleappointap(e){
  199. let that=this;
  200. let obj=this.data.subscribelist[e.currentTarget.dataset.idx];
  201. if (obj.order_type > 0) {
  202. if (obj.type == "预约量房") {
  203. wx.showLoading()
  204. this.addrecord(4, obj.subscribe_date);
  205. }
  206. if (obj.type == "预约到店") {
  207. wx.showLoading()
  208. this.addrecord(5, obj.subscribe_date);
  209. }
  210. if (obj.type == "预约活动") {
  211. wx.showLoading()
  212. this.addrecord(6, obj.subscribe_date);
  213. }
  214. }
  215. },
  216. crmsgfun(){
  217. let date = new Date();
  218. let m = date.getMonth() * 1 + 1;
  219. let d = date.getDate();
  220. let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
  221. this.setData({
  222. amountdate: str,
  223. start: str,
  224. nowdate: str,
  225. visitdate:str
  226. })
  227. this.crmmsgfun();
  228. this.tracklog();
  229. },
  230. dothis(){},
  231. closetracktap: function () {
  232. this.setData({
  233. trackflag: false
  234. })
  235. },
  236. setstorenumtap(e){
  237. this.setData({
  238. storenum:e.detail.value
  239. })
  240. },
  241. jdHandleClick(e) {
  242. this.setData({
  243. deposit_mode: e.currentTarget.dataset.text
  244. })
  245. },
  246. amountimetap1(e) {
  247. let num = e.currentTarget.dataset.text;
  248. let date = new Date();
  249. let nowTime = date.getTime();
  250. let oneDayTime = 24 * 60 * 60 * 1000;
  251. var day = date.getDay();
  252. //显示周日
  253. var sun = nowTime - (day - 7) * oneDayTime;
  254. //显示周六
  255. var wen = nowTime - (day - 6) * oneDayTime;
  256. let str = num == 1 ? 0 : num == 2 ? 1 : '';
  257. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  258. let year = new Date(timenum).getFullYear();
  259. let month = new Date(timenum).getMonth();
  260. let daystr = new Date(timenum).getDate();
  261. this.setData({
  262. amountime1: num,
  263. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  264. })
  265. if (this.data.tacktype == 3) {
  266. this.setData({
  267. amountime1: num
  268. })
  269. if (num == 5) {
  270. return false;
  271. }
  272. this.setData({
  273. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  274. })
  275. } else if (this.data.tacktype == 4) {
  276. this.setData({
  277. amountime1: num
  278. })
  279. if (num == 5) {
  280. return false;
  281. }
  282. this.setData({
  283. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  284. })
  285. } else if (this.data.tacktype == 5) {
  286. this.setData({
  287. amountime1: num
  288. })
  289. if (num == 5) {
  290. return false;
  291. }
  292. this.setData({
  293. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  294. })
  295. }
  296. },
  297. uptracklogtap:function(){
  298. const that = this;
  299. wx.chooseMedia({
  300. count: 9,
  301. mediaType: ['image'],
  302. sizeType: ['compressed'],
  303. sourceType: ['album', 'camera'],
  304. success(res) {
  305. // tempFilePath可以作为img标签的src属性显示图片
  306. if (res.errMsg == "chooseMedia:ok") {
  307. that.createImagePayment1(res.tempFiles);
  308. }
  309. },
  310. fail(res) {
  311. wx.showToast({
  312. title: '上传失败请重试!',
  313. icon: 'error',
  314. duration: 2000
  315. })
  316. }
  317. })
  318. },
  319. createImagePayment1: function (imgUrl) {
  320. var that = this;
  321. if (imgUrl.length == 0) return;
  322. var lent = that.data.trackimgarr1.length + imgUrl.length;
  323. if (lent > 9) {
  324. lent = 9
  325. } else {
  326. lent = lent;
  327. }
  328. let trackimgarr1 = that.data.trackimgarr1;
  329. let len = imgUrl.length;
  330. if ((trackimgarr1.length + len) > 9) {
  331. for (let j = 0; j < len; j++) {
  332. if (trackimgarr1.length < 9) {
  333. trackimgarr1.push(imgUrl[j]);
  334. }
  335. }
  336. } else {
  337. trackimgarr1 = trackimgarr1.concat(imgUrl);
  338. }
  339. that.setData({
  340. trackimgarr1: trackimgarr1
  341. })
  342. },
  343. uploadimg: function () {
  344. const that = this;
  345. wx.chooseMedia({
  346. count: 9,
  347. mediaType: ['image'],
  348. sizeType: ['compressed'],
  349. sourceType: ['album', 'camera'],
  350. success(res) {
  351. // tempFilePath可以作为img标签的src属性显示图片 res.tempFilePaths
  352. // console.log(res)
  353. // var trackimgarr=that.data.trackimgarr;
  354. if (res.errMsg == "chooseMedia:ok") {
  355. // let len=res.tempFilePaths.length;
  356. that.createImagePayment(res.tempFiles);
  357. // if((trackimgarr.length+len)>9){
  358. // for(let j=0;j<len;j++){
  359. // if(trackimgarr.length<9){
  360. // trackimgarr.push(res.tempFilePaths[j]);
  361. // }
  362. // }
  363. // }else{
  364. // trackimgarr=trackimgarr.concat(res.tempFilePaths);
  365. // }
  366. // that.setData({
  367. // trackimgarr:trackimgarr
  368. // })
  369. }
  370. },
  371. fail(res) {
  372. wx.showToast({
  373. title: '上传失败请重试!',
  374. icon: 'error',
  375. duration: 2000
  376. })
  377. }
  378. })
  379. },
  380. createImagePayment: function (imgUrl) {
  381. var that = this;
  382. if (imgUrl.length == 0) return;
  383. var lent = that.data.trackimgarr.length + imgUrl.length;
  384. if (lent > 9) {
  385. lent = 9
  386. } else {
  387. lent = lent;
  388. }
  389. let trackimgarr = that.data.trackimgarr;
  390. let len = imgUrl.length;
  391. if ((trackimgarr.length + len) > 9) {
  392. for (let j = 0; j < len; j++) {
  393. if (trackimgarr.length < 9) {
  394. trackimgarr.push(imgUrl[j]);
  395. }
  396. }
  397. } else {
  398. trackimgarr = trackimgarr.concat(imgUrl);
  399. }
  400. that.setData({
  401. trackimgarr: trackimgarr
  402. })
  403. },
  404. delimgtap: function (e) {
  405. const that = this;
  406. wx.showModal({
  407. title: '确认删除',
  408. content: '是否删除这张图片?',
  409. success(res) {
  410. if (res.confirm) {
  411. let trackimgarr = that.data.trackimgarr,amountext=that.data.amountext;
  412. trackimgarr.splice(e.currentTarget.dataset.idx, 1)
  413. amountext.splice(e.currentTarget.dataset.idx, 1)
  414. that.setData({
  415. trackimgarr: trackimgarr,
  416. amountext:amountext
  417. })
  418. }
  419. }
  420. })
  421. },
  422. deltracktap: function (e) {
  423. const that = this;
  424. wx.showModal({
  425. title: '确认删除',
  426. content: '是否删除这张图片?',
  427. success(res) {
  428. if (res.confirm) {
  429. let trackimgarr1 = that.data.trackimgarr1;
  430. trackimgarr1.splice(e.currentTarget.dataset.idx, 1)
  431. that.setData({
  432. trackimgarr1: trackimgarr1
  433. })
  434. }
  435. }
  436. })
  437. },
  438. ossuploadimg: function (e) {
  439. let that = this;
  440. let trackimgarr = that.data.trackimgarr;
  441. var arr = [];
  442. for (let i = 0; i < trackimgarr.length; i++) {
  443. //获取文件后缀
  444. // 随机生成文件名称
  445. let rstr = trackimgarr[i].tempFilePath.split('.');
  446. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  447. var imgName = fileRandName + '.' + 'png';
  448. // var fileName = that.data.;
  449. var date = new Date();
  450. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  451. var imgstr = 'crm/' + time + '/' + imgName;
  452. var nowimagearr = that.data.nowimagearr;
  453. nowimagearr.push(imgstr);
  454. that.setData({
  455. nowimagearr: nowimagearr
  456. })
  457. wx.uploadFile({
  458. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  459. filePath: trackimgarr[i].tempFilePath,
  460. name: 'file',
  461. formData: {
  462. // name: that.data.imgSrc[0],
  463. key: 'crm/' + time + '/' + imgName,
  464. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  465. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  466. success_action_status: "200",
  467. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  468. },
  469. header: {
  470. "Content-Type": "multipart/form-data",
  471. 'accept': 'application/json',
  472. },
  473. success: function (rs) {
  474. if (rs.errMsg == 'uploadFile:ok') {
  475. arr.push('0');
  476. if (arr.length == trackimgarr.length) {
  477. that.addrecord();
  478. }
  479. }
  480. },
  481. fail(res) {
  482. wx.hideLoading()
  483. }
  484. })
  485. }
  486. },
  487. setmoney: function (e) {
  488. this.setData({
  489. money: e.detail.value
  490. })
  491. },
  492. setwxtypetap(e){
  493. let text='',extarr=this.data.extarr;
  494. for(let i in this.data.extarr[0].select){
  495. if(this.data.extarr[0].select[i].id == e.currentTarget.dataset.text){
  496. text=this.data.extarr[0].select[i].name;
  497. }
  498. }
  499. if (extarr[0].keytext != text) {
  500. extarr[0].keytext = text;
  501. extarr[0].value = e.currentTarget.dataset.text;
  502. } else {
  503. extarr[0].keytext = text;
  504. extarr[0].value = e.currentTarget.dataset.text;
  505. }
  506. this.setData({
  507. extarr: extarr,
  508. addwxtypeflag:false
  509. })
  510. this.editwxtap();
  511. },
  512. setoptap() {
  513. const that = this;
  514. utils.$post({
  515. url: app.globalData.webUrl + 'api/crmCustomer/customer_top',
  516. header: {
  517. 'Authorization': 'bearer ' + app.globalData.token
  518. },
  519. data: {
  520. type: 2,
  521. id: that.data.nowcid,
  522. },
  523. success: function (res) {
  524. if (res.data.code == '0') {
  525. let customerobj = that.data.customerobj;
  526. if (customerobj.addtoptime) {
  527. customerobj.addtoptime = '';
  528. }else{
  529. customerobj.addtoptime = '2022';
  530. }
  531. that.setData({
  532. customerobj:customerobj
  533. })
  534. that.triggerEvent('myevent', that.data.customerobj)
  535. }
  536. }
  537. })
  538. },
  539. addwxtap() {
  540. let extarr=this.data.extarr;
  541. if (this.data.extarr[0].select.length == 2) {
  542. this.setData({
  543. addwxtypeflag:true
  544. })
  545. } else {
  546. extarr[0].keytext = this.data.extarr[0].select[0].name;
  547. extarr[0].value = this.data.extarr[0].select[0].id;
  548. this.setData({
  549. addwxtypeflag:false,
  550. extarr: extarr
  551. })
  552. this.editwxtap();
  553. }
  554. },
  555. inputap() {
  556. this.setData({
  557. nowtext: !this.data.nowtext
  558. })
  559. },
  560. onChange(event) {
  561. this.setData({
  562. scoleval: event.detail,
  563. });
  564. },
  565. measurehousetap(e) {
  566. let num=e.currentTarget.dataset.type;
  567. // 量房预约
  568. let date = new Date();
  569. let nowTime = date.getTime();
  570. let oneDayTime = 24 * 60 * 60 * 1000;
  571. var day = date.getDay();
  572. //显示周日
  573. var sun = nowTime - (day - 7) * oneDayTime;
  574. //显示周六
  575. var wen = nowTime - (day - 6) * oneDayTime;
  576. let str = num == 1 ? 0 : num == 2 ? 1 : "";
  577. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  578. let year = new Date(timenum).getFullYear();
  579. let month = new Date(timenum).getMonth();
  580. let daystr = new Date(timenum).getDate();
  581. this.setData({
  582. measurenum:num
  583. })
  584. if (num == 5) {
  585. return false;
  586. }
  587. this.setData({
  588. measuretime:year + "-" + (month * 1 + 1) + "-" + daystr
  589. })
  590. if (!!this.data.reachstorenum) {
  591. let num = util.dayDiff(
  592. new Date(this.data.reachstoretime.split("-").join("/")),
  593. new Date(this.data.measuretime.split("-").join("/"))
  594. );
  595. if (num == 0) {
  596. this.setData({
  597. measuretime:'',
  598. measurenum:this.data.measurenum != 5 ? "" : this.data.measurenum
  599. })
  600. wx.showToast({
  601. title: '同一时间只能预约一个提醒,请重新预约!',
  602. icon: 'none',
  603. duration: 2000
  604. })
  605. return false;
  606. }
  607. }
  608. if (!!this.data.activityvalue) {
  609. let num = util.dayDiff(
  610. new Date(this.data.measuretime.split("-").join("/")),
  611. new Date(this.data.orderactivitydate.split("-").join("/"))
  612. );
  613. if (num == 0) {
  614. this.setData({
  615. measuretime:'',
  616. measurenum:this.data.measurenum != 5 ? "" : this.data.measurenum
  617. })
  618. wx.showToast({
  619. title: '同一时间只能预约一个提醒,请重新预约!',
  620. icon: 'none',
  621. duration: 2000
  622. })
  623. }
  624. }
  625. },
  626. // 到店
  627. reachstoretap(e){
  628. let num=e.currentTarget.dataset.type;
  629. let date = new Date();
  630. let nowTime = date.getTime();
  631. let oneDayTime = 24 * 60 * 60 * 1000;
  632. var day = date.getDay();
  633. //显示周日
  634. var sun = nowTime - (day - 7) * oneDayTime;
  635. //显示周六
  636. var wen = nowTime - (day - 6) * oneDayTime;
  637. let str = num == 1 ? 0 : num == 2 ? 1 : "";
  638. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  639. let year = new Date(timenum).getFullYear();
  640. let month = new Date(timenum).getMonth();
  641. let daystr = new Date(timenum).getDate();
  642. this.setData({
  643. reachstorenum:num
  644. })
  645. if (num == 5) {
  646. return false;
  647. }
  648. this.setData({
  649. reachstoretime:year + "-" + (month * 1 + 1) + "-" + daystr
  650. })
  651. if (!!this.data.measurenum) {
  652. let num = util.dayDiff(
  653. new Date(this.data.reachstoretime.split("-").join("/")),
  654. new Date(this.data.measuretime.split("-").join("/"))
  655. );
  656. if (num == 0) {
  657. this.setData({
  658. reachstoretime: "",
  659. reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
  660. })
  661. wx.showToast({
  662. title: '同一时间只能预约一个提醒,请重新预约!',
  663. icon: 'none',
  664. duration: 2000
  665. })
  666. return false;
  667. }
  668. }
  669. if (!!this.data.activityvalue) {
  670. let num = util.dayDiff(
  671. new Date(this.data.reachstoretime.split("-").join("/")),
  672. new Date(this.data.orderactivitydate.split("-").join("/"))
  673. );
  674. if (num == 0) {
  675. this.setData({
  676. reachstoretime: "",
  677. reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
  678. })
  679. wx.showToast({
  680. title: '同一时间只能预约一个提醒,请重新预约!',
  681. icon: 'none',
  682. duration: 2000
  683. })
  684. }
  685. }
  686. },
  687. setitypetap(e) {
  688. this.setData({
  689. titype: e.currentTarget.dataset.text,
  690. })
  691. if(e.currentTarget.dataset.text==2){
  692. let amountext=this.data.amountext;
  693. amountext=[];
  694. if(this.data.amountarr.length==1){
  695. amountext[0]=this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
  696. }
  697. this.setData({
  698. tacktype: 3,
  699. amountext:amountext,
  700. trackimgarr:[]
  701. })
  702. this.visitlogfun('量房');
  703. this.packagefun();
  704. } else if(e.currentTarget.dataset.text==3){
  705. this.subscribefun();
  706. }else{
  707. this.setData({
  708. trackimgarr1:[],
  709. nowimagearr1:[],
  710. })
  711. this.tracklog();
  712. }
  713. this.depositinitfun();
  714. },
  715. packagefun(){
  716. const that=this;
  717. utils.$post({
  718. url: app.globalData.webUrl + 'api/customerPackage/list',
  719. header: {
  720. 'Authorization': 'bearer ' + app.globalData.token
  721. },
  722. data: {},
  723. success: function (res) {
  724. if (res.data.code == "0") {
  725. that.setData({
  726. depositproductlist:res.data.data
  727. })
  728. if(!!that.data.customerobj.package_id){
  729. for(let i in that.data.depositproductlist){
  730. if(that.data.depositproductlist[i].id==that.data.customerobj.package_id){
  731. that.setData({
  732. depositproductnum:i
  733. })
  734. }
  735. }
  736. }else{
  737. that.setData({
  738. depositproductnum:'',
  739. })
  740. }
  741. }
  742. }
  743. })
  744. },
  745. bindsigndate: function (e) {
  746. this.setData({
  747. addtime: e.detail.value
  748. })
  749. },
  750. bindproductap(e){
  751. this.setData({
  752. depositproductnum:e.detail.value
  753. })
  754. },
  755. settacktap(e) {
  756. this.setData({
  757. tacktype: e.currentTarget.dataset.text,
  758. trackimgarr: [],
  759. nowimagearr: [],
  760. tacktext: '',
  761. nowtext1: '自定义',
  762. amountdate:this.data.nowdate
  763. })
  764. let customerobj=this.data.customerobj;
  765. if(e.currentTarget.dataset.text == 3){
  766. let amountext=this.data.amountext;
  767. amountext=[];
  768. if(this.data.amountarr.length==1){
  769. amountext[0]=this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
  770. }
  771. this.setData({
  772. amountext:amountext
  773. })
  774. this.visitlogfun('量房');
  775. }else if(e.currentTarget.dataset.text == 4){
  776. this.visitlogfun('到店');
  777. }else if(e.currentTarget.dataset.text == 5){
  778. this.visitlogfun('到场');
  779. let arr = customerobj.subscirbe;
  780. for (let i in arr) {
  781. if(arr[i].type=='预约活动'){
  782. this.setData({
  783. activityname:arr[i].activity.title,
  784. nowaid:arr[i].aid
  785. })
  786. }
  787. }
  788. }else if (e.currentTarget.dataset.text == 6) {
  789. this.depositinitfun();
  790. } else if (e.currentTarget.dataset.text == 7) {
  791. this.signinitfun();
  792. }
  793. },
  794. setextap(e) {
  795. this.setData({
  796. nowtext1: e.currentTarget.dataset.text,
  797. tacktext: e.currentTarget.dataset.text == '自定义' ? '' : e.currentTarget.dataset.text
  798. })
  799. },
  800. setcluestatetap(e) {
  801. const that = this;
  802. if (e.currentTarget.dataset.text == 1) {
  803. if (this.data.customerobj.state == "待确认" || !this.data.customerobj.state) {
  804. this.setData({
  805. cluestate: e.currentTarget.dataset.text,
  806. })
  807. }
  808. } else {
  809. this.setData({
  810. cluestate: e.currentTarget.dataset.text,
  811. })
  812. }
  813. },
  814. amountypetap(e) {
  815. if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5 && this.data.activitylist.length == 0) {
  816. wx.showToast({
  817. title: '公司暂无活动不能预约活动',
  818. icon: 'none',
  819. duration: 2000
  820. })
  821. return false;
  822. }
  823. const that = this;
  824. let day = new Date();
  825. let month = day.getMonth() * 1 + 1;
  826. let date = day.getDate();
  827. let year = day.getFullYear();
  828. let str = year + '-' + month + '-' + date;
  829. if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5) {
  830. this.setData({
  831. amountdate: this.data.activitylist[0].start_date,
  832. nowaid: this.data.activitylist[0].id,
  833. start: this.data.activitylist[0].start_date,
  834. end: this.data.activitylist[0].end_date,
  835. activityname: this.data.activitylist[0].title,
  836. })
  837. } else {
  838. this.setData({
  839. amountdate: str,
  840. amountime: 1
  841. })
  842. }
  843. },
  844. bindwChange: function (e) {
  845. this.setData({
  846. amountdate: e.detail.value
  847. })
  848. },
  849. bindvisitChange: function (e) {
  850. this.setData({
  851. visitdate: e.detail.value
  852. })
  853. },
  854. setactivitytap() {
  855. this.setData({
  856. showPicker: true,
  857. nowaid:'',
  858. appointype:1
  859. })
  860. },
  861. setactivitytap1() {
  862. this.setData({
  863. showPicker: true,
  864. nowaid:'',
  865. appointype:2
  866. })
  867. },
  868. onCancel() {
  869. this.setData({
  870. showPicker: false,
  871. })
  872. },
  873. // 量房预约
  874. clearmeasuretap(){
  875. this.setData({
  876. measurenum:'',
  877. measuretime:''
  878. })
  879. },
  880. showmeasuretap(){
  881. this.setData({
  882. ordertimeshow:true,
  883. ordertype:1
  884. })
  885. },
  886. cleareachstoretap(){
  887. this.setData({
  888. reachstorenum:'',
  889. reachstoretime:''
  890. })
  891. },
  892. showreachstoretap(){
  893. this.setData({
  894. ordertimeshow:true,
  895. ordertype:2
  896. })
  897. },
  898. bindactivityChange: function (e) {
  899. if(this.data.titype==2){
  900. this.setData({
  901. showPicker: false,
  902. start: this.data.activitylist[e.detail.index].start_date,
  903. end: this.data.activitylist[e.detail.index].end_date,
  904. activityname: e.detail.value,
  905. nowaid: this.data.activitylist[e.detail.index].id
  906. })
  907. }else if(this.data.titype==3){
  908. this.setData({
  909. showPicker: false,
  910. start: this.data.activitylist[e.detail.index].start_date,
  911. end: this.data.activitylist[e.detail.index].end_date,
  912. activityvalue: this.data.appointype==1?e.detail.value:this.data.activityvalue,
  913. nowaid: this.data.activitylist[e.detail.index].id,
  914. storeactivityvalue:this.data.appointype==2?e.detail.value:this.data.storeactivityvalue,
  915. storeactivityid:this.data.appointype==2?this.data.activitylist[e.detail.index].id:this.data.storeactivityid,
  916. })
  917. }
  918. },
  919. bindstoretap:function (e) {
  920. this.setData({
  921. reachstoretime: e.detail.value,
  922. reachstorenum:3
  923. })
  924. if (!!this.data.measurenum) {
  925. let num = util.dayDiff(
  926. new Date(this.data.reachstoretime.split("-").join("/")),
  927. new Date(this.data.measuretime.split("-").join("/"))
  928. );
  929. if (num == 0) {
  930. this.setData({
  931. reachstoretime: "",
  932. reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
  933. })
  934. wx.showToast({
  935. title: '同一时间只能预约一个提醒,请重新预约!',
  936. icon: 'none',
  937. duration: 2000
  938. })
  939. return false;
  940. }
  941. }
  942. if (!!this.data.activityvalue) {
  943. let num = util.dayDiff(
  944. new Date(this.data.reachstoretime.split("-").join("/")),
  945. new Date(this.data.orderactivitydate.split("-").join("/"))
  946. );
  947. if (num == 0) {
  948. this.setData({
  949. reachstoretime: "",
  950. reachstorenum:this.reachstorenum != 5 ? "" : this.reachstorenum
  951. })
  952. wx.showToast({
  953. title: '同一时间只能预约一个提醒,请重新预约!',
  954. icon: 'none',
  955. duration: 2000
  956. })
  957. }
  958. }
  959. },
  960. bindactivitytap:function (e) {
  961. this.setData({
  962. orderactivitydate: e.detail.value
  963. })
  964. if (!!this.data.measurenum) {
  965. let num = util.dayDiff(
  966. new Date(this.data.orderactivitydate.split("-").join("/")),
  967. new Date(this.data.measuretime.split("-").join("/"))
  968. );
  969. if (num == 0) {
  970. this.setData({
  971. orderactivitydate:''
  972. })
  973. wx.showToast({
  974. title: '同一时间只能预约一个提醒,请重新预约!',
  975. icon: 'none',
  976. duration: 2000
  977. })
  978. return false;
  979. }
  980. }
  981. if (!!this.data.reachstorenum) {
  982. let num = util.dayDiff(
  983. new Date(this.data.reachstoretime.split("-").join("/")),
  984. new Date(this.data.orderactivitydate.split("-").join("/"))
  985. );
  986. if (num == 0) {
  987. this.setData({
  988. orderactivitydate:''
  989. })
  990. wx.showToast({
  991. title: '同一时间只能预约一个提醒,请重新预约!',
  992. icon: 'none',
  993. duration: 2000
  994. })
  995. }
  996. }
  997. },
  998. depositinitfun() {
  999. let date = new Date();
  1000. let year = date.getFullYear();
  1001. let month = date.getMonth();
  1002. month = month * 1 + 1;
  1003. let day = date.getDate();
  1004. let str = year + "-" + month + "-" + day;
  1005. if (!!this.data.customerobj.deposit) {
  1006. this.setData({
  1007. money: this.data.customerobj.deposit_money1 ? this.data.customerobj.deposit_money1 : '',
  1008. addtime: this.data.customerobj.deposit ? this.data.customerobj.deposit.split(' ')[0] : ''
  1009. })
  1010. } else {
  1011. this.setData({
  1012. addtime: str,
  1013. money:''
  1014. })
  1015. }
  1016. },
  1017. signinitfun() {
  1018. let date = new Date();
  1019. let year = date.getFullYear();
  1020. let month = date.getMonth();
  1021. month = month * 1 + 1;
  1022. let day = date.getDate();
  1023. let str = year + "-" + month + "-" + day;
  1024. if (!!this.data.customerobj.sign) {
  1025. this.setData({
  1026. money: this.data.customerobj.signed_money ? this.data.customerobj.signed_money : '',
  1027. addtime: this.data.customerobj.sign ? this.data.customerobj.sign.split(' ')[0] : ''
  1028. })
  1029. } else {
  1030. this.setData({
  1031. addtime: str,
  1032. money:''
  1033. })
  1034. }
  1035. },
  1036. typeinitfun() {
  1037. const that = this;
  1038. let day = new Date();
  1039. let month = day.getMonth() * 1 + 1;
  1040. let date = day.getDate();
  1041. let year = day.getFullYear();
  1042. let str = year + '-' + month + '-' + date;
  1043. this.setData({
  1044. visitdate: str,
  1045. amountdate: str,
  1046. nowtext1: '自定义',
  1047. tacktext: ''
  1048. })
  1049. },
  1050. closeaddwxtap(){
  1051. this.setData({
  1052. addwxtypeflag:false
  1053. })
  1054. },
  1055. crmmsgfun() {
  1056. const that = this;
  1057. if(!this.data.nextvisitflag){
  1058. this.setData({
  1059. visitdate:'',
  1060. amountime1:''
  1061. })
  1062. }else{
  1063. let date = new Date();
  1064. let m = date.getMonth() * 1 + 1;
  1065. let d = date.getDate();
  1066. let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
  1067. this.setData({
  1068. visitdate:str,
  1069. amountime1:1
  1070. })
  1071. }
  1072. utils.$post({
  1073. url: app.globalData.webUrl + 'api/crm_customer/detail',
  1074. header: {
  1075. 'Authorization': 'bearer ' + app.globalData.token
  1076. },
  1077. data: {
  1078. id: this.data.nowcid
  1079. },
  1080. success: function (res) {
  1081. if (res.data.code == "0") {
  1082. let apointobj = that.data.apointobj;
  1083. that.setData({
  1084. customerobj: res.data.data
  1085. })
  1086. let arr = res.data.data.subscirbe;
  1087. apointobj = {};
  1088. for (let i in arr) {
  1089. if(arr[i].type=='预约活动'){
  1090. that.setData({
  1091. activityname:arr[i].activity.title,
  1092. nowaid:arr[i].aid
  1093. })
  1094. }
  1095. apointobj[arr[i].type] = arr[i].subscribe_date;
  1096. }
  1097. that.setData({
  1098. apointobj: apointobj,
  1099. cluestate: that.data.customerobj.state == "待确认" ? 1 : 2
  1100. })
  1101. }
  1102. }
  1103. })
  1104. },
  1105. editwxtap() {
  1106. const that = this;
  1107. utils.$post({
  1108. url: app.globalData.webUrl + 'api/crm_customer/add_customer_extfield',
  1109. header: {
  1110. 'Authorization': 'bearer ' + app.globalData.token
  1111. },
  1112. data: {
  1113. id: that.data.nowcid,
  1114. alertshow: '1',
  1115. ext: [
  1116. {
  1117. id:this.data.extarr[0].id,
  1118. keyname: this.data.extarr[0].keyname,
  1119. value: this.data.extarr[0].value
  1120. }
  1121. ]
  1122. },
  1123. success: function (res) {
  1124. if (res.data.code == "0") {
  1125. }
  1126. }
  1127. })
  1128. },
  1129. tracklog: function (e) {
  1130. let that = this;
  1131. utils.$post({
  1132. url: app.globalData.webUrl + 'api/crm_customer/visitlog',
  1133. header: {
  1134. 'Authorization': 'bearer ' + app.globalData.token
  1135. },
  1136. data: {
  1137. id: that.data.nowcid
  1138. },
  1139. success: function (res) {
  1140. setTimeout(() => {
  1141. wx.hideLoading()
  1142. }, 1000)
  1143. if (res.data.code == "0") {
  1144. let t = 0;
  1145. var str = "red";
  1146. for (let i = 0; i < res.data.data.length; i++) {
  1147. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1148. if (i == 0) {
  1149. res.data.data[0].color = str;
  1150. t = t * 1 + 1;
  1151. } else if (res.data.data[i].addtime.split(' ')[0] != res.data.data[i - 1].addtime.split(' ')[0]) {
  1152. t = t * 1 + 1;
  1153. if (t % 3 == 0) {
  1154. str = 'red';
  1155. } else if (t % 3 == 1) {
  1156. str = 'blue';
  1157. } else if (t % 3 == 2) {
  1158. str = 'cyan';
  1159. }
  1160. res.data.data[i].color = str;
  1161. } else {
  1162. res.data.data[i].color = str;
  1163. }
  1164. }
  1165. that.setData({
  1166. visitlogarr: res.data.data,
  1167. visitcount: res.data.count,
  1168. })
  1169. }
  1170. }
  1171. })
  1172. },
  1173. visitlogfun:function(text){
  1174. let that = this;
  1175. utils.$post({
  1176. url: app.globalData.webUrl + 'api/crmCustomer/visitlogDetails',
  1177. header: {
  1178. 'Authorization': 'bearer ' + app.globalData.token
  1179. },
  1180. data: {
  1181. id: that.data.nowcid,
  1182. state: text == "活动" ? "到场" : text,
  1183. },
  1184. success: function (res) {
  1185. setTimeout(() => {
  1186. wx.hideLoading()
  1187. }, 1000)
  1188. if (res.data.code == "0") {
  1189. for (let i = 0; i < res.data.data.length; i++) {
  1190. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1191. }
  1192. that.setData({
  1193. loglist: res.data.data
  1194. })
  1195. }
  1196. }
  1197. })
  1198. },
  1199. subscribefun(){
  1200. let that = this;
  1201. utils.$post({
  1202. url: app.globalData.webUrl + 'api/crmCustomer/subscribe',
  1203. header: {
  1204. 'Authorization': 'bearer ' + app.globalData.token
  1205. },
  1206. data: {
  1207. id: that.data.nowcid,
  1208. },
  1209. success: function (res) {
  1210. setTimeout(() => {
  1211. wx.hideLoading()
  1212. }, 1000)
  1213. if (res.data.code == "0") {
  1214. let date = new Date();
  1215. let year = date.getFullYear();
  1216. let month = date.getMonth();
  1217. month = month * 1 + 1;
  1218. let day = date.getDate();
  1219. let date1 = year + "/" + month + "/" + day;
  1220. for (let i = 0; i < res.data.data.length; i++) {
  1221. let num = util.dayDiff(
  1222. new Date(res.data.data[i].subscribe_date.split('-').join('/')),
  1223. new Date(date1)
  1224. );
  1225. res.data.data[i].order_type = num >= 0 ? 1 : 0;
  1226. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1227. }
  1228. that.setData({
  1229. subscribelist: res.data.data
  1230. })
  1231. }
  1232. }
  1233. })
  1234. },
  1235. getstate:function(num){
  1236. const that = this;
  1237. switch (this.data.titype*1) {
  1238. case 1:
  1239. let str = "";
  1240. str = this.data.cluestate == 1 ? "待确认" : this.data.cluestate == 2 ? "未到访" : "无效";
  1241. return str;
  1242. case 2:
  1243. let str1 = "";
  1244. str1 =
  1245. that.data.tacktype == 3
  1246. ? "已量房"
  1247. : this.data.tacktype == 4
  1248. ? "已到店"
  1249. : this.data.tacktype == 5
  1250. ? "已到场"
  1251. : this.data.tacktype == 6
  1252. ? "已交定"
  1253. : this.data.tacktype == 7
  1254. ? "已签单"
  1255. : "预约回访";
  1256. return str1;
  1257. case 3:
  1258. let str2 = "";
  1259. str2 =
  1260. num == 1
  1261. ? "预约量房"
  1262. : num == 2
  1263. ? "预约到店"
  1264. : num == 3
  1265. ? "预约活动"
  1266. : num == 4
  1267. ? "未量房"
  1268. : num == 5
  1269. ? "未到店"
  1270. : num == 6
  1271. ? "未到场"
  1272. : "";
  1273. return str2;
  1274. default:
  1275. break;
  1276. }
  1277. },
  1278. addappointap() {
  1279. const that = this;
  1280. if (!!this.data.measuretime) {
  1281. this.addrecord(1);
  1282. }
  1283. if (!!this.data.reachstoretime) {
  1284. this.addrecord(2);
  1285. }
  1286. if (!!this.data.nowaid && !!this.data.orderactivitydate) {
  1287. this.addrecord(3);
  1288. }
  1289. },
  1290. ossuploadimg1: function (e) {
  1291. let that = this;
  1292. let trackimgarr = that.data.trackimgarr1;
  1293. var arr = [];
  1294. for (let i = 0; i < trackimgarr.length; i++) {
  1295. //获取文件后缀
  1296. // 随机生成文件名称
  1297. let rstr = trackimgarr[i].tempFilePath.split('.');
  1298. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  1299. var imgName = fileRandName + '.' + 'png';
  1300. // var fileName = that.data.;
  1301. var date = new Date();
  1302. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  1303. var imgstr = 'crm/' + time + '/' + imgName;
  1304. var nowimagearr = that.data.nowimagearr1;
  1305. nowimagearr.push(imgstr);
  1306. that.setData({
  1307. nowimagearr1: nowimagearr
  1308. })
  1309. wx.uploadFile({
  1310. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  1311. filePath: trackimgarr[i].tempFilePath,
  1312. name: 'file',
  1313. formData: {
  1314. // name: that.data.imgSrc[0],
  1315. key: 'crm/' + time + '/' + imgName,
  1316. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  1317. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  1318. success_action_status: "200",
  1319. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  1320. },
  1321. header: {
  1322. "Content-Type": "multipart/form-data",
  1323. 'accept': 'application/json',
  1324. },
  1325. success: function (rs) {
  1326. if (rs.errMsg == 'uploadFile:ok') {
  1327. arr.push('0');
  1328. if (arr.length == trackimgarr.length) {
  1329. that.addrecord();
  1330. }
  1331. }
  1332. },
  1333. fail(res) {
  1334. wx.hideLoading()
  1335. }
  1336. })
  1337. }
  1338. },
  1339. addrecord: function (num,time) {
  1340. let that = this;
  1341. wx.showLoading({
  1342. title: '加载中...',
  1343. })
  1344. utils.$post({
  1345. url: app.globalData.webUrl + 'api/crm_customer/addvisitlog',
  1346. header: {
  1347. 'Authorization': 'bearer ' + app.globalData.token
  1348. },
  1349. data: {
  1350. customer_id: that.data.nowcid,
  1351. img: that.data.titype == 2?that.data.nowimagearr.join(','):'',
  1352. img1: that.data.titype == 1?that.data.nowimagearr1.join(','):'',
  1353. type: '',
  1354. next_contact_date: that.data.visitdate,
  1355. remark: that.data.tacktext,
  1356. starts: that.data.scoleval * 2,
  1357. state: that.getstate(num),
  1358. aid: num==3?that.data.nowaid: num==2?this.data.storeactivityid:that.data.titype == 2&&this.data.tacktype==5?that.data.nowaid:'',
  1359. money: this.data.money,
  1360. deposit_mode: this.data.deposit_mode,
  1361. 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 : '' ,
  1362. number_of_visitors: that.data.titype == 2&&that.data.tacktype == 4?that.data.storenum:'',
  1363. measure_room_img_type:that.data.titype == 2&&that.data.tacktype == 3?that.data.amountext.length>0?that.data.amountext.join(','):'':'',
  1364. package:this.data.titype == 2 &&this.data.tacktype == 6?this.data.depositproductlist.length>0&&this.data.depositproductnum!==''?this.data.depositproductlist[this.data.depositproductnum].id:'':'',
  1365. },
  1366. success: function (res) {
  1367. wx.hideLoading()
  1368. if (res.data.code == "0") {
  1369. // trackflag:false,
  1370. wx.showToast({
  1371. title: res.data.msg,
  1372. icon: 'none',
  1373. duration: 2000
  1374. })
  1375. that.crmmsgfun();
  1376. that.typeinitfun();
  1377. if(that.data.titype == 1){
  1378. that.setData({
  1379. trackimgarr1:[],
  1380. nowimagearr1:[],
  1381. })
  1382. that.tracklog();
  1383. }else if(that.data.titype == 2){
  1384. let amountext=that.data.amountext;
  1385. amountext=[];
  1386. if(that.data.amountarr.length==1){
  1387. amountext[0]=that.data.amountarr[0].name.slice(2, that.data.amountarr[0].name.length)
  1388. }
  1389. that.setData({
  1390. tacktype:3,
  1391. amountext:amountext,
  1392. })
  1393. that.visitlogfun('量房');
  1394. that.tracklog();
  1395. }else if(that.data.titype == 3){
  1396. that.setData({
  1397. nowaid:'',
  1398. activityvalue:'',
  1399. orderactivitydate:'',
  1400. reachstoretime:'',
  1401. reachstorenum:'',
  1402. measurenum:'',
  1403. measuretime:'',
  1404. appointype:'',
  1405. storeactivityid:'',
  1406. storeactivityvalue:''
  1407. })
  1408. that.subscribefun();
  1409. }
  1410. that.setData({
  1411. trackimgarr: [],
  1412. nowimagearr: [],
  1413. tacktext: '',
  1414. money: '',
  1415. })
  1416. that.triggerEvent("run", '')
  1417. }
  1418. }
  1419. })
  1420. },
  1421. saverecordtap: function (e) {
  1422. const that = this;
  1423. 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) {
  1424. if(this.data.nextvisitflag&&!that.data.visitdate){
  1425. wx.showToast({
  1426. title: "下次回访时间不能为空",
  1427. icon: 'none',
  1428. duration: 2000
  1429. })
  1430. return false;
  1431. }
  1432. }
  1433. if(that.data.titype == 2&&that.data.tacktype == 3){
  1434. if (that.data.trackimgarr.length > 0) {
  1435. that.ossuploadimg();
  1436. } else {
  1437. wx.showToast({
  1438. title: "确定量房必须传照片!",
  1439. icon: 'none',
  1440. duration: 2000
  1441. })
  1442. }
  1443. } else {
  1444. if(that.data.titype == 1){
  1445. if (that.data.trackimgarr1.length > 0) {
  1446. that.ossuploadimg1();
  1447. }else{
  1448. that.addrecord();
  1449. }
  1450. }else{
  1451. that.addrecord();
  1452. }
  1453. }
  1454. },
  1455. }
  1456. })