<template>
  <div class="card">
    <div class="head">
      <div class="operation">
        <div class="idNum">ID：{{ card.pageCode }}</div>
        <div class="btns">
          <el-button type="text" @click="$emit('relationDetail')">关联详情</el-button>
          <el-button type="text" @click="$emit('deleteTemp')">删除</el-button>
          <el-button type="text" @click="$emit('editTemp')">编辑</el-button>
        </div>
      </div>
      <div class="tempName">{{ card.pageName }}</div>
      <div class="cardName">
        <div class="createName">{{ card.createorName }}</div>

        <div class="createTime">{{ card.createTime | formatTimeStamp }}</div>
      </div>
    </div>
    <div class="iphone-content">
      <div class="iphone">
        <span class="pageTitle">{{ card.pageTitle }}</span>
        <img src="@/assets/iphone-head.png" />
        <div class="content">
          <img :src="card.pageBackgroudImg" v-show="card.pageBackgroudImg" class="bgImg" />
          <div class="enterpriseInfo">
            <div class="logo">
              <img :src="card.merchantLogo" />
            </div>
            <div class="name">{{ card.merchantName }}</div>
          </div>
          <div class="QRcode"></div>
          <div class="leadingText">{{ card.guideComment }}</div>
          <div class="enterpriseNum">
            <i class="iconfont-hb3 iconhuawushuju"></i>
            <p>{{ card.merchantPhoneNumber }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      card: {
        pageName: '',
        pageCode: '',
        pageId: '',
        pageTitle: '',
        merchantName: '',
        merchantPhoneNumber: '',
        merchantLogo: '',
        pageBackgroudImg: '',
        guideComment: ''
      }
    };
  },

  props: {
    content: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    content: {
      handler(val) {
        if (val) {
          const { pageName, pageCode, pageId, pageTitle, merchantName, merchantPhoneNumber, merchantLogo, pageBackgroudImg, guideComment, createorName, createTime } = val;
          this.card = { pageName, pageCode, pageId, pageTitle, merchantName, merchantPhoneNumber, merchantLogo, pageBackgroudImg, guideComment, createorName, createTime };
        }
      },
      immediate: true
    }
  }
};
</script>

<style type="text/scss" lang="scss" scoped>
.card {
  width: 384px;
  height: 687px;
  border-radius: 8px;
  border: 1px solid #dcdfe6;
  background: #e5e7ed;
  .head {
    width: 384px;
    height: 87px;

    border-radius: 8px 8px 0px 0px;
    box-sizing: border-box;
    padding: 15px 16px 8px 16px;
  }
  .operation {
    display: flex;
    justify-content: space-between;
    margin-bottom: 7px;
    .idNum {
      font-size: 12px;
      color: #606266;
      line-height: 17px;
    }
  }
  .tempName {
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    line-height: 20px;
  }
  .cardName {
    display: flex;
    justify-content: space-between;
    .createName,
    .createTime {
      font-size: 12px;

      color: #606266;
      line-height: 17px;
    }
  }
  .iphone-content {
    width: 384px;
    height: 600px;
    display: flex;
    justify-content: center;
    background: #ffffff;

    border-radius: 0px 0px 8px 8px;
  }
  .iphone {
    width: 320px;
    height: 570px;
    background: #f7f8fa;
    box-shadow: 0px 4px 8px 0px rgba(220, 223, 230, 0.6);
    border-radius: 8px;
    position: relative;
    margin-top: 11px;
    .pageTitle {
      position: absolute;
      font-size: 14px;
      color: #000000;
      font-weight: 500;
      width: 135px;
      margin-left: 85px;
      line-height: 20px;
      white-space: nowrap;
      text-align: center;
      top: 44px;
    }
    .content {
      width: 320px;
      height: 475px;
      background: #ffffff;
      border-radius: 8px;
      top: 95px;
      left: 0;
      box-sizing: border-box;
      padding: 20px 16px;
      position: absolute;
      display: flex;
      align-items: center;
      flex-direction: column;

      .bgImg {
        position: absolute;
        width: 100%;
        border-radius: 8px;
        top: 0;
        z-index: 0;
        max-height: 100%;
      }
      .enterpriseInfo {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        z-index: 100;
        margin-bottom: 19px;
        .logo {
          width: 48px;
          height: 48px;
          background: #f6f6f6;
          border-radius: 60px;
          img {
            width: 48px;
            height: 48px;
            border-radius: 60px;
          }
        }
        .name {
          margin-left: 10px;

          font-size: 14px;
          font-weight: 500;
          color: #242835;

          line-height: 20px;
          width: 80%;
        }
      }
      .QRcode {
        z-index: 100;
        width: 236px;
        height: 236px;
        background: #f6f6f6;
        background-image: url('../../../../../assets/QRcode.png');
        background-size: 236px auto;
      }
      .leadingText {
        z-index: 100;
        font-size: 12px;
        color: #7f818a;
        line-height: 17px;
        width: 88%;
        margin-top: 16px;
        height: 50px;
        text-align: center;
      }
      .enterpriseNum {
        z-index: 100;
        min-width: 160px;
        margin-top: 25px;
        height: 40px;
        box-sizing: border-box;
        border-radius: 40px;
        border: 1px solid #9da0a6;
        display: flex;
        align-items: center;
        padding: 9px 12px;
        line-height: 14px;
        color: #63666b;
        font-size: 12px;
        i {
          font-size: 17px;
        }
        p {
          margin-left: 5px;
        }
      }
    }
  }
}
</style>
