OrderMessageItem.vue 4.0 KB

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