selectCard.vue 2.99 KB
<template>
  <div class="help-main">
    <el-drawer class="help-drawer" size="1080px" title="更换卡背景" :visible.sync="drawer" :before-close="handleClose">
      <div class="market-container">
        <div class="help-drawer-h4">预览</div>
        <div class="drawer-overview">
          <img :src="require(`@/assets/img/home/card${selectIndex}.png`)" alt="" />
        </div>
        <div class="help-drawer-h4">名片模板</div>
        <div class="drawer-card">
          <div @click="selectIndex = item" v-for="item in 4" :key="item" :class="{ 'card-item': true, 'card-checked': selectIndex == item }">
            <img :src="require(`@/assets/img/home/card${item}.png`)" alt="" />
            <i class="el-icon-success" v-if="selectIndex == item"></i>
          </div>
        </div>
      </div>
      <div class="drawer-btn">
        <el-button @click="drawer = false" size="small">
          取消
        </el-button>
        <el-button type="primary" @click="handleSaveConfig" size="small">提交</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  name: 'marketConfig',
  data() {
    return {
      selectIndex: 1,
      drawer: false
    }
  },
  methods: {
    init(idx) {
      this.selectIndex = idx
      this.drawer = true
    },
    handleSaveConfig() {
      this.drawer = false
      this.$emit('cardConfigChecked', this.selectIndex)
    }
  }
}
</script>

<style lang="scss" scoped>
.help-drawer {
  /deep/ .el-drawer__header {
    border-bottom: 1px solid #e6e6e6;
    padding: 18px 20px;
    margin-bottom: 20px;
    font-size: 20px;
  }
  .market-container {
    padding: 20px;
    height: calc(100vh - 164px);
    overflow: auto;
    .help-drawer-h4 {
      font-size: 14px;
      color: #666666;
      line-height: 20px;
      font-weight: 500;
      margin-bottom: 10px;
    }
    .drawer-overview {
      height: 304px;
      width: auto;
      margin-bottom: 20px;
      img {
        width: auto;
        height: 100%;
      }
    }
    .drawer-card {
      display: flex;
      .card-item {
        cursor: pointer;
        width: 224px;
        height: 224px;
        background: #ffffff;
        border-radius: 8px;
        border: 1px solid #e5e5e5;
        margin-right: 24px;
        padding: 16px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        img {
          width: 100%;
          height: auto;
        }
        &.card-checked {
          box-shadow: 0px 6px 12px 0px rgba(0, 0, 0, 0.1);
          border: 1px solid #5850ff;
          position: relative;
          i {
            position: absolute;
            top: 6px;
            right: 6px;
            color: #5850ff;
            font-size: 16px;
          }
        }
        &:last-child {
          margin-right: 0px;
        }
      }
    }
  }
  .drawer-btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    height: 64px;
    border-top: 1px solid #e6e6e6;
  }
}
</style>