<template>
  <div id="site_set" class="right_con">
    <p class="title_summny" style="left:130px;top:26px">说明：针对管理后台的显示进行基本配置</p>
    <Tabs type="card" >
      <TabPane label="站点设置">
        <Form ref="siteSetInfo" :model="siteSetInfo" :rules="siteSet_rule" :label-width="120">
          <FormItem label="客服电话">
            <Input v-model="siteSetInfo.saleMobile" class="wid_275 zd1 fl"></Input>
            <p class="form_tap_text">用于改密通知短信内显示</p>
            <div class="clear"></div>
          </FormItem>
          <FormItem label="后台iCO图标" style="margin-bottom:16px">
            <uploadIcon @uploadSuc="uploadicon" :covers="iconcovers" :uploadicontext='"上传文件"' class="wid_275 zd1 fl"></uploadIcon>
            <p class="form_tap_text">后台网址ico图标，尺寸16 * 16px</p>
            <div class="clear"></div>
          </FormItem>
          <FormItem label="后台LOGO">
            <uploadIcon @uploadSuc="uploadlogo" :covers="logocovers" :uploadicontext='"上传图片"' class="wid_275 zd1 fl"></uploadIcon>
            <p class="form_tap_text">用于管理中心展示，尺寸360*96px</p>
            <div class="clear"></div>
          </FormItem>
          <FormItem class="form_btn">
            <Button type="primary" @click="editSiteInfo">保存</Button>
          </FormItem>
        </Form>
      </TabPane>
    </Tabs>
  </div>
</template>
<script>
import uploadIcon from "@@/base/upload_icon";
import { setStore} from "@/utils/utils";
export default {
  name: "site_set",
  components: { uploadIcon },
  data() {
    return {
      siteSetInfo: {
        saleMobile:''
      },
      siteSet_rule: {},
      iconcovers:'',
      logocovers:'',
      iconsavename:'',
      logosavename:'',
    };
  },
  watch: {},
  methods: {
    uploadicon(cover){
      if(cover[0].savename){
        this.iconsavename=cover[0].savename
        this.iconcovers=cover[0].url
      }
    },
    uploadlogo(cover){
      if(cover[0].savename){
        this.logosavename=cover[0].savename
        this.logocovers=cover[0].url
      }
    },
    editSiteInfo(){
      this.$api.setSiteInfo({
        service_tel:this.siteSetInfo.saleMobile,
        admin_icon:this.iconsavename,
        admin_logo:this.logosavename,
      }).then(data =>{
        if(data.code==200){
          this.$Message.info(data.msg)
          this.getSiteInfo()
        }else{
          this.$Message.info(data.msg)
        }
      })
    },
    getSiteInfo(){
      this.$api.getSiteInfo().then(data => {
        if(data.code==200){
          this.siteSetInfo.saleMobile=data.data.service_tel
          this.iconcovers=data.data.admin_icon_url
          this.logocovers=data.data.admin_logo_url
          this.iconsavename=data.data.admin_icon
          this.logosavename=data.data.admin_logo
          setStore('logoIco',{logo:this.logocovers,ico:this.iconcovers})
        }
      })
    }
  },
  mounted(){
    this.getSiteInfo()
  }
};
</script>
<style>
#site_set .ivu-upload-drag {
  border: 1px solid #e2e2e2 !important;
}
</style>




