orderDetail.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. raterStatus: {
  33. 1: '差',
  34. 2: '较差',
  35. 3: '一般',
  36. 4: '满意',
  37. 5: '非常好',
  38. },
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad: function (options) {
  44. console.log(options)
  45. this.setData({
  46. id: options.orderId
  47. },() => {
  48. this.getOrderInfo()
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. this.getFeedbackList(1)
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. this.setData({
  67. visible: false
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面卸载
  72. */
  73. onUnload: function () {
  74. },
  75. /**
  76. * 页面相关事件处理函数--监听用户下拉动作
  77. */
  78. onPullDownRefresh: function () {
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom: function () {
  84. if(this.data.page * 10 < this.data.total) {
  85. this.getFeedbackList(++this.data.page)
  86. }
  87. },
  88. /**
  89. * 用户点击右上角分享
  90. */
  91. onShareAppMessage: function () {
  92. },
  93. /**
  94. * 复制订单号
  95. */
  96. onCopyOrderNum(e) {
  97. wx.setClipboardData({
  98. data: e.currentTarget.dataset.num || '',
  99. success(res) {
  100. console.log(res)
  101. }
  102. })
  103. },
  104. /**
  105. * 打开弹框
  106. */
  107. onEditItem(e) {
  108. console.log(e)
  109. this.setData({
  110. visible: true,
  111. currentItem: e.currentTarget.dataset.item
  112. })
  113. },
  114. /**
  115. * 关闭弹框
  116. */
  117. onPopupState() {
  118. this.setData({
  119. visible: false
  120. })
  121. },
  122. /**
  123. * 预览图片和视频
  124. */
  125. previewMedia(e) {
  126. let { idx,index } = e.currentTarget.dataset;
  127. let arr = this.data.list[idx].media_list
  128. let current = index
  129. wx.previewMedia({
  130. sources: arr,
  131. current
  132. })
  133. },
  134. /**
  135. * 删除反馈记录
  136. * api/feedback/delete
  137. */
  138. onDelete(e) {
  139. post('api/feedback/delete',{
  140. id: this.data.currentItem.id
  141. },(res) => {
  142. wx.showToast({
  143. title: res.msg,
  144. icon: 'none'
  145. })
  146. this.setData({
  147. visible: false
  148. })
  149. this.getFeedbackList(1)
  150. })
  151. },
  152. /**
  153. * 获取订单详情
  154. */
  155. getOrderInfo(id) {
  156. get('api/order/info',{
  157. order_id: this.data.id
  158. },(res) => {
  159. this.setData({
  160. detailData: res.data
  161. // detailData: {}
  162. })
  163. })
  164. },
  165. /**
  166. * 获取反馈记录列表
  167. * api/feedback/list/order
  168. */
  169. getFeedbackList(_page) {
  170. let { list,page } = this.data;
  171. get('api/feedback/list/order',{
  172. order_id: this.data.id,
  173. page: _page || page,
  174. limit: 10
  175. },(res) => {
  176. if (_page == 1 || page == 1) {
  177. list = []
  178. this.data.page = 1
  179. }
  180. res.data.list.forEach((item,index) => {
  181. item.media_list = JSON.parse(item.media_list)
  182. })
  183. list.push(...res.data.list)
  184. this.setData({ list,total: res.data.total, })
  185. console.log(res)
  186. })
  187. }
  188. })