VipDialog.vue 3.68 KB
<template>
  <van-action-sheet
    v-model="showBox"
    cancel-text="取消"
    close-on-click-action
    @cancel="onCancel"
    @click-overlay="onCancel"
    close-on-popstate
  >
    <div class="box">
      <div class="title flex">
        <div class="name text-hide">{{data.packageName}}</div>
        <div class="subtitle">内含{{data.couponsDetailList&&data.couponsDetailList.length}}项权益项目</div>
      </div>
      <div class="items">
        <template v-for="(i,index) in data.couponsDetailList">
          <div
            :key="index"
            class="item"
          >
            <div class="name flex">
              {{index + 1}}、{{i.couponName}}
              <div class="num">数量:x{{i.serviceQuantity}}</div>
            </div>
            <div class="decoration flex">
              <template v-if="i.effectiveType == 1">
                有效期:{{i.effectiveDays}}天
              </template>
              <template v-else-if="i.effectiveType == 2">
                有效期:{{new Date(i.effectiveStartTime).format('yyyy-MM-dd')}} ~ {{new Date(i.effectiveEndTime).format('yyyy-MM-dd')}}
              </template>
              <template v-else>
                无有效期
              </template>
              <span>
                <template v-if="i.useType == '0'">
                  不限制次数
                </template>
                <template v-if="i.useType == 1">
                  有效期内可用{{i.useAmount}}次
                </template>
                <template v-if="i.useType == 2">
                  {{i.useLimitDays}}天内使用{{i.useAmount}}次
                </template>
              </span>
            </div>
          </div>
        </template>
      </div>
      <div class="tips">
        <template v-if="data.notes">
          附:{{data.notes}}
        </template>

      </div>
    </div>

  </van-action-sheet>
</template>

<script type='text/ecmascript-6'>
import { equityApi } from '@/api'

export default {
  name: 'VipDialog',
  props: ['value', 'id'],
  watch: {
    value (n) {
      let { id, component_id } = this
      if (component_id == id && n) {
        this.showBox = true
        return
      }
      if (n) {
        this.showLoading()
        this.component_id = id
        equityApi.getEquityDetail({ id }).then(res => {
          console.log(res)
          this.data = res
          this.hideLoading()
          this.showBox = true
        }).catch(() => {
          this.hideLoading()
        })
      }
    }
  },
  data () {
    return {
      showBox: false,
      data: {},
      component_id: ''
    }
  },
  mounted () {
  },
  methods: {
    onCancel () {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped lang='scss'>
.box {
  padding: 0 16px;
  .title {
    height: 56px;
    color: #333333;
    font-size: 16px;
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 2;
    .name{
      max-width: 70%;
    }
    .subtitle {
      font-size: 12px;
      color: #3a3a3a;
      margin-left: auto;
    }
  }
  .tips {
    color: #656566;
    font-size: 11px;
    padding: 9px 0 22px;
    word-break: break-all;
  }
  .items {
    padding-left: 23px;
    .item {
      height: 61px;
      border-bottom: 1px solid #f8f8f8;
      position: relative;
      font-size: 14px;
      color: #333333;
      padding: 12px 0;
      box-sizing: border-box;
      .name {
        width: calc(100% + 23px);
        margin-left: -23px;
        font-weight: 500;
        .num {
          margin-left: auto;
          color: #282829;
          font-size: 12px;
        }
      }
      .decoration {
        font-size: 12px;
        color: #cfcfd1;
        span {
          margin-left: auto;
        }
      }
    }
  }
}
</style>