//获取值：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', '已取消']
        ])
    }
}


// 认证状态
class AuthenticationDict extends BaseDict {
    constructor() {
        super([
            ['PENDING_CERTIFICATION', '待认证'],
            ['CERTIFICATION_DFFILED', '已提交'],
            ['CERTIFICATION_PASSED', '认证通过'],
            ['CERTIFICATION_FAILED', '认证失败']
        ])
    }
}

// 认证类型
class AuthenticationTypeDict extends BaseDict {
    constructor() {
        super([
            ['USER', '个人'],
            ['COMPANY', '企业'] 
        ])
    }
}

// 状态
class DisabledDict extends BaseDict {
    constructor() {
        super([
            ['ENABLED', '启用'],
            ['DISABLED', '禁用'] 
        ])
    }
}
//如何使用:import {payTypeDict} from '@/enums/dict
//获取下拉框列表：payTypeDict.options
//获取label:payTypeDict.getLabel(1)
export const payTypeDict = new PayTypeDict()
export const payStatusDict = new PayStatusDict()
export const authenticationDict = new AuthenticationDict()
export const authenticationTypeDict = new AuthenticationTypeDict()
export const disabledDict = new DisabledDict()
