OrderItem.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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-5px">
  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-5px">
  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. border: 1px #6a6a6a solid;
  95. background-color: var(--app-content-bg-color);
  96. .order-card-header {
  97. height: 28px;
  98. .order-no {
  99. font-size: 10px;
  100. font-weight: 500;
  101. }
  102. }
  103. .pay-box {
  104. padding-top: 10px;
  105. .discounts-title {
  106. font-size: 16px;
  107. line-height: normal;
  108. color: #999999;
  109. }
  110. .discounts-money {
  111. font-size: 16px;
  112. line-height: normal;
  113. color: #999;
  114. font-family: OPPOSANS;
  115. }
  116. .pay-color {
  117. font-size: 13px;
  118. color: var(--left-menu-text-color);
  119. }
  120. }
  121. }
  122. .warning-color {
  123. color: #faad14;
  124. font-size: 11px;
  125. font-weight: bold;
  126. }
  127. .danger-color {
  128. color: #ff3000;
  129. font-size: 11px;
  130. font-weight: bold;
  131. }
  132. .success-color {
  133. color: #52c41a;
  134. font-size: 11px;
  135. font-weight: bold;
  136. }
  137. .info-color {
  138. color: #999999;
  139. font-size: 11px;
  140. font-weight: bold;
  141. }
  142. </style>