1
0

payResult.js 4.1 KB

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