orderItem.ets
4.4 KB
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
import { orderRow } from '../api/recordsType'
import { quarterType } from '../api/options/optionsType'
@Extend(Text) function info () {
.fontColor('#909399').backgroundColor('#f4f4f5')
.borderColor('#e9e9eb')
}
@Extend(Text) function primary () {
.fontColor('#1890ff').backgroundColor('#e8f4ff')
.borderColor('#d1e9ff')
}
@Extend(Text) function warning () {
.fontColor('#ffba00').backgroundColor('#fff8e6')
.borderColor('#fff1cc')
}
@Extend(Text) function success () {
.fontColor('#13ce66').backgroundColor('#e7faf0')
.borderColor('#d0f5e0')
}
@Extend(Text) function danger () {
.fontColor('#ff4949').backgroundColor('#ffeded')
.borderColor('#ffdbdb')
}
interface listClassType {
listClass: string,
dictLabel: string
}
@Component
export default struct orderItem {
@Prop orderInfo: orderRow
@Prop sourceList: quarterType[]
@Prop stateList: quarterType[]
getSource = () => {
let listClassObj: listClassType = { listClass: 'info', dictLabel: '小程序' }
let sourceValue: string = this.orderInfo?.source.toString()
let newArr = this.sourceList.filter((item: quarterType) => item.dictValue == sourceValue)
return newArr[0] || listClassObj
}
getState = () => {
let listClassObj: listClassType = { listClass: 'info', dictLabel: '未支付' }
let stateValue: string = this.orderInfo.state.toString()
let newArr = this.stateList.filter((item: quarterType) => item.dictValue == stateValue)
return newArr[0] || listClassObj
}
build() {
Row(){
Column({space: 5}){
Text(`订单编号:${this.orderInfo?.orderNo}`).fontSize(14).fontColor('#000').fontWeight(600)
Row(){
Text(`套餐:${this.orderInfo?.comboName}`).fontSize(12).fontColor('#999').margin({right: 5})
if(this.getSource().listClass == 'info') {
Text(this.getSource().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).info()
} else if(this.getSource().listClass == 'primary'){
Text(this.getSource().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).primary()
} else if(this.getSource().listClass == 'warning'){
Text(this.getSource().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).warning()
} else if(this.getSource().listClass == 'success'){
Text(this.getSource().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).success()
} else if(this.getSource().listClass == 'danger'){
Text(this.getSource().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).danger()
}
}
Row(){
Text(`金额:${this.orderInfo?.amount}`).fontSize(12).fontColor('#999').margin({right: 5})
if(this.getState().listClass == 'info') {
Text(this.getState().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).info()
} else if(this.getState().listClass == 'primary'){
Text(this.getState().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).primary()
} else if(this.getState().listClass == 'warning'){
Text(this.getState().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).warning()
} else if(this.getState().listClass == 'success'){
Text(this.getState().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).success()
} else if(this.getState().listClass == 'danger'){
Text(this.getState().dictLabel).padding({left: 10, right: 10})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).danger()
}
}
Text(`时间:${this.orderInfo?.createTime}`).fontSize(12).fontColor('#999')
}.alignItems(HorizontalAlign.Start)
Text(`+${this.orderInfo?.bean}`).fontStyle(14).fontStyle(FontStyle.Italic).fontColor('#1890ff').fontWeight(600)
}.padding({top: 20, bottom: 20, left: 10, right: 10})
.border({width: {bottom: 1}, color: '#eee'}).width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
}