payResult.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. var util = require('../../utils/util.js');
  2. var api = require('../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. status: false,
  7. orderId: 0,
  8. orderInfo: {},
  9. openCoupon: false,
  10. orderIds: [],
  11. orderGoods: [],
  12. actualPrice: 0,
  13. isOrderBizType10: null
  14. },
  15. onLoad: function (options) {
  16. // 页面初始化 options为页面跳转所带来的参数
  17. this.setData({
  18. status: parseInt(options.status),
  19. // orderId: parseInt(options.orderId)
  20. orderIds: options.orderIds,
  21. isOrderBizType10: options.orderBizType10
  22. });
  23. },
  24. getOrderDetail() {
  25. let that = this;
  26. wx.showLoading({
  27. title: '加载中...',
  28. });
  29. util.request(api.OrderDetailList, {
  30. orderIds: that.data.orderIds,
  31. status: that.data.status
  32. }).then(function (res) {
  33. if (res.errno === 0) {
  34. wx.hideLoading();
  35. console.log(res.data);
  36. that.setData({
  37. actualPrice: res.data.actualPrice,
  38. orderGoods: res.data.orderGoods,
  39. });
  40. //团购订单,1期暂时不实现
  41. // if (that.data.status && res.data.orderInfo.order_type == 2) {
  42. // util.request(api.GroupOpenDetail, {
  43. // detailId: res.data.orderInfo.activity_id
  44. // }).then(function (resData) {
  45. // let url = '/pages/joinGroup/joinGroup?openId=' + resData.data.open_id + '&groupId=' + resData.data.group_id
  46. // + '&goodsId=' + resData.data.goods_id
  47. // + '&min_open_group=' + resData.data.min_open_group
  48. // + '&attend_num=' + resData.data.attend_num
  49. // + '&end_time=' + resData.data.end_time;
  50. // console.log(url);
  51. // wx.redirectTo({
  52. // url: url
  53. // })
  54. // })
  55. // }
  56. }
  57. });
  58. },
  59. onReady: function () {
  60. },
  61. onShow: function () {
  62. let that = this;
  63. // 页面显示
  64. if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
  65. if (wx.getStorageSync('storeId')) {
  66. util.request(api.ChooseStoreId, {
  67. storeId: wx.getStorageSync('storeId'),
  68. merchSn: wx.getStorageSync('merchSn'),
  69. isRefusedLogin: wx.getStorageSync('isRefusedLogin')
  70. }, 'POST').then(function (res) {
  71. if (res.errno === 0) {
  72. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  73. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  74. that.reLoad();
  75. }
  76. });
  77. this.getOrderDetail();
  78. }
  79. } else {
  80. wx.navigateTo({
  81. url: '/pages/auth/btnAuth/btnAuth',
  82. })
  83. }
  84. },
  85. onHide: function () {
  86. // 页面隐藏
  87. },
  88. onUnload: function () {
  89. // 页面关闭
  90. },
  91. reLoad: function () {
  92. let that = this;
  93. if (wx.getStorageSync('storeId')) {
  94. if (wx.getStorageSync('userId')) {
  95. wx.request({
  96. url: api.updateLoginUser,
  97. data: {
  98. userId: wx.getStorageSync('userId'), storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn')
  99. },
  100. method: 'POST',
  101. header: {
  102. 'Content-Type': 'application/json'
  103. },
  104. success: function (wxRes) {
  105. if (wxRes.data.errno === 0) {
  106. // console.log("用户信息更新成功");
  107. }
  108. },
  109. fail: function (err) {
  110. console.log("failed");
  111. }
  112. });
  113. }
  114. }
  115. },
  116. onShareAppMessage: function () {
  117. var that = this;
  118. // console.log("url:" + that.data.goods.list_pic_url);
  119. // var userId = wx.getStorageSync('userId');
  120. // console.log("userId:" + userId);
  121. return {
  122. title: '中网跨境电商商品分类',
  123. // desc: '分享有机会获得优惠券',
  124. desc: '中网跨境电商商品分类页进行购买',
  125. imageUrl: '/static/imgys/share.png',
  126. path: '/pages/catalog/catalog?sourceKey=' + that.data.orderIds + '&referrer=' + wx.getStorageSync('userId'),
  127. success: function (res) {
  128. console.log("转发成功");
  129. // 转发成功
  130. that.setData({
  131. openCoupon: true
  132. });
  133. },
  134. fail: function (res) {
  135. // 转发失败
  136. console.log("转发失败");
  137. }
  138. }
  139. },
  140. /**
  141. * 用户分享领券,暂时无此优惠券
  142. */
  143. shareCoupon: function () {
  144. // {sourceKey: util.uuid()}
  145. var that = this;
  146. // util.request(api.CouponTransActivit,
  147. // { sourceKey: that.data.orderIds }).then(function (res) {
  148. // if (res.errno === 0) {
  149. // that.setData({
  150. // openCoupon: false
  151. // });
  152. // wx.showToast({
  153. // title: '领券成功',
  154. // duration: 2000
  155. // });
  156. // setTimeout(function () {
  157. // wx.switchTab({
  158. // url: '/pages/catalog/catalog',
  159. // });
  160. // }, 2000);
  161. // // wx.redirectTo({ url: '/pages/ucenter/coupon/coupon' });
  162. // } else if (res.errno === 1) {
  163. // that.setData({
  164. // openCoupon: false
  165. // });
  166. // util.showErrorToast(res.errmsg);
  167. // } else if (res.errno === 2) {
  168. // // 已经领取过了
  169. // that.setData({
  170. // openCoupon: false
  171. // });
  172. // util.showErrorToast(res.errmsg);
  173. // }
  174. // });
  175. },
  176. closeCoupon: function () {
  177. var that = this;
  178. that.setData({
  179. openCoupon: false
  180. });
  181. }
  182. })