<template>
  <div class="iphone">
    <span class="pageTitle">{{ card.pageTitle }}</span>
    <div class="content">
      <img :src="card.pageBackgroundImg" class="bgImg" v-if="card.pageBackgroundImg" />
      <div class="enterpriseInfo">
        <div class="logo">
          <img :src="card.merchantLogo" v-if="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>
</template>

<script>
export default {
  data() {
    return {
      card: {
        pageTitle: '',
        merchantName: '',
        merchantPhoneNumber: '',
        merchantLogo: '',
        pageBackgroundImg: '',
        guideComment: ''
      }
    };
  },
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    data: {
      handler(val) {
        if (val) {
          const { pageTitle, merchantName, merchantPhoneNumber, merchantLogo, pageBackgroundImg, guideComment } = val;
          this.card = { pageTitle, merchantName, merchantPhoneNumber, merchantLogo, pageBackgroundImg, guideComment };
        }
      },
      deep: true
    }
  }
};
</script>

<style type="text/scss" lang="scss" scoped>
.iphone {
  position: relative;
  display: inline-block;
  font-size: 0;
  line-height: 0;
  background-image: url('../assets/iphone3.png');
  background-repeat: no-repeat;
  background-size: 280px auto;
  width: 280px;
  height: 543px;
  .pageTitle {
    font-size: 14px;
    position: sticky;
    color: #000000;
    font-weight: 500;
    top: 105px;
    width: 125px;
    margin-left: 78px;
    line-height: 20px;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
  }
  .content {
    width: 228px;
    height: 410px;
    box-sizing: border-box;
    padding: 20px 16px;
    position: absolute;
    top: 97px;
    left: 26px;
    background: #ffffff;
    display: flex;
    align-items: center;
    flex-direction: column;
    border-radius: 10px 10px 24px 24px;
    .bgImg {
      position: absolute;
      width: 228px;
      border-radius: 10px 10px 24px 24px;
      top: 0;
      z-index: 0;
      max-height: 410px;
    }
    .enterpriseInfo {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      width: 100%;
      z-index: 100;
      .logo {
        width: 36px;
        height: 36px;
        background: #f6f6f6;
        border-radius: 60px;
        img {
          width: 36px;
          height: 36px;
          border-radius: 60px;
        }
      }
      .name {
        margin-left: 10px;
        font-size: 12px;
        font-weight: 500;
        color: #242835;
        line-height: 17px;
        width: 80%;
      }
    }
    .QRcode {
      z-index: 100;
      width: 176px;
      height: 176px;
      margin: 11px 0 16px 0;
      background: #f6f6f6;
      background-image: url('../assets/QRcode.png');
      background-size: 176px auto;
    }
    .leadingText {
      z-index: 100;
      font-size: 10px;
      color: #7f818a;
      line-height: 14px;
      width: 88%;
      text-align: center;
    }
    .enterpriseNum {
      z-index: 100;
      min-width: 130px;
      margin-top: 68px;
      height: 32px;
      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: 12px;
      }
      p {
        margin-left: 5px;
      }
    }
  }
}
</style>
