<template>
  <vxe-modal v-model="value" id="autoShopModal" width="450" v-loading="load" @show="show" @hide="hide" height="260" show-footer title="店铺授权">
    <by-form :propConfig="config" ref="form"></by-form>
    <template #footer>
      <div class="btn">
        <el-button plain size="small" @click="value = false">取消</el-button>
        <el-button type="primary" size="small" @click="btn">确定</el-button>
      </div>
    </template>
  </vxe-modal>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { updateRemark } from '@/api/omsOrder'
import { query,save,update,del,dian3ShopQuery,shopAuth,shopSign } from '@/api/shop'
@Component({components:{}})
export default class UpdateRmkModal extends Vue {
  value=false;
  load=false;
  billValue:Array<any>=[];
  config:any={
    attr:{
      labelWidth:'120px',
      rules:{
        posPlatform: [
          { required: true, message: '店铺平台类型不能为空！', trigger: 'blur' }
        ]
      }
    },
    columns:[
      [{
        label:'店铺平台类型',
        prop:'posPlatform',
        component:'by-select',
        compConfig:{
          attr:{
            clearable:true,
            data:[{
              value:'TB',
              label:'淘宝'
            },{
              value:'JD',
              label:'京东'
            },{
              value:'PDD',
              label:'拼多多'
            },{
              value:'WPH',
              label:'唯品会'
            },{
              value:'YZ',
              label:'有赞'
            },{
              value:'DY',
              label:'抖音'
            },{
              value:'KS',
              label:'快手'
            },{
              value:'SN',
              label:'苏宁'
            },{
              value:'ALI',
              label:'阿里巴巴'
            },{
              value:'GM',
              label:'国美'
            },{
              value:'MEITUAN',
              label:'美团'
            },{
              value:'XIAOMI',
              label:'小米'
            },{
              value:'ELE',
              label:'饿了么'
            },{
              value:'WM',
              label:'微盟'
            },{
              value:'HW',
              label:'华为'
            },{
              value:'XHS',
              label:'小红书'
            },{
              value:'WD',
              label:'微店'
            },{
              value:'WX',
              label:'微信'
            },{
              value:'SELF',
              label:'自有'
            }]
          }
        }
      }]
    ]
  }
  setShow(v:boolean){
    this.value = v;
  }
  setBillValue(data:Array<any>){
    this.billValue = data;
  }
  show(){}
  hide(){
    (this.$refs.form as any).clearValidate();
    (this.$refs.form as any).clearValue();
  }
  btn(){
    (this.$refs.form as any).validate().then(()=>{
      let data = (this.$refs.form as any).getValue();
      let url = encodeURIComponent(window.location.origin + '/shopAuto');
      this.load = true
      shopAuth({
        platformType:data.posPlatform,
        url:url
      }).then((res:any)=>{
        this.load = false;
        this.value=false;
        if(res.msg){
          (window as any).location.href=res.msg
          // (window as any).open(res.msg)
          
        }
      }).catch(()=>{})

    }).catch(()=>{})
  }
}
</script>

<style lang="scss" scoped>

</style>