orderDetail.js 3.9 KB

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