OrderItem.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div v-if="isObject(getMessageContent)">
  3. <div :key="getMessageContent.id" class="order-list-card-box mt-14px">
  4. <div class="order-card-header flex items-center justify-between p-x-20px">
  5. <div class="order-no">订单号:{{ getMessageContent.no }}</div>
  6. <div :class="formatOrderColor(getMessageContent)" class="order-state font-16">
  7. {{ formatOrderStatus(getMessageContent) }}
  8. </div>
  9. </div>
  10. <div v-for="item in getMessageContent.items" :key="item.id" class="border-bottom">
  11. <ProductItem
  12. :num="item.count"
  13. :picUrl="item.picUrl"
  14. :price="item.price"
  15. :skuText="item.properties.map((property: any) => property.valueName).join(' ')"
  16. :title="item.spuName"
  17. />
  18. </div>
  19. <div class="pay-box flex justify-end pr-20px">
  20. <div class="flex items-center">
  21. <div class="discounts-title pay-color"
  22. >共 {{ getMessageContent?.productCount }} 件商品,总金额:
  23. </div>
  24. <div class="discounts-money pay-color">
  25. ¥{{ fenToYuan(getMessageContent?.payPrice) }}
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script lang="ts" setup>
  33. import { fenToYuan, jsonParse } from '@/utils'
  34. import { KeFuMessageRespVO } from '@/api/mall/promotion/kefu/message'
  35. import { isObject } from '@/utils/is'
  36. import ProductItem from '@/views/mall/promotion/kefu/components/message/ProductItem.vue'
  37. defineOptions({ name: 'OrderItem' })
  38. const props = defineProps<{
  39. message?: KeFuMessageRespVO
  40. order?: any
  41. }>()
  42. const getMessageContent = computed(() =>
  43. typeof props.message !== 'undefined' ? jsonParse(props!.message!.content) : props.order
  44. )
  45. /**
  46. * 格式化订单状态的颜色
  47. *
  48. * @param order 订单
  49. * @return {string} 颜色的 class 名称
  50. */
  51. function formatOrderColor(order: any) {
  52. if (order.status === 0) {
  53. return 'info-color'
  54. }
  55. if (order.status === 10 || order.status === 20 || (order.status === 30 && !order.commentStatus)) {
  56. return 'warning-color'
  57. }
  58. if (order.status === 30 && order.commentStatus) {
  59. return 'success-color'
  60. }
  61. return 'danger-color'
  62. }
  63. /**
  64. * 格式化订单状态
  65. *
  66. * @param order 订单
  67. */
  68. function formatOrderStatus(order: any) {
  69. if (order.status === 0) {
  70. return '待付款'
  71. }
  72. if (order.status === 10 && order.deliveryType === 1) {
  73. return '待发货'
  74. }
  75. if (order.status === 10 && order.deliveryType === 2) {
  76. return '待核销'
  77. }
  78. if (order.status === 20) {
  79. return '待收货'
  80. }
  81. if (order.status === 30 && !order.commentStatus) {
  82. return '待评价'
  83. }
  84. if (order.status === 30 && order.commentStatus) {
  85. return '已完成'
  86. }
  87. return '已关闭'
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .order-list-card-box {
  92. border-radius: 10px;
  93. padding: 10px;
  94. background-color: #e2e2e2;
  95. .order-card-header {
  96. height: 28px;
  97. .order-no {
  98. font-size: 16px;
  99. font-weight: 500;
  100. }
  101. }
  102. .pay-box {
  103. .discounts-title {
  104. font-size: 16px;
  105. line-height: normal;
  106. color: #999999;
  107. }
  108. .discounts-money {
  109. font-size: 16px;
  110. line-height: normal;
  111. color: #999;
  112. font-family: OPPOSANS;
  113. }
  114. .pay-color {
  115. color: #333;
  116. }
  117. }
  118. }
  119. .warning-color {
  120. color: #faad14;
  121. }
  122. .danger-color {
  123. color: #ff3000;
  124. }
  125. .success-color {
  126. color: #52c41a;
  127. }
  128. .info-color {
  129. color: #999999;
  130. }
  131. </style>