<template>
  <div class="subject">
    <h1>添加捐赠记录</h1>
    <div class="default-list">
      <div
        class="default-list-item"
        v-for="(item, index) in theTemplateList"
        :key="index"
        :style="bg(item)"
        @click="EnterSystemTemplate(item)"
      >
        <span class="default-list-item-name">{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { GO_URLS } from "@/config/URLS";
import * as storage from "@/plugins/storage";
export default {
  //   引入组件
  components: {},
  props: [],
  data() {
    return {
      theTemplateList: [], //系统模板>分类>模板: "",
    };
  },
  created() {
    this.listOfSystem();
  },
  computed: {
    //
  },
  methods: {
    // 进入系统模板
    EnterSystemTemplate(item) {
      this.$router.push({
        path: "/editTemplate",
        query: { systemTemplateId: item.id },
      });
    },
    // 背景图
    bg(item) {
      if (item.image_url) {
        return "background-image:url('" + item.image_url + "')";
      } else {
        return "background-image:url('https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3622895792,2096692088&fm=26&gp=0.jpg')";
      }
    },
    async listOfSystem() {
      const res = await this.$ajax({
        url: GO_URLS.systemList,
        type: "post",
      });
      if (res && res.data && res.data.results[0]) {
        this.theTemplateList = res.data.results[0].detail;
      }
    },
  },
};
</script>
<style scoped lang="less">
.subject {
  width: 799px;
  height: 542px;
  background: #ffffff;
  border-radius: 10px;
}
h1 {
  line-height: 67px;
  text-align: center;
  margin: 0;
  padding: 0;
  font-size: 22px;
  color: #353535;
  border-bottom: 1px solid #e9e9e9;
}
.default-list {
  margin-top: 27px;
  margin-left: 16px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  display: -webkit-flex;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-box-pack: start;
  -ms-flex-pack: start;
  justify-content: flex-start;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}
.default-list-item {
  width: 228px;
  height: 116px;
  border-radius: 5px;
  margin-bottom: 20px;
  margin-left: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  position: relative;
  cursor: pointer;
}
.default-list-item-name {
  font-size: 16px;
  font-family: PingFangSC-Semibold;
  font-weight: 600;
  color: #ffffff;
  line-height: 22px;
  position: absolute;
  top: 20px;
  left: 20px;
}
</style>

