1
0

payResult.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. },
  14. onLoad: function (options) {
  15. // 页面初始化 options为页面跳转所带来的参数
  16. this.setData({
  17. status: parseInt(options.status),
  18. // orderId: parseInt(options.orderId)
  19. orderIds: options.orderIds
  20. });
  21. this.getOrderDetail();
  22. },
  23. getOrderDetail() {
  24. let that = this;
  25. wx.showLoading({
  26. title: '加载中...',
  27. });
  28. util.request(api.OrderDetailList, {
  29. orderIds: that.data.orderIds,
  30. status:that.data.status
  31. }).then(function (res) {
  32. if (res.errno === 0) {
  33. wx.hideLoading();
  34. console.log(res.data);
  35. that.setData({
  36. actualPrice: res.data.actualPrice,
  37. orderGoods: res.data.orderGoods,
  38. });
  39. //团购订单,1期暂时不实现
  40. // if (that.data.status && res.data.orderInfo.order_type == 2) {
  41. // util.request(api.GroupOpenDetail, {
  42. // detailId: res.data.orderInfo.activity_id
  43. // }).then(function (resData) {
  44. // let url = '/pages/joinGroup/joinGroup?openId=' + resData.data.open_id + '&groupId=' + resData.data.group_id
  45. // + '&goodsId=' + resData.data.goods_id
  46. // + '&min_open_group=' + resData.data.min_open_group
  47. // + '&attend_num=' + resData.data.attend_num
  48. // + '&end_time=' + resData.data.end_time;
  49. // console.log(url);
  50. // wx.redirectTo({
  51. // url: url
  52. // })
  53. // })
  54. // }
  55. }
  56. });
  57. },
  58. onReady: function () {
  59. },
  60. onShow: function () {
  61. // 页面显示
  62. },
  63. onHide: function () {
  64. // 页面隐藏
  65. },
  66. onUnload: function () {
  67. // 页面关闭
  68. },
  69. onShareAppMessage: function () {
  70. var that = this;
  71. // console.log("url:" + that.data.goods.list_pic_url);
  72. // var userId = wx.getStorageSync('userId');
  73. // console.log("userId:" + userId);
  74. return {
  75. title: '商业版',
  76. desc: '分享有机会获得优惠券',
  77. imageUrl: '/static/imgys/share.png',
  78. path: '/pages/catalog/catalog?sourceKey=' + that.data.orderIds + '&referrer=' + wx.getStorageSync('userId'),
  79. success: function (res) {
  80. console.log("转发成功");
  81. // 转发成功
  82. that.setData({
  83. openCoupon: true
  84. });
  85. },
  86. fail: function (res) {
  87. // 转发失败
  88. console.log("转发失败");
  89. }
  90. }
  91. },
  92. /**
  93. * 用户分享领券
  94. */
  95. shareCoupon: function () {
  96. var that = this;
  97. // {sourceKey: util.uuid()}
  98. util.request(api.CouponTransActivit,
  99. { sourceKey: that.data.orderIds}).then(function (res) {
  100. if (res.errno === 0) {
  101. that.setData({
  102. openCoupon: false
  103. });
  104. wx.showToast({
  105. title: '领券成功',
  106. duration: 2000
  107. });
  108. setTimeout(function () {
  109. wx.switchTab({
  110. url: '/pages/catalog/catalog',
  111. });
  112. }, 2000);
  113. // wx.redirectTo({ url: '/pages/ucenter/coupon/coupon' });
  114. } else if (res.errno === 1) {
  115. that.setData({
  116. openCoupon: false
  117. });
  118. util.showErrorToast(res.errmsg);
  119. } else if (res.errno === 2) {
  120. // 已经领取过了
  121. that.setData({
  122. openCoupon: false
  123. });
  124. util.showErrorToast(res.errmsg);
  125. }
  126. });
  127. },
  128. closeCoupon: function () {
  129. var that = this;
  130. that.setData({
  131. openCoupon: false
  132. });
  133. }
  134. })