// 收银台
import Vue from 'vue'
const cardMixins = {
    data() {
        return {
            popupShow: false, // 控制支付记录弹窗
            popupShow1: false, // 控制快捷支付银行弹窗
            tabCurrentIndex: 0,
            weChatFlag: false, // 微信支付开关
            B2BpayFlag: false, //企业网银支付开关
            QuickPayFlag: false, // 快捷支付开发
            buttonText: '微信支付',
            btnColor: '#0ABC64',
            cardsList:[],//查看银行列表
            defaultCards: null,
        }
    },
    filters:{
        bankNumeberFilter(value){
            return value.substring(value.length-4,value.length)
        }
    },
    computed: {
        showWeChatPayMode() {
            return this.weChatFlag
        },
        showB2BpayMode() {
            return this.B2BpayFlag
        },
        showQuickpayMode() {
            return this.QuickPayFlag
        }
    },
    methods: {
        handleChoiceaCards(data) {
            //选择的银行
            this.tabCurrentIndex = 3
            this.tabClick(3)
            this.defaultCards = data
            this.quickParams = { ...this.quickParams , ...data}
        },
        hanldeShowPopup(index) {
            switch (index) {
            case 0:
                this.popupShow = true
                break
            case 1:
                this.popupShow1 = true
                break
            default:
                break
            }
        },
        tabClick(index) { //tab切换
            this.tabCurrentIndex = index
            switch (index) {
            case 0:
                this.btnColor = '#0ABC64'
                this.buttonText = '微信支付'
                break
            case 1:
                this.btnColor = '#007ACC'
                this.buttonText = '企业网银支付'
                break
            case 2:
                this.btnColor = '#16AFE8'
                this.buttonText = '个人网银支付'
                break
            case 3:
                this.btnColor = '#F3B574'
                this.buttonText = '使用银行卡快捷支付'
                break
            }
        },
        checkPayMode(range) {
            // 校验支付模式
            // 1微信 2支付宝 3个人网银 4企业网银 5快捷支付
            this.weChatFlag = range.indexOf('1') > -1
            this.B2BpayFlag = range.indexOf('4') > -1
            this.QuickPayFlag = range.indexOf('5') > -1
            // // 设置默认支付方式
            // if(this.QuickPayFlag){
            //     this.tabCurrentIndex = 3
            // }else{
            //     this.tabCurrentIndex = this.weChatFlag ? 0 : this.B2BpayFlag ? 1 : 2 
            // }
            this.tabClick(0)
        }
    }
}

export default cardMixins