RedEnvelopeItem.vue 2.01 KB
<template>
  <div
    @click="chooseRed(data.id)"
    :class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
  >
    <div class="icon">
      <img src="@/assets/red-radio.png" />
    </div>
    <div class="title">{{ data.activityName }}</div>
    <div class="type">活动形式:{{ {0: '随机红包', 1: '九宫格', 2: '翻牌', 3: '大转盘' }[data.activityType] }}</div>
    <div class="time">活动时间:{{dayjs(data.activityStartTime).format('YYYY/MM/DD')}} - {{dayjs(data.activityEndTime).format('YYYY/MM/DD')}}</div>
    <div class="status">状态:{{ {0: '活动待进行', 1: '活动进行中', 2: '红包已用完', 3: '活动已结束' }[data.activityStatus] }}</div>
  </div>
</template>

<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'

export default {
  name: '',
  props: {
    data: {
      type: Object,
      default: () => { }
    },
    configForm: {
      type: Object,
      default: () => { }
    },
    disabled: Boolean
  },
  data () {
    return {
      dayjs,
    }
  },
  mounted () {
  },
  methods: {
    chooseRed (id) {
      const { activityId } = this.configForm,
        { disabled } = this
      if (disabled) return
      if (activityId && activityId == id) id = ''
      this.$emit('choose', id)
    }
  }
}
</script>

<style scoped lang='scss'>
.item {
  width: 282px;
  height: 132px;
  background: #f9f9f9;
  border-radius: 4px;
  border: 2px solid #f9f9f9;
  box-sizing: border-box;
  cursor: pointer;
  padding: 0 16px;
  font-size: 14px;
  color: #666666;
  line-height: 20px;
  position: relative;
  user-select: none;
  .icon {
    display: none;
  }
  div {
    margin-top: 8px;
  }
  .title {
    font-weight: 500;
    font-size: 14px;
    color: #333333;
    padding-top: 4px;
  }
  &:hover {
    opacity: 0.95;
  }
}
.active {
  border-color: #5850ff;
  .icon {
    display: block;
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    background-color: #5850ff;
  }
}
.disabled {
  cursor: not-allowed;
}
</style>