generated from Leo_Ding/web-template
Compare commits
No commits in common. "abee5ef4a426ac90c5479d2fac7cee7008e906ec" and "78ea0032b88731d00481acce8e4919e54ed081e0" have entirely different histories.
abee5ef4a4
...
78ea0032b8
@ -1,46 +0,0 @@
|
|||||||
//获取值:payType.get(1)
|
|
||||||
//如果是下拉框需要获取列表:
|
|
||||||
export class BaseDict {
|
|
||||||
constructor(entries) {
|
|
||||||
this.map = new Map(entries)
|
|
||||||
}
|
|
||||||
//获取数组
|
|
||||||
get options() {
|
|
||||||
return Array.from(this.map, ([value, label]) => ({ value, label }))
|
|
||||||
}
|
|
||||||
//获取label
|
|
||||||
getLabel(value) {
|
|
||||||
return this.map.get(value)
|
|
||||||
}
|
|
||||||
//是否包含
|
|
||||||
has(value) {
|
|
||||||
return this.map.has(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//支付方式
|
|
||||||
class PayTypeDict extends BaseDict {
|
|
||||||
constructor() {
|
|
||||||
super([
|
|
||||||
[1, '微信支付'],
|
|
||||||
[2, '支付宝支付'],
|
|
||||||
[3, '银行卡支付'],
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//支付状态
|
|
||||||
class PayStatusDict extends BaseDict {
|
|
||||||
constructor() {
|
|
||||||
super([
|
|
||||||
['PaymentProcessing', '支付中'],
|
|
||||||
['PaymentSuccessful', '支付成功'],
|
|
||||||
['PaymentFailed', '支付失败'],
|
|
||||||
['PaymentCancelled','已取消']
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如何使用:import {payTypeDict} from '@/enums/dict
|
|
||||||
//获取下拉框列表:payTypeDict.options
|
|
||||||
//获取label:payTypeDict.getLabel(1)
|
|
||||||
export const payTypeDict=new PayTypeDict()
|
|
||||||
export const payStatusDict=new PayStatusDict()
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user