<style>
.WebSiteAbout {
  height: calc(100% - 15px);
}
.WebSiteAbout .WebSiteTopdiv {
  /* text-align: right; */
  margin: 10px auto;
  max-width: 1080px;
  min-width: 800px;

  height: calc(100% - 20px);
}
.WebSiteAbout .WebSiteTopdiv .title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 270px);
  padding: 10px 5px;
  margin: 15px 0 0 0;
  border: 1px solid #d1d1d1;
  border-bottom: 1px solid #eee;
  background: #fff;
}
</style>
<template>
  <!--关于我们-->
  <div class="WebSiteAbout">
    <div class="WebSiteTopdiv">
      <div class="title">
        <div>关于我们版面設定</div>
        <div>
          <el-button type="primary" size="small" @click="saveData()">保存</el-button>
          <el-button type="primary" size="small" @click="goAbout()">瀏覽頁面</el-button>
        </div>
      </div>
        <WebSiteEdit
          ref="WebSiteEdit"
          :templateData="postMsg.HomeDataList"
          v-on:getNewTemplateData="getNewTemplateData"
        ></WebSiteEdit>
    </div>
  </div>
</template>
<script>
import WebSiteEdit from "../WebSet/WebSiteEdit.vue";
export default {
  data() {
    return {
      postMsg: {
        Id: 0,
        AboutDataList: [],
        //当前登录用户信息
        CurrentUserInfo: {}
      }
    };
  },
  mounted() {
    this.getData();
    let userInfo = this.getLocalStorage();
    this.CurrentUserInfo = userInfo;
  },
  components: {
    WebSiteEdit
  },
  methods: {
    //获取配置
    getData() {
      this.apipost(
        "ws_get_GetHomeAboutTrip",
        {},
        res => {
          if (res.data.resultCode == 1) {
            var tempData = res.data.data;
            if (tempData) {
              if (tempData.Id) {
                this.postMsg.Id = tempData.Id;
              }
              if (tempData.AboutDataList && tempData.AboutDataList.length > 0) {
                this.postMsg.AboutDataList = tempData.AboutDataList;
              }
            }
            this.$refs.WebSiteEdit.initData(this.postMsg.AboutDataList);
          } else {
            this.Error(res.data.message);
          }
        },
        err => {}
      );
    },
    //保存数据
    saveData() {
      this.apipost(
        "ws_post_SetAboutData",
        this.postMsg,
        res => {
          if (res.data.resultCode == 1) {
            this.getData();
            this.Success(res.data.message);
          } else {
            this.Error(res.data.message);
          }
        },
        err => {}
      );
    },
    //获取模板数据
    getNewTemplateData(templateDataList) {
      this.postMsg.AboutDataList = templateDataList;
    },
    //跳转至预览
    goAbout() {
      var B2BDomain = this.CurrentUserInfo.B2BDomain;
      this.$tripUtils.GotoB2CAbout(B2BDomain);
    }
  }
};
</script>