xuqiang 4 jaren geleden
bovenliggende
commit
d83b26b10e
1 gewijzigde bestanden met toevoegingen van 25 en 19 verwijderingen
  1. 25 19
      src/main/pc-space/src/components/CouponInfo.vue

+ 25 - 19
src/main/pc-space/src/components/CouponInfo.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="page">
+    <div class="page" v-if="list">
         <div v-for="(item, index) in list" :key="index">
             <div class="coupon" @click="choose">
                 <div class="coupon-top">
@@ -13,45 +13,51 @@
                     <span>有效期至:{{ item.expiration }}</span>
                     <span v-if="!item.limited">规定商品可用</span>
                 </div>
-
-                <!-- <img v-if="chooseId === item.id" class="icon" src="../assets/icon_gouxuan_pre.png" alt="" />
-                <img v-else class="icon" src="../assets/icon_gouxuan_huise.png" alt="" /> -->
-                <el-empty v-if="empty" description="暂无兑换券哦~" />
             </div>
         </div>
+        <el-empty v-if="empty" description="暂无兑换券哦"></el-empty>
     </div>
 </template>
 
 <script>
 import { mapState } from 'vuex';
-import pageableTable from '../mixins/pageableTable';
 export default {
     name: 'couponList',
-    mixins: [pageableTable],
     data() {
         return {
-            url: '/userCoupon/all',
             list: [],
             empty: false,
             chooseId: 0
         };
     },
     computed: {
-        ...mapState(['couponInfo'])
+        ...mapState(['couponInfo', 'userInfo'])
     },
     mounted() {
-        console.log(this.list);
+        if (this.isLogin) {
+            this.add();
+        }
     },
     methods: {
-        beforeData() {
-            return {
-                query: {
-                    userId: this.userInfo.id
-                }
-            };
-        },
-        setList(list) {
-            this.list = list;
+        add() {
+            this.$http
+                .post(
+                    '/userCoupon/all',
+                    {
+                        query: {
+                            userId: this.userInfo.id
+                        }
+                    },
+                    {
+                        body: 'json'
+                    }
+                )
+                .then(res => {
+                    this.list = res.content;
+                    if (this.list.length === 0) {
+                        this.empty = true;
+                    }
+                });
         },
         choose(info) {
             this.$router.push('/collection');