<template>
  <div>
    <div class="breadcrumb">
      <a-breadcrumb>
        <a-breadcrumb-item>资金结算分账管理</a-breadcrumb-item>
        <a-breadcrumb-item>支付方式设置</a-breadcrumb-item>
      </a-breadcrumb>
    </div>
    <div class="body ">
      <div class="body1">
        <p class="f_title">请选择可用支付方式</p>
        <div class="pay">
          <a-checkbox v-model="checked">微信</a-checkbox>
          <a-checkbox v-model="checked1">支付宝</a-checkbox>
          <a-checkbox v-model="checked2">网银支付</a-checkbox>
        </div>
        <!-- <a-radio-group v-model="value" name="radioGroup">
          <a-radio :value="1">
            微信
          </a-radio>
          <a-radio :value="2">
            支付宝
          </a-radio>
          <a-radio :value="3">
            网银支付
          </a-radio>
        </a-radio-group> -->
        <a-button type="primary" class="query_button" @click="setPaySetting">应 用</a-button>
      </div>
    </div>

  </div>
</template>

<script>
  import {getPaySetting,setPaySetting}from '../../../api/index'
  export default {
    data(){
      return{
        checked:false,
        checked1:false,
        checked2:false,
        query:{
          alipay:0,
          ebank_pay:0,
          wechat_pay:0,
        }
      }
    },
    created(){
      this.getList()
    },
    methods:{
      setPaySetting(){
        if(this.checked){
          this.query.wechat_pay=1
        }else{
          this.query.wechat_pay=0
        }
        if(this.checked1){
          this.query.alipay=1
        }else{
          this.query.alipay=0
        }
        if(this.checked2){
          this.query.ebank_pay=1
        }else{
          this.query.ebank_pay=0
        }
        setPaySetting(this.query).then(res=>{
          if(res.code==200){
            this.$message.success('设置成功！');
          }else{
            this.$message.error(res.msg);
          }
        })
      },
      getList(){
        getPaySetting().then(res=>{
          if(res.code==200){
            this.query=res.data
            this.pay()
          }else{
            this.$message.error(res.msg);
          }
        })
      },
      pay(){
        if(this.query.wechat_pay==0){
          this.checked=false
        }else{
          this.checked=true
        }
        if(this.query.alipay==0){
          this.checked1=false
        }else{
          this.checked1=true
        }
        if(this.query.ebank_pay==0){
          this.checked2=false
        }else{
          this.checked2=true
        }
      }
    }
  }
</script>

<style scoped>
  .body1{
    background-color: white;
    height:185px;
    box-sizing: border-box;
    padding:20px 20px;
    display:flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .pay{
    display: flex;
    width: 350px;
    justify-content: space-between;
  }
</style>
