btnAction.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. export default {
  2. data() {
  3. return {
  4. actionList: [],
  5. showReportSheet: false,
  6. order: {}
  7. }
  8. },
  9. onShow() {
  10. let selectEditAddr = uni.getStorageSync('selectEditAddr')
  11. if (selectEditAddr.id) {
  12. this.handleAddressSubmit(selectEditAddr.id)
  13. }
  14. },
  15. methods: {
  16. //操作成功之后的回调
  17. successFeedback() {
  18. uni.$emit('btnActionSuccess')
  19. },
  20. //修改地址
  21. handleAddressSubmit(addressId) {
  22. const params = {
  23. orderId: this.order.orderId,
  24. addressId
  25. }
  26. uni.$u.http.post('/token/order/modifyAddress', params).then(res => {
  27. if (res.code === 200) {
  28. uni.showToast({
  29. title: '地址修改成功',
  30. icon: 'none'
  31. })
  32. this.$emit('success')
  33. this.successFeedback()
  34. uni.removeStorageSync('selectEditAddr')
  35. } else {
  36. uni.showToast({
  37. title: res.msg,
  38. icon: 'none'
  39. })
  40. }
  41. }).finally(() => {
  42. uni.removeStorageSync('selectEditAddr')
  43. uni.hideLoading()
  44. })
  45. },
  46. //根据code获取字典 /token/common/getDictOptions
  47. getDict(code) {
  48. return uni.$u.http.get('/token/common/getDictOptions?type=' + code)
  49. },
  50. //获取一键上报的选项 code user_report_options
  51. getReportOptions() {
  52. this.getDict('user_report_options').then(res => {
  53. if (res.code === 200) {
  54. this.actionList = res.data.map(item => ({
  55. text: item.dictLabel,
  56. value: item.dictValue
  57. }))
  58. }
  59. })
  60. },
  61. //一键上报相关操作
  62. handleReportSelect(index) {
  63. this.showReportSheet = false
  64. let reason = this.actionList[index].value
  65. if (this.actionList[index]?.isCancel) {
  66. this.submitCancel(reason)
  67. } else {
  68. this.submitReport(reason)
  69. }
  70. },
  71. submitReport(reason) {
  72. const params = {
  73. orderId: this.order.orderId,
  74. reason: reason
  75. }
  76. uni.$u.http.post('/token/order/userReport', params).then(res => {
  77. if (res.code === 200) {
  78. uni.showToast({
  79. title: '一键上报已上报给管理员',
  80. icon: 'none'
  81. })
  82. this.$emit('success')
  83. this.successFeedback()
  84. }
  85. })
  86. },
  87. //订单取消字典 order_cancel_reason_user
  88. getCancelReason() {
  89. this.getDict('order_cancel_reason_user').then(res => {
  90. if (res.code === 200) {
  91. this.actionList = res.data.map(item => ({
  92. text: item.dictLabel,
  93. value: item.dictValue,
  94. isCancel: true
  95. }))
  96. }
  97. })
  98. },
  99. // 订单操作方法
  100. handleAction({ type, order }) {
  101. console.log('handleAction', type, order)
  102. this.order = order
  103. switch (type) {
  104. case 'submit':
  105. uni.navigateTo({
  106. url: "/pages-home/pages/book-order"
  107. })
  108. uni.setStorageSync('orderId', this.order.orderId)
  109. break
  110. case 'editAddress':
  111. uni.navigateTo({
  112. url: `/pages-mine/pages/address/list?id=${this.order.addressId}&isSelect=1&editAddress=1`
  113. })
  114. break
  115. case 'cancel':
  116. this.showReportSheet = true
  117. this.getCancelReason()
  118. break
  119. case 'report':
  120. this.showReportSheet = true
  121. this.getReportOptions()
  122. break
  123. case 'remindAudit':
  124. this.submitRemindAudit()
  125. break
  126. case 'complaint':
  127. uni.navigateTo({
  128. url: `/pages-mine/pages/complaint?orderId=${this.order.orderId}`
  129. })
  130. break
  131. case 'compensation':
  132. this.$emit('compensation', this.order)
  133. break
  134. }
  135. },
  136. submitCancel(reason) {
  137. const params = {
  138. orderId: this.order.orderId,
  139. reason: reason
  140. }
  141. uni.$u.http.post('/token/order/userCancel', params).then(res => {
  142. if (res.code === 200) {
  143. uni.showToast({
  144. title: '您的订单已取消',
  145. icon: 'none'
  146. })
  147. this.$emit('success')
  148. this.successFeedback()
  149. }
  150. })
  151. },
  152. //提醒审核
  153. submitRemindAudit() {
  154. uni.$u.http.post('/api/token/order/urgeOrder', {
  155. orderId: this.order.orderId
  156. }).then(res => {
  157. if (res.code === 200) {
  158. uni.showToast({
  159. title: '已提醒给管理员进行加急审核',
  160. icon: 'none'
  161. })
  162. } else {
  163. uni.showToast({
  164. title: res.msg,
  165. icon: 'none'
  166. })
  167. }
  168. })
  169. },
  170. }
  171. }