orderDetail.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import {
  2. get,
  3. post
  4. } from '../../utils/http';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. urls: [
  11. "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto",
  12. "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto",
  13. "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto",
  14. "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto",
  15. "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto",
  16. "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto",
  17. "https://img0.baidu.com/it/u=3098615520,360170704&fm=26&fmt=auto",
  18. "https://img1.baidu.com/it/u=510862345,2249984174&fm=26&fmt=auto",
  19. "https://img2.baidu.com/it/u=2222750380,2392750381&fm=26&fmt=auto",
  20. ],
  21. status: {
  22. 1: '待进行',
  23. 2: '进行中',
  24. 3: '已完成'
  25. },
  26. list: [],
  27. total: 0,
  28. page: 1,
  29. index: 0,
  30. visible: false,
  31. currentItem: {}
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. console.log(options)
  38. this.setData({
  39. id: options.orderId
  40. },() => {
  41. this.getOrderInfo()
  42. })
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. this.getFeedbackList(1)
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. this.setData({
  60. visible: false
  61. })
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function () {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function () {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function () {
  77. if(this.data.page * 10 < this.data.total) {
  78. this.getFeedbackList(++this.data.page)
  79. }
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. },
  86. /**
  87. * 复制订单号
  88. */
  89. onCopyOrderNum(e) {
  90. wx.setClipboardData({
  91. data: e.currentTarget.dataset.num || '',
  92. success(res) {
  93. console.log(res)
  94. }
  95. })
  96. },
  97. /**
  98. * 打开弹框
  99. */
  100. onEditItem(e) {
  101. console.log(e)
  102. this.setData({
  103. visible: true,
  104. currentItem: e.currentTarget.dataset.item
  105. })
  106. },
  107. /**
  108. * 关闭弹框
  109. */
  110. onPopupState() {
  111. this.setData({
  112. visible: false
  113. })
  114. },
  115. /**
  116. * 预览图片和视频
  117. */
  118. previewMedia(e) {
  119. let { idx,index } = e.currentTarget.dataset;
  120. let arr = this.data.list[idx].media_list
  121. let current = index
  122. wx.previewMedia({
  123. sources: arr,
  124. current
  125. })
  126. },
  127. /**
  128. * 删除反馈记录
  129. * api/feedback/delete
  130. */
  131. onDelete(e) {
  132. post('api/feedback/delete',{
  133. id: this.data.currentItem.id
  134. },(res) => {
  135. wx.showToast({
  136. title: res.msg,
  137. icon: 'none'
  138. })
  139. this.setData({
  140. visible: false
  141. })
  142. this.getFeedbackList(1)
  143. })
  144. },
  145. /**
  146. * 获取订单详情
  147. */
  148. getOrderInfo(id) {
  149. get('api/order/info',{
  150. order_id: this.data.id
  151. },(res) => {
  152. this.setData({
  153. detailData: res.data
  154. // detailData: {}
  155. })
  156. })
  157. },
  158. /**
  159. * 获取反馈记录列表
  160. * api/feedback/list/order
  161. */
  162. getFeedbackList(_page) {
  163. let { list,page } = this.data;
  164. get('api/feedback/list/order',{
  165. order_id: this.data.id,
  166. page: _page || page,
  167. limit: 10
  168. },(res) => {
  169. if (_page == 1 || page == 1) {
  170. list = []
  171. this.data.page = 1
  172. }
  173. res.data.list.forEach((item,index) => {
  174. item.media_list = JSON.parse(item.media_list)
  175. })
  176. list.push(...res.data.list)
  177. this.setData({ list,total: res.data.total, })
  178. console.log(res)
  179. })
  180. }
  181. })