orderItem.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="order-item" @click.stop="toDetail">
  3. <view class="display-flex-between">
  4. <text class="fw400 fs12 lh18 color-666">订单号:{{data.order_no}}</text>
  5. <view class="color-556 fs12 lh18">{{statusDisplay}}</view>
  6. </view>
  7. <view class="display-flex-common goods-list" v-for="(item, index) in data.items" :key="index">
  8. <image style="width: 144rpx; height: 144rpx; border-radius: 10rpx;margin-right: 30rpx;flex-shrink: 0;"
  9. :src="item.goods_cover" mode="aspectFill">
  10. </image>
  11. <view style="width: 100%;">
  12. <view class="display-flex-between mb8 fs14 lh18 color-333">
  13. <text class="fw600 ">{{item.goods_name}}</text>
  14. <text ><text class="fs10">¥</text>{{item.price_selling}}</text>
  15. </view>
  16. <view class="display-flex-between fs12 lh18 color-333 fw400">
  17. <text class="gray-tag">{{item.goods_spec}}</text>
  18. <text>×{{item.stock_sales}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="goods-total display-flex-between">
  23. <view >
  24. <text class="fs12 lh18 color-3E3D44 fw400">实付:</text><text class="fs18 lh15 fw600 color-556"><text class="fs10">¥</text>{{data.amount_total}}</text>
  25. </view>
  26. <view class="display-flex-center">
  27. <text class="btn-gray-border" @click.stop="cancelOrder"
  28. v-if="[1, 2, 3].includes(data.status) && !isRefund">取消订单</text>
  29. <text class="common-btn ml10" @click.stop="toPay" v-if="[1, 2].includes(data.status)">立即付款</text>
  30. <text class="btn-gray-border ml10" @click.stop="confirm" v-if="[4].includes(data.status)">确认收货</text>
  31. <text class="btn-gray-border ml10" v-if="[6, 9].includes(data.status) && !isRefund"
  32. @click.stop="toAfterSales">申请售后</text>
  33. <template v-if="isRefund">
  34. <text class="btn-gray-border ml10" @click.stop="cancelAfter"
  35. v-if="[1,2,3].includes(data.refund_status)">取消申请</text>
  36. <text class="btn-gray-border ml10" @click="toDetail"
  37. v-if="[-2, -1, 4].includes(data.refund_status)">查看详情</text>
  38. </template>
  39. </view>
  40. </view>
  41. <!-- 取消订单原因 -->
  42. <AfterReson v-model="showReson" @confirm="cancelConfirm"></AfterReson>
  43. <!-- 确认框 -->
  44. <u-modal :show="confirmShow" :showCancelButton="true" @cancel="confirmShow = false"
  45. :content='confirmData.content' @confirm="confirmHandler"></u-modal>
  46. </view>
  47. </template>
  48. <script>
  49. import AfterReson from '@/components/AfterReson.vue'
  50. export default {
  51. props: {
  52. data: {
  53. type: Object,
  54. default: () => {
  55. return {}
  56. }
  57. }
  58. },
  59. components: { AfterReson },
  60. data() {
  61. return {
  62. showReson: false,
  63. cancelRemark: '',
  64. confirmShow: false,
  65. confirmData: {
  66. title: '',
  67. content: ''
  68. },
  69. confirmType: ''
  70. }
  71. },
  72. watch: {
  73. },
  74. computed: {
  75. statusDisplay() {
  76. if (this.data.refund_status == 0) {
  77. switch (this.data.status) {
  78. case 0:
  79. return '已取消'
  80. case 1:
  81. case 2:
  82. return '待付款'
  83. case 3:
  84. return '待发货'
  85. case 4:
  86. return '待收货'
  87. case 6:
  88. case 9:
  89. return '已完成'
  90. default:
  91. return ''
  92. }
  93. } else {
  94. return this.data.refund_status_name
  95. }
  96. },
  97. isRefund() {
  98. return this.data.refund_status != 0
  99. }
  100. },
  101. methods: {
  102. confirmHandler() {
  103. // 确认弹框
  104. let currentApi = null
  105. if (this.confirmType == 'cancelOrder') {
  106. // 取消订单
  107. this.$api.cancelOrder({ order_no: this.data.order_no }).then(res => {
  108. this.confirmShow = false
  109. this.$emit('refresh')
  110. }).catch(() => {
  111. this.confirmShow = false
  112. })
  113. } else if (this.confirmType == 'confirm') {
  114. this.$api.confirmOrder({ order_no: this.data.order_no }).then(res => {
  115. this.confirmShow = false
  116. this.$emit('refresh')
  117. }).catch(() => {
  118. this.confirmShow = false
  119. })
  120. } else if (this.confirmType == 'cancelAfter') {
  121. this.$api.cancelAfterSales({ order_no: this.data.order_no }).then(res => {
  122. this.confirmShow = false
  123. this.$emit('refresh')
  124. }).catch(() => {
  125. this.confirmShow = false
  126. })
  127. }
  128. },
  129. toAfterSales() {
  130. uni.navigateTo({
  131. url: `/subPages/afterSales/afterSales?orderNo=${this.data.order_no}`
  132. })
  133. },
  134. toPay() {
  135. // 立即付款
  136. this.$toWechatPay(this.data.order_no)
  137. },
  138. cancelAfter() {
  139. this.confirmShow = true
  140. this.confirmType = 'cancelAfter'
  141. this.confirmData = {
  142. title: '取消申请',
  143. content: '确认取消申请吗?'
  144. }
  145. },
  146. cancelOrder() {
  147. if (this.data.status == 3) {
  148. uni.navigateTo({
  149. url: `/subPages/cancelOrder/cancelOrder?orderNo=${this.data.order_no}`
  150. })
  151. } else {
  152. this.showReson = true
  153. }
  154. },
  155. cancelConfirm(data) {
  156. this.confirmShow = true
  157. this.confirmType = 'cancelOrder'
  158. this.confirmData = {
  159. title: '取消订单',
  160. content: '确认取消订单吗?'
  161. }
  162. },
  163. confirm() {
  164. this.confirmShow = true
  165. this.confirmType = 'confirm'
  166. this.confirmData = {
  167. title: '确认收货',
  168. content: '确认收货码?'
  169. }
  170. },
  171. toDetail() {
  172. uni.navigateTo({
  173. url: `../orderDetail/orderDetail?orderNo=${this.data.order_no}`
  174. })
  175. },
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .order-item {
  181. background-color: #fff;
  182. border-radius: 16rpx;
  183. padding: 30rpx 30rpx 24rpx;
  184. margin-bottom: 20rpx;
  185. }
  186. .goods-list {
  187. // margin: 0 30rpx;
  188. margin-bottom: 20rpx;
  189. padding: 30rpx 0;
  190. border-bottom: 1rpx solid #F5F5F5;
  191. }
  192. .common-btn,
  193. .btn-gray-border {
  194. height: 64rpx;
  195. line-height: 64rpx;
  196. }
  197. </style>