xqaddtrack.js 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  1. // miniprogram/xqaddtrack/xqaddtrack.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. wactivitylist: Array,
  22. wcolumns: Array,
  23. nextvisitflag: {
  24. type: Boolean,
  25. value: false//true是必填,false不必传 下次回访时间
  26. },
  27. amountarr: Array,
  28. activityobj: Object
  29. },
  30. /**
  31. * 组件的初始数据
  32. */
  33. data: {
  34. imgUrl: app.globalData.imgUrl,
  35. clientype: app.globalData.clientype,
  36. aid: '',
  37. aType: "2",
  38. storeIndex: null,
  39. activityobj: {},
  40. titype: 1,
  41. trackflag: false,
  42. showWPicker: false,
  43. subscribeAbled: false,
  44. tracktype: '1',
  45. clueType: "1",
  46. trackimgarr: [],
  47. nowimagearr: [],
  48. visitField: [],
  49. nowcid: '',
  50. recordtext: '',
  51. visitcount: 0,
  52. firstmoney: '',
  53. staylength: '',
  54. visitlogarr: [],
  55. statype: '1',
  56. activityname: '',
  57. invitecrm: [],
  58. showUpcrm: [],
  59. datashow: true,
  60. showSelect: true,
  61. start: "",
  62. end: '',
  63. nowaid: '',
  64. personobj: app.globalData.personMsg,
  65. typeflag: false,
  66. type: 1,
  67. tacktype: 3,
  68. tackarr: [],
  69. subscribeTitle: "提交预约",
  70. nowtext1: '自定义',
  71. tacktext: '',
  72. amountdate: '',
  73. nowtext: false,
  74. amountime: 1,
  75. amountime1: 1,
  76. visitdate: '',
  77. apointobj: {},
  78. customerobj: {},
  79. changeModuleObj: {},
  80. subscribeObj: {},
  81. moduleSwitchObj: {},
  82. nowidx: 0,
  83. scoleval: 0,
  84. orderTime: '',
  85. nowdate: '',
  86. cluestate: 1,
  87. activityType: '',
  88. nextdate: "1",
  89. addwxarr: [],
  90. addwxtypeflag: false,
  91. measurenum: '',
  92. measuretime: '',
  93. showPicker: false,
  94. storenum: 1,
  95. loglist: [],
  96. orderactivitydate: '',
  97. activityvalue: '',
  98. subscribelist: [],
  99. amountext: [],
  100. storeArr: [],
  101. amountshow: false,
  102. trackimgarr1: [],
  103. nowimagearr1: [],
  104. depositproductlist: [],
  105. depositproductnum: '',
  106. deposit_mode: '1',
  107. appointype: '',//1是预约活动,2是预约到店
  108. storeactivityvalue: '',
  109. storeactivityid: '',
  110. reachstoretime: "",
  111. subType: "1",
  112. signOrderTagText: "转单",
  113. deliveryTagText: "签单",
  114. contractTagText: "合同",
  115. extarr: [
  116. {
  117. keyname: '',
  118. value: '',
  119. keytext: '',
  120. select: '',
  121. id: ''
  122. }
  123. ],
  124. },
  125. /**
  126. * 组件的方法列表
  127. */
  128. methods: {
  129. getChangeModule() {
  130. if (this.data.clientype == 'vL0CQQ') {
  131. this.setData({
  132. signOrderTagText: "签单",
  133. deliveryTagText: "交定",
  134. contractTagText: "签单"
  135. })
  136. }
  137. const that = this;
  138. utils.$post({
  139. url: app.globalData.webUrl + 'api/crm_customer/changeModule',
  140. header: {
  141. 'Authorization': 'bearer ' + app.globalData.token
  142. },
  143. data: {
  144. id: this.data.nowcid
  145. },
  146. success: function (res) {
  147. if (res.data.code == 0) {
  148. that.setData({
  149. changeModuleObj: res.data.data
  150. })
  151. }
  152. }
  153. })
  154. },
  155. getSubscribeModule() {
  156. const that = this;
  157. utils.$post({
  158. url: app.globalData.webUrl + 'api/crm_customer/subscribeModule',
  159. header: {
  160. 'Authorization': 'bearer ' + app.globalData.token
  161. },
  162. data: {
  163. id: this.data.nowcid
  164. },
  165. success: function (res) {
  166. if (res.data.code == 0) {
  167. that.setData({
  168. subscribeObj: res.data.data
  169. })
  170. }
  171. }
  172. })
  173. },
  174. getModuleSwitch() {
  175. const that = this;
  176. utils.$post({
  177. url: app.globalData.webUrl + 'api/crm_customer/moduleSwitch',
  178. header: {
  179. 'Authorization': 'bearer ' + app.globalData.token
  180. },
  181. data: {},
  182. success: function (res) {
  183. if (res.data.code == 0) {
  184. that.setData({
  185. moduleSwitchObj: res.data.data
  186. })
  187. }
  188. }
  189. })
  190. },
  191. getClueTag() {
  192. const that = this;
  193. utils.$post({
  194. url: app.globalData.webUrl + 'api/crm_customer/clueTag',
  195. header: {
  196. 'Authorization': 'bearer ' + app.globalData.token
  197. },
  198. data: {},
  199. success: function (res) {
  200. if (res.data.code == 0) {
  201. let clueTagArr = res.data.data;
  202. clueTagArr.unshift('自定义');
  203. clueTagArr = clueTagArr.map((v,i) => {
  204. return {id: i+1, text: v};
  205. })
  206. that.setData({
  207. tackarr: clueTagArr
  208. })
  209. }
  210. }
  211. })
  212. },
  213. getVisitField() {
  214. const that = this;
  215. utils.$post({
  216. url: app.globalData.webUrl + 'api/crm_customer/visitField',
  217. header: {
  218. 'Authorization': 'bearer ' + app.globalData.token
  219. },
  220. data: {
  221. id: this.data.nowcid
  222. },
  223. success: function (res) {
  224. if (res.data.code == 0) {
  225. that.setData({
  226. visitField: res.data.data
  227. })
  228. that.selectComponent('#customfield').getField();
  229. }
  230. }
  231. })
  232. },
  233. getShoplistApi() {
  234. if (this.data.storeArr.length) {
  235. return;
  236. }
  237. const that = this;
  238. utils.$post({
  239. url: app.globalData.webUrl + 'api/crm_customer/shop_list',
  240. header: {
  241. 'Authorization': 'bearer ' + app.globalData.token
  242. },
  243. data: {},
  244. success: function (res) {
  245. if (res.data.code == 0) {
  246. that.setData({
  247. storeArr: res.data.data
  248. })
  249. }
  250. }
  251. })
  252. },
  253. setcrmfun(cid) {
  254. const that = this;
  255. utils.$post({
  256. url: app.globalData.webUrl + 'api/crm_customer/get_portrait_field',
  257. header: {
  258. 'Authorization': 'bearer ' + app.globalData.token
  259. },
  260. data: {
  261. id: this.data.nowcid
  262. },
  263. success: function (res) {
  264. if (res.data.code == 0) {
  265. let extarr = [];
  266. for (let i in res.data.data) {
  267. for (let j in res.data.data[i].child) {
  268. if (res.data.data[i].child[j].keyname == 'add_wechat_type') {
  269. let obj = {
  270. keyname: res.data.data[i].child[j].keyname,
  271. value: res.data.data[i].child[j].value ? res.data.data[i].child[j].value : '',
  272. keytext: res.data.data[i].child[j].valname,
  273. select: res.data.data[i].child[j].select,
  274. id: res.data.data[i].child[j].id
  275. };
  276. extarr[0] = obj;
  277. }
  278. }
  279. }
  280. that.setData({
  281. extarr: extarr
  282. })
  283. }
  284. }
  285. })
  286. },
  287. amounthouseimgtap() {
  288. if (this.data.amountarr.length == 1) {
  289. this.uploadimg();
  290. } else {
  291. this.setData({
  292. amountshow: true,
  293. })
  294. }
  295. },
  296. onClose() {
  297. this.setData({
  298. amountshow: false
  299. })
  300. },
  301. onSelect(event) {
  302. let amountext = this.data.amountext;
  303. amountext.push(event.detail.name.slice(2, event.detail.name.length));
  304. this.setData({
  305. amountext: amountext,
  306. amountshow: false,
  307. })
  308. this.uploadimg();
  309. },
  310. prelooktap(e) {
  311. wx.previewImage({
  312. current: this.data.loglist[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  313. urls: this.data.loglist[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
  314. fail(res) {
  315. console.log(res)
  316. }
  317. })
  318. },
  319. previewImg(e) {
  320. wx.previewImage({
  321. current: this.data.visitlogarr[e.currentTarget.dataset.src].img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  322. urls: this.data.visitlogarr[e.currentTarget.dataset.src].img, // 需要预览的图片http链接列表
  323. fail(res) {
  324. console.log(res)
  325. }
  326. })
  327. },
  328. preview1Img(e) {
  329. wx.previewImage({
  330. current: this.data.visitlogarr[e.currentTarget.dataset.src].img1[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  331. urls: this.data.visitlogarr[e.currentTarget.dataset.src].img1, // 需要预览的图片http链接列表
  332. fail(res) {
  333. console.log(res)
  334. }
  335. })
  336. },
  337. preview2Img(e) {
  338. wx.previewImage({
  339. current: this.data.visitlogarr[e.currentTarget.dataset.src].delivery_img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  340. urls: this.data.visitlogarr[e.currentTarget.dataset.src].delivery_img, // 需要预览的图片http链接列表
  341. fail(res) {
  342. console.log(res)
  343. }
  344. })
  345. },
  346. preview3Img(e) {
  347. wx.previewImage({
  348. current: this.data.visitlogarr[e.currentTarget.dataset.src].sign_img[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  349. urls: this.data.visitlogarr[e.currentTarget.dataset.src].sign_img, // 需要预览的图片http链接列表
  350. fail(res) {
  351. console.log(res)
  352. }
  353. })
  354. },
  355. preview4Img(e){
  356. wx.previewImage({
  357. current: this.data.visitlogarr[e.currentTarget.dataset.src].portraitarr[e.currentTarget.dataset.field].valname[e.currentTarget.dataset.idx], // 当前显示图片的http链接
  358. urls: this.data.visitlogarr[e.currentTarget.dataset.src].portraitarr[e.currentTarget.dataset.field].valname, // 需要预览的图片http链接列表
  359. fail(res) {
  360. console.log(res)
  361. }
  362. })
  363. },
  364. cancleappointap(e) {
  365. let that = this;
  366. let obj = this.data.subscribelist[e.currentTarget.dataset.idx];
  367. if (obj.order_type > 0) {
  368. if (obj.type == "预约量房") {
  369. wx.showLoading()
  370. this.addrecord(4, obj.subscribe_date);
  371. }
  372. if (obj.type == "预约到店") {
  373. wx.showLoading()
  374. this.addrecord(5, obj.subscribe_date);
  375. }
  376. if (obj.type == "预约活动") {
  377. wx.showLoading()
  378. this.addrecord(6, obj.subscribe_date);
  379. }
  380. }
  381. },
  382. crmsgfun() {
  383. let date = new Date();
  384. let m = date.getMonth() * 1 + 1;
  385. let d = date.getDate();
  386. let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
  387. this.setData({
  388. amountdate: str,
  389. start: str,
  390. nowdate: str,
  391. visitdate: str
  392. })
  393. this.crmmsgfun();
  394. this.tracklog();
  395. },
  396. dothis() { },
  397. bindPickerChange: function(e) {
  398. this.setData({
  399. storeIndex: e.detail.value
  400. })
  401. },
  402. closetracktap: function () {
  403. this.setData({
  404. trackflag: false
  405. })
  406. },
  407. setstorenumtap(e) {
  408. this.setData({
  409. storenum: e.detail.value
  410. })
  411. },
  412. setorderTimenumtap() {
  413. this.setData({
  414. orderTime: e.detail.value
  415. })
  416. },
  417. getOrderTimeInput(e) {
  418. this.setData({
  419. orderTime: e.detail.value
  420. })
  421. },
  422. setstaylengthnumtap() {
  423. this.setData({
  424. staylength: e.detail.value
  425. })
  426. },
  427. jdHandleClick(e) {
  428. this.setData({
  429. deposit_mode: e.currentTarget.dataset.text
  430. })
  431. },
  432. amountimetap1(e) {
  433. let num = e.currentTarget.dataset.text;
  434. let date = new Date();
  435. let nowTime = date.getTime();
  436. let oneDayTime = 24 * 60 * 60 * 1000;
  437. var day = date.getDay();
  438. //显示周日
  439. var sun = nowTime - (day - 7) * oneDayTime;
  440. //显示周六
  441. var wen = nowTime - (day - 6) * oneDayTime;
  442. let str = num == 1 ? 0 : num == 2 ? 1 : '';
  443. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  444. let year = new Date(timenum).getFullYear();
  445. let month = new Date(timenum).getMonth();
  446. let daystr = new Date(timenum).getDate();
  447. this.setData({
  448. amountime1: num,
  449. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  450. })
  451. if (this.data.tacktype == 3) {
  452. this.setData({
  453. amountime1: num
  454. })
  455. if (num == 5) {
  456. return false;
  457. }
  458. this.setData({
  459. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  460. })
  461. } else if (this.data.tacktype == 4) {
  462. this.setData({
  463. amountime1: num
  464. })
  465. if (num == 5) {
  466. return false;
  467. }
  468. this.setData({
  469. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  470. })
  471. } else if (this.data.tacktype == 5) {
  472. this.setData({
  473. amountime1: num
  474. })
  475. if (num == 5) {
  476. return false;
  477. }
  478. this.setData({
  479. visitdate: year + '-' + (month * 1 + 1) + '-' + daystr
  480. })
  481. }
  482. },
  483. setSubscriteDate(e) {
  484. let num = e.detail;
  485. let date = new Date();
  486. let nowTime = date.getTime();
  487. let oneDayTime = 24 * 60 * 60 * 1000;
  488. var day = date.getDay();
  489. //显示周日
  490. var sun = nowTime - (day - 7) * oneDayTime;
  491. //显示周六
  492. var wen = nowTime - (day - 6) * oneDayTime;
  493. let str = num == 1 ? 0 : num == 2 ? 1 : '';
  494. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  495. let year = new Date(timenum).getFullYear();
  496. let month = new Date(timenum).getMonth();
  497. let daystr = new Date(timenum).getDate();
  498. this.setData({
  499. nextdate: num,
  500. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
  501. })
  502. if (this.data.tacktype == 3) {
  503. this.setData({
  504. nextdate: num
  505. })
  506. if (num == 5) {
  507. return false;
  508. }
  509. this.setData({
  510. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
  511. })
  512. } else if (this.data.tacktype == 4) {
  513. this.setData({
  514. nextdate: num
  515. })
  516. if (num == 5) {
  517. return false;
  518. }
  519. this.setData({
  520. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
  521. })
  522. } else if (this.data.tacktype == 5) {
  523. this.setData({
  524. nextdate: num
  525. })
  526. if (num == 5) {
  527. return false;
  528. }
  529. this.setData({
  530. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr
  531. })
  532. }
  533. },
  534. setlfyyDate(e) {
  535. let num = e.detail;
  536. let date = new Date();
  537. let nowTime = date.getTime();
  538. let oneDayTime = 24 * 60 * 60 * 1000;
  539. var day = date.getDay();
  540. //显示周日
  541. var sun = nowTime - (day - 7) * oneDayTime;
  542. //显示周六
  543. var wen = nowTime - (day - 6) * oneDayTime;
  544. let str = num == 1 ? 0 : num == 2 ? 1 : '';
  545. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  546. let year = new Date(timenum).getFullYear();
  547. let month = new Date(timenum).getMonth();
  548. let daystr = new Date(timenum).getDate();
  549. this.setData({
  550. nextdate: num,
  551. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
  552. })
  553. if (this.data.tacktype == 3) {
  554. this.setData({
  555. nextdate: num
  556. })
  557. if (num == 5) {
  558. return false;
  559. }
  560. this.setData({
  561. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
  562. })
  563. } else if (this.data.tacktype == 4) {
  564. this.setData({
  565. nextdate: num
  566. })
  567. if (num == 5) {
  568. return false;
  569. }
  570. this.setData({
  571. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
  572. })
  573. } else if (this.data.tacktype == 5) {
  574. this.setData({
  575. nextdate: num
  576. })
  577. if (num == 5) {
  578. return false;
  579. }
  580. this.setData({
  581. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr
  582. })
  583. }
  584. },
  585. uptracklogtap: function () {
  586. const that = this;
  587. wx.chooseMedia({
  588. count: 9,
  589. mediaType: ['image'],
  590. sizeType: ['compressed'],
  591. sourceType: ['album', 'camera'],
  592. success(res) {
  593. // tempFilePath可以作为img标签的src属性显示图片
  594. if (res.errMsg == "chooseMedia:ok") {
  595. that.createImagePayment1(res.tempFiles);
  596. }
  597. },
  598. fail(res) {
  599. wx.showToast({
  600. title: '上传失败请重试!',
  601. icon: 'error',
  602. duration: 2000
  603. })
  604. }
  605. })
  606. },
  607. createImagePayment1: function (imgUrl) {
  608. var that = this;
  609. if (imgUrl.length == 0) return;
  610. var lent = that.data.trackimgarr1.length + imgUrl.length;
  611. if (lent > 9) {
  612. lent = 9
  613. } else {
  614. lent = lent;
  615. }
  616. let trackimgarr1 = that.data.trackimgarr1;
  617. let len = imgUrl.length;
  618. if ((trackimgarr1.length + len) > 9) {
  619. for (let j = 0; j < len; j++) {
  620. if (trackimgarr1.length < 9) {
  621. trackimgarr1.push(imgUrl[j]);
  622. }
  623. }
  624. } else {
  625. trackimgarr1 = trackimgarr1.concat(imgUrl);
  626. }
  627. that.setData({
  628. trackimgarr1: trackimgarr1
  629. })
  630. },
  631. uploadimg: function () {
  632. const that = this;
  633. wx.chooseMedia({
  634. count: 9,
  635. mediaType: ['image'],
  636. sizeType: ['compressed'],
  637. sourceType: ['album', 'camera'],
  638. success(res) {
  639. // tempFilePath可以作为img标签的src属性显示图片 res.tempFilePaths
  640. // console.log(res)
  641. // var trackimgarr=that.data.trackimgarr;
  642. if (res.errMsg == "chooseMedia:ok") {
  643. // let len=res.tempFilePaths.length;
  644. that.createImagePayment(res.tempFiles);
  645. // if((trackimgarr.length+len)>9){
  646. // for(let j=0;j<len;j++){
  647. // if(trackimgarr.length<9){
  648. // trackimgarr.push(res.tempFilePaths[j]);
  649. // }
  650. // }
  651. // }else{
  652. // trackimgarr=trackimgarr.concat(res.tempFilePaths);
  653. // }
  654. // that.setData({
  655. // trackimgarr:trackimgarr
  656. // })
  657. }
  658. },
  659. fail(res) {
  660. wx.showToast({
  661. title: '上传失败请重试!',
  662. icon: 'error',
  663. duration: 2000
  664. })
  665. }
  666. })
  667. },
  668. createImagePayment: function (imgUrl) {
  669. var that = this;
  670. if (imgUrl.length == 0) return;
  671. var lent = that.data.trackimgarr.length + imgUrl.length;
  672. if (lent > 9) {
  673. lent = 9
  674. } else {
  675. lent = lent;
  676. }
  677. let trackimgarr = that.data.trackimgarr;
  678. let len = imgUrl.length;
  679. if ((trackimgarr.length + len) > 9) {
  680. for (let j = 0; j < len; j++) {
  681. if (trackimgarr.length < 9) {
  682. trackimgarr.push(imgUrl[j]);
  683. }
  684. }
  685. } else {
  686. trackimgarr = trackimgarr.concat(imgUrl);
  687. }
  688. that.setData({
  689. trackimgarr: trackimgarr
  690. })
  691. },
  692. delimgtap: function (e) {
  693. const that = this;
  694. wx.showModal({
  695. title: '确认删除',
  696. content: '是否删除这张图片?',
  697. success(res) {
  698. if (res.confirm) {
  699. let trackimgarr = that.data.trackimgarr, amountext = that.data.amountext;
  700. trackimgarr.splice(e.currentTarget.dataset.idx, 1)
  701. amountext.splice(e.currentTarget.dataset.idx, 1)
  702. that.setData({
  703. trackimgarr: trackimgarr,
  704. amountext: amountext
  705. })
  706. }
  707. }
  708. })
  709. },
  710. deltracktap: function (e) {
  711. const that = this;
  712. wx.showModal({
  713. title: '确认删除',
  714. content: '是否删除这张图片?',
  715. success(res) {
  716. if (res.confirm) {
  717. let trackimgarr1 = that.data.trackimgarr1;
  718. trackimgarr1.splice(e.currentTarget.dataset.idx, 1)
  719. that.setData({
  720. trackimgarr1: trackimgarr1
  721. })
  722. }
  723. }
  724. })
  725. },
  726. ossuploadimg: function (e) {
  727. let that = this;
  728. let trackimgarr = that.data.trackimgarr;
  729. var arr = [];
  730. for (let i = 0; i < trackimgarr.length; i++) {
  731. //获取文件后缀
  732. // 随机生成文件名称
  733. let rstr = trackimgarr[i].tempFilePath.split('.');
  734. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  735. var imgName = fileRandName + '.' + 'png';
  736. // var fileName = that.data.;
  737. var date = new Date();
  738. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  739. var imgstr = 'crm/' + time + '/' + imgName;
  740. var nowimagearr = that.data.nowimagearr;
  741. nowimagearr.push(imgstr);
  742. that.setData({
  743. nowimagearr: nowimagearr
  744. })
  745. wx.uploadFile({
  746. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  747. filePath: trackimgarr[i].tempFilePath,
  748. name: 'file',
  749. formData: {
  750. // name: that.data.imgSrc[0],
  751. key: 'crm/' + time + '/' + imgName,
  752. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  753. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  754. success_action_status: "200",
  755. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  756. },
  757. header: {
  758. "Content-Type": "multipart/form-data",
  759. 'accept': 'application/json',
  760. },
  761. success: function (rs) {
  762. if (rs.errMsg == 'uploadFile:ok') {
  763. arr.push('0');
  764. if (arr.length == trackimgarr.length) {
  765. that.addrecord();
  766. }
  767. }
  768. },
  769. fail(res) {
  770. wx.hideLoading()
  771. }
  772. })
  773. }
  774. },
  775. setmoney: function (e) {
  776. this.setData({
  777. money: e.detail.value
  778. })
  779. },
  780. setfirstmoney(e) {
  781. this.setData({
  782. firstmoney: e.detail.value
  783. })
  784. },
  785. setwxtypetap(e) {
  786. let text = '', extarr = this.data.extarr;
  787. for (let i in this.data.extarr[0].select) {
  788. if (this.data.extarr[0].select[i].id == e.currentTarget.dataset.text) {
  789. text = this.data.extarr[0].select[i].name;
  790. }
  791. }
  792. if (extarr[0].keytext != text) {
  793. extarr[0].keytext = text;
  794. extarr[0].value = e.currentTarget.dataset.text;
  795. } else {
  796. extarr[0].keytext = text;
  797. extarr[0].value = e.currentTarget.dataset.text;
  798. }
  799. this.setData({
  800. extarr: extarr,
  801. addwxtypeflag: false
  802. })
  803. this.editwxtap();
  804. },
  805. setoptap() {
  806. const that = this;
  807. utils.$post({
  808. url: app.globalData.webUrl + 'api/crmCustomer/customer_top',
  809. header: {
  810. 'Authorization': 'bearer ' + app.globalData.token
  811. },
  812. data: {
  813. type: 2,
  814. id: that.data.nowcid,
  815. },
  816. success: function (res) {
  817. if (res.data.code == '0') {
  818. let customerobj = that.data.customerobj;
  819. if (customerobj.addtoptime) {
  820. customerobj.addtoptime = '';
  821. } else {
  822. customerobj.addtoptime = '2022';
  823. }
  824. that.setData({
  825. customerobj: customerobj
  826. })
  827. that.triggerEvent('myevent', that.data.customerobj)
  828. }
  829. }
  830. })
  831. },
  832. addwxtap() {
  833. let extarr = this.data.extarr;
  834. if (this.data.extarr[0].select.length == 2) {
  835. this.setData({
  836. addwxtypeflag: true
  837. })
  838. } else {
  839. extarr[0].keytext = this.data.extarr[0].select[0].name;
  840. extarr[0].value = this.data.extarr[0].select[0].id;
  841. this.setData({
  842. addwxtypeflag: false,
  843. extarr: extarr
  844. })
  845. this.editwxtap();
  846. }
  847. },
  848. inputap() {
  849. this.setData({
  850. nowtext: !this.data.nowtext
  851. })
  852. },
  853. onChange(event) {
  854. this.setData({
  855. scoleval: event.detail,
  856. });
  857. },
  858. measurehousetap(e) {
  859. let num = e.currentTarget.dataset.type;
  860. // 量房预约
  861. let date = new Date();
  862. let nowTime = date.getTime();
  863. let oneDayTime = 24 * 60 * 60 * 1000;
  864. var day = date.getDay();
  865. //显示周日
  866. var sun = nowTime - (day - 7) * oneDayTime;
  867. //显示周六
  868. var wen = nowTime - (day - 6) * oneDayTime;
  869. let str = num == 1 ? 0 : num == 2 ? 1 : "";
  870. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  871. let year = new Date(timenum).getFullYear();
  872. let month = new Date(timenum).getMonth();
  873. let daystr = new Date(timenum).getDate();
  874. this.setData({
  875. measurenum: num
  876. })
  877. if (num == 5) {
  878. return false;
  879. }
  880. this.setData({
  881. measuretime: year + "-" + (month * 1 + 1) + "-" + daystr
  882. })
  883. if (!!this.data.reachstorenum) {
  884. let num = util.dayDiff(
  885. new Date(this.data.reachstoretime.split("-").join("/")),
  886. new Date(this.data.measuretime.split("-").join("/"))
  887. );
  888. if (num == 0) {
  889. this.setData({
  890. measuretime: '',
  891. measurenum: this.data.measurenum != 5 ? "" : this.data.measurenum
  892. })
  893. wx.showToast({
  894. title: '同一时间只能预约一个提醒,请重新预约!',
  895. icon: 'none',
  896. duration: 2000
  897. })
  898. return false;
  899. }
  900. }
  901. if (!!this.data.activityvalue) {
  902. let num = util.dayDiff(
  903. new Date(this.data.measuretime.split("-").join("/")),
  904. new Date(this.data.orderactivitydate.split("-").join("/"))
  905. );
  906. if (num == 0) {
  907. this.setData({
  908. measuretime: '',
  909. measurenum: this.data.measurenum != 5 ? "" : this.data.measurenum
  910. })
  911. wx.showToast({
  912. title: '同一时间只能预约一个提醒,请重新预约!',
  913. icon: 'none',
  914. duration: 2000
  915. })
  916. }
  917. }
  918. },
  919. // 到店
  920. reachstoretap(e) {
  921. let num = e.currentTarget.dataset.type;
  922. let date = new Date();
  923. let nowTime = date.getTime();
  924. let oneDayTime = 24 * 60 * 60 * 1000;
  925. var day = date.getDay();
  926. //显示周日
  927. var sun = nowTime - (day - 7) * oneDayTime;
  928. //显示周六
  929. var wen = nowTime - (day - 6) * oneDayTime;
  930. let str = num == 1 ? 0 : num == 2 ? 1 : "";
  931. let timenum = num == 3 ? wen : num == 4 ? sun : nowTime + str * oneDayTime;
  932. let year = new Date(timenum).getFullYear();
  933. let month = new Date(timenum).getMonth();
  934. let daystr = new Date(timenum).getDate();
  935. this.setData({
  936. reachstorenum: num
  937. })
  938. if (num == 5) {
  939. return false;
  940. }
  941. this.setData({
  942. reachstoretime: year + "-" + (month * 1 + 1) + "-" + daystr
  943. })
  944. if (!!this.data.measurenum) {
  945. let num = util.dayDiff(
  946. new Date(this.data.reachstoretime.split("-").join("/")),
  947. new Date(this.data.measuretime.split("-").join("/"))
  948. );
  949. if (num == 0) {
  950. this.setData({
  951. reachstoretime: "",
  952. reachstorenum: this.reachstorenum != 5 ? "" : this.reachstorenum
  953. })
  954. wx.showToast({
  955. title: '同一时间只能预约一个提醒,请重新预约!',
  956. icon: 'none',
  957. duration: 2000
  958. })
  959. return false;
  960. }
  961. }
  962. if (!!this.data.activityvalue) {
  963. let num = util.dayDiff(
  964. new Date(this.data.reachstoretime.split("-").join("/")),
  965. new Date(this.data.orderactivitydate.split("-").join("/"))
  966. );
  967. if (num == 0) {
  968. this.setData({
  969. reachstoretime: "",
  970. reachstorenum: this.reachstorenum != 5 ? "" : this.reachstorenum
  971. })
  972. wx.showToast({
  973. title: '同一时间只能预约一个提醒,请重新预约!',
  974. icon: 'none',
  975. duration: 2000
  976. })
  977. }
  978. }
  979. },
  980. setitypetap(e) {
  981. this.setData({
  982. titype: e.currentTarget.dataset.text,
  983. })
  984. if (e.currentTarget.dataset.text == 2) {
  985. let curIndex = "";
  986. let amountext = this.data.amountext;
  987. amountext = [];
  988. if (this.data.amountarr.length == 1) {
  989. amountext[0] = this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
  990. }
  991. if (this.data.changeModuleObj.lf.show == 1) {
  992. curIndex = "3";
  993. } else if (this.data.changeModuleObj.dd.show == 1) {
  994. curIndex = "4";
  995. } else if (this.data.changeModuleObj.hd.show == 1) {
  996. curIndex = "5";
  997. } else if (this.data.changeModuleObj.jd.show == 1) {
  998. curIndex = "6";
  999. } else if (this.data.changeModuleObj.zd.show == 1) {
  1000. curIndex = "7";
  1001. } else {
  1002. curIndex = "8";
  1003. }
  1004. this.setData({
  1005. tacktype: curIndex,
  1006. amountext: amountext,
  1007. trackimgarr: [],
  1008. trackimgarr1: [],
  1009. nowimagearr1: [],
  1010. })
  1011. this.visitlogfun('量房');
  1012. this.packagefun();
  1013. setTimeout(() => {
  1014. this.selectComponent('#customfield').getField();
  1015. },300)
  1016. } else if (e.currentTarget.dataset.text == 3) {
  1017. this.subscribefun();
  1018. if (this.data.subscribeObj.hd.show == 1) {
  1019. if (!this.data.wactivitylist.length) {
  1020. this.setData({
  1021. subType: 1,
  1022. subscribeAbled: true,
  1023. subscribeTitle: "~暂无外场活动-无法预约~"
  1024. })
  1025. } else {
  1026. this.setData({
  1027. subType: 1,
  1028. subscribeAbled: false,
  1029. subscribeTitle: "提交预约"
  1030. })
  1031. }
  1032. } else if (this.data.subscribeObj.dd.show == 1) {
  1033. this.setData({
  1034. subType: 2,
  1035. subscribeAbled: false,
  1036. subscribeTitle: "提交预约"
  1037. })
  1038. } else if (this.data.subscribeObj.lf.show == 1) {
  1039. this.setData({
  1040. subType: 3,
  1041. subscribeAbled: false,
  1042. subscribeTitle: "提交预约"
  1043. })
  1044. }
  1045. setTimeout(() => {
  1046. this.selectComponent('#customfield').getField();
  1047. },300)
  1048. } else {
  1049. setTimeout(() => {
  1050. this.selectComponent('#customfield').getField();
  1051. },300)
  1052. this.setData({
  1053. trackimgarr1: [],
  1054. nowimagearr1: [],
  1055. })
  1056. this.tracklog();
  1057. }
  1058. this.depositinitfun();
  1059. },
  1060. packagefun() {
  1061. const that = this;
  1062. utils.$post({
  1063. url: app.globalData.webUrl + 'api/customerPackage/list',
  1064. header: {
  1065. 'Authorization': 'bearer ' + app.globalData.token
  1066. },
  1067. data: {},
  1068. success: function (res) {
  1069. if (res.data.code == "0") {
  1070. that.setData({
  1071. depositproductlist: res.data.data
  1072. })
  1073. if (!!that.data.customerobj.package_id) {
  1074. for (let i in that.data.depositproductlist) {
  1075. if (that.data.depositproductlist[i].id == that.data.customerobj.package_id) {
  1076. that.setData({
  1077. depositproductnum: i
  1078. })
  1079. }
  1080. }
  1081. } else {
  1082. that.setData({
  1083. depositproductnum: '',
  1084. })
  1085. }
  1086. }
  1087. }
  1088. })
  1089. },
  1090. bindsigndate: function (e) {
  1091. this.setData({
  1092. addtime: e.detail.value
  1093. })
  1094. },
  1095. bindproductap(e) {
  1096. this.setData({
  1097. depositproductnum: e.detail.value
  1098. })
  1099. },
  1100. settacktap(e) {
  1101. this.setData({
  1102. tacktype: e.currentTarget.dataset.text,
  1103. trackimgarr: [],
  1104. nowimagearr: [],
  1105. trackimgarr1: [],
  1106. nowimagearr1: [],
  1107. tacktext: '',
  1108. nowtext1: '自定义',
  1109. amountdate: this.data.nowdate
  1110. })
  1111. let customerobj = this.data.customerobj;
  1112. if (e.currentTarget.dataset.text == 3) {
  1113. let amountext = this.data.amountext;
  1114. amountext = [];
  1115. if (this.data.amountarr.length == 1) {
  1116. amountext[0] = this.data.amountarr[0].name.slice(2, this.data.amountarr[0].name.length)
  1117. }
  1118. this.setData({
  1119. amountext: amountext
  1120. })
  1121. this.visitlogfun('量房');
  1122. } else if (e.currentTarget.dataset.text == 4) {
  1123. this.visitlogfun('到店');
  1124. this.getShoplistApi();
  1125. if (this.data.changeModuleObj.ddhd.show == 1) {
  1126. this.setData({
  1127. activityname: this.data.activityobj.title,
  1128. nowaid: this.data.activityobj.id
  1129. })
  1130. }
  1131. } else if (e.currentTarget.dataset.text == 5) {
  1132. this.visitlogfun('到场');
  1133. let arr = customerobj.subscirbe;
  1134. this.setData({
  1135. activityname: this.data.activityobj.title,
  1136. nowaid: this.data.activityobj.id
  1137. })
  1138. } else if (e.currentTarget.dataset.text == 6) {
  1139. this.depositinitfun();
  1140. } else if (e.currentTarget.dataset.text == 7) {
  1141. this.setData({
  1142. firstmoney: this.data.customerobj.down_payment
  1143. })
  1144. this.signinitfun();
  1145. }
  1146. setTimeout(() => {
  1147. this.selectComponent('#customfield').getField();
  1148. },300)
  1149. },
  1150. setsubtypetap(e) {
  1151. let year = new Date().getFullYear();
  1152. let month = new Date().getMonth();
  1153. let daystr = new Date().getDate();
  1154. if (!this.data.wactivitylist.length && e.currentTarget.dataset.text == 1) {
  1155. this.setData({
  1156. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr,
  1157. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr,
  1158. subType: e.currentTarget.dataset.text,
  1159. subscribeAbled: true,
  1160. subscribeTitle: "~暂无外场活动-无法预约~"
  1161. })
  1162. } else {
  1163. this.setData({
  1164. reachstoretime: year + '-' + (month * 1 + 1) + '-' + daystr,
  1165. measuretime: year + '-' + (month * 1 + 1) + '-' + daystr,
  1166. subType: e.currentTarget.dataset.text,
  1167. subscribeAbled: false,
  1168. subscribeTitle: "提交预约"
  1169. })
  1170. }
  1171. setTimeout(() => {
  1172. this.selectComponent('#customfield').getField();
  1173. },300)
  1174. },
  1175. setextap(e) {
  1176. this.setData({
  1177. nowtext1: e.currentTarget.dataset.text,
  1178. tacktext: e.currentTarget.dataset.text == '自定义' ? '' : e.currentTarget.dataset.text
  1179. })
  1180. },
  1181. setcluestatetap(e) {
  1182. const that = this;
  1183. if (e.currentTarget.dataset.text == 1) {
  1184. if (this.data.customerobj.state == "待确认" || !this.data.customerobj.state) {
  1185. this.setData({
  1186. cluestate: e.currentTarget.dataset.text,
  1187. })
  1188. }
  1189. } else {
  1190. this.setData({
  1191. cluestate: e.currentTarget.dataset.text,
  1192. })
  1193. }
  1194. },
  1195. setcluetypetap(e) {
  1196. this.setData({
  1197. clueType: e.currentTarget.dataset.text
  1198. })
  1199. },
  1200. amountypetap(e) {
  1201. if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5 && this.data.activitylist.length == 0) {
  1202. wx.showToast({
  1203. title: '公司暂无活动不能预约活动',
  1204. icon: 'none',
  1205. duration: 2000
  1206. })
  1207. return false;
  1208. }
  1209. const that = this;
  1210. let day = new Date();
  1211. let month = day.getMonth() * 1 + 1;
  1212. let date = day.getDate();
  1213. let year = day.getFullYear();
  1214. let str = year + '-' + month + '-' + date;
  1215. if (e.currentTarget.dataset.text == '2' && this.data.tacktype == 5) {
  1216. this.setData({
  1217. amountdate: this.data.activitylist[0].start_date,
  1218. nowaid: this.data.activitylist[0].id,
  1219. start: this.data.activitylist[0].start_date,
  1220. end: this.data.activitylist[0].end_date,
  1221. activityname: this.data.activitylist[0].title,
  1222. })
  1223. } else {
  1224. this.setData({
  1225. amountdate: str,
  1226. amountime: 1
  1227. })
  1228. }
  1229. },
  1230. bindwChange: function (e) {
  1231. this.setData({
  1232. amountdate: e.detail.value
  1233. })
  1234. },
  1235. bindvisitChange: function (e) {
  1236. this.setData({
  1237. visitdate: e.detail.value
  1238. })
  1239. },
  1240. setactivitytap() {
  1241. if (this.data.activityobj.cate == 1) {
  1242. this.setData({
  1243. showWPicker: true,
  1244. nowaid: '',
  1245. appointype: 1
  1246. })
  1247. } else {
  1248. this.setData({
  1249. showPicker: true,
  1250. nowaid: '',
  1251. appointype: 1
  1252. })
  1253. }
  1254. },
  1255. setactivitytap1() {
  1256. this.setData({
  1257. showPicker: true,
  1258. nowaid: '',
  1259. appointype: 2
  1260. })
  1261. },
  1262. setactivitytap2() {
  1263. if (this.data.aType == 1) {
  1264. this.setData({
  1265. showPicker: true,
  1266. nowaid: '',
  1267. appointype: 1
  1268. })
  1269. } else {
  1270. this.setData({
  1271. showWPicker: true,
  1272. nowaid: '',
  1273. appointype: 1
  1274. })
  1275. }
  1276. },
  1277. onCancel() {
  1278. this.setData({
  1279. showPicker: false,
  1280. showWPicker: false,
  1281. showSelect: true,
  1282. })
  1283. },
  1284. showDesignerDialog() {
  1285. this.setData({
  1286. showSelect: false,
  1287. })
  1288. },
  1289. submitDesigner(e) {
  1290. let itemArr = e.detail;
  1291. const that = this;
  1292. utils.$post({
  1293. url: app.globalData.webUrl + 'api/crm_customer/reserveDesigner',
  1294. header: {
  1295. 'Authorization': 'bearer ' + app.globalData.token
  1296. },
  1297. data: {
  1298. id: this.data.nowcid,
  1299. designerId: itemArr.map(v => v.id).join(',')
  1300. },
  1301. success: function (res) {
  1302. if (res.data.code == 0) {
  1303. wx.showToast({
  1304. title: '指派成功',
  1305. icon: "success",
  1306. duration: 1500,
  1307. success: function() {
  1308. setTimeout(() => {
  1309. that.setData({
  1310. showSelect: true
  1311. })
  1312. },1500)
  1313. that.crmmsgfun();
  1314. }
  1315. })
  1316. }
  1317. }
  1318. })
  1319. },
  1320. // 量房预约
  1321. clearmeasuretap() {
  1322. this.setData({
  1323. measurenum: '',
  1324. measuretime: ''
  1325. })
  1326. },
  1327. showmeasuretap() {
  1328. this.setData({
  1329. ordertimeshow: true,
  1330. ordertype: 1
  1331. })
  1332. },
  1333. bindlfDate(e) {
  1334. this.setData({
  1335. measuretime: e.detail.value
  1336. })
  1337. },
  1338. cleareachstoretap() {
  1339. this.setData({
  1340. reachstorenum: '',
  1341. reachstoretime: ''
  1342. })
  1343. },
  1344. showreachstoretap() {
  1345. this.setData({
  1346. ordertimeshow: true,
  1347. ordertype: 2
  1348. })
  1349. },
  1350. bindactivityChange: function (e) {
  1351. if (this.data.titype == 2) {
  1352. this.setData({
  1353. showPicker: false,
  1354. start: this.data.activitylist[e.detail.index].start_date,
  1355. end: this.data.activitylist[e.detail.index].end_date,
  1356. activityname: e.detail.value,
  1357. nowaid: this.data.activitylist[e.detail.index].id
  1358. })
  1359. } else if (this.data.titype == 3) {
  1360. this.setData({
  1361. showPicker: false,
  1362. start: this.data.activitylist[e.detail.index].start_date,
  1363. end: this.data.activitylist[e.detail.index].end_date,
  1364. activityvalue: this.data.appointype == 1 ? e.detail.value : this.data.activityvalue,
  1365. nowaid: this.data.activitylist[e.detail.index].id,
  1366. storeactivityvalue: this.data.appointype == 2 ? e.detail.value : this.data.storeactivityvalue,
  1367. storeactivityid: this.data.appointype == 2 ? this.data.activitylist[e.detail.index].id : this.data.storeactivityid,
  1368. })
  1369. }
  1370. },
  1371. onRadioChange(e) {
  1372. this.setData({
  1373. aType: e.detail,
  1374. activityvalue: "",
  1375. nowaid: ""
  1376. })
  1377. },
  1378. bindWactivityChange(e) {
  1379. if (this.data.titype == 2) {
  1380. this.setData({
  1381. showWPicker: false,
  1382. start: this.data.activitylist[e.detail.index].start_date,
  1383. end: this.data.activitylist[e.detail.index].end_date,
  1384. activityname: e.detail.value,
  1385. nowaid: this.data.activitylist[e.detail.index].id
  1386. })
  1387. } else if (this.data.titype == 3) {
  1388. this.setData({
  1389. showWPicker: false,
  1390. start: this.data.activitylist[e.detail.index].start_date,
  1391. end: this.data.activitylist[e.detail.index].end_date,
  1392. activityvalue: this.data.appointype == 1 ? e.detail.value : this.data.activityvalue,
  1393. nowaid: this.data.activitylist[e.detail.index].id,
  1394. storeactivityvalue: this.data.appointype == 2 ? e.detail.value : this.data.storeactivityvalue,
  1395. storeactivityid: this.data.appointype == 2 ? this.data.activitylist[e.detail.index].id : this.data.storeactivityid,
  1396. })
  1397. }
  1398. },
  1399. bindstoretap: function (e) {
  1400. this.setData({
  1401. reachstoretime: e.detail.value,
  1402. reachstorenum: 3
  1403. })
  1404. if (!!this.data.measurenum) {
  1405. let num = util.dayDiff(
  1406. new Date(this.data.reachstoretime.split("-").join("/")),
  1407. new Date(this.data.measuretime.split("-").join("/"))
  1408. );
  1409. if (num == 0) {
  1410. this.setData({
  1411. reachstoretime: "",
  1412. reachstorenum: this.reachstorenum != 5 ? "" : this.reachstorenum
  1413. })
  1414. wx.showToast({
  1415. title: '同一时间只能预约一个提醒,请重新预约!',
  1416. icon: 'none',
  1417. duration: 2000
  1418. })
  1419. return false;
  1420. }
  1421. }
  1422. if (!!this.data.activityvalue) {
  1423. let num = util.dayDiff(
  1424. new Date(this.data.reachstoretime.split("-").join("/")),
  1425. new Date(this.data.orderactivitydate.split("-").join("/"))
  1426. );
  1427. if (num == 0) {
  1428. this.setData({
  1429. reachstoretime: "",
  1430. reachstorenum: this.reachstorenum != 5 ? "" : this.reachstorenum
  1431. })
  1432. wx.showToast({
  1433. title: '同一时间只能预约一个提醒,请重新预约!',
  1434. icon: 'none',
  1435. duration: 2000
  1436. })
  1437. }
  1438. }
  1439. },
  1440. bindactivitytap: function (e) {
  1441. this.setData({
  1442. orderactivitydate: e.detail.value
  1443. })
  1444. if (!!this.data.measurenum) {
  1445. let num = util.dayDiff(
  1446. new Date(this.data.orderactivitydate.split("-").join("/")),
  1447. new Date(this.data.measuretime.split("-").join("/"))
  1448. );
  1449. if (num == 0) {
  1450. this.setData({
  1451. orderactivitydate: ''
  1452. })
  1453. wx.showToast({
  1454. title: '同一时间只能预约一个提醒,请重新预约!',
  1455. icon: 'none',
  1456. duration: 2000
  1457. })
  1458. return false;
  1459. }
  1460. }
  1461. if (!!this.data.reachstorenum) {
  1462. let num = util.dayDiff(
  1463. new Date(this.data.reachstoretime.split("-").join("/")),
  1464. new Date(this.data.orderactivitydate.split("-").join("/"))
  1465. );
  1466. if (num == 0) {
  1467. this.setData({
  1468. orderactivitydate: ''
  1469. })
  1470. wx.showToast({
  1471. title: '同一时间只能预约一个提醒,请重新预约!',
  1472. icon: 'none',
  1473. duration: 2000
  1474. })
  1475. }
  1476. }
  1477. },
  1478. depositinitfun() {
  1479. let date = new Date();
  1480. let year = date.getFullYear();
  1481. let month = date.getMonth();
  1482. month = month * 1 + 1;
  1483. let day = date.getDate();
  1484. let str = year + "-" + month + "-" + day;
  1485. if (!!this.data.customerobj.deposit) {
  1486. this.setData({
  1487. money: this.data.customerobj.deposit_money1 ? this.data.customerobj.deposit_money1 : '',
  1488. addtime: this.data.customerobj.deposit ? this.data.customerobj.deposit.split(' ')[0] : ''
  1489. })
  1490. } else {
  1491. this.setData({
  1492. addtime: str,
  1493. money: ''
  1494. })
  1495. }
  1496. },
  1497. signinitfun() {
  1498. let date = new Date();
  1499. let year = date.getFullYear();
  1500. let month = date.getMonth();
  1501. month = month * 1 + 1;
  1502. let day = date.getDate();
  1503. let str = year + "-" + month + "-" + day;
  1504. if (!!this.data.customerobj.sign) {
  1505. this.setData({
  1506. money: this.data.customerobj.money ? this.data.customerobj.money : '',
  1507. addtime: this.data.customerobj.sign ? this.data.customerobj.sign.split(' ')[0] : ''
  1508. })
  1509. } else {
  1510. this.setData({
  1511. addtime: str,
  1512. money: ''
  1513. })
  1514. }
  1515. },
  1516. typeinitfun() {
  1517. const that = this;
  1518. let day = new Date();
  1519. let month = day.getMonth() * 1 + 1;
  1520. let date = day.getDate();
  1521. let year = day.getFullYear();
  1522. let str = year + '-' + month + '-' + date;
  1523. this.setData({
  1524. visitdate: str,
  1525. amountdate: str,
  1526. nowtext1: '自定义',
  1527. tacktext: ''
  1528. })
  1529. },
  1530. closeaddwxtap() {
  1531. this.setData({
  1532. addwxtypeflag: false
  1533. })
  1534. },
  1535. crmmsgfun() {
  1536. const that = this;
  1537. if (!this.data.nextvisitflag) {
  1538. this.setData({
  1539. visitdate: '',
  1540. amountime1: ''
  1541. })
  1542. } else {
  1543. let date = new Date();
  1544. let m = date.getMonth() * 1 + 1;
  1545. let d = date.getDate();
  1546. let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
  1547. this.setData({
  1548. visitdate: str,
  1549. amountime1: 1
  1550. })
  1551. }
  1552. this.getChangeModule();
  1553. this.getSubscribeModule();
  1554. this.getModuleSwitch();
  1555. this.getClueTag();
  1556. this.getVisitField();
  1557. utils.$post({
  1558. url: app.globalData.webUrl + 'api/crm_customer/detail',
  1559. header: {
  1560. 'Authorization': 'bearer ' + app.globalData.token
  1561. },
  1562. data: {
  1563. id: this.data.nowcid
  1564. },
  1565. success: function (res) {
  1566. if (res.data.code == "0") {
  1567. let apointobj = that.data.apointobj;
  1568. that.setData({
  1569. customerobj: res.data.data
  1570. })
  1571. let arr = res.data.data.subscirbe;
  1572. apointobj = {};
  1573. for (let i in arr) {
  1574. if (arr[i].type == '预约活动') {
  1575. that.setData({
  1576. activityname: arr[i].activity.title,
  1577. nowaid: arr[i].aid
  1578. })
  1579. }
  1580. apointobj[arr[i].type] = arr[i].subscribe_date;
  1581. }
  1582. that.setData({
  1583. apointobj: apointobj,
  1584. cluestate: that.data.customerobj.state == "待确认" ? 1 : 2
  1585. })
  1586. }
  1587. }
  1588. })
  1589. },
  1590. editwxtap() {
  1591. const that = this;
  1592. utils.$post({
  1593. url: app.globalData.webUrl + 'api/crm_customer/add_customer_extfield',
  1594. header: {
  1595. 'Authorization': 'bearer ' + app.globalData.token
  1596. },
  1597. data: {
  1598. id: that.data.nowcid,
  1599. alertshow: '1',
  1600. ext: [
  1601. {
  1602. id: this.data.extarr[0].id,
  1603. keyname: this.data.extarr[0].keyname,
  1604. value: this.data.extarr[0].value
  1605. }
  1606. ]
  1607. },
  1608. success: function (res) {
  1609. if (res.data.code == "0") {
  1610. }
  1611. }
  1612. })
  1613. },
  1614. tracklog: function (e) {
  1615. let that = this;
  1616. utils.$post({
  1617. url: app.globalData.webUrl + 'api/crm_customer/visitlog',
  1618. header: {
  1619. 'Authorization': 'bearer ' + app.globalData.token
  1620. },
  1621. data: {
  1622. id: that.data.nowcid
  1623. },
  1624. success: function (res) {
  1625. setTimeout(() => {
  1626. wx.hideLoading()
  1627. }, 1000)
  1628. if (res.data.code == "0") {
  1629. let t = 0;
  1630. var str = "red";
  1631. for (let i = 0; i < res.data.data.length; i++) {
  1632. res.data.data[i].portraitarr=JSON.parse(res.data.data[i].save_portrait_field);
  1633. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1634. if (i == 0) {
  1635. res.data.data[0].color = str;
  1636. t = t * 1 + 1;
  1637. } else if (res.data.data[i].addtime.split(' ')[0] != res.data.data[i - 1].addtime.split(' ')[0]) {
  1638. t = t * 1 + 1;
  1639. if (t % 3 == 0) {
  1640. str = 'red';
  1641. } else if (t % 3 == 1) {
  1642. str = 'blue';
  1643. } else if (t % 3 == 2) {
  1644. str = 'cyan';
  1645. }
  1646. res.data.data[i].color = str;
  1647. } else {
  1648. res.data.data[i].color = str;
  1649. }
  1650. if(res.data.data[i].portraitarr){
  1651. for(let j=0;j<res.data.data[i].portraitarr.length;j++){
  1652. if(res.data.data[i].portraitarr[j].type==6){
  1653. res.data.data[i].portraitarr[j].valname=res.data.data[i].portraitarr[j].valname.split(',');
  1654. }
  1655. }
  1656. }
  1657. }
  1658. that.setData({
  1659. visitlogarr: res.data.data,
  1660. visitcount: res.data.count,
  1661. })
  1662. }
  1663. }
  1664. })
  1665. },
  1666. visitlogfun: function (text) {
  1667. let that = this;
  1668. utils.$post({
  1669. url: app.globalData.webUrl + 'api/crmCustomer/visitlogDetails',
  1670. header: {
  1671. 'Authorization': 'bearer ' + app.globalData.token
  1672. },
  1673. data: {
  1674. id: that.data.nowcid,
  1675. state: text == "活动" ? "到场" : text,
  1676. },
  1677. success: function (res) {
  1678. setTimeout(() => {
  1679. wx.hideLoading()
  1680. }, 1000)
  1681. if (res.data.code == "0") {
  1682. for (let i = 0; i < res.data.data.length; i++) {
  1683. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1684. }
  1685. that.setData({
  1686. loglist: res.data.data
  1687. })
  1688. }
  1689. }
  1690. })
  1691. },
  1692. subscribefun() {
  1693. let that = this;
  1694. utils.$post({
  1695. url: app.globalData.webUrl + 'api/crmCustomer/subscribe',
  1696. header: {
  1697. 'Authorization': 'bearer ' + app.globalData.token
  1698. },
  1699. data: {
  1700. id: that.data.nowcid,
  1701. },
  1702. success: function (res) {
  1703. setTimeout(() => {
  1704. wx.hideLoading()
  1705. }, 1000)
  1706. if (res.data.code == "0") {
  1707. let date = new Date();
  1708. let year = date.getFullYear();
  1709. let month = date.getMonth();
  1710. month = month * 1 + 1;
  1711. let day = date.getDate();
  1712. let date1 = year + "/" + month + "/" + day;
  1713. for (let i = 0; i < res.data.data.length; i++) {
  1714. let num = util.dayDiff(
  1715. new Date(res.data.data[i].subscribe_date.split('-').join('/')),
  1716. new Date(date1)
  1717. );
  1718. res.data.data[i].order_type = num >= 0 ? 1 : 0;
  1719. res.data.data[i].colortime = res.data.data[i].addtime.split(' ')[0];
  1720. }
  1721. that.setData({
  1722. subscribelist: res.data.data
  1723. })
  1724. }
  1725. }
  1726. })
  1727. },
  1728. getstate: function (num) {
  1729. const that = this;
  1730. switch (this.data.titype * 1) {
  1731. case 1:
  1732. let str = "";
  1733. str = this.data.cluestate == 1 ? "待确认" : this.data.cluestate == 2 ? "未到访" : "无效";
  1734. return str;
  1735. case 2:
  1736. let str1 = "";
  1737. str1 =
  1738. that.data.tacktype == 3
  1739. ? "已量房"
  1740. : this.data.tacktype == 4
  1741. ? "已到店"
  1742. : this.data.tacktype == 5
  1743. ? "已到场"
  1744. : this.data.tacktype == 6
  1745. ? "已交定"
  1746. : this.data.tacktype == 7
  1747. ? "已签单"
  1748. : "预约回访";
  1749. return str1;
  1750. case 3:
  1751. let str2 = "";
  1752. str2 =
  1753. num == 1
  1754. ? "预约量房"
  1755. : num == 2
  1756. ? "预约到店"
  1757. : num == 3
  1758. ? "预约活动"
  1759. : num == 4
  1760. ? "未量房"
  1761. : num == 5
  1762. ? "未到店"
  1763. : num == 6
  1764. ? "未到场"
  1765. : "";
  1766. return str2;
  1767. default:
  1768. break;
  1769. }
  1770. },
  1771. addappointap() {
  1772. const that = this;
  1773. if (!!this.data.measuretime) {
  1774. this.addrecord(1);
  1775. }
  1776. if (!!this.data.reachstoretime) {
  1777. this.addrecord(2);
  1778. }
  1779. if (!!this.data.nowaid && !!this.data.orderactivitydate) {
  1780. this.addrecord(3);
  1781. }
  1782. },
  1783. ossuploadimg1: function (e) {
  1784. let that = this;
  1785. let trackimgarr = that.data.trackimgarr1;
  1786. var arr = [];
  1787. for (let i = 0; i < trackimgarr.length; i++) {
  1788. //获取文件后缀
  1789. // 随机生成文件名称
  1790. let rstr = trackimgarr[i].tempFilePath.split('.');
  1791. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  1792. var imgName = fileRandName + '.' + 'png';
  1793. // var fileName = that.data.;
  1794. var date = new Date();
  1795. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  1796. var imgstr = 'crm/' + time + '/' + imgName;
  1797. var nowimagearr = that.data.nowimagearr1;
  1798. nowimagearr.push(imgstr);
  1799. that.setData({
  1800. nowimagearr1: nowimagearr
  1801. })
  1802. wx.uploadFile({
  1803. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  1804. filePath: trackimgarr[i].tempFilePath,
  1805. name: 'file',
  1806. formData: {
  1807. // name: that.data.imgSrc[0],
  1808. key: 'crm/' + time + '/' + imgName,
  1809. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  1810. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  1811. success_action_status: "200",
  1812. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  1813. },
  1814. header: {
  1815. "Content-Type": "multipart/form-data",
  1816. 'accept': 'application/json',
  1817. },
  1818. success: function (rs) {
  1819. if (rs.errMsg == 'uploadFile:ok') {
  1820. arr.push('0');
  1821. if (arr.length == trackimgarr.length) {
  1822. that.addrecord();
  1823. }
  1824. }
  1825. },
  1826. fail(res) {
  1827. wx.hideLoading()
  1828. }
  1829. })
  1830. }
  1831. },
  1832. addrecord: function (num, time) {
  1833. this.selectComponent('#customfield').addCustomer();
  1834. let that = this;
  1835. wx.showLoading({
  1836. title: '加载中...',
  1837. })
  1838. utils.$post({
  1839. url: app.globalData.webUrl + 'api/crm_customer/addvisitlog',
  1840. header: {
  1841. 'Authorization': 'bearer ' + app.globalData.token
  1842. },
  1843. data: {
  1844. customer_id: that.data.nowcid,
  1845. img: that.data.titype == 2 && that.data.tacktype == 3 ? that.data.nowimagearr.join(',') : '',
  1846. img1: that.data.titype == 1 ? that.data.nowimagearr1.join(',') : '',
  1847. delivery_img: that.data.titype == 2 && that.data.tacktype == 6 ? that.data.nowimagearr1.join(',') : '',
  1848. sign_img: that.data.titype == 2 && that.data.tacktype == 7 ? that.data.nowimagearr1.join(',') : '',
  1849. type: this.data.clueType,
  1850. next_contact_date: that.data.visitdate,
  1851. remark: that.data.tacktext,
  1852. starts: that.data.scoleval * 2,
  1853. state: that.getstate(num),
  1854. 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 : '',
  1855. money: this.data.money,
  1856. deposit_mode: this.data.deposit_mode,
  1857. 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 : '',
  1858. number_of_visitors: that.data.titype == 2 && that.data.tacktype == 4 ? that.data.storenum : '',
  1859. measure_room_img_type: that.data.titype == 2 && that.data.tacktype == 3 ? that.data.amountext.length > 0 ? that.data.amountext.join(',') : '' : '',
  1860. package: this.data.titype == 2 && this.data.tacktype == 6 ? this.data.depositproductlist.length > 0 && this.data.depositproductnum !== '' ? this.data.depositproductlist[this.data.depositproductnum].id : '' : '',
  1861. talking_order_time: this.data.titype == 2 && this.data.tacktype == 4 ? this.data.orderTime : "",
  1862. stay_length: this.data.titype == 2 && this.data.tacktype == 5 ? this.data.staylength : "",
  1863. down_payment: this.data.titype == 2 && this.data.tacktype == 7 ? this.data.firstmoney : "",
  1864. shop_id: this.data.titype == 2 && this.data.tacktype == 4 && (this.data.storeIndex || this.data.storeIndex == 0) ? this.data.storeArr[this.data.storeIndex].id : ''
  1865. },
  1866. success: function (res) {
  1867. wx.hideLoading()
  1868. if (res.data.code == "0") {
  1869. wx.showToast({
  1870. title: res.data.msg,
  1871. icon: 'none',
  1872. duration: 2000
  1873. })
  1874. that.crmmsgfun();
  1875. that.typeinitfun();
  1876. if (that.data.titype == 1) {
  1877. that.setData({
  1878. trackimgarr1: [],
  1879. nowimagearr1: [],
  1880. })
  1881. that.tracklog();
  1882. } else if (that.data.titype == 2) {
  1883. let amountext = that.data.amountext;
  1884. amountext = [];
  1885. if (that.data.amountarr.length == 1) {
  1886. amountext[0] = that.data.amountarr[0].name.slice(2, that.data.amountarr[0].name.length)
  1887. }
  1888. that.setData({
  1889. tacktype: 3,
  1890. amountext: amountext,
  1891. orderTime: "",
  1892. staylength: "",
  1893. firstmoney: "",
  1894. trackimgarr1: [],
  1895. nowimagearr1: [],
  1896. })
  1897. that.visitlogfun('量房');
  1898. that.tracklog();
  1899. } else if (that.data.titype == 3) {
  1900. that.setData({
  1901. nowaid: '',
  1902. activityvalue: '',
  1903. orderactivitydate: '',
  1904. reachstoretime: '',
  1905. reachstorenum: '',
  1906. measurenum: '',
  1907. measuretime: '',
  1908. appointype: '',
  1909. storeactivityid: '',
  1910. storeactivityvalue: ''
  1911. })
  1912. that.subscribefun();
  1913. }
  1914. that.setData({
  1915. trackimgarr: [],
  1916. nowimagearr: [],
  1917. tacktext: '',
  1918. money: '',
  1919. storeIndex: null
  1920. })
  1921. that.triggerEvent("run", '')
  1922. }
  1923. }
  1924. })
  1925. },
  1926. saverecordtap: function (e) {
  1927. const that = this;
  1928. 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) {
  1929. if (this.data.nextvisitflag && !that.data.visitdate) {
  1930. wx.showToast({
  1931. title: "下次回访时间不能为空",
  1932. icon: 'none',
  1933. duration: 2000
  1934. })
  1935. return false;
  1936. }
  1937. }
  1938. if (that.data.titype == 2 && that.data.tacktype == 3) {
  1939. if (that.data.trackimgarr.length > 0) {
  1940. that.ossuploadimg();
  1941. } else {
  1942. wx.showToast({
  1943. title: "确定量房必须传照片!",
  1944. icon: 'none',
  1945. duration: 2000
  1946. })
  1947. }
  1948. } else if (that.data.titype == 2 && that.data.tacktype == 6) {
  1949. if (that.data.trackimgarr1.length > 0) {
  1950. that.ossuploadimg1();
  1951. } else {
  1952. wx.showToast({
  1953. title: `请上传${that.data.deliveryTagText}依据!`,
  1954. icon: 'none',
  1955. duration: 2000
  1956. })
  1957. return;
  1958. }
  1959. } else if (that.data.titype == 2 && that.data.tacktype == 7) {
  1960. if (that.data.trackimgarr1.length > 0) {
  1961. that.ossuploadimg1();
  1962. } else {
  1963. wx.showToast({
  1964. title: `请上传${that.data.contractTagText}依据!`,
  1965. icon: 'none',
  1966. duration: 2000
  1967. })
  1968. return;
  1969. }
  1970. } else {
  1971. if (that.data.titype == 1) {
  1972. if (that.data.trackimgarr1.length > 0) {
  1973. that.ossuploadimg1();
  1974. } else {
  1975. that.addrecord();
  1976. }
  1977. } else {
  1978. that.addrecord();
  1979. }
  1980. }
  1981. },
  1982. }
  1983. })