<template>
  <normalLayout >
  <div slot="content">
<!--    <div class="container normal-panel" style="padding-bottom:0">
      <el-descriptions title="企业设置"></el-descriptions>
    </div>-->
    <basicInfo @onSuccess="infoData"></basicInfo>
    <!--消息提示设置-->
    <messageTips/>
    
    <div class="container normal-panel" style="display:flex;justify-content:space-around;border-bottom:none">
      <el-descriptions title="安全配置"></el-descriptions>
    </div>
    <div class="panel">
      <div class="flex-align-center flex-between">
        <div class="flex-align-stretch">
          <img width="72" height="72" src="../../../assets/icons/login_type_1.png" alt="">
          <div class="text-panel">
            <p class="explain-title">密码安全强制要求</p>
            <p class="explain-tips">当前设置:<span class="color-yellow">密码{{obj.password_length}}位数，{{obj.password_needcapital == 1?'大写英文字母，':''}}{{obj.password_needlowercase==1?'小写英文字母，':''}}{{obj.password_neednum==1?'数字0-9，':''}}{{obj.password_needspecialchar == 1?'特殊符号~,!,@,#,$,%,^;':''}}</span></p>
          </div>
        </div>
        <set-password v-if="tool.checkAuth($route.name,'psdValidate')" @setPassword="querySite_Parameter"></set-password>
      </div>
    </div>
     <div class="panel">
      <div class="flex-align-center flex-between">
        <div class="flex-align-stretch">
          <img v-if="watermarkImage.length === 0" width="72" height="72" src="../../../assets/icons/login_type_2.png" alt="">
          <img v-else width="72" height="72" :src=watermarkImage.image alt="">
          <div class="text-panel">
            <p class="explain-title">企业水印图片</p>
            <p class="explain-tips">当前设置：{{watermarkImage.length === 0 ? '还未上传水印图片' : '已上传水印图片'}}</p>
          </div>
        </div>
        <set-watermark :basicInfo="basicInfo" v-if="tool.checkAuth($route.name,'setWatermark')" @setWatermark="queryEnterpriseWatermark"></set-watermark>
      </div>
    </div>
    <div class="panel">
      <div class="flex-align-center flex-between">
        <div class="flex-align-stretch">
          <img v-if="productImage.length === 0" width="72" height="72" src="../../../assets/icons/login_type_2.png" alt="">
          <img v-else width="72" height="72" :src=productImage.image alt="">
          <div class="text-panel">
            <p class="explain-title">产品默认图</p>
            <p class="explain-tips">当前设置：{{productImage.length === 0 ? '还未上传产品默认图':'已上传产品默认图'}}</p>
          </div>
        </div>
        <productImage @setProductImage="queryProductImage"></productImage>
      </div>
    </div>
    <div class="panel" style="margin-bottom:16px">
      <div class="flex-align-center flex-between">
        <div class="flex-align-stretch">
          <img width="72" height="72" src="../../../assets/icons/login_type_3.png" alt="">
          <div class="text-panel">
            <p class="explain-title">登录方式</p>
            <p class="explain-tips">当前设置：{{obj.loginmode_account === 1?'账号登录,':''}}{{obj.loginmode_phonenumber ===1?'手机动态短信登录,':''}}{{obj.loginmode_wechat ===1?'微信登录,':''}}</p>
          </div>
        </div>
        <login-select v-if="tool.checkAuth($route.name,'loginType')" @setLogin="querySite_Parameter"></login-select>
      </div>
    </div>
    <div class="container normal-panel" style="display:flex;justify-content:space-around;border-bottom:none">
      <el-descriptions title="广告位管理"></el-descriptions>
    </div>
    <div>
      <advertisementMag />
    </div>
  </div>
  </normalLayout>
</template>

<script>
import {mapGetters} from 'vuex'

import basicInfo from './modules/basicinfo.vue'

import setPassword from './modules/password.vue'
import setWatermark from './modules/watermark.vue'
import productImage from './modules/productImage.vue'

import loginSelect from './modules/loginSelect.vue'
import messageTips from '../messageSendtype/index.vue'
import advertisementMag from '../advertisement_mag/index'

export default {
  components:{
    setPassword,
    setWatermark,
    loginSelect,
    basicInfo,
    productImage,
    messageTips,
    advertisementMag
  },
  data () {
    return {
      basicInfo:{},
      obj:{},
      watermarkImage:{},
      productImage:{}
    }
  },
  computed:{
    ...mapGetters({
      siteinfo:'siteinfo'
    })
  },
  methods:{
    // 查询站点信息
    async infoData () {
      this.$store.dispatch('querySiteInfo',{
        "classname": "webmanage.site.site",
        "method": "querySite",
        "content": {}
      })
      console.log(1);
      
    },
    /*安全配置信息*/
    async querySite_Parameter () {
      
      const res = await this.$api.requested({
        "classname": "webmanage.site.site",
        "method": "querySite_Parameter",
        "content": {
        }
      })
      this.obj = {
        password_needcapital:res.data.password_needcapital,
        password_needlowercase:res.data.password_needlowercase,
        password_neednum:res.data.password_neednum,
        password_needspecialchar:res.data.password_needspecialchar,
        password_length:res.data.password_length,
        loginmode_account:res.data.loginmode_account,
        loginmode_phonenumber:res.data.loginmode_phonenumber,
        loginmode_wechat:res.data.loginmode_wechat
      }
    },
    /*企业水印*/
    async queryEnterpriseWatermark(){
      const res = await this.$api.requested({
        "classname": "system.attachment.Attachment",
        "method": "queryFileLink",
        "content": {
          "ownertable": 'sys_site',
          "ownerid": this.siteinfo.siteuid,
          "usetype":'watermark'//传空返回有所
        }
      })
      console.log(res,'企业水印信息')
      this.watermarkImage = {
        length:res.data.length,
        image:res.data.length !== 0 ? res.data[0].url: ''
      }
      console.log(this.watermarkImage)
    },
    /*产品默认图*/
    async queryProductImage(){
      const res = await this.$api.requested({
        "classname": "system.attachment.Attachment",
        "method": "queryFileLink",
        "content": {
          "ownertable": 'system',
          "ownerid": 1,
          "usetype":'defaultImage'//传空返回有所
        }
      })
      this.productImage = {
        length:res.data.length,
        image:res.data.length !== 0 ? res.data[0].url: ''
      }
    }
  },
  mounted () {
    this.infoData()
    this.querySite_Parameter()
    this.queryEnterpriseWatermark()
    this.queryProductImage()
  }
}

</script>
<style>
</style>
<style scoped>
.panel{
  padding: 50px;
  background: #fff;
  border-bottom: 1px solid #EEEEEE;
}
.panel img{
  margin-right: 30px;
}
.text-panel{
  display: flex;
  flex-direction:column;
  justify-content: space-between;
}
.explain-title{
  flex: 1 0 auto;
  width: 100%;
  font-size: 20px;
}
.explain-tips{
  color: #999999;
  font-size: 14px;
}
.color-yellow{
  color: #FA8C16;
}
</style>