payResult.js 4.3 KB

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