index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. showOrderNo: false,
  6. showGoodsRecom: false,
  7. showAddress: false, //地址
  8. imgPath: util.config.imgPath,
  9. imgUrl: util.config.imgUrl,
  10. query: {
  11. orderid: '',
  12. otype: 0,
  13. presellStatus: 0
  14. },
  15. changeMeal_oid: '',
  16. info: {},
  17. percent: 0,
  18. loadingSuc: true,
  19. npsOptons: {},
  20. npsStatus: false, //nps组件是否显示
  21. isGet: true,
  22. prevpagePath: '',
  23. iconView: false,
  24. showChat: false,
  25. showSku: false, //换场次弹窗
  26. invitefbtn: true, //是否显示邀请海报按钮
  27. refundShow: false,
  28. type: 0,
  29. codeShow: false,
  30. orderInfo: {},
  31. oid: "",
  32. atype: 0,
  33. moreIsShow: false, //更多图片是否显示
  34. selectIsShow: false, //更多下拉框是否显示
  35. },
  36. // 预付信息 orderStatus 1-待付款 2-已付款 3-退款/售后 4-待付尾款 5-订金失效
  37. onLoad(query) {
  38. console.log(query)
  39. this.setData({
  40. query
  41. });
  42. let pages = getCurrentPages();
  43. let prevpage = pages[pages.length - 2];
  44. this.setData({
  45. prevpagePath: prevpage.route
  46. })
  47. },
  48. onUnload() { //由付款页跳转至当前页面的,通过左上角返回至活动详情页
  49. if (this.data.prevpagePath == 'pages/product/buy/index') {
  50. let url = '';
  51. if (this.data.info.atype == 0) {
  52. url = `/pages/product/activity/index?aid=${this.data.info.aid}`;
  53. } else {
  54. url = `/pages/product/goods/detail?aid=${this.data.info.aid}`;
  55. }
  56. wx.reLaunch({
  57. url: url
  58. })
  59. }
  60. },
  61. onShow() {
  62. if (this.data.isGet) {
  63. this.getData();
  64. }
  65. },
  66. showAddressPopup() {
  67. this.setData({
  68. showOrderNo: true
  69. })
  70. },
  71. copyAddress(e) {
  72. wx.setClipboardData({
  73. data: e.currentTarget.dataset.text,
  74. success: function (res) {
  75. wx.getClipboardData({
  76. success: function (res) {
  77. wx.showToast({
  78. title: '复制成功',
  79. })
  80. }
  81. })
  82. }
  83. })
  84. },
  85. closeOrderNo() {
  86. this.setData({
  87. showOrderNo: false
  88. })
  89. },
  90. subOrderNo(e) {
  91. let data = e.detail,
  92. that = this;
  93. util.ajax({
  94. func: "v2/order/refund/express/save",
  95. data: data,
  96. method: 'POST',
  97. }, function (res) {
  98. if (res.code == 0) {
  99. util.showTips(res.reason);
  100. setTimeout(() => {
  101. that.closeOrderNo()
  102. // that.getData();
  103. }, 500);
  104. } else {
  105. util.showTips(res.reason);
  106. }
  107. })
  108. },
  109. // 规则弹框
  110. showFund() {
  111. // if(this.data.orderInfo.refundRule==1){
  112. // this.data.type=this.data.orderInfo.refundRule
  113. // }
  114. this.setData({
  115. refundShow: true,
  116. type: this.data.orderInfo.refundRule,
  117. // type:3,
  118. showSku: false
  119. })
  120. },
  121. closeRefund() {
  122. this.setData({
  123. refundShow: false
  124. })
  125. },
  126. isOK() {
  127. this.setData({
  128. codeShow: false
  129. })
  130. },
  131. showCode() {
  132. this.setData({
  133. codeShow: true,
  134. showSku: false
  135. })
  136. },
  137. // 换场次
  138. confirmChange(e) {
  139. console.log(this.data.orderInfo);
  140. let that = this
  141. util.ajax({
  142. func: "v2/order/getRefundPriceByOid",
  143. data: {
  144. "oid": that.data.oid
  145. }
  146. }, function (res) {
  147. console.log(res);
  148. if (res.code == 0) {
  149. console.log("confirmChange" + "执行了" + e);
  150. let data = {};
  151. data.newAlipayId = e.detail ? e.detail : '';
  152. data.oid = that.data.changeMeal_oid;
  153. data.password = that.data.info.subOrders[0].password
  154. data.priceInfo = that.data.orderInfo
  155. console.log(data);
  156. util.ajax({
  157. func: "v2/order/change/audit",
  158. data,
  159. method: 'POST',
  160. load: false
  161. }, function (res) {
  162. if (res.code == 0) {
  163. util.showTips('已发起申请,请耐心等待宝大大审核~');
  164. that.setData({
  165. showSku: false,
  166. changeMeal_oid: ''
  167. })
  168. that.getData();
  169. } else {
  170. util.showTips(res.reason);
  171. }
  172. })
  173. } else if (res.code == -10) {
  174. util.showTips('不满足更换场次要求,请联系宝大大处理')
  175. } else {
  176. util.showTips(res.reason);
  177. }
  178. })
  179. },
  180. // 活动评价/修改评价
  181. actEvaluate(e) {
  182. let val = e.currentTarget.dataset.index;
  183. wx.navigateTo({
  184. url: '/pages/order/comment/comment?orderid=' + this.data.info.orderid + '&otype=' + this.data.query.otype + (val == 1 ? '&act=edit' : ''),
  185. })
  186. },
  187. // 修改追评/追加评价
  188. editEvaluate(e) {
  189. wx.navigateTo({
  190. url: '/pages/order/addComment/addComment?orderid=' + this.data.info.orderid +
  191. '&otype=' + this.data.query.otype +
  192. '&act=' + (this.data.info.comment.additional == 1 ? 'edit' : ''),
  193. })
  194. },
  195. // 跳转首页
  196. jumpPage() {
  197. wx.reLaunch({
  198. url: '/pages/home/index',
  199. })
  200. },
  201. // 点击联系客服弹窗
  202. showfixedChat() {
  203. this.setData({
  204. showChat: true
  205. })
  206. },
  207. // 修改订单信息
  208. editOrderDetail() {
  209. if ( //和修改信息按钮同样判断逻辑
  210. this.data.info.atype != '1' &&
  211. this.data.info.orderStatus == 2 &&
  212. this.data.info.detailStopUpdate != 1 &&
  213. (this.data.info.waitComment != 2 || (this.data.info.comment.additional == 1 && this.data.info.comment.modified == 1))
  214. ) {
  215. wx.navigateTo({
  216. url: '/pages/order/editOrderDetail/index?orderId=' + this.data.info.orderid,
  217. })
  218. }
  219. },
  220. // 点击更多
  221. showMore() {
  222. this.setData({
  223. moreIsShow: !this.data.moreIsShow,
  224. selectIsShow: !this.data.selectIsShow
  225. })
  226. // console.log(this.data.selectIsShow);
  227. // this.setData({showChat:true})
  228. },
  229. // 开票页面
  230. invoicing() {
  231. console.log(this.data.info);
  232. if (!this.data.info.verify) {
  233. util.showTips('需验票后3天才可申请开票')
  234. } else {
  235. wx.navigateTo({
  236. url: '/pages/order/invoicing/index',
  237. })
  238. }
  239. },
  240. // 客服
  241. customer() {
  242. this.setData({
  243. showChat: true
  244. })
  245. },
  246. // 修改邮寄地址
  247. chooseAddress() {
  248. this.setData({
  249. showAddress: true
  250. })
  251. },
  252. // 提交地址
  253. submitAddress(e) {
  254. let that = this,
  255. data = e.detail,
  256. info = that.data.info;
  257. this.setData({
  258. 'info.mailAddress': data.name + ' ' + data.mobile + ' ' + data.provincial + ' ' + data.address
  259. });
  260. util.ajax({
  261. func: "v2/order/mail/address/save",
  262. data: {
  263. 'orderid': info.orderid,
  264. 'mailAddress': info.mailAddress
  265. },
  266. method: 'POST'
  267. }, function (res) {
  268. console.log(res);
  269. if (res.code == 0) {
  270. util.showTips(res.reason);
  271. } else {
  272. util.showTips(res.reason);
  273. }
  274. })
  275. },
  276. // 关闭地址弹窗
  277. closeAddress(e) {
  278. this.setData({
  279. showAddress: false
  280. })
  281. },
  282. // 默认评价弹窗
  283. nps() {
  284. let that = this,
  285. newDate = util.getNowFormatDate('yyyy-MM-dd hh:mm:ss');
  286. let npsData = wx.getStorageSync("nps") || {
  287. num: 0,
  288. oldDate: newDate,
  289. timesSec: newDate
  290. };
  291. if (((npsData.num < util.config.npsNum) && util.datedifference(newDate, npsData.timesSec, true) > 3600) || util.isObjEmpty(npsData)) {
  292. util.ajax({
  293. func: "v2/order/reviews/one",
  294. load: false
  295. }, function (res) {
  296. if (res.code == 0 && !util.isObjEmpty(res.data)) {
  297. that.setData({
  298. npsOptons: res.data,
  299. npsStatus: true
  300. });
  301. npsData.num += 1;
  302. npsData.timesSec = newDate;
  303. wx.setStorageSync("nps", npsData)
  304. }
  305. })
  306. }
  307. },
  308. close(e) { //关闭nps
  309. this.setData({
  310. npsStatus: false
  311. });
  312. this.getData();
  313. },
  314. getData(val) {
  315. console.log(val);
  316. let that = this;
  317. let data = {};
  318. if (!util.isEmpty(that.data.query.orderid)) {
  319. data.orderid = that.data.query.orderid;
  320. }
  321. if (!util.isEmpty((val || that.data.query.presellStatus))) {
  322. data.presellStatus = val || that.data.query.presellStatus
  323. }
  324. if (!util.isEmpty(that.data.query.otype)) {
  325. data.otype = that.data.query.otype
  326. }
  327. console.log(data);
  328. util.ajax({
  329. func: "v2/order/detail",
  330. data,
  331. load: false
  332. }, function (res) {
  333. console.log(res);
  334. if (res.code == 0) {
  335. that.setData({
  336. atype: res.data.atype
  337. })
  338. let datas = res.data;
  339. // datas.totalFeeStr = datas.totalFee;
  340. datas.timeContrast = util.timeContrast(datas.stopBuy);
  341. // if (datas.mdiscount > 0) datas.totalFeeStr += " - " + datas.mdiscount + "(会员折扣)";
  342. // if (datas.ldiscount > 0) datas.totalFeeStr += " - " + datas.ldiscount + "(早鸟)";
  343. // if (datas.voucher > 0) datas.totalFeeStr += " - " + datas.voucher + "(现金券)";
  344. // if (datas.bonus > 0) datas.totalFeeStr += " - " + datas.bonus + "(红包)";
  345. // if (datas.coin > 0) datas.totalFeeStr += " - " + datas.coin + "(钱包)";
  346. // if (datas.accountBalance > 0) datas.totalFeeStr += " - " + datas.accountBalance + "(账户余额)";
  347. // if (datas.mdiscount > 0 || datas.voucher > 0 || datas.bonus > 0 || datas.ldiscount > 0 || datas.coin > 0 || datas.accountBalance > 0) {
  348. // datas.totalFeeStr += " = " + datas.price + "元";
  349. // } else {
  350. // datas.totalFeeStr = datas.totalFee + "元";
  351. // }
  352. if (!util.isEmpty(datas.mailAddress)) {
  353. var info = datas.mailAddress.split(" ");
  354. datas.mail = {};
  355. datas.mail.name = info[0] || "";
  356. datas.mail.postMobile = info[1] || "";
  357. datas.mail.province = info[2] || "";
  358. datas.mail.address = datas.mail.province.replace("/", "") + info[3];
  359. }
  360. if (datas.comment) {
  361. datas.comment.tag = datas.comment.content.match(/#([^#]+)#/g) ? datas.comment.content.match(/#([^#]+)#/g).join("") : '';
  362. datas.comment.content = datas.comment.content.replace(/#([^#]+)#/g, "").replace(/<br\/>/g, '\n');
  363. if (datas.comment.additionalComment.content) {
  364. datas.comment.additionalComment.content = datas.comment.additionalComment.content.replace(/<br\/>/g, '\n')
  365. }
  366. }
  367. that.nps();
  368. if (datas.saleTime && datas.presellPaymentDeadline) {
  369. datas.startTime = util.formatDate(util.formatUnixtimestamp(datas.saleTime), 'MM月dd日 hh:mm', false);
  370. datas.endTime = util.formatDate(util.formatUnixtimestamp(datas.presellPaymentDeadline), 'MM月dd日 hh:mm', false);
  371. }
  372. let num = 0,
  373. length = (datas.groupinfo.discount && !util.isEmpty(datas.groupinfo.discount.users)) ? datas.groupinfo.discount.users.length : 0;
  374. if (length > 0) {
  375. datas.groupinfo.discount.users.forEach(el => {
  376. num = el.status == 4 ? num++ : num;
  377. if (el.status == 4) {
  378. num++;
  379. }
  380. that.setData({
  381. iconView: num == 0 ? false : true
  382. });
  383. });
  384. }
  385. that.setData({
  386. info: datas
  387. });
  388. console.log(that.data.info);
  389. that.getGoodsRecommend()
  390. if (datas.groupinfo.gstatus == 0 && datas.groupinfo.discount && datas.groupinfo.discount.status == 0 && datas.groupinfo.discount.deadline > 0) {
  391. that.data.info.groupinfo.discount.deadline = that.data.info.groupinfo.discount.deadline - new Date().getTime();
  392. that.updateTime();
  393. }
  394. } else
  395. util.showTips(res.reason);
  396. });
  397. },
  398. getGoodsRecommend() {
  399. let that = this;
  400. util.getGoodsRecommend(this.data.info.aid).then(res => {
  401. that.setData({
  402. showGoodsRecom: res
  403. })
  404. })
  405. },
  406. closeSku() {
  407. this.setData({
  408. showSku: false,
  409. changeMeal_oid: ''
  410. });
  411. },
  412. // 获取订单信息
  413. OrderInfo(oid) {
  414. // console.log(this.data.oid);
  415. let that = this
  416. util.ajax({
  417. func: "v2/order/getRefundPriceByOid",
  418. data: {
  419. "oid": oid
  420. }
  421. }, function (res) {
  422. console.log(res);
  423. if (res.code == 0) {
  424. that.setData({
  425. orderInfo: res.data,
  426. showSku: true,
  427. changeMeal_oid: oid
  428. })
  429. } else if (res.code == -10) {
  430. util.showTips('不满足更换场次要求,请联系宝大大处理');
  431. that.setData({
  432. showSku: false,
  433. changeMeal_oid: oid
  434. });
  435. } else {
  436. util.showTips(res.reason);
  437. that.setData({
  438. showSku: false,
  439. changeMeal_oid: oid
  440. });
  441. }
  442. })
  443. },
  444. // 换场次
  445. changeMeals(e) {
  446. let status = e.currentTarget.dataset.status,
  447. oid = e.currentTarget.dataset.oid;
  448. if (status == 1) {
  449. this.setData({
  450. showSku: false
  451. });
  452. util.showTips('已提交申请,请耐心等待宝大大审核~');
  453. return false;
  454. } else {
  455. this.setData({
  456. oid: e.currentTarget.dataset.oid
  457. })
  458. this.OrderInfo(e.currentTarget.dataset.oid)
  459. }
  460. // this.setData({showSku:true,changeMeal_oid:oid});
  461. },
  462. cancelOrder(e) {
  463. let that = this,
  464. val = e.target.dataset.presellstatus;
  465. util.ajax({
  466. func: "order/cancel",
  467. data: {
  468. orderid: that.data.info.orderid
  469. }
  470. }, function (res) {
  471. if (res.code == 0) {
  472. if (val != 2) {
  473. if (that.data.prevpagePath == 'pages/product/buy/index') {
  474. wx.reLaunch({
  475. url: '/pages/product/activity/index?aid=' + that.data.info.aid
  476. })
  477. } else {
  478. wx.navigateBack();
  479. }
  480. } else {
  481. that.getData(1)
  482. }
  483. } else {
  484. utils.showTips(res.reason);
  485. }
  486. })
  487. },
  488. // 跳转至表单详情页(支付尾款)
  489. jumpBalancePayment(e) {
  490. let data = e.currentTarget.dataset;
  491. wx.navigateTo({
  492. url: '/pages/product/balancePayment/balancePayment?aid=' + data.aid + '&otype=' + data.otype + '&orderid=' + data.orderid + '&presellstatus=' + data.presellstatus + '&military=' + data.military + '&campSex=' + data.campSex,
  493. })
  494. },
  495. previewImage(e) {
  496. let index = e.currentTarget.dataset.index,
  497. id = e.currentTarget.dataset.id,
  498. comments = [],
  499. datas = this.data.info;
  500. if (id == 0) { //评论
  501. comments = datas.comment.images;
  502. } else { //追加评论
  503. comments = datas.comment.additionalComment.images;
  504. }
  505. wx.previewImage({
  506. current: comments[index], // 当前显示图片的http链接
  507. urls: comments // 需要预览的图片http链接列表
  508. })
  509. },
  510. toDetail() {
  511. let url = '';
  512. if (this.data.info.atype == 0) {
  513. url = `/pages/product/activity/index?aid=${this.data.info.aid}`;
  514. } else {
  515. url = `/pages/product/goods/detail?aid=${this.data.info.aid}`;
  516. }
  517. wx.navigateTo({
  518. url: url,
  519. })
  520. },
  521. goPay() {
  522. let that = this,
  523. btype = 0;
  524. util.WXPay({
  525. orderid: this.data.info.orderid,
  526. btype: that.data.query.presellStatus == 2 ? 0 : that.data.query.presellStatus
  527. }, this.data.info.aid, this.data.info.title, ).then(function () {
  528. that.data.query.otype = 2;
  529. that.setData({
  530. query: that.data.query
  531. });
  532. that.getData();
  533. }, function (msg) {
  534. utils.showTips(msg);
  535. })
  536. },
  537. trip(e) {
  538. let datas = this.data.info
  539. wx.reportAnalytics('click_news', {
  540. aid: datas.aid,
  541. title: datas.title,
  542. });
  543. wx.navigateTo({
  544. url: '/pages/order/trip/trip?orderid=' + datas.orderid + '&refundpwd=' + e.currentTarget.dataset.refundpwd
  545. })
  546. },
  547. scheduling(e) {
  548. let oid = e.currentTarget.dataset.oid,
  549. optionId = e.currentTarget.dataset.optionid;
  550. wx.navigateTo({
  551. url: '/pages/order/scheduling/scheduling?oid=' + oid + '&optionId=' + optionId,
  552. })
  553. },
  554. refund(e) {
  555. console.log(e);
  556. let index = e.currentTarget.dataset.index
  557. let datas = this.data.info,
  558. value = e.currentTarget.dataset;
  559. console.log(value);
  560. console.log(this.data.info);
  561. let info = this.data.info
  562. let that = this
  563. // console.log(that.data.info.subOrders[index].oid);
  564. // v2/order/getRefundPriceByOid
  565. if (that.data.atype != "1") {
  566. util.ajax({
  567. func: "v2/order/getRefundPriceByOid",
  568. data: {
  569. oid: that.data.info.subOrders[index].oid,
  570. }
  571. }, function (res) {
  572. console.log(res);
  573. if (res.code == 0) {
  574. wx.navigateTo({
  575. url: '/pages/order/refund/refund?orderid=' + datas.orderid + (value.password ? '&refundpwd=' + value.password : '') + '&refundStatus=' + value.status + (datas.groupinfo && datas.groupinfo.groupid ? ('&groupid=' + datas.groupinfo.groupid) : '') + '&index=' + value.index + '&oid=' + that.data.info.subOrders[index].oid
  576. })
  577. } else {
  578. util.showTips(res.reason);
  579. }
  580. })
  581. } else {
  582. wx.navigateTo({
  583. url: '/pages/order/Copyrefund/Copyrefund?orderid=' + datas.orderid + (value.password ? '&refundpwd=' + value.password : '') + '&refundStatus=' + value.status + (datas.groupinfo && datas.groupinfo.groupid ? ('&groupid=' + datas.groupinfo.groupid) : '') + '&index=' + value.index + "&atype=" + that.data.atype
  584. })
  585. }
  586. wx.reportAnalytics('order_refund', {
  587. aid: datas.aid,
  588. title: datas.title,
  589. });
  590. },
  591. cancelRefund(e) {
  592. let that = this;
  593. wx.showModal({
  594. title: '提示',
  595. content: '确定取消退款',
  596. success: function (res) {
  597. if (res.confirm) {
  598. wx.reportAnalytics('cancel_refund', {
  599. aid: that.data.info.aid,
  600. title: that.data.info.title,
  601. });
  602. util.ajax({
  603. func: "order/cancel_refund",
  604. data: {
  605. orderid: that.data.info.orderid,
  606. password: e.currentTarget.dataset.password || ""
  607. }
  608. }, function (res) {
  609. if (res.code == 0) {
  610. if (res.data.count <= 0) {
  611. wx.navigateBack();
  612. } else {
  613. that.getData();
  614. }
  615. } else {
  616. util.showTips(res.reason);
  617. }
  618. })
  619. }
  620. }
  621. })
  622. },
  623. errorImg() {
  624. this.data.info.logo = "/images/noimg.png";
  625. this.setData({
  626. info: this.data.info
  627. });
  628. },
  629. lookContract(e) {
  630. let datas = this.data.info,
  631. that = this;
  632. let type = e.currentTarget.dataset.type
  633. console.log(type);
  634. wx.reportAnalytics('look_contract', {
  635. aid: datas.aid,
  636. title: datas.title,
  637. });
  638. const downloadTask = wx.downloadFile({
  639. url: e.currentTarget.dataset.url,
  640. success: function (res) {
  641. console.log(res)
  642. if (res.statusCode === 200) {
  643. var filePath = res.tempFilePath
  644. if (type == "电子合同") {
  645. wx.openDocument({
  646. filePath: filePath,
  647. fileType: 'pdf',
  648. })
  649. } else if (type == "行程单") {
  650. wx.openDocument({
  651. filePath: filePath,
  652. fileType: 'docx',
  653. })
  654. }
  655. } else {
  656. that.setData({
  657. loadingSuc: false
  658. });
  659. }
  660. },
  661. fail: function (res) {
  662. that.setData({
  663. loadingSuc: false
  664. });
  665. util.showTips('合同链接失效,请联系宝大大处理。');
  666. }
  667. })
  668. downloadTask.onProgressUpdate((res) => {
  669. that.setData({
  670. percent: res.progress
  671. });
  672. })
  673. },
  674. layer() {
  675. this.setData({
  676. percent: 0
  677. })
  678. },
  679. qrcode(e) {
  680. let data = e.currentTarget.dataset;
  681. if (data.status == 1) {
  682. wx.navigateTo({
  683. url: '/pages/order/qrcode/index?password=' + data.password,
  684. });
  685. }
  686. },
  687. updateTime() {
  688. let self = this,
  689. data = this.data.info,
  690. lag = Math.floor(data.groupinfo.discount.deadline / 1000);
  691. data.updateTime = {};
  692. data.updateTime.second = Math.floor(lag % 60);
  693. data.updateTime.minite = Math.floor((lag / 60) % 60);
  694. data.updateTime.hour = Math.floor(lag / 3600);
  695. data.updateTime.day = Math.floor((lag / 3600) / 24);
  696. data.updateTime.hour = isTimeLeng(data.updateTime.hour);
  697. data.updateTime.minite = isTimeLeng(data.updateTime.minite);
  698. data.updateTime.second = isTimeLeng(data.updateTime.second);
  699. data.groupinfo.discount.deadline = data.groupinfo.discount.deadline - 1000;
  700. self.setData({
  701. info: data
  702. });
  703. clearTimeout(updateTimer);
  704. let updateTimer = setTimeout(function () {
  705. self.updateTime();
  706. }, 1000);
  707. function isTimeLeng(val) {
  708. var s = val.toString();
  709. return s.length == 1 ? "0" + val : val;
  710. }
  711. },
  712. // 拼团邀请
  713. inviteGroup(e) {
  714. this.setData({
  715. show: true,
  716. invitefbtn: e.currentTarget.dataset.invitefbtn == '0' ? true : false
  717. })
  718. },
  719. onShareAppMessage(res) {
  720. let datas = this.data.info,
  721. article = '';
  722. let path = '';
  723. if (res.from === 'button') {
  724. let str = [];
  725. str.push('aid=' + datas.aid)
  726. str.push('orderid=' + datas.orderid)
  727. str.push('invite=' + app.globalData.userInfo.code)
  728. str.push('sharesid=' + datas.sid)
  729. str.push('sharepid=' + datas.pid)
  730. str.push('sharer=' + app.globalData.userInfo.nickname)
  731. if (!util.isEmpty(datas.groupinfo.groupid) && datas.groupinfo.groupid != 'null' && datas.groupinfo.groupid != 'undefined' && datas.groupinfo.groupbook == 1 && datas.subOrders[0].status != 15) {
  732. str.push('groupid=' + datas.groupinfo.groupid)
  733. }
  734. path = '/pages/product/activity/index?' + str.join('&');
  735. wx.reportAnalytics('order_share', {
  736. aid: datas.aid,
  737. title: datas.title,
  738. });
  739. } else {
  740. path = '/pages/home/index'
  741. }
  742. if (!util.isEmpty(datas.sid) && !util.isEmpty(datas.pid) && util.isEmpty(datas.groupinfo.groupid)) {
  743. article = app.globalData.userInfo.nickname + '已报名并邀请你一起参与' + datas.title
  744. } else {
  745. article = (datas.groupbook != -1 ? '约吗?快来和我家孩子一起拼团挑战' : '') + datas.title;
  746. }
  747. return {
  748. title: article,
  749. path: path,
  750. imageUrl: '../images/share.png'
  751. }
  752. }
  753. })