<template>
<div class="siteInfo">
  <el-form ref="form" :model="form" label-width="80px" style="width: 80%">
    <el-form-item label="网站名称">
      <el-input v-model="form.SiteName"></el-input>
    </el-form-item>
    <el-form-item label="网站logo">
      <el-image
        style="width: 100px; height: 100px"
        :src="form.SiteLogo"></el-image>

      <el-button>选择图片</el-button>
    </el-form-item>
    <el-form-item label="客服电话">
      <el-input v-model="form.SitePhone"></el-input>
    </el-form-item>
    <el-form-item label="营业时间">
      <el-input v-model="form.SiteTime"></el-input>
    </el-form-item>
    <el-form-item label="企业地址">
      <el-input v-model="form.SiteAddress"></el-input>
    </el-form-item>
    <el-form-item label="版权信息">
      <el-input v-model="form.SiteCopyRight"></el-input>
    </el-form-item>
    <el-form-item label="备案号">
      <el-input v-model="form.SiteICP"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="savatInfo">保存</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
import { getSiteInfo } from '@/api/system/config'
export default {
  name: 'SiteInfo',
  data() {
    return {
      form: {
        SiteAddress: '',
        SiteCopyRight: '',
        SiteICP: '',
        SiteLogo: '',
        SiteName: '',
        SitePhone: '',
        SiteTime: ''
      }
    }
  },
  mounted() {
    this.getInfo()
  },
  methods: {
    // 获取网站信息
    getInfo() {
      var _that = this
      var data = {}
      getSiteInfo(data).then(res => {
        console.log(res)
        var info = res.data
        _that.form = {
          SiteAddress: info.SiteAddress,
          SiteCopyRight: info.SiteCopyRight,
          SiteICP: info.SiteICP,
          SiteLogo: info.SiteLogo,
          SiteName: info.SiteName,
          SitePhone: info.SitePhone,
          SiteTime: info.SiteTime
        }
      })
    },

    // 保存网站信息
    savatInfo() {
      var _that = this
      var data = {
        'configList': JSON.stringify(_that.form)
      }
      getSiteInfo(data).then(res => {
        // console.log(res);
        if (res.httpCode == 200) {
          _that.$message({
            message: '保存成功',
            type: 'success'
          })
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    }
  }
}
</script>

<style scoped>
.siteInfo{
  margin: 20px 40px;
}
</style>
