order-detail.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // pages/order-detail/order-detail.js
  2. var http = require('../../utils/http.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. orderItemDtos: [],
  9. remarks: "",
  10. actualTotal: 0,
  11. userAddrDto: null,
  12. orderNumber: "",
  13. createTime: "",
  14. status: 0,
  15. productTotalAmount: '',
  16. transfee: '',
  17. reduceAmount: '',
  18. shopId: '',
  19. prodid: ''
  20. },
  21. //跳转商品详情页
  22. toProdPage: function(e) {
  23. var prodid = e.currentTarget.dataset.prodid;
  24. wx.navigateTo({
  25. url: '/pages/prod/prod?prodid=' + prodid,
  26. })
  27. },
  28. /**
  29. * 加入购物车
  30. */
  31. addToCart: function(event) {
  32. let index = event.currentTarget.dataset.index
  33. // if (!this.orderItemDtos) {
  34. // console.log(1213)
  35. // return;
  36. // }
  37. var ths = this;
  38. wx.showLoading({
  39. mask: true
  40. });
  41. var params = {
  42. url: "/p/shopCart/changeItem",
  43. method: "POST",
  44. data: {
  45. basketId: 0,
  46. count: this.data.orderItemDtos[index].prodCount,
  47. prodId: this.data.orderItemDtos[index].prodId,
  48. shopId: this.data.shopId,
  49. skuId: this.data.orderItemDtos[index].skuId
  50. },
  51. callBack: function(res) {
  52. //console.log(res);
  53. wx.hideLoading();
  54. wx.showToast({
  55. title: "加入购物车成功",
  56. icon: "none"
  57. })
  58. wx.switchTab({
  59. url: '/pages/basket/basket',
  60. })
  61. }
  62. };
  63. http.request(params);
  64. },
  65. /**
  66. * 生命周期函数--监听页面加载
  67. */
  68. onLoad: function(options) {
  69. this.loadOrderDetail(options.orderNum);
  70. },
  71. /**
  72. * 加载订单数据
  73. */
  74. loadOrderDetail: function(orderNum) {
  75. var ths = this;
  76. wx.showLoading();
  77. //加载订单详情
  78. var params = {
  79. url: "/p/myOrder/orderDetail",
  80. method: "GET",
  81. data: {
  82. orderNumber: orderNum
  83. },
  84. callBack: function(res) {
  85. ths.setData({
  86. orderNumber: orderNum,
  87. actualTotal: res.actualTotal,
  88. userAddrDto: res.userAddrDto,
  89. remarks: res.remarks,
  90. orderItemDtos: res.orderItemDtos,
  91. createTime: res.createTime,
  92. status: res.status,
  93. productTotalAmount: res.orderItemDtos[0].productTotalAmount,
  94. transfee: res.transfee,
  95. reduceAmount: res.reduceAmount,
  96. actualTotal: res.actualTotal,
  97. shopId: res.shopId
  98. });
  99. wx.hideLoading();
  100. }
  101. };
  102. http.request(params);
  103. },
  104. /**
  105. * 生命周期函数--监听页面初次渲染完成
  106. */
  107. onReady: function() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow: function() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面隐藏
  116. */
  117. onHide: function() {
  118. },
  119. /**
  120. * 生命周期函数--监听页面卸载
  121. */
  122. onUnload: function() {
  123. },
  124. /**
  125. * 页面相关事件处理函数--监听用户下拉动作
  126. */
  127. onPullDownRefresh: function() {
  128. },
  129. /**
  130. * 页面上拉触底事件的处理函数
  131. */
  132. onReachBottom: function() {
  133. },
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage: function() {
  138. },
  139. // 一键复制事件
  140. copyBtn: function(e) {
  141. var ths = this;
  142. wx.setClipboardData({
  143. //准备复制的数据
  144. data: ths.data.orderNumber,
  145. success: function(res) {
  146. wx.showToast({
  147. title: '复制成功',
  148. });
  149. }
  150. })
  151. },
  152. })