orderMixins.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import Vue from 'vue'
  2. const orderMixins = {
  3. data() {
  4. return {
  5. btnClubUserId: 0,
  6. handleShopOrderId: 0, //点击按钮传入的的订单ID
  7. handleModelEven: 0,
  8. modal: false,
  9. contentModalText: '订单查询失败,请稍候重试~', //操作文字提示语句
  10. modalButton: [
  11. {
  12. text: '取消',
  13. type: 'gray',
  14. plain: true //是否空心
  15. },
  16. {
  17. text: '确定',
  18. customStyle: {
  19. color: '#fff',
  20. bgColor: '#F3B574'
  21. },
  22. plain: false
  23. }
  24. ]
  25. }
  26. },
  27. filters: {
  28. NumFormat(value) {
  29. //处理金额
  30. return Number(value).toFixed(2)
  31. },
  32. statusFilters(value) {
  33. //处理订单状态显示
  34. const map = {
  35. 0: '待确认',
  36. 2: '交易完成',
  37. 4: '已关闭',
  38. 5: '交易全退',
  39. 6: '交易全退',
  40. 11: '待付款待发货',
  41. 12: '待付款部分发货',
  42. 13: '待付款已发货',
  43. 21: '部分付款待发货',
  44. 22: '部分付款部分发货',
  45. 23: '部分付款已发货',
  46. 31: '已付款待发货',
  47. 32: '已付款部分发货',
  48. 33: '已付款已发货'
  49. }
  50. return map[value]
  51. }
  52. },
  53. computed: {
  54. },
  55. methods: {
  56. //确认操作
  57. handleClick(e) {
  58. if (e.index == 1) {
  59. switch (this.handleModelEven) {
  60. case 1: //取消订单
  61. this.cancelOrder(this.handleShopOrderId)
  62. break
  63. case 2: //删除订单
  64. this.deleteOrder(this.handleShopOrderId)
  65. break
  66. case 3: //确认订单
  67. this.affirmOrder(this.handleShopOrderId)
  68. break
  69. }
  70. }
  71. this.modal = false
  72. },
  73. //取消订单
  74. async cancelOrder(shopOrderId) {
  75. try {
  76. const res = await this.OrderService.CancelOrder({ shopOrderId: shopOrderId, userIdentity: 1 })
  77. this.$util.msg(res.msg, 2000, true, 'success')
  78. setTimeout(() => {
  79. this.getOrderDatainit(this.currentTab)
  80. }, 2000)
  81. } catch (error) {
  82. this.$util.msg(error.msg, 2000)
  83. }
  84. },
  85. //删除订单
  86. async deleteOrder(shopOrderId) {
  87. try {
  88. const res = await this.OrderService.DeleteOrder({ shopOrderId: shopOrderId })
  89. this.$util.msg(res.msg, 2000, true, 'success')
  90. setTimeout(() => {
  91. this.getOrderDatainit(this.currentTab)
  92. }, 2000)
  93. } catch (error) {
  94. this.$util.msg(error.msg, 2000)
  95. }
  96. },
  97. //确认订单
  98. async affirmOrder(shopOrderId) {
  99. try {
  100. const res = await this.OrderService.AffirmOrder({ shopOrderId: shopOrderId })
  101. this.$util.msg(res.msg, 2000, true, 'success')
  102. setTimeout(() => {
  103. this.getOrderDatainit(this.currentTab)
  104. }, 2000)
  105. } catch (error) {
  106. this.$util.msg(error.msg, 2000)
  107. }
  108. },
  109. // 再来一单
  110. async handOrderAgain(shopOrderId) {
  111. try {
  112. const res = await this.SellerService.SellerCreateOrderAgain({
  113. confirmFlag: 0,
  114. shopOrderId: shopOrderId,
  115. serviceProviderId: this.listQuery.serviceProviderId
  116. })
  117. const data = res.data
  118. this.$api.setStorage('orderUserInfo', {
  119. clubId: data.clubId,
  120. againBuyProductIds: data.productIds,
  121. userId: data.userId
  122. })
  123. this.$api.navigateTo('/pages/seller/cart/cart')
  124. } catch (error) {
  125. if (error.code == -3) {
  126. this.showAgan = true
  127. this.promptitle = error.msg
  128. this.failList = error.data
  129. } else if (error.code == -2) {
  130. this.$util.modal('', error.msg, '确定', '', false, () => {})
  131. } else {
  132. this.$util.msg(error.msg, 2000)
  133. }
  134. }
  135. },
  136. // 再来一单弹窗
  137. async handleAddAgian() {
  138. try {
  139. await this.SellerService.SellerCreateOrderAgain({
  140. confirmFlag: 1,
  141. shopOrderId: this.handleShopOrderId,
  142. serviceProviderId: this.listQuery.serviceProviderId
  143. })
  144. this.$api.navigateTo('/pages/seller/cart/cart')
  145. this.showAgan = false
  146. } catch (error) {
  147. this.$util.msg(error.msg, 2000)
  148. }
  149. }
  150. },
  151. onShareAppMessage(res) {
  152. //分享转发
  153. this.isShareModal = false
  154. if (res.from === 'button') {
  155. // 来自页面内转发按钮
  156. }
  157. return {
  158. title: '您有新的分享订单,快来查看吧~',
  159. path: `/pages/user/order/order-sharelogin?shopOrderId=${this.handleShopOrderId}&userId=${
  160. this.btnClubUserId
  161. }&serviceProviderId=${this.listQuery.serviceProviderId}`,
  162. imageUrl: 'https://static.caimei365.com/app/mini-mcare/icon/icon_shareOrder@2x.png'
  163. }
  164. }
  165. }
  166. export default orderMixins