verificationDetail.vue 8.88 KB
<template>
  <div
    class="layout"
    v-if="flag"
  >
    <div class="title">客户信息</div>
    <div class="box">
      <template v-for="(i,index) in customerObj">
        <div
          :key="index"
          class="item flex"
        >
          <div class="label">{{i.label}}</div>
          <div class="value">
            <template v-if="i.format">
              {{ i.format(detail)}}
            </template>
            <template v-else>
              {{detail[i.key] || ''}}
            </template>
          </div>
        </div>
      </template>
    </div>
    <div class="title">{{detail.discountType == 7?'服务信息':'优惠券信息'}}</div>
    <div class="box">
      <template v-for="(i,index) in  infoObj">
        <div
          :key="index"
          class="item flex"
          v-if="detail[i.key]"
        >
          <div class="label">
            {{i.label}}
            <template v-if="i.tipsLabel">
              <div class="item-tips">{{i.tipsLabel}}</div>
            </template>
          </div>
          <div class="value">
            <template v-if="i.format">
              <div v-html="i.format(detail)"></div>
            </template>
            <template v-else>
              <span class="gift-name"><span v-if="i.key == 'directionalGiftName' && detail.merchantType==2" class="group-label">集团</span> {{detail[i.key] || ''}}</span>
              <template v-if="i.tipsValue">
                <div
                  class="item-tips"
                  v-html="i.tipsValue(detail)"
                ></div>
              </template>
            </template>
          </div>
        </div>
      </template>
      <template v-if="detail.discountType == 7">
        <div class="item flex">
          <div class="label">使用限制</div>
          <div class="value flex">
            <div class="value-btn text-center">
              已经核销{{detail.usedAmount}}次
            </div>
            <div class="use-type">
              <template v-if="detail.useType == 0">不限次数</template>
              <template v-else-if="detail.useType == 1">
                {{detail.effectiveType > 2 ? '' : '有效期内'}}可用{{detail.useAllAmount}}次
              </template>
              <template v-else>
                每隔{{detail.useLimitDays}}天
                |
                可用{{detail.useAmount}}次
              </template>
            </div>
          </div>
        </div>
        <template v-if="detail.directionalGiftName">
          <div class="item flex">
            <div class="label">
              所属定向礼包
              <div
                v-if="detail.directionalGiftReceiveWay"
                class="item-tips"
              >领取条件</div>
            </div>
            <div class="value">
              <span class="gift-name"><span v-if="detail.merchantType==2" class="group-label">集团</span>{{detail.directionalGiftName}}</span>
              <div class="item-tips">
                <template v-if="detail.directionalGiftReceiveCondition">
                  {{detail.directionalGiftReceiveWay == 1?'手机号':'车架号后6位'}}:{{detail.directionalGiftReceiveCondition}}
                </template>
                <template v-else>直接领取</template>
              </div>
            </div>
          </div>
        </template>
      </template>
      <div class="item flex">
        <div class="label">发放门店</div>
        <div class="value">
          {{detail.userCouponMerchantName}}
        </div>
      </div>
      <div
        v-if="detail.packageId"
        class="item flex"
      >
        <div class="label">所属套餐</div>
        <div class="value">
          <div class="value">{{ detail.packageName }}</div>
          <div
            v-if="detail.receiveWay == 6"
            class="sprite-icon icon-detail-group"
          ></div>
        </div>
      </div>

    </div>
    <div
      v-if="!hideBtn"
      class="btn text-center"
      @click="submit"
    >确认核销</div>
  </div>
</template>

