|
@@ -0,0 +1,192 @@
|
|
|
+<template>
|
|
|
+ <div class="hui-flex hui-content border-box">
|
|
|
+ <div class="hui-content-title">
|
|
|
+ <div class="hui-title-item active">优惠券</div>
|
|
|
+ </div>
|
|
|
+ <div class="hui-flex-box">
|
|
|
+ <ul class="coupon-list">
|
|
|
+ <li :class="item.state === 1?'coupon-item':'coupon-item use'" v-for="(item,index) in list" :key="index">
|
|
|
+ <div class="coupon-info">
|
|
|
+ <div class="coupon-val">
|
|
|
+ <div v-if="item.type === 1">
|
|
|
+ <span class="symbol">¥</span>
|
|
|
+ <span class="coupon-val-num">{{item.couponAmount}}</span>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <span class="coupon-val-num">{{item.discount*100}}</span>
|
|
|
+ <span class="symbol">折</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <p class="coupon-condition">
|
|
|
+ {{item.type === 1?`满${item.threshold}减${item.couponAmount}`:`满${item.threshold}可用,最高抵扣${item.mostConstraint}`}}
|
|
|
+ </p>
|
|
|
+ <p class="coupon-condition">
|
|
|
+ 有效期至:{{$dayjs(item.receiveTime).add(item.lifespan, 'hour').format('YYYY-MM-DD HH:mm:ss')}}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <div class="coupon-detail">
|
|
|
+ <p class="coupon-detail-title">使用规则</p>
|
|
|
+ <div class="coupon-detail-content">
|
|
|
+ <div class="coupon-detail-item" v-for="(item,index) in JSON.parse(item.description)"
|
|
|
+ :key="index">
|
|
|
+ {{(index+1)+'.'+item.content}}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="coupon-status">
|
|
|
+ {{returnStateName(item.state)}}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ getCouponListByQuery
|
|
|
+ } from '@/api/discount'
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ list: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ getCouponListByQuery({
|
|
|
+ userId: this.$store.getters.user.userId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.list = res.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ returnStateName(state) {
|
|
|
+ let str = '';
|
|
|
+ switch (state) {
|
|
|
+ case 1:
|
|
|
+ str = '待使用'
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ str = '已使用'
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ str = '已过期'
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .coupon-list {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ padding: 10px;
|
|
|
+
|
|
|
+ .coupon-item {
|
|
|
+ width: 248px;
|
|
|
+ margin: 10px;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-info {
|
|
|
+ height: 120px;
|
|
|
+ background: $--color-primary;
|
|
|
+ border-radius: 5px;
|
|
|
+ position: relative;
|
|
|
+ color: $--color-white;
|
|
|
+ padding: 15px 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-val {
|
|
|
+ padding-bottom: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-val-num {
|
|
|
+ font-size: 30px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-condition {
|
|
|
+ font-size: $--font-size-small;
|
|
|
+ margin-top: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-detail {
|
|
|
+ height: 180px;
|
|
|
+ padding: 15px 20px;
|
|
|
+ border: 1px solid $--border-color-base;
|
|
|
+ border-radius: 5px;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ &:after,
|
|
|
+ &:before {
|
|
|
+ content: "";
|
|
|
+ width: 14px;
|
|
|
+ height: 14px;
|
|
|
+ background: #fff;
|
|
|
+ border-bottom: 1px solid $--border-color-base;
|
|
|
+ border-radius: 7px;
|
|
|
+ position: absolute;
|
|
|
+ top: -7px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:after {
|
|
|
+ border-left: 1px solid $--border-color-base;
|
|
|
+ transform: rotate(45deg);
|
|
|
+ right: -7px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:before {
|
|
|
+ border-left: 1px solid $--border-color-base;
|
|
|
+ transform: rotate(-45deg);
|
|
|
+ left: -7px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-detail-title {
|
|
|
+ margin-bottom: 5px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-detail-content {
|
|
|
+ color: $--color-text-secondary;
|
|
|
+ font-size: $--font-size-small;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-detail-item {
|
|
|
+ margin-bottom: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-status {
|
|
|
+ width: 128px;
|
|
|
+ height: 32px;
|
|
|
+ line-height: 32px;
|
|
|
+ background: $--color-primary;
|
|
|
+ color: $--color-white;
|
|
|
+ text-align: center;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 58px;
|
|
|
+ right: 0;
|
|
|
+ transform-origin: right top;
|
|
|
+ transform: rotate(-45deg);
|
|
|
+ }
|
|
|
+
|
|
|
+ .use {
|
|
|
+
|
|
|
+ .coupon-status,
|
|
|
+ .coupon-info {
|
|
|
+ background: #b4b6b7;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|