index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. close(e) { //关闭nps
  283. this.setData({
  284. npsStatus: false
  285. });
  286. this.getData();
  287. },
  288. getData(val) {
  289. console.log(val);
  290. let that = this;
  291. let data = {};
  292. if (!util.isEmpty(that.data.query.orderid)) {
  293. data.orderid = that.data.query.orderid;
  294. }
  295. if (!util.isEmpty((val || that.data.query.presellStatus))) {
  296. data.presellStatus = val || that.data.query.presellStatus
  297. }
  298. if (!util.isEmpty(that.data.query.otype)) {
  299. data.otype = that.data.query.otype
  300. }
  301. console.log(data);
  302. util.ajax({
  303. func: "v2/order/detail",
  304. data,
  305. load: false
  306. }, function (res) {
  307. console.log(res);
  308. if (res.code == 0) {
  309. that.setData({
  310. atype: res.data.atype
  311. })
  312. let datas = res.data;
  313. // datas.totalFeeStr = datas.totalFee;
  314. datas.timeContrast = util.timeContrast(datas.stopBuy);
  315. // if (datas.mdiscount > 0) datas.totalFeeStr += " - " + datas.mdiscount + "(会员折扣)";
  316. // if (datas.ldiscount > 0) datas.totalFeeStr += " - " + datas.ldiscount + "(早鸟)";
  317. // if (datas.voucher > 0) datas.totalFeeStr += " - " + datas.voucher + "(现金券)";
  318. // if (datas.bonus > 0) datas.totalFeeStr += " - " + datas.bonus + "(红包)";
  319. // if (datas.coin > 0) datas.totalFeeStr += " - " + datas.coin + "(钱包)";
  320. // if (datas.accountBalance > 0) datas.totalFeeStr += " - " + datas.accountBalance + "(账户余额)";
  321. // if (datas.mdiscount > 0 || datas.voucher > 0 || datas.bonus > 0 || datas.ldiscount > 0 || datas.coin > 0 || datas.accountBalance > 0) {
  322. // datas.totalFeeStr += " = " + datas.price + "元";
  323. // } else {
  324. // datas.totalFeeStr = datas.totalFee + "元";
  325. // }
  326. if (!util.isEmpty(datas.mailAddress)) {
  327. var info = datas.mailAddress.split(" ");
  328. datas.mail = {};
  329. datas.mail.name = info[0] || "";
  330. datas.mail.postMobile = info[1] || "";
  331. datas.mail.province = info[2] || "";
  332. datas.mail.address = datas.mail.province.replace("/", "") + info[3];
  333. }
  334. if (datas.comment) {
  335. datas.comment.tag = datas.comment.content.match(/#([^#]+)#/g) ? datas.comment.content.match(/#([^#]+)#/g).join("") : '';
  336. datas.comment.content = datas.comment.content.replace(/#([^#]+)#/g, "").replace(/<br\/>/g, '\n');
  337. if (datas.comment.additionalComment.content) {
  338. datas.comment.additionalComment.content = datas.comment.additionalComment.content.replace(/<br\/>/g, '\n')
  339. }
  340. }
  341. if (datas.saleTime && datas.presellPaymentDeadline) {
  342. datas.startTime = util.formatDate(util.formatUnixtimestamp(datas.saleTime), 'MM月dd日 hh:mm', false);
  343. datas.endTime = util.formatDate(util.formatUnixtimestamp(datas.presellPaymentDeadline), 'MM月dd日 hh:mm', false);
  344. }
  345. let num = 0,
  346. length = (datas.groupinfo.discount && !util.isEmpty(datas.groupinfo.discount.users)) ? datas.groupinfo.discount.users.length : 0;
  347. if (length > 0) {
  348. datas.groupinfo.discount.users.forEach(el => {
  349. num = el.status == 4 ? num++ : num;
  350. if (el.status == 4) {
  351. num++;
  352. }
  353. that.setData({
  354. iconView: num == 0 ? false : true
  355. });
  356. });
  357. }
  358. that.setData({
  359. info: datas
  360. });
  361. console.log(that.data.info);
  362. that.getGoodsRecommend()
  363. if (datas.groupinfo.gstatus == 0 && datas.groupinfo.discount && datas.groupinfo.discount.status == 0 && datas.groupinfo.discount.deadline > 0) {
  364. that.data.info.groupinfo.discount.deadline = that.data.info.groupinfo.discount.deadline - new Date().getTime();
  365. that.updateTime();
  366. }
  367. } else
  368. util.showTips(res.reason);
  369. });
  370. },
  371. getGoodsRecommend() {
  372. let that = this;
  373. util.getGoodsRecommend(this.data.info.aid).then(res => {
  374. that.setData({
  375. showGoodsRecom: res
  376. })
  377. })
  378. },
  379. closeSku() {
  380. this.setData({
  381. showSku: false,
  382. changeMeal_oid: ''
  383. });
  384. },
  385. // 获取订单信息
  386. OrderInfo(oid) {
  387. // console.log(this.data.oid);
  388. let that = this
  389. util.ajax({
  390. func: "v2/order/getRefundPriceByOid",
  391. data: {
  392. "oid": oid
  393. }
  394. }, function (res) {
  395. console.log(res);
  396. if (res.code == 0) {
  397. that.setData({
  398. orderInfo: res.data,
  399. showSku: true,
  400. changeMeal_oid: oid
  401. })
  402. } else if (res.code == -10) {
  403. util.showTips('不满足更换场次要求,请联系宝大大处理');
  404. that.setData({
  405. showSku: false,
  406. changeMeal_oid: oid
  407. });
  408. } else {
  409. util.showTips(res.reason);
  410. that.setData({
  411. showSku: false,
  412. changeMeal_oid: oid
  413. });
  414. }
  415. })
  416. },
  417. // 换场次
  418. changeMeals(e) {
  419. let status = e.currentTarget.dataset.status,
  420. oid = e.currentTarget.dataset.oid;
  421. if (status == 1) {
  422. this.setData({
  423. showSku: false
  424. });
  425. util.showTips('已提交申请,请耐心等待宝大大审核~');
  426. return false;
  427. } else {
  428. this.setData({
  429. oid: e.currentTarget.dataset.oid
  430. })
  431. this.OrderInfo(e.currentTarget.dataset.oid)
  432. }
  433. // this.setData({showSku:true,changeMeal_oid:oid});
  434. },
  435. cancelOrder(e) {
  436. let that = this,
  437. val = e.target.dataset.presellstatus;
  438. util.ajax({
  439. func: "order/cancel",
  440. data: {
  441. orderid: that.data.info.orderid
  442. }
  443. }, function (res) {
  444. if (res.code == 0) {
  445. if (val != 2) {
  446. if (that.data.prevpagePath == 'pages/product/buy/index') {
  447. wx.reLaunch({
  448. url: '/pages/product/activity/index?aid=' + that.data.info.aid
  449. })
  450. } else {
  451. wx.navigateBack();
  452. }
  453. } else {
  454. that.getData(1)
  455. }
  456. } else {
  457. utils.showTips(res.reason);
  458. }
  459. })
  460. },
  461. // 跳转至表单详情页(支付尾款)
  462. jumpBalancePayment(e) {
  463. let data = e.currentTarget.dataset;
  464. wx.navigateTo({
  465. url: '/pages/product/balancePayment/balancePayment?aid=' + data.aid + '&otype=' + data.otype + '&orderid=' + data.orderid + '&presellstatus=' + data.presellstatus + '&military=' + data.military + '&campSex=' + data.campSex,
  466. })
  467. },
  468. previewImage(e) {
  469. let index = e.currentTarget.dataset.index,
  470. id = e.currentTarget.dataset.id,
  471. comments = [],
  472. datas = this.data.info;
  473. if (id == 0) { //评论
  474. comments = datas.comment.images;
  475. } else { //追加评论
  476. comments = datas.comment.additionalComment.images;
  477. }
  478. wx.previewImage({
  479. current: comments[index], // 当前显示图片的http链接
  480. urls: comments // 需要预览的图片http链接列表
  481. })
  482. },
  483. toDetail() {
  484. let url = '';
  485. if (this.data.info.atype == 0) {
  486. url = `/pages/product/activity/index?aid=${this.data.info.aid}`;
  487. } else {
  488. url = `/pages/product/goods/detail?aid=${this.data.info.aid}`;
  489. }
  490. wx.navigateTo({
  491. url: url,
  492. })
  493. },
  494. goPay() {
  495. let that = this,
  496. btype = 0;
  497. util.WXPay({
  498. orderid: this.data.info.orderid,
  499. btype: that.data.query.presellStatus == 2 ? 0 : that.data.query.presellStatus
  500. }, this.data.info.aid, this.data.info.title, ).then(function () {
  501. that.data.query.otype = 2;
  502. that.setData({
  503. query: that.data.query
  504. });
  505. that.getData();
  506. }, function (msg) {
  507. utils.showTips(msg);
  508. })
  509. },
  510. trip(e) {
  511. let datas = this.data.info
  512. wx.reportAnalytics('click_news', {
  513. aid: datas.aid,
  514. title: datas.title,
  515. });
  516. wx.navigateTo({
  517. url: '/pages/order/trip/trip?orderid=' + datas.orderid + '&refundpwd=' + e.currentTarget.dataset.refundpwd
  518. })
  519. },
  520. scheduling(e) {
  521. let oid = e.currentTarget.dataset.oid,
  522. optionId = e.currentTarget.dataset.optionid;
  523. wx.navigateTo({
  524. url: '/pages/order/scheduling/scheduling?oid=' + oid + '&optionId=' + optionId,
  525. })
  526. },
  527. refund(e) {
  528. console.log(e);
  529. let index = e.currentTarget.dataset.index
  530. let datas = this.data.info,
  531. value = e.currentTarget.dataset;
  532. console.log(value);
  533. console.log(this.data.info);
  534. let info = this.data.info
  535. let that = this
  536. // console.log(that.data.info.subOrders[index].oid);
  537. // v2/order/getRefundPriceByOid
  538. if (that.data.atype != "1") {
  539. util.ajax({
  540. func: "v2/order/getRefundPriceByOid",
  541. data: {
  542. oid: that.data.info.subOrders[index].oid,
  543. }
  544. }, function (res) {
  545. console.log(res);
  546. if (res.code == 0) {
  547. wx.navigateTo({
  548. 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
  549. })
  550. } else {
  551. util.showTips(res.reason);
  552. }
  553. })
  554. } else {
  555. wx.navigateTo({
  556. 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
  557. })
  558. }
  559. wx.reportAnalytics('order_refund', {
  560. aid: datas.aid,
  561. title: datas.title,
  562. });
  563. },
  564. cancelRefund(e) {
  565. let that = this;
  566. wx.showModal({
  567. title: '提示',
  568. content: '确定取消退款',
  569. success: function (res) {
  570. if (res.confirm) {
  571. wx.reportAnalytics('cancel_refund', {
  572. aid: that.data.info.aid,
  573. title: that.data.info.title,
  574. });
  575. util.ajax({
  576. func: "order/cancel_refund",
  577. data: {
  578. orderid: that.data.info.orderid,
  579. password: e.currentTarget.dataset.password || ""
  580. }
  581. }, function (res) {
  582. if (res.code == 0) {
  583. if (res.data.count <= 0) {
  584. wx.navigateBack();
  585. } else {
  586. that.getData();
  587. }
  588. } else {
  589. util.showTips(res.reason);
  590. }
  591. })
  592. }
  593. }
  594. })
  595. },
  596. errorImg() {
  597. this.data.info.logo = "/images/noimg.png";
  598. this.setData({
  599. info: this.data.info
  600. });
  601. },
  602. lookContract(e) {
  603. let datas = this.data.info,
  604. that = this;
  605. let type = e.currentTarget.dataset.type
  606. console.log(type);
  607. wx.reportAnalytics('look_contract', {
  608. aid: datas.aid,
  609. title: datas.title,
  610. });
  611. const downloadTask = wx.downloadFile({
  612. url: e.currentTarget.dataset.url,
  613. success: function (res) {
  614. console.log(res)
  615. if (res.statusCode === 200) {
  616. var filePath = res.tempFilePath
  617. if (type == "电子合同") {
  618. wx.openDocument({
  619. filePath: filePath,
  620. fileType: 'pdf',
  621. })
  622. } else if (type == "行程单") {
  623. wx.openDocument({
  624. filePath: filePath,
  625. fileType: 'docx',
  626. })
  627. }
  628. } else {
  629. that.setData({
  630. loadingSuc: false
  631. });
  632. }
  633. },
  634. fail: function (res) {
  635. that.setData({
  636. loadingSuc: false
  637. });
  638. util.showTips('合同链接失效,请联系宝大大处理。');
  639. }
  640. })
  641. downloadTask.onProgressUpdate((res) => {
  642. that.setData({
  643. percent: res.progress
  644. });
  645. })
  646. },
  647. layer() {
  648. this.setData({
  649. percent: 0
  650. })
  651. },
  652. qrcode(e) {
  653. let data = e.currentTarget.dataset;
  654. if (data.status == 1) {
  655. wx.navigateTo({
  656. url: '/pages/order/qrcode/index?password=' + data.password,
  657. });
  658. }
  659. },
  660. updateTime() {
  661. let self = this,
  662. data = this.data.info,
  663. lag = Math.floor(data.groupinfo.discount.deadline / 1000);
  664. data.updateTime = {};
  665. data.updateTime.second = Math.floor(lag % 60);
  666. data.updateTime.minite = Math.floor((lag / 60) % 60);
  667. data.updateTime.hour = Math.floor(lag / 3600);
  668. data.updateTime.day = Math.floor((lag / 3600) / 24);
  669. data.updateTime.hour = isTimeLeng(data.updateTime.hour);
  670. data.updateTime.minite = isTimeLeng(data.updateTime.minite);
  671. data.updateTime.second = isTimeLeng(data.updateTime.second);
  672. data.groupinfo.discount.deadline = data.groupinfo.discount.deadline - 1000;
  673. self.setData({
  674. info: data
  675. });
  676. clearTimeout(updateTimer);
  677. let updateTimer = setTimeout(function () {
  678. self.updateTime();
  679. }, 1000);
  680. function isTimeLeng(val) {
  681. var s = val.toString();
  682. return s.length == 1 ? "0" + val : val;
  683. }
  684. },
  685. // 拼团邀请
  686. inviteGroup(e) {
  687. this.setData({
  688. show: true,
  689. invitefbtn: e.currentTarget.dataset.invitefbtn == '0' ? true : false
  690. })
  691. },
  692. onShareAppMessage(res) {
  693. let datas = this.data.info,
  694. article = '';
  695. let path = '';
  696. if (res.from === 'button') {
  697. let str = [];
  698. str.push('aid=' + datas.aid)
  699. str.push('orderid=' + datas.orderid)
  700. str.push('invite=' + app.globalData.userInfo.code)
  701. str.push('sharesid=' + datas.sid)
  702. str.push('sharepid=' + datas.pid)
  703. str.push('sharer=' + app.globalData.userInfo.nickname)
  704. if (!util.isEmpty(datas.groupinfo.groupid) && datas.groupinfo.groupid != 'null' && datas.groupinfo.groupid != 'undefined' && datas.groupinfo.groupbook == 1 && datas.subOrders[0].status != 15) {
  705. str.push('groupid=' + datas.groupinfo.groupid)
  706. }
  707. path = '/pages/product/activity/index?' + str.join('&');
  708. wx.reportAnalytics('order_share', {
  709. aid: datas.aid,
  710. title: datas.title,
  711. });
  712. } else {
  713. path = '/pages/home/index'
  714. }
  715. if (!util.isEmpty(datas.sid) && !util.isEmpty(datas.pid) && util.isEmpty(datas.groupinfo.groupid)) {
  716. article = app.globalData.userInfo.nickname + '已报名并邀请你一起参与' + datas.title
  717. } else {
  718. article = (datas.groupbook != -1 ? '约吗?快来和我家孩子一起拼团挑战' : '') + datas.title;
  719. }
  720. return {
  721. title: article,
  722. path: path,
  723. imageUrl: '../images/share.png'
  724. }
  725. }
  726. })