<script type='text/ecmascript-6'>
import { discountTypeMixin } from '@/mixins'
import { couponApi } from '@/api'
const couponObj = [
  {
    label: '优惠券名称',
    key: 'couponName'
  },
  {
    label: '券编号',
    key: 'verificationCode'
  },
  {
    label: '类型',
    key: 'discountType',
    format (item) {
      return `${window.$discountType[item.discountType]}券`
    }
  },
  {
    label: '所属定向礼包',
    key: 'directionalGiftName',
    tipsLabel: '领取条件',
    tipsValue (item) {
      return item.directionalGiftReceiveCondition ? `${item.directionalGiftReceiveWay == 1 ? '手机号' : '车架号后6位'}:${item.directionalGiftReceiveCondition}` : '直接领取'
    }
  },
  {
    label: '发放人',
    key: 'issueName'
  },
  {
    label: '发放时间',
    key: 'issueDate',
    format (item) {
      return item.issueDate ? new Date(item.issueDate).format('yyyy年MM月dd日') : ''
    }
  }
]
const vipObj = [
  {
    label: '所属套餐',
    key: 'packageName'
  },
  {
    label: '服务名称',
    key: 'couponName'
  },
  {
    label: '类型',
    key: 'discountType',
    format () {
      return '服务券'
    }
  },
  {
    label: '有效期',
    key: 'effectiveType',
    format (item) {
      let { effectiveType } = item
      let str = ''
      if (effectiveType == 1) str = `${item.effectiveDays}天`
      else if (effectiveType == 1) str = `${new Date(item.effectiveStartTime).format('yyyy/MM/dd')} ~ ${new Date(item.effectiveEndTime).format('yyyy/MM/dd')}`
      else str = '无有效期'
      return str
    }
  },
]
export default {
  name: '',
  mixins: [discountTypeMixin],
  data () {
    return {
      detail: {},
      customerObj: [
        {
          label: '客户姓名',
          key: 'userName'
        },
        {
          label: '客户手机号',
          key: 'phone'
        },
        {
          label: '领取时间',
          key: 'receiveTime',
          format (item) {
            return item.receiveTime ? new Date(item.receiveTime).format('yyyy年MM月dd日') : ''
          }
        }
      ],
      infoObj: [],
      verficationCode: '',
      flag: false,
      hideBtn: false
    }
  },
  activated () {
    let { verficationCode, hideBtn } = this.getParams()
    this.showLoading()
    this.hideBtn = hideBtn
    couponApi.scan({ verficationCode }).then(res => {
      this.hideLoading()
      this.detail = res || {}
      this.infoObj = res.discountType == 7 ? vipObj : couponObj
      this.verficationCode = verficationCode
      this.flag = true
    })
  },
  mounted () {

  },
  deactivated () {
    Object.assign(this.$data, this.$options.data.call(this))
  },
  methods: {
    submit () {
      let { detail: { discountType } } = this
      let { verficationCode } = this
      this.showLoading()
      couponApi.verificationCode({ verficationCode }).then(res => {
        this.hideLoading()
        if (res) {
          this.$route.params.discountType = discountType
          this.showToast('已核销', () => {
            this.$router.back()
          })
        }
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.layout {
  padding: 0 16px 60px;
  .title {
    padding: 16px 0 10px;
    font-weight: 500;
    font-size: 16px;
    color: #393939;
  }
  .box {
    background: #ffffff;
    box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
    border-radius: 4px;
    .item {
      height: 66px;
      font-size: 14px;
      color: #3a3a3a;
      padding: 0 16px;
      border-bottom: 1px solid rgba(195, 195, 195, 0.3);
      &-tips {
        color: #666666;
        margin-top: 10px;
        font-size: 12px;
      }
      .label {
        .item-tips {
          margin-left: 8px;
        }
      }
      &:last-of-type {
        border-bottom: none;
      }
      .value {
        margin-left: auto;
        color: #333333;
        text-align: right;
        &-btn {
          font-size: 12px;
          color: #3975c6;
          // padding: 0 6px;
          height: 24px;
          // background: rgba(57, 117, 198, 0.15);
          // border-radius: 4px;
          margin-right: 4px;
        }
        .gift-name{
           display: flex;
           align-items: center;
          .group-label{
            width: 42px;
            height: 20px;
            line-height: 20px;
            display: inline-block;
            text-align: center;
            background: rgba(255,101,61,0.15);
            border-radius: 4px;
            font-size: 12px;
            margin-right: 4px;
            color: #FF653D;
          }
        }
        .item-tips {
          color: #333333;
        }
      }
    }
  }
  .btn {
    position: fixed;
    width: 343px;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    height: 42px;
    font-size: 14px;
    border-radius: 21px;
    box-sizing: border-box;
  }
}
.icon-detail-group {
  width: 64px;
  height: 24px;
  background-image: url(../../assets/images/icon-detail-group.png);
  background-size: 64px 24px;
  margin-top: 4px;
}
</style>