Flex
6 小时以前 cd3691d8d7d294e4cb91b9f7f0eef2af0b162625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
  <div v-if="isObject(getMessageContent)">
    <div :key="getMessageContent.id" class="order-list-card-box mt-14px">
      <div class="order-card-header flex items-center justify-between p-x-5px">
        <div class="order-no">
          订单号:
          <span style="cursor: pointer" @click="openDetail(getMessageContent.id)">
            {{ getMessageContent.no }}
          </span>
        </div>
        <div :class="formatOrderColor(getMessageContent)" class="order-state font-16">
          {{ formatOrderStatus(getMessageContent) }}
        </div>
      </div>
      <div v-for="item in getMessageContent.items" :key="item.id" class="border-bottom">
        <ProductItem
          :spu-id="item.spuId"
          :num="item.count"
          :picUrl="item.picUrl"
          :price="item.price"
          :skuText="item.properties.map((property: any) => property.valueName).join(' ')"
          :title="item.spuName"
        />
      </div>
      <div class="pay-box flex justify-end pr-5px">
        <div class="flex items-center">
          <div class="discounts-title pay-color"
            >共 {{ getMessageContent?.productCount }} 件商品,总金额:
          </div>
          <div class="discounts-money pay-color">
            ¥{{ fenToYuan(getMessageContent?.payPrice) }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script lang="ts" setup>
import { fenToYuan, jsonParse } from '@/utils'
import { KeFuMessageRespVO } from '@/api/mall/promotion/kefu/message'
import { isObject } from '@/utils/is'
import ProductItem from '@/views/mall/promotion/kefu/components/message/ProductItem.vue'
 
const { push } = useRouter()
 
defineOptions({ name: 'OrderItem' })
const props = defineProps<{
  message?: KeFuMessageRespVO
  order?: any
}>()
 
const getMessageContent = computed(() =>
  typeof props.message !== 'undefined' ? jsonParse(props!.message!.content) : props.order
)
 
/** 查看订单详情 */
const openDetail = (id: number) => {
  console.log(getMessageContent)
  push({ name: 'TradeOrderDetail', params: { id } })
}
 
/**
 * 格式化订单状态的颜色
 *
 * @param order 订单
 * @return {string} 颜色的 class 名称
 */
function formatOrderColor(order: any) {
  if (order.status === 0) {
    return 'info-color'
  }
  if (order.status === 10 || order.status === 20 || (order.status === 30 && !order.commentStatus)) {
    return 'warning-color'
  }
  if (order.status === 30 && order.commentStatus) {
    return 'success-color'
  }
  return 'danger-color'
}
 
/**
 * 格式化订单状态
 *
 * @param order 订单
 */
function formatOrderStatus(order: any) {
  if (order.status === 0) {
    return '待付款'
  }
  if (order.status === 10 && order.deliveryType === 1) {
    return '待发货'
  }
  if (order.status === 10 && order.deliveryType === 2) {
    return '待核销'
  }
  if (order.status === 20) {
    return '待收货'
  }
  if (order.status === 30 && !order.commentStatus) {
    return '待评价'
  }
  if (order.status === 30 && order.commentStatus) {
    return '已完成'
  }
  return '已关闭'
}
</script>
 
<style lang="scss" scoped>
.order-list-card-box {
  border-radius: 10px;
  padding: 10px;
  border: 1px var(--el-border-color) solid;
  background-color: var(--app-content-bg-color);
 
  .order-card-header {
    height: 28px;
 
    .order-no {
      font-size: 12px;
      font-weight: 500;
 
      span {
        &:hover {
          text-decoration: underline;
          color: var(--left-menu-bg-active-color);
        }
      }
    }
  }
 
  .pay-box {
    padding-top: 10px;
 
    .discounts-title {
      font-size: 16px;
      line-height: normal;
      color: #999999;
    }
 
    .discounts-money {
      font-size: 16px;
      line-height: normal;
      color: #999;
      font-family: OPPOSANS;
    }
 
    .pay-color {
      font-size: 13px;
      color: var(--left-menu-text-color);
    }
  }
}
 
.warning-color {
  color: #faad14;
  font-size: 11px;
  font-weight: bold;
}
 
.danger-color {
  color: #ff3000;
  font-size: 11px;
  font-weight: bold;
}
 
.success-color {
  color: #52c41a;
  font-size: 11px;
  font-weight: bold;
}
 
.info-color {
  color: #999999;
  font-size: 11px;
  font-weight: bold;
}
</style>