orderDetailsProject.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // pages/orderDetailsProject/orderDetailsProject.js
  2. import {
  3. get,
  4. post
  5. } from '../../utils/http'
  6. import {
  7. trackUserEvent
  8. } from '../../utils/util'
  9. const app = getApp()
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. orderDetailsId: '',
  16. orderDetails: '',
  17. storeDataid: ''
  18. },
  19. onCopy: function (e) {
  20. let content = e.currentTarget.dataset.no
  21. var that = this;
  22. wx.setClipboardData({
  23. data: content,
  24. success: function (res) {
  25. wx.showToast({
  26. title: '复制成功!',
  27. icon: "none"
  28. })
  29. }
  30. });
  31. },
  32. /**
  33. * 取消订单
  34. */
  35. btmBack(e) {
  36. let that = this
  37. wx.showModal({
  38. title: '提示',
  39. content: '是否申请退款',
  40. success(res) {
  41. if (res.confirm) {
  42. console.log('用户点击确定')
  43. post(
  44. 'v2/api/order/cancel', {
  45. id: that.data.orderDetails.id
  46. },
  47. (res) => {
  48. wx.showToast({
  49. title: res.msg,
  50. icon: 'success',
  51. duration: 2000
  52. })
  53. that.getOrderData()
  54. }
  55. )
  56. } else if (res.cancel) {
  57. console.log('用户点击取消')
  58. }
  59. }
  60. })
  61. },
  62. /**
  63. * 获取订单详情
  64. */
  65. async getOrderData() {
  66. let resp = await get('v2/api/order/info', { id: this.data.orderDetailsId })
  67. if (resp.code === 200) {
  68. this.setData({
  69. orderDetails: resp.data
  70. })
  71. }
  72. },
  73. /**
  74. * 获取订单详情
  75. */
  76. productRecommend() {
  77. get('v2/api/product/recommend', {
  78. store_id:this.data.storeDataid,
  79. page: 1,
  80. limit:10
  81. }, (res) => {
  82. this.setData({
  83. productRecommend: res.data.list
  84. }, )
  85. })
  86. },
  87. /**
  88. * 生命周期函数--监听页面加载
  89. */
  90. onLoad: async function (options) {
  91. this.setData({
  92. orderDetailsId: options.id
  93. })
  94. await this.getOrderData()
  95. let storeDataid = this.data.orderDetails.store_id
  96. let lat1 = app.address.latitude
  97. let lng1 = app.address.longitude
  98. this.setData({
  99. storeDataid:storeDataid,
  100. lat1: lat1,
  101. lng1: lng1,
  102. })
  103. this.productRecommend()
  104. if (options.click) {
  105. trackUserEvent(options.click)
  106. }
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onReady: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onShow: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面隐藏
  120. */
  121. onHide: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面卸载
  125. */
  126. onUnload: function () {
  127. },
  128. /**
  129. * 页面相关事件处理函数--监听用户下拉动作
  130. */
  131. onPullDownRefresh: function () {
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom: function () {
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage: function () {
  142. }
  143. })