order.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. var util = require('../../utils/util.js');
  2. var app = getApp();
  3. var status = require('../../utils/index.js');
  4. var location = require("../../utils/Location");
  5. var canpay = true;
  6. function count_down(that, total_micro_second) {
  7. var second = Math.floor(total_micro_second / 1000);
  8. var days = second / 3600 / 24;
  9. var daysRound = Math.floor(days);
  10. var hours = second / 3600 - (24 * daysRound);
  11. var hoursRound = Math.floor(hours);
  12. var minutes = second / 60 - (24 * 60 * daysRound) - (60 * hoursRound);
  13. var minutesRound = Math.floor(minutes);
  14. var seconds = second - (24 * 3600 * daysRound) - (3600 * hoursRound) - (60 * minutesRound);
  15. that.setData({
  16. endtime: {
  17. days: daysRound,
  18. hours: fill_zero_prefix(hoursRound),
  19. minutes: fill_zero_prefix(minutesRound),
  20. seconds: fill_zero_prefix(seconds),
  21. show_detail: 1
  22. }
  23. });
  24. if (total_micro_second <= 0) {
  25. that.setData({
  26. changeState: 1,
  27. endtime: {
  28. days: "00",
  29. hours: "00",
  30. minutes: "00",
  31. seconds: "00",
  32. }
  33. });
  34. return;
  35. }
  36. setTimeout(function() {
  37. total_micro_second -= 1000;
  38. count_down(that, total_micro_second);
  39. }, 1000)
  40. }
  41. // 位数不足补零
  42. function fill_zero_prefix(num) {
  43. return num < 10 ? "0" + num : num
  44. }
  45. Page({
  46. mixins: [require('../../mixin/compoentCartMixin.js'), require('../../mixin/globalMixin.js')],
  47. data: {
  48. endtime: {
  49. days: "00",
  50. hours: "00",
  51. minutes: "00",
  52. seconds: "00",
  53. },
  54. cancelOrderVisible: false,
  55. orderSkuResps: [],
  56. tablebar: 4,
  57. navState: 0,
  58. theme_type: '',
  59. loadover: false,
  60. pingtai_deal: 0,
  61. is_show: false,
  62. order: {},
  63. common_header_backgroundimage: '',
  64. isShowModal: false,
  65. userInfo: {},
  66. groupInfo: {
  67. group_name: '社区',
  68. owner_name: '团长',
  69. delivery_ziti_name: '社区自提',
  70. delivery_tuanzshipping_name: '团长配送',
  71. delivery_express_name: '快递配送',
  72. localtown_modifypickingname: '包装费'
  73. },
  74. is_show_guess_like: 1,
  75. showRefundModal: false,
  76. order_hexiao_type: 0, //0订单,1按次,2混合
  77. salesroomIdx: 0,
  78. order_goods_list: '',
  79. hx_receive_info: '',
  80. salesroom_list: '',
  81. goodsHexiaoIdx: 0,
  82. share_title: '',
  83. presale_info: '',
  84. presalePickup: {
  85. pickup: '自提', localtown_delivery:'配送', express:'发货', hexiao: '核销', tuanz_send: '配送'
  86. },
  87. showPresalePayModal: false
  88. },
  89. is_show_tip: '',
  90. timeOut: function() {
  91. console.log('计时完成')
  92. },
  93. options: '',
  94. canCancel: true,
  95. isFirst: 1,
  96. onLoad: function(options) {
  97. var that = this;
  98. that.options = options;
  99. var userInfo = wx.getStorageSync('userInfo');
  100. userInfo && (userInfo.shareNickName = userInfo.nickName.length > 3 ? userInfo.nickName.substr(0, 3) + "..." : userInfo.nickName);
  101. status.setGroupInfo().then((groupInfo) => {
  102. that.setData({
  103. groupInfo
  104. })
  105. });
  106. util.check_login() ? this.setData({
  107. needAuth: false
  108. }) : this.setData({
  109. needAuth: true
  110. });
  111. let delivery = options.delivery || '';
  112. that.setData({
  113. userInfo,
  114. delivery
  115. });
  116. // wx.showLoading();
  117. var is_show_tip = options && options.is_show || 0;
  118. let isfail = options && options.isfail || '';
  119. this.is_show_tip = is_show_tip;
  120. if (isfail != undefined && isfail == 1) {
  121. wx.showToast({
  122. title: '支付失败',
  123. icon: 'none'
  124. })
  125. }
  126. let latitude = wx.getStorageSync('latitude2') || '';
  127. let longitude = wx.getStorageSync('longitude2') || '';
  128. if(delivery=='hexiao'&&!latitude) {
  129. this.getMyLocal().then(res=>{
  130. this.getData(options.id, res.latitude, res.longitude, is_show_tip, delivery);
  131. }).catch(()=>{
  132. this.getData(options.id, latitude, longitude, is_show_tip, delivery);
  133. });
  134. } else {
  135. console.log('step2')
  136. this.getData(options.id, latitude, longitude, is_show_tip, delivery);
  137. }
  138. },
  139. getData: function(id, latitude="", longitude="", is_show_tip='', delivery=''){
  140. wx.showLoading({
  141. title: '加载中',
  142. })
  143. if (is_show_tip != undefined && is_show_tip == 1) {
  144. //todo 弹出分享
  145. } else {
  146. wx.showLoading();
  147. }
  148. var that = this;
  149. var token = wx.getStorageSync('token');
  150. app.util.request({
  151. url: 'entry/wxapp/index',
  152. data: {
  153. controller: 'order.order_info',
  154. token,
  155. id,
  156. latitude,
  157. longitude
  158. },
  159. dataType: 'json',
  160. method: 'POST',
  161. success: function(res) {
  162. setTimeout(() => {
  163. wx.hideLoading();
  164. }, 1000);
  165. if(res.data.code==0){
  166. let order_info = res.data.data.order_info;
  167. if (is_show_tip != undefined && is_show_tip == 1 && order_info.type == 'integral') {
  168. wx.showToast({
  169. title: '兑换成功'
  170. })
  171. } else if (is_show_tip != undefined && is_show_tip == 1) {
  172. if (res.data.order_pay_after_share == 1) {
  173. let share_img = res.data.data.share_img;
  174. let share_title = res.data.data.share_title;
  175. that.setData({
  176. share_title,
  177. share_img,
  178. isShowModal: true
  179. })
  180. } else {
  181. wx.showToast({
  182. title: '支付成功'
  183. })
  184. }
  185. }
  186. if (order_info.order_status_id == 3) {
  187. var seconds = (order_info.over_buy_time - order_info.cur_time) * 1000;
  188. if (seconds > 0) {
  189. count_down(that, seconds);
  190. } else {
  191. order_info.open_auto_delete == 1 && that.setData({
  192. changeState: 1
  193. })
  194. }
  195. }
  196. let {
  197. pingtai_deal,
  198. order_refund,
  199. order_can_del_cancle,
  200. is_hidden_orderlist_phone,
  201. is_show_guess_like,
  202. user_service_switch,
  203. common_header_backgroundimage,
  204. order_can_shen_refund,
  205. order_note_open,
  206. order_note_name,
  207. open_comment_gift,
  208. presale_info,
  209. virtualcard_info
  210. } = res.data;
  211. let order = res.data.data || {order_info: {}};
  212. order.order_info.order_note_open = order_note_open || '';
  213. order.order_info.order_note_name = order_note_name || '';
  214. let markers = [];
  215. // if(delivery=='hexiao'&&order.order_info.salesroom_list) {
  216. // let marker = that.createMarker(order.order_info.salesroom_list[0].lat, order.order_info.salesroom_list[0].lon);
  217. // markers.push(marker)
  218. // }
  219. let order_goods_list = order.order_goods_list || '';
  220. let hx_receive_info = order.order_info.hx_receive_info || '';
  221. let salesroom_list = order.salesroom_list || '';
  222. // 预售订单
  223. presale_info = Object.keys(presale_info).length>0 ? presale_info : '';
  224. if(presale_info) {
  225. if(presale_info.presale_type==0) {
  226. let goodsTot = 0;
  227. order_goods_list.forEach(goodsItem=>{ goodsTot += goodsItem.price*goodsItem.quantity; });
  228. let { presale_deduction_money, presale_ding_money } = presale_info;
  229. presale_deduction_money = presale_deduction_money>0?presale_deduction_money:presale_ding_money;
  230. let payTot = order.order_info.total*1-presale_deduction_money*1;
  231. presale_info.payTot = payTot>0?payTot.toFixed(2):0;
  232. let weikuan = goodsTot - presale_deduction_money*1;
  233. presale_info.weikuan = weikuan>0?weikuan.toFixed(2):0;
  234. presale_info.presale_deduction_money = presale_deduction_money;
  235. }
  236. }
  237. // 礼品卡
  238. virtualcard_info = Object.keys(virtualcard_info).length>0 ? virtualcard_info : '';
  239. that.setData({
  240. order,
  241. order_goods_list,
  242. hx_receive_info,
  243. salesroom_list,
  244. pingtai_deal: pingtai_deal,
  245. order_refund: order_refund,
  246. order_can_del_cancle: order_can_del_cancle,
  247. loadover: true,
  248. is_show: 1,
  249. hide_lding: true,
  250. is_hidden_orderlist_phone: is_hidden_orderlist_phone || 0,
  251. is_show_guess_like: is_show_guess_like || 0,
  252. user_service_switch: user_service_switch || 1,
  253. common_header_backgroundimage,
  254. order_can_shen_refund,
  255. open_comment_gift,
  256. latitude,
  257. longitude,
  258. markers,
  259. presale_info,
  260. virtualcard_info
  261. })
  262. that.caclGoodsTot(res.data.data);
  263. that.hide_lding();
  264. } else if(res.data.code==2){
  265. that.setData({ needAuth: true })
  266. }
  267. }
  268. })
  269. },
  270. onShow: function(){
  271. console.log(this.isFirst, 'onShow', this.options.id);
  272. if (this.isFirst>1) this.reload_data();
  273. this.isFirst++;
  274. },
  275. onHide: function(){
  276. console.log('order Hide');
  277. },
  278. getMyLocal: function() {
  279. let that = this;
  280. return new Promise((resovle, reject)=>{
  281. location.getGps().then(ret=>{
  282. console.log('step1')
  283. wx.getLocation({
  284. type: 'wgs84',
  285. success: (res) => {
  286. resovle(res)
  287. that.setData({
  288. scale: 12,
  289. longitude: res.longitude,
  290. latitude: res.latitude
  291. })
  292. },
  293. fail: ()=>{
  294. reject();
  295. }
  296. });
  297. }).catch(()=>{
  298. console.log('step3')
  299. reject();
  300. app.util.message('地图功能开启失败,部分功能受影响', '', 'error');
  301. })
  302. })
  303. },
  304. caclGoodsTot: function(order){
  305. if(order && order.order_goods_list) {
  306. let order_goods_list = order.order_goods_list;
  307. let goodsTot = 0;
  308. Object.keys(order_goods_list).forEach(k=>{
  309. if(order_goods_list[k].is_vipcard_buy==1 || order_goods_list[k].is_level_buy) {
  310. goodsTot += order_goods_list[k].total;
  311. } else {
  312. goodsTot += order_goods_list[k].real_total;
  313. }
  314. })
  315. this.setData({ goodsTot: goodsTot.toFixed(2) })
  316. }
  317. },
  318. /**
  319. * 授权成功回调
  320. */
  321. authSuccess: function() {
  322. this.onLoad(this.options);
  323. },
  324. reload_data: function() {
  325. console.log('reload_data--', this.options.id);
  326. var that = this;
  327. var token = wx.getStorageSync('token');
  328. let id = this.options.id || '';
  329. let latitude = wx.getStorageSync('latitude2');
  330. let longitude = wx.getStorageSync('longitude2');
  331. // this.getData(id, latitude, longitude, '', this.data.delivery)
  332. id && app.util.request({
  333. url: 'entry/wxapp/index',
  334. data: {
  335. controller: 'order.order_info',
  336. token,
  337. id,
  338. latitude,
  339. longitude
  340. },
  341. dataType: 'json',
  342. method: 'POST',
  343. success: function(res) {
  344. let order_info = res.data.data.order_info;
  345. if (order_info.order_status_id == 3) {
  346. var seconds = (order_info.over_buy_time - order_info.cur_time) * 1000;
  347. if (seconds > 0) {
  348. count_down(that, seconds);
  349. } else {
  350. that.setData({
  351. changeState: 1
  352. })
  353. }
  354. }
  355. that.setData({
  356. order: res.data.data,
  357. pingtai_deal: res.data.pingtai_deal,
  358. order_refund: res.data.order_refund,
  359. loadover: true,
  360. is_show: 1,
  361. hide_lding: true
  362. })
  363. }
  364. })
  365. },
  366. receivOrder: function(event) {
  367. let id = event.currentTarget.dataset.type || '';
  368. var token = wx.getStorageSync('token');
  369. var that = this;
  370. var that = this;
  371. wx.showModal({
  372. title: '提示',
  373. content: '确认收到',
  374. confirmColor: '#F75451',
  375. success(res) {
  376. if (res.confirm) {
  377. app.util.request({
  378. 'url': 'entry/wxapp/index',
  379. 'data': {
  380. controller: 'order.receive_order',
  381. token: token,
  382. order_id: id
  383. },
  384. dataType: 'json',
  385. success: function(res) {
  386. if (res.data.code == 0) {
  387. wx.showToast({
  388. title: '收货成功',
  389. icon: 'success',
  390. duration: 1000
  391. })
  392. that.reload_data();
  393. } else {
  394. app.util.message(res.data.msg||'收货失败', '', 'error');
  395. }
  396. }
  397. })
  398. }
  399. }
  400. })
  401. },
  402. callDialog: function(e) {
  403. var order_id = e.currentTarget.dataset.type || '';
  404. var token = wx.getStorageSync('token');
  405. wx.showModal({
  406. title: '取消支付',
  407. content: '好不容易挑出来,确定要取消吗?',
  408. confirmColor: '#F75451',
  409. success(res) {
  410. if (res.confirm) {
  411. app.util.request({
  412. 'url': 'entry/wxapp/index',
  413. 'data': {
  414. controller: 'order.cancel_order',
  415. token: token,
  416. order_id: order_id
  417. },
  418. dataType: 'json',
  419. success: function(res) {
  420. wx.showToast({
  421. title: '取消成功',
  422. icon: 'success',
  423. complete: function() {
  424. wx.redirectTo({
  425. url: '/lionfish_comshop/pages/order/index'
  426. })
  427. }
  428. })
  429. }
  430. })
  431. }
  432. }
  433. })
  434. },
  435. applyForService: function(e) {
  436. var order_id = e.currentTarget.dataset.type || '';
  437. var order_goods_id = e.currentTarget.dataset.order_goods_id;
  438. order_id && wx.redirectTo({
  439. url: '/lionfish_comshop/pages/order/refund?id=' + order_id + '&order_goods_id=' + order_goods_id + '&delivery=' + this.data.delivery
  440. })
  441. },
  442. /**
  443. * 支付防抖
  444. */
  445. // preOrderPay: util.debounce(function(event) {
  446. // canpay && this.payNow(event);
  447. // }),
  448. preOrderPay: function(event) {
  449. canpay && this.payNow(event);
  450. },
  451. payNow: function(e) {
  452. wx.showLoading({
  453. title: '支付中',
  454. })
  455. canpay = false;
  456. let that = this;
  457. var order_id = e.currentTarget.dataset.type || '';
  458. var token = wx.getStorageSync('token');
  459. order_id && app.util.request({
  460. url: 'entry/wxapp/index',
  461. data: {
  462. controller: 'car.wxpay',
  463. token,
  464. order_id,
  465. scene: app.globalData.scene,
  466. pay_method:'fypay'
  467. },
  468. dataType: 'json',
  469. method: 'POST',
  470. success: function(res) {
  471. wx.hideLoading();
  472. if (res.data.code == 0) {
  473. // 交易组件
  474. if(res.data.isRequestOrderPayment==1) {
  475. wx.requestOrderPayment({
  476. orderInfo: res.data.order_info,
  477. timeStamp: res.data.timeStamp,
  478. nonceStr: res.data.nonceStr,
  479. package: res.data.package,
  480. signType: res.data.signType,
  481. paySign: res.data.paySign,
  482. success: function(wxres) {
  483. canpay = true;
  484. wx.redirectTo({
  485. url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&is_show=1&delivery='+that.data.delivery
  486. })
  487. },
  488. 'fail': function(res) {
  489. canpay = true;
  490. console.log(res);
  491. }
  492. })
  493. } else {
  494. wx.requestPayment({
  495. "appId": res.data.appId,
  496. "timeStamp": res.data.timeStamp,
  497. "nonceStr": res.data.nonceStr,
  498. "package": res.data.package,
  499. "signType": res.data.signType,
  500. "paySign": res.data.paySign,
  501. 'success': function(wxres) {
  502. canpay = true;
  503. wx.redirectTo({
  504. url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&is_show=1&delivery='+that.data.delivery
  505. })
  506. },
  507. 'fail': function(res) {
  508. canpay = true;
  509. console.log(res);
  510. }
  511. })
  512. }
  513. } else if (res.data.code == 1) {
  514. wx.showToast({
  515. title: res.data.RETURN_MSG || '支付错误',
  516. icon: 'none'
  517. })
  518. canpay = true;
  519. } else if (res.data.code == 2) {
  520. wx.showToast({
  521. title: res.data.msg,
  522. icon: 'none'
  523. })
  524. setTimeout(() => {
  525. canpay = true;
  526. that.reload_data();
  527. }, 1500);
  528. }
  529. },
  530. fail: ()=>{
  531. wx.hideLoading();
  532. canpay = true;
  533. }
  534. })
  535. },
  536. hide_lding: function() {
  537. wx.hideLoading();
  538. this.setData({
  539. is_show: true
  540. })
  541. },
  542. call_mobile: function(event) {
  543. let mobile = event.currentTarget.dataset.mobile;
  544. wx.makePhoneCall({
  545. phoneNumber: mobile
  546. })
  547. },
  548. goComment: function(event) {
  549. let id = event.currentTarget.dataset.type;
  550. let order_goods_id = event.currentTarget.dataset.order_goods_id;
  551. var goods_id = event.currentTarget.dataset.goods_id;
  552. var pages_all = getCurrentPages();
  553. if (pages_all.length > 3) {
  554. wx.redirectTo({
  555. url: '/lionfish_comshop/pages/order/evaluate?id=' + id + '&goods_id=' + goods_id + '&order_goods_id=' + order_goods_id
  556. })
  557. } else {
  558. wx.navigateTo({
  559. url: '/lionfish_comshop/pages/order/evaluate?id=' + id + '&goods_id=' + goods_id + '&order_goods_id=' + order_goods_id
  560. })
  561. }
  562. },
  563. gokefu: function(event) {
  564. let id = event.currentTarget.dataset.s_id;
  565. var pages_all = getCurrentPages();
  566. if (pages_all.length > 3) {
  567. wx.redirectTo({
  568. url: '/pages/im/index?id=' + id
  569. })
  570. } else {
  571. wx.navigateTo({
  572. url: '/pages/im/index?id=' + id
  573. })
  574. }
  575. },
  576. goRefund: function(event) {
  577. let id = event.currentTarget.dataset.id || 0;
  578. if(id) {
  579. var pages_all = getCurrentPages();
  580. if (pages_all.length > 3) {
  581. wx.redirectTo({
  582. url: `/lionfish_comshop/pages/order/refunddetail?id=${id}`
  583. })
  584. } else {
  585. wx.navigateTo({
  586. url: `/lionfish_comshop/pages/order/refunddetail?id=${id}`
  587. })
  588. }
  589. }
  590. },
  591. closeModal: function(event) {
  592. let h = {};
  593. let type = event.currentTarget.dataset.type || 0;
  594. if(type==1) {
  595. h.showRefundModal = false;
  596. } else {
  597. h.isShowModal = false;
  598. }
  599. this.setData(h)
  600. },
  601. //取消订单
  602. cancelOrder: function(e){
  603. let that = this;
  604. this.canCancel && wx.showModal({
  605. title: '取消订单并退款',
  606. content: '取消订单后,款项将原路退回到您的支付账户;详情请查看退款进度。',
  607. confirmText: '取消订单',
  608. confirmColor: '#ff5344',
  609. cancelText: '再等等',
  610. cancelColor: '#666666',
  611. success(res) {
  612. if (res.confirm) {
  613. that.canCancel = false;
  614. let order_id = e.currentTarget.dataset.type;
  615. let token = wx.getStorageSync('token');
  616. app.util.request({
  617. 'url': 'entry/wxapp/index',
  618. 'data': {
  619. controller: 'order.del_cancle_order',
  620. token,
  621. order_id
  622. },
  623. dataType: 'json',
  624. method: 'POST',
  625. success: function (res) {
  626. if(res.data.code==0){
  627. //提交成功
  628. wx.showModal({
  629. title: '提示',
  630. content: '取消订单成功',
  631. showCancel: false,
  632. confirmColor: '#ff5344',
  633. success(ret) {
  634. if(ret.confirm) {
  635. wx.redirectTo({
  636. url: '/lionfish_comshop/pages/order/index'
  637. })
  638. }
  639. }
  640. })
  641. } else {
  642. that.canCancel = true;
  643. wx.showToast({
  644. title: res.data.msg || '取消订单失败',
  645. icon: 'none'
  646. })
  647. }
  648. }
  649. })
  650. console.log('用户点击确定')
  651. } else if (res.cancel) {
  652. that.canCancel = true;
  653. console.log('用户点击取消')
  654. }
  655. }
  656. })
  657. },
  658. /**
  659. * 弹窗显示退款信息
  660. * @param {*} res
  661. */
  662. showRefundInfo: function(e) {
  663. let idx = e.currentTarget.dataset.idx;
  664. let hasrefund = e.currentTarget.dataset.hasrefund;
  665. if(hasrefund>0) {
  666. let order = this.data.order;
  667. let refundGoodsInfo = order.order_goods_list[idx];
  668. this.setData({
  669. showRefundModal: true,
  670. refundGoodsInfo
  671. })
  672. }
  673. },
  674. /**
  675. * 查看地图
  676. */
  677. gotoMap: function (e) {
  678. let tot = e.currentTarget.dataset.tot || '';
  679. let longitude = '';
  680. let latitude = '';
  681. let name = '';
  682. let address = '';
  683. if(tot==1) {
  684. let salesroom_list = this.data.order.order_info.salesroom_list;
  685. let salesroomIdx = this.data.salesroomIdx;
  686. longitude = salesroom_list[salesroomIdx].lon;
  687. latitude = salesroom_list[salesroomIdx].lat;
  688. name = salesroom_list[salesroomIdx].room_name;
  689. address = salesroom_list[salesroomIdx].room_address;
  690. } else {
  691. longitude = e.currentTarget.dataset.lon;
  692. latitude = e.currentTarget.dataset.lat;
  693. name = e.currentTarget.dataset.name;
  694. address = e.currentTarget.dataset.address;
  695. }
  696. wx.openLocation({
  697. latitude: parseFloat(latitude),
  698. longitude: parseFloat(longitude),
  699. name,
  700. address,
  701. scale: 28
  702. })
  703. },
  704. createMarker: function(latitude, longitude){
  705. let marker = {
  706. iconPath: "../../images/location-red.png",
  707. id: '',
  708. title: '门店',
  709. latitude: parseFloat(latitude),
  710. longitude: parseFloat(longitude),
  711. label:{
  712. anchorX: -12,
  713. anchorY: 0,
  714. content: '门店'
  715. },
  716. width: 30,
  717. height: 30
  718. };
  719. return marker;
  720. },
  721. handleHexiaoModal: function() {
  722. this.setData({
  723. showHexiaoModal: !this.data.showHexiaoModal
  724. })
  725. },
  726. changeMendian: function(e) {
  727. let salesroomIdx = e.currentTarget.dataset.idx;
  728. this.setData({ salesroomIdx, showHexiaoModal: !this.data.showHexiaoModal })
  729. },
  730. handleHexiaoGoodsModal: function() {
  731. this.setData({
  732. showHexiaoGoodsModal: !this.data.showHexiaoGoodsModal
  733. })
  734. },
  735. handleGoodsHexiao: function(e) {
  736. let goodsHexiaoIdx = e.currentTarget.dataset.idx;
  737. this.setData({ goodsHexiaoIdx, showHexiaoGoodsModal: true })
  738. },
  739. hanlePresaleModal: function(e) {
  740. this.setData({
  741. showPresaleDesc: !this.data.showPresaleDesc
  742. })
  743. },
  744. hanlePresalePayModal: function(){
  745. console.log(this.data.showPresalePayModal)
  746. this.setData({
  747. showPresalePayModal: !this.data.showPresalePayModal
  748. })
  749. },
  750. copyCont: function(e) {
  751. let data = e.currentTarget.dataset.code || "";
  752. data&&wx.setClipboardData({
  753. data,
  754. success:function (res) {
  755. wx.showToast({
  756. title: '复制成功',
  757. })
  758. }
  759. })
  760. },
  761. goLink: function(event) {
  762. let url = event.currentTarget.dataset.link;
  763. let needauth = event.currentTarget.dataset.needauth || '';
  764. if(needauth){ if (!this.authModal()) return; }
  765. url && wx.redirectTo({ url })
  766. },
  767. showFanliView: function() {
  768. let pin_rebate = this.data.order.pin_rebate || '';
  769. console.log(pin_rebate)
  770. let text = "";
  771. if(pin_rebate&&pin_rebate.rebate_reward==1) {
  772. text = "拼团返利赠送"+ pin_rebate.reward_amount +"积分";
  773. } else {
  774. text = "拼团返利赠送余额:+"+ pin_rebate.reward_amount;
  775. }
  776. pin_rebate&&wx.showModal({
  777. title: "返利详情",
  778. content: text,
  779. showCancel: false,
  780. confirmText: "我知道了"
  781. })
  782. },
  783. onShareAppMessage: function(res) {
  784. var order_id = this.data.order.order_info.order_id || '';
  785. let goods_share_image = this.data.order.order_goods_list[0].goods_share_image;
  786. let share_img = this.data.share_img;
  787. let share_title = this.data.share_title;
  788. share_title = share_title?share_title:`@${this.data.order.order_info.ziti_name}${this.data.groupInfo.owner_name},我是${this.data.userInfo.shareNickName},刚在你这里下单啦!!!`;
  789. if (order_id && this.is_show_tip == 1) {
  790. return {
  791. title: share_title,
  792. path: "lionfish_comshop/pages/order/shareOrderInfo?order_id=" + order_id,
  793. imageUrl: share_img ? share_img : goods_share_image
  794. };
  795. }
  796. }
  797. })