payResult.js 4.3 KB

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