activitymsg.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. const app = getApp();
  2. var utils = require("../../../utils/http")
  3. const util = require("../../../utils/util");
  4. let page = 1, sharepage = 1;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgUrl: app.globalData.imgUrl,
  11. clientype: app.globalData.clientype,
  12. aid: '',
  13. activityobj: {},
  14. itemDataMsg: {},
  15. wshareshow: false,
  16. showAction: false,
  17. titype: 1,
  18. trackflag: false,
  19. tracktype: '1',
  20. customerlist: [],
  21. trackimgarr: [],
  22. nowimagearr: [],
  23. actions: [],
  24. nowcid: '',
  25. recordtext: '',
  26. visitobj: {},
  27. housestate: '预约回访',
  28. seletime: '',
  29. visitcount: 0,
  30. visitlogarr: [],
  31. statype: '1',
  32. activitylist: [],
  33. wactivitylist: [],
  34. wcolumns: [],
  35. activityname: '',
  36. invitecrm: [],
  37. showUpcrm: [],
  38. datashow: true,
  39. start: "",
  40. end: '',
  41. columns: [],
  42. showPicker: false,
  43. nowaid: '',
  44. personobj: app.globalData.personMsg,
  45. typeflag: false,
  46. ranktype: '预约',
  47. orgtype: '公司排行',
  48. shareranklist: [],
  49. gotranklist: [],
  50. sharemyrankobj: {},
  51. gotmyrankobj: {},
  52. topdataobj: {},
  53. type: 1,
  54. tacktype: 1,
  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. timeshow: false,
  71. amountime: 1,
  72. amountime1: 1,
  73. visitdate: '',
  74. apointobj: {},
  75. customerobj: {},
  76. nowidx: 0,
  77. scoleval: 0,
  78. nowdate: '',
  79. cluestate: 1,
  80. activityType: '',
  81. addwxarr: [],
  82. addwxtypeflag: false,
  83. nextvisitflag: false,//true是必填,false不必传 下次回访时间
  84. measurenum: '',
  85. measuretime: '',
  86. amountarr: [],
  87. signOrderTagText: "转单",
  88. deliveryTagText: "签单",
  89. signTag: "转",
  90. deliveryTag: "签"
  91. },
  92. /**
  93. * 生命周期函数--监听页面加载
  94. */
  95. onLoad: function (options) {
  96. if (this.data.clientype == 'vL0CQQ') {
  97. this.setData({
  98. signOrderTagText: "签单",
  99. deliveryTagText: "交定",
  100. signTag: "签",
  101. deliveryTag: "定"
  102. })
  103. }
  104. let date = new Date();
  105. let m = date.getMonth() * 1 + 1;
  106. let d = date.getDate();
  107. let str = date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? ('0' + d) : d);
  108. this.setData({
  109. aid: options.aid,
  110. amountdate: str,
  111. start: str,
  112. nowdate: str,
  113. personobj: app.globalData.personMsg,
  114. imgUrl: app.globalData.imgUrl,
  115. })
  116. if (!!options.type) {
  117. this.setData({
  118. activityType: options.type
  119. })
  120. }
  121. if (!!options.type && options.type == 'broker') {
  122. this.activityfun();
  123. } else {
  124. this.crmtopdatafun();
  125. this.activityfun();
  126. this.crmlistfun();
  127. this.ranklistfun();
  128. this.activitylistfun('0');
  129. this.activitylistfun('1');
  130. }
  131. if(options.ltype){
  132. this.setData({
  133. type:options.ltype
  134. })
  135. }
  136. },
  137. crmtopdatafun() {
  138. const that = this;
  139. utils.$post({
  140. url: app.globalData.webUrl + 'api/activity/statistics',
  141. header: {
  142. 'Authorization': 'bearer ' + app.globalData.token
  143. },
  144. data: {
  145. aid: that.data.aid,
  146. },
  147. success: function (res) {
  148. if (res.data.code == '0') {
  149. that.setData({
  150. topdataobj: res.data.data
  151. })
  152. }
  153. }
  154. })
  155. },
  156. setranktypetap(e) {
  157. this.setData({
  158. ranktype: e.currentTarget.dataset.text
  159. })
  160. this.ranklistfun();
  161. },
  162. typeinitfun() {
  163. const that = this;
  164. let day = new Date();
  165. let month = day.getMonth() * 1 + 1;
  166. let date = day.getDate();
  167. let year = day.getFullYear();
  168. let str = year + '-' + month + '-' + date;
  169. this.setData({
  170. visitdate: str,
  171. amountdate: str,
  172. nowtext1: '自定义',
  173. tacktext: ''
  174. })
  175. },
  176. openorgtypetap(e) {
  177. this.setData({
  178. typeflag: true,
  179. })
  180. },
  181. closeorgtypetap(e) {
  182. this.setData({
  183. typeflag: false
  184. })
  185. },
  186. setorgtypetap(e) {
  187. this.setData({
  188. orgtype: e.currentTarget.dataset.type,
  189. typeflag: false
  190. })
  191. this.ranklistfun();
  192. },
  193. ranklistfun() {
  194. const that = this;
  195. sharepage = 1;
  196. var str = "api/activity/ranking_list";
  197. let data = {
  198. id: that.data.aid,
  199. type: that.data.ranktype,
  200. is_org: this.data.orgtype == '公司排行' ? 0 : '1',//0公司排行,1团队排行,
  201. page: sharepage,
  202. limit: 15,
  203. };
  204. if (this.data.orgtype == '部门排行') {
  205. str = "api/activity/org_ranking_list";
  206. data = {
  207. id: that.data.aid,
  208. type: that.data.ranktype,
  209. page: sharepage,
  210. limit: 15,
  211. };
  212. }
  213. utils.$post({
  214. url: app.globalData.webUrl + str,
  215. header: {
  216. 'Authorization': 'bearer ' + app.globalData.token
  217. },
  218. data: data,
  219. success: function (res) {
  220. setTimeout(() => {
  221. wx.hideLoading()
  222. }, 1000)
  223. if (res.data.code == "0") {
  224. if (that.data.orgtype == '公司排行' || that.data.orgtype == '团队排行') {
  225. that.setData({
  226. shareranklist: res.data.data.data,
  227. sharemyrankobj: res.data.data.my,
  228. })
  229. } else {
  230. that.setData({
  231. gotranklist: res.data.data.data,
  232. gotmyrankobj: res.data.data.my,
  233. })
  234. }
  235. }
  236. }
  237. })
  238. },
  239. setoptap(obj) {
  240. const that = this;
  241. let customerobj = obj.detail;
  242. // 详情的状态已经修改过了
  243. if (!customerobj.addtoptime) {
  244. this.crmlistfun();
  245. } else {
  246. if (that.data.statype == 1) {
  247. let invitecrm = [];
  248. invitecrm = invitecrm.concat(that.data.invitecrm);
  249. invitecrm[that.data.nowidx].addtoptime = '2022';
  250. var obj = invitecrm.splice(that.data.nowidx, 1);
  251. invitecrm.unshift(obj[0]);
  252. that.setData({
  253. invitecrm: invitecrm
  254. })
  255. } else {
  256. let showUpcrm = [];
  257. showUpcrm = showUpcrm.concat(that.data.showUpcrm);
  258. showUpcrm[that.data.nowidx].addtoptime = '2022';
  259. var obj = showUpcrm.splice(that.data.nowidx, 1);
  260. showUpcrm.unshift(obj[0]);
  261. that.setData({
  262. showUpcrm: showUpcrm
  263. })
  264. }
  265. }
  266. },
  267. setypetap(e) {
  268. this.setData({
  269. type: e.currentTarget.dataset.type
  270. })
  271. if (this.data.type == 1) {
  272. this.setData({
  273. tacktype: 1,
  274. cluestate: this.data.customerobj.state == "待确认" ? 1 : 2
  275. })
  276. } else if (this.data.type == 2) {
  277. this.setData({
  278. tacktype: 3
  279. })
  280. }
  281. },
  282. bindsignChange: function (e) {
  283. this.setData({
  284. amountdate: e.detail.value
  285. })
  286. },
  287. bindsigndate1: function (e) {
  288. this.setData({
  289. addtime: e.detail.value
  290. })
  291. },
  292. dothis() { },
  293. trackfuntap: function (e) {
  294. this.setData({
  295. tracktype: e.currentTarget.dataset.type
  296. })
  297. },
  298. textareatap: function (e) {
  299. const that = this;
  300. if (this.data.nowtext1 != '自定义') {
  301. if (this.data.tacktext.indexOf(this.data.nowtext1) != 0) {
  302. that.setData({
  303. tacktext: this.data.nowtext1
  304. })
  305. } else {
  306. that.setData({
  307. tacktext: e.detail.value
  308. })
  309. }
  310. } else {
  311. that.setData({
  312. tacktext: e.detail.value
  313. })
  314. }
  315. },
  316. addtracktap: function (e) {
  317. this.getsetfun();
  318. this.setData({
  319. trackflag: true,
  320. nowcid: e.currentTarget.dataset.aid,
  321. nowidx: e.currentTarget.dataset.idx,
  322. })
  323. this.selectComponent('#addtrack').setcrmfun();
  324. this.activitylistfun('0');
  325. this.activitylistfun('1');
  326. this.typeinitfun();
  327. },
  328. // 加微类型等
  329. getsetfun() {
  330. const that = this;
  331. utils.$post({
  332. url: app.globalData.webUrl + 'api/crm_customer/get_setting',
  333. header: {
  334. 'Authorization': 'bearer ' + app.globalData.token
  335. },
  336. data: {},
  337. success: function (res) {
  338. if (res.data.code == 0) {
  339. var arr = res.data.data.img_type, amountarr = [];
  340. for (let i in arr) {
  341. let obj = {
  342. id: i,
  343. name: "上传" + arr[i],
  344. color: "#384855",
  345. };
  346. amountarr.push(obj);
  347. }
  348. that.setData({
  349. addwxarr: res.data.data.wechat_type,
  350. nextvisitflag: res.data.data.next_visit_time_is_ok == 1 ? true : false,
  351. amountarr: amountarr
  352. })
  353. }
  354. that.loginbox = that.selectComponent("#addtrack");
  355. that.loginbox.crmsgfun();
  356. }
  357. })
  358. },
  359. activitylistfun(cate) {
  360. const that = this;
  361. utils.$post({
  362. url: app.globalData.webUrl + 'api/activity/activity_list',
  363. header: {
  364. 'Authorization': 'bearer ' + app.globalData.token
  365. },
  366. data: {
  367. cate: cate
  368. },
  369. success: function (res) {
  370. setTimeout(() => {
  371. wx.hideLoading()
  372. }, 1000)
  373. if (res.data.code == "0") {
  374. if (cate == '0') {
  375. let columns = [];
  376. for (let i in res.data.data) {
  377. columns.push(res.data.data[i].title)
  378. }
  379. that.setData({
  380. activitylist: res.data.data,
  381. columns: columns
  382. })
  383. } else {
  384. let columns1 = [];
  385. for (let i in res.data.data) {
  386. columns1.push(res.data.data[i].title)
  387. }
  388. that.setData({
  389. wactivitylist: res.data.data,
  390. wcolumns: columns1
  391. })
  392. }
  393. }
  394. }
  395. })
  396. },
  397. statypetap(e) {
  398. this.setData({
  399. statype: e.currentTarget.dataset.type
  400. })
  401. this.crmlistfun();
  402. },
  403. crmmsgtap(e) {
  404. wx.navigateTo({
  405. url: "/pages/other/other?cid=" + e.currentTarget.dataset.aid + '&type=88&aid=' + this.data.aid,
  406. });
  407. },
  408. crmlistfun() {
  409. const that = this;
  410. page = 1;
  411. utils.$post({
  412. url: app.globalData.webUrl + 'api/activity/invite_list',
  413. header: {
  414. 'Authorization': 'bearer ' + app.globalData.token
  415. },
  416. data: {
  417. p: page,
  418. pagesize: 15,
  419. aid: that.data.aid,
  420. type: that.data.statype == 1 ? '预约活动' : that.data.statype == 2 ? '已到场' : that.data.statype == 3 ? '已交定' : '已签单'
  421. },
  422. success: function (res) {
  423. if (res.data.code == '0') {
  424. for (let i = 0; i < res.data.data.length; i++) {
  425. res.data.data[i].lastday = util.nowdayDiff(
  426. res.data.data[i].last_contact_date
  427. );
  428. }
  429. if (that.data.statype == 1) {
  430. that.setData({
  431. invitecrm: res.data.data
  432. })
  433. } else {
  434. that.setData({
  435. showUpcrm: res.data.data
  436. })
  437. }
  438. }
  439. }
  440. })
  441. },
  442. callphonetap(e) {
  443. const that = this;
  444. wx.showLoading({
  445. title: '正在拨打电话...',
  446. })
  447. utils.$post({
  448. url: app.globalData.webUrl + 'api/crmCustomer/getCrmPhone',
  449. header: {
  450. 'Authorization': 'bearer ' + app.globalData.token
  451. },
  452. data: {
  453. id: e.currentTarget.dataset.aid
  454. },
  455. success: function (res) {
  456. if (res.data.code == 0) {
  457. wx.hideLoading();
  458. let dataObj = res.data;
  459. dataObj.aid = e.currentTarget.dataset.aid;
  460. that.setData({
  461. itemDataMsg: dataObj
  462. })
  463. if (dataObj.out_call_check == 1) {
  464. if (dataObj.out_call_phone.length == 1) {
  465. that.onCallBindFunc(dataObj.out_call_phone[0],dataObj);
  466. } else {
  467. let mobileArr = dataObj.out_call_phone.map(v => {
  468. return {name: v};
  469. })
  470. that.setData({
  471. actions: mobileArr,
  472. showAction: true
  473. })
  474. }
  475. } else {
  476. that.onCallBindFunc(dataObj.out_call_phone[0],dataObj);
  477. }
  478. } else {
  479. wx.hideLoading();
  480. }
  481. }
  482. })
  483. },
  484. outCallMobileApi(dataObj) {
  485. const that = this;
  486. utils.$post({
  487. url: app.globalData.webUrl + 'api/outCall/mobile',
  488. header: {
  489. 'Authorization': 'bearer ' + app.globalData.token
  490. },
  491. data: {
  492. id: dataObj.aid,
  493. alertshow: '123'
  494. },
  495. success: function (res) {
  496. if (res.data.code == 1) {}
  497. }
  498. })
  499. },
  500. onCallBindFunc(phone,dataObj) {
  501. const that = this;
  502. utils.$post({
  503. url: app.globalData.webUrl + 'api/outCall/bind',
  504. header: {
  505. 'Authorization': 'bearer ' + app.globalData.token
  506. },
  507. data: {
  508. phone: phone,
  509. customer_id: dataObj.aid,
  510. alertshow: '123'
  511. },
  512. success: function (res) {
  513. wx.hideLoading();
  514. if (res.data.code == 1) {
  515. that.outCallMobileApi(dataObj);
  516. wx.makePhoneCall({
  517. phoneNumber: dataObj.phone.phone ? dataObj.phone.phone : dataObj.phone.phone1 ? dataObj.phone.phone1 : dataObj.phone.phone2,
  518. success() {
  519. that.getsetfun();
  520. that.setData({
  521. trackflag: true,
  522. nowcid: dataObj.aid,
  523. })
  524. that.selectComponent('#addtrack').setcrmfun();
  525. that.activitylistfun('0');
  526. that.activitylistfun('1');
  527. that.typeinitfun();
  528. }
  529. })
  530. } else {
  531. if (res.data.mobile) {
  532. wx.makePhoneCall({
  533. phoneNumber: res.data.mobile,
  534. success() {
  535. that.getsetfun();
  536. that.setData({
  537. trackflag: true,
  538. nowcid: dataObj.aid,
  539. })
  540. that.selectComponent('#addtrack').setcrmfun();
  541. that.activitylistfun('0');
  542. that.activitylistfun('1');
  543. that.typeinitfun();
  544. }
  545. })
  546. } else {
  547. wx.showLoading({
  548. title: '电话拨通中,请等待5s-10s',
  549. duration: 5000,
  550. icon: "none"
  551. })
  552. setTimeout(() => {
  553. wx.hideLoading();
  554. },5000)
  555. }
  556. }
  557. }
  558. })
  559. },
  560. onClose() {
  561. const that = this;
  562. this.setData({
  563. showAction: false,
  564. trackflag: true,
  565. nowcid: this.data.itemDataMsg.aid,
  566. })
  567. that.getsetfun();
  568. that.selectComponent('#addtrack').setcrmfun();
  569. that.activitylistfun('0');
  570. that.activitylistfun('1');
  571. that.typeinitfun();
  572. },
  573. onSelect(e) {
  574. this.onCallBindFunc(e.detail.name,this.data.itemDataMsg);
  575. this.setData({
  576. showAction: false
  577. })
  578. },
  579. /**
  580. * 生命周期函数--监听页面初次渲染完成
  581. */
  582. onReady: function () {
  583. },
  584. sharewaytap: function () {
  585. this.setData({
  586. wshareshow: true
  587. })
  588. },
  589. shareurltap: function () {
  590. wx.showLoading({
  591. title: '加载中...',
  592. })
  593. if (this.data.activityType && this.data.activityType == 'broker') {
  594. util.schemefun('/share/pages/activitymsg/activitymsg', 'aid=' + this.data.aid + '&bid=' + app.globalData.brokeruserId + '&ctp=' + app.globalData.clientype + '&t=b', this.data.aid, 'activity', '');
  595. } else {
  596. this.activitytap();
  597. util.schemefun('/share/pages/activitymsg/activitymsg', 'aid=' + this.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.aid, 'activity', '');
  598. }
  599. },
  600. activityfun: function () {
  601. var that = this;
  602. if (that.data.activityType && that.data.activityType == 'broker') {
  603. utils.$post({
  604. url: app.globalData.webUrl + 'api/agents_work/activity_detail',
  605. header: {
  606. 'Authorization': 'bearer ' + app.globalData.token
  607. },
  608. data: {
  609. id: that.data.aid,
  610. uid: app.globalData.personMsg.id
  611. },
  612. success: function (res) {
  613. if (res.data.code == '0') {
  614. that.setData({
  615. activityobj: res.data.data
  616. })
  617. wx.setNavigationBarTitle({
  618. title: res.data.data.title
  619. })
  620. }
  621. }
  622. })
  623. } else {
  624. utils.$post({
  625. url: app.globalData.webUrl + 'api/activity/details',
  626. header: {
  627. 'Authorization': 'bearer ' + app.globalData.token
  628. },
  629. data: {
  630. id: that.data.aid,
  631. uid: app.globalData.personMsg.id
  632. },
  633. success: function (res) {
  634. if (res.data.code == '0') {
  635. that.setData({
  636. activityobj: res.data.data
  637. })
  638. wx.setNavigationBarTitle({
  639. title: res.data.data.title
  640. })
  641. }
  642. }
  643. })
  644. }
  645. },
  646. setpostertap: function () {
  647. if (this.data.activityType && this.data.activityType == 'broker') {
  648. wx.navigateTo({
  649. url: '/index/pages/setposter/setposter?type=activity&aid=' + this.data.aid + "&tp=broker" + "&listshare=",
  650. })
  651. } else {
  652. wx.navigateTo({
  653. url: '/index/pages/setposter/setposter?type=activity&aid=' + this.data.aid + "&listshare=",
  654. })
  655. }
  656. },
  657. collectap: function () {
  658. var that = this;
  659. let activityobj = that.data.activityobj;
  660. if (!that.data.activityobj.collected) {
  661. utils.$post({
  662. url: app.globalData.webUrl + 'api/activity/collection',
  663. header: {
  664. 'Authorization': 'bearer ' + app.globalData.token
  665. },
  666. data: {
  667. user_id: app.globalData.personMsg.id,
  668. id: that.data.aid
  669. },
  670. success: function (res) {
  671. if (res.data.code == '0') {
  672. wx.showToast({
  673. title: res.data.msg,
  674. icon: 'success',
  675. duration: 2000
  676. })
  677. activityobj.collected = true;
  678. that.setData({
  679. activityobj: activityobj
  680. })
  681. }
  682. }
  683. })
  684. } else {
  685. utils.$post({
  686. url: app.globalData.webUrl + 'api/activity/collectCancel',
  687. header: {
  688. 'Authorization': 'bearer ' + app.globalData.token
  689. },
  690. data: {
  691. user_id: app.globalData.personMsg.id,
  692. id: that.data.aid
  693. },
  694. success: function (res) {
  695. if (res.data.code == '0') {
  696. wx.showToast({
  697. title: res.data.msg,
  698. icon: 'none',
  699. duration: 2000
  700. })
  701. activityobj.collected = false;
  702. that.setData({
  703. activityobj: activityobj
  704. })
  705. }
  706. }
  707. })
  708. }
  709. },
  710. activitytap: function () {
  711. let that = this;
  712. utils.$post({
  713. url: app.globalData.webUrl + 'api/share/addlog',
  714. header: {
  715. 'Authorization': 'bearer ' + app.globalData.token
  716. },
  717. data: {
  718. id: that.data.aid,
  719. type: 'activity',
  720. },
  721. success: function (r) {
  722. }
  723. })
  724. },
  725. prelooktap() {
  726. wx.previewImage({
  727. current: this.data.activityobj.cover, // 当前显示图片的http链接
  728. urls: [this.data.activityobj.cover], // 需要预览的图片http链接列表
  729. fail(res) {
  730. console.log(res)
  731. }
  732. })
  733. },
  734. /**
  735. * 生命周期函数--监听页面显示
  736. */
  737. onShow: function () {
  738. },
  739. /**
  740. * 生命周期函数--监听页面隐藏
  741. */
  742. onHide: function () {
  743. },
  744. /**
  745. * 生命周期函数--监听页面卸载
  746. */
  747. onUnload: function () {
  748. },
  749. /**
  750. * 页面相关事件处理函数--监听用户下拉动作
  751. */
  752. onPullDownRefresh: function () {
  753. if (this.data.type == 1) {
  754. wx.stopPullDownRefresh();
  755. return false;
  756. }
  757. if (this.data.type == '3') {
  758. this.ranklistfun();
  759. wx.stopPullDownRefresh()
  760. } else {
  761. this.crmtopdatafun();
  762. const that = this;
  763. page = 1;
  764. utils.$post({
  765. url: app.globalData.webUrl + 'api/activity/invite_list',
  766. header: {
  767. 'Authorization': 'bearer ' + app.globalData.token
  768. },
  769. data: {
  770. p: page,
  771. pagesize: 15,
  772. aid: that.data.aid,
  773. type: that.data.statype == 1 ? '预约活动' : that.data.statype == 2 ? '已到场' : that.data.statype == 3 ? '已交定' : '已签单'
  774. },
  775. success: function (res) {
  776. wx.stopPullDownRefresh()
  777. if (res.data.code == '0') {
  778. for (let i = 0; i < res.data.data.length; i++) {
  779. res.data.data[i].lastday = util.nowdayDiff(
  780. res.data.data[i].last_contact_date
  781. );
  782. }
  783. if (that.data.statype == 1) {
  784. that.setData({
  785. invitecrm: res.data.data
  786. })
  787. } else {
  788. that.setData({
  789. showUpcrm: res.data.data
  790. })
  791. }
  792. }
  793. }
  794. })
  795. }
  796. },
  797. /**
  798. * 页面上拉触底事件的处理函数
  799. */
  800. onReachBottom: function () {
  801. const that = this;
  802. if (this.data.type == 1) {
  803. return false;
  804. }
  805. if (that.data.type == 3) {
  806. sharepage = sharepage * 1 + 1;
  807. var str = "api/activity/ranking_list";
  808. let data = {
  809. id: that.data.aid,
  810. type: that.data.ranktype,
  811. is_org: this.data.orgtype == '公司排行' ? 0 : '1',//0公司排行,1团队排行,
  812. page: sharepage,
  813. limit: 15,
  814. };
  815. if (this.data.orgtype == '部门排行') {
  816. str = "api/activity/org_ranking_list";
  817. data = {
  818. id: that.data.aid,
  819. type: that.data.ranktype,
  820. page: sharepage,
  821. limit: 15,
  822. };
  823. }
  824. utils.$post({
  825. url: app.globalData.webUrl + str,
  826. header: {
  827. 'Authorization': 'bearer ' + app.globalData.token
  828. },
  829. data: data,
  830. success: function (res) {
  831. setTimeout(() => {
  832. wx.hideLoading()
  833. }, 1000)
  834. if (res.data.code == "0") {
  835. if (that.data.orgtype == '公司排行' || that.data.orgtype == '团队排行') {
  836. let shareranklist = that.data.shareranklist;
  837. shareranklist = shareranklist.concat(res.data.data.data);
  838. that.setData({
  839. shareranklist: shareranklist
  840. })
  841. } else {
  842. let gotranklist = that.data.gotranklist;
  843. gotranklist = gotranklist.concat(res.data.data.data);
  844. that.setData({
  845. gotranklist: gotranklist
  846. })
  847. }
  848. }
  849. }
  850. })
  851. } else {
  852. page = page * 1 + 1;
  853. utils.$post({
  854. url: app.globalData.webUrl + 'api/activity/invite_list',
  855. header: {
  856. 'Authorization': 'bearer ' + app.globalData.token
  857. },
  858. data: {
  859. p: page,
  860. pagesize: 15,
  861. aid: that.data.aid,
  862. type: that.data.statype == 1 ? '预约活动' : that.data.statype == 2 ? '已到场' : that.data.statype == 3 ? '已交定' : '已签单'
  863. },
  864. success: function (res) {
  865. if (res.data.code == '0') {
  866. for (let i = 0; i < res.data.data.length; i++) {
  867. res.data.data[i].lastday = util.nowdayDiff(
  868. res.data.data[i].last_contact_date
  869. );
  870. }
  871. if (that.data.statype == 1) {
  872. let invitecrm = that.data.invitecrm;
  873. invitecrm = invitecrm.concat(res.data.data);
  874. that.setData({
  875. invitecrm: invitecrm
  876. })
  877. } else {
  878. let showUpcrm = that.data.showUpcrm;
  879. showUpcrm = showUpcrm.concat(res.data.data);
  880. that.setData({
  881. showUpcrm: showUpcrm
  882. })
  883. }
  884. }
  885. }
  886. })
  887. }
  888. },
  889. /**
  890. * 用户点击右上角分享
  891. */
  892. onShareAppMessage: function () {
  893. var img = this.data.activityobj.cover;
  894. if (this.data.activityType && this.data.activityType == 'broker') {
  895. return {
  896. title: this.data.activityobj.title,
  897. imageUrl: img,
  898. path: '/share/pages/activitymsg/activitymsg?aid=' + this.data.aid + '&bid=' + app.globalData.brokeruserId + "&ctp=" + app.globalData.clientype + '&t=b'
  899. }
  900. } else {
  901. var poster = this.data.activityobj.poster;
  902. this.activitytap();
  903. return {
  904. title: this.data.activityobj.title,
  905. imageUrl: poster,
  906. path: '/share/pages/activitymsg/activitymsg?aid=' + this.data.aid + '&uid=' + app.globalData.personMsg.id + "&ctp=" + app.globalData.clientype
  907. }
  908. }
  909. }
  910. })