panhui %!s(int64=4) %!d(string=hai) anos
pai
achega
fe99c38ca0
Modificáronse 4 ficheiros con 56 adicións e 22 borrados
  1. 23 10
      src/mixins/product.js
  2. 2 2
      src/styles/app.less
  3. 3 8
      src/views/Home.vue
  4. 28 2
      src/views/product/Detail.vue

+ 23 - 10
src/mixins/product.js

@@ -39,7 +39,9 @@ export default {
                 最HOT收藏品: 'soldOut;likes,desc;sort,desc;createdAt,desc',
                 更多藏品: 'soldOut;source,asc;sale,desc;likes,desc'
             },
-            timer: null
+            startTimetimer: null,
+            saleTimetimer: null,
+            saleTime: ''
         };
     },
     computed: {
@@ -56,6 +58,13 @@ export default {
                 return false;
             }
         },
+        isSale() {
+            if (this.info.saleTime) {
+                return this.dayjs().isBefore(this.dayjs(this.info.saleTime));
+            } else {
+                return false;
+            }
+        },
         isSold() {
             return this.info && this.info.soldOut && this.info.salable;
         },
@@ -85,11 +94,15 @@ export default {
             n = n + '';
             return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
         },
-        getTime(startTime) {
+        getTime(startTime, key = 'startTime') {
             if (!startTime) {
                 return;
             }
-            if (!this.isAppointment) {
+            if (key == 'startTime' && !this.isAppointment) {
+                return;
+            }
+
+            if (key == 'saleTime' && !this.isSale) {
                 return;
             }
 
@@ -103,25 +116,25 @@ export default {
                 str += d + '天 ';
             }
 
-            this.startTime =
+            this[key] =
                 str +
                 this.pad(parseInt(seconds / 3600) % 24, 2) +
                 ':' +
                 this.pad(parseInt(seconds / 60) % 60, 2) +
                 ':' +
                 this.pad(seconds % 60, 2);
-            if (this.timer) {
-                clearTimeout(this.timer);
-                this.timer = null;
+            if (this[key + 'timer']) {
+                clearTimeout(this[key + 'timer']);
+                this[key + 'timer'] = null;
             }
             if (!this.dayjs().isBefore(this.dayjs(startTime, 'YYYY-MM-DD HH:mm:ss'))) {
                 if (this.getProduct) {
                     this.getProduct();
                 }
-                this.startTime = '';
+                this[key] = '';
             } else {
-                this.timer = setTimeout(() => {
-                    this.getTime(startTime);
+                this[key + 'timer'] = setTimeout(() => {
+                    this.getTime(startTime, key);
                 }, 1000);
             }
         },

+ 2 - 2
src/styles/app.less

@@ -214,8 +214,8 @@ input:-webkit-autofill {
     bottom: 0;
     filter: blur(20px);
     background-position: center;
-    background-size: cover;
-    background-attachment: fixed;
+    background-size: content;
+    // background-attachment: fixed;
 }
 .van-key--blue {
     background-color: @prim!important;

+ 3 - 8
src/views/Home.vue

@@ -24,11 +24,11 @@
             v-if="banners.length > 0"
         >
             <swiper-slide v-for="item in banners" :key="item.id">
-                <product-small :info="item"></product-small>    
+                <product-small :info="item"></product-small>
             </swiper-slide>
         </swiper>
 
-        <div class="tabs">
+        <div class="tabs" v-if="!empty">
             <div class="tab" :class="{ active: active === 0 }" @click="active = 0">数字藏品</div>
             <div class="tab" :class="{ active: active === 1 }" @click="active = 1">产品新闻端</div>
         </div>
@@ -121,6 +121,7 @@ export default {
             this.getProduct('LIST').then(res => {
                 this.products = res;
             });
+            this.getNews();
         },
         getProduct(type = 'BANNER') {
             return this.$http
@@ -153,9 +154,6 @@ export default {
             if (this.page === 0) {
                 this.list = [];
             }
-            this.loading = true;
-            this.finished = false;
-            this.empty = false;
             this.$http
                 .post(
                     '/collection/all',
@@ -172,9 +170,6 @@ export default {
                 )
                 .then(res => {
                     this.list = [...this.list, ...res.content];
-                    this.empty = res.empty;
-                    this.loading = false;
-                    this.finished = res.last;
                     if (!this.finished) {
                         this.page = this.page + 1;
                     }

+ 28 - 2
src/views/product/Detail.vue

@@ -256,22 +256,44 @@
                             <span>{{ startTime }}</span>
                         </div>
                     </van-button>
+
                     <!-- <van-button class="no-btn" v-else-if="isSold" block round>已售罄</van-button> -->
                     <van-button class="no-btn" v-else-if="isSolded" block round>已售罄</van-button>
                     <van-button class="no-btn" v-else-if="isSold" block round>即将售罄</van-button>
                     <van-button class="no-btn" v-else-if="limit.limit > 0 && limit.count >= limit.limit" block round>
                         限购{{ limit.limit }}件
                     </van-button>
-                    <template v-else-if="assignment && assignments.length < assignment">
+                    <template v-else-if="assignment && ((isLogin && userInfo.vipPoint < 1) || !isLogin)">
                         <div class="btn-assignments" v-if="isLogin && userInfo.vipPurchase">
                             <van-button @click="vipAssignment" class="vip" type="danger" block round>
                                 vip通道
                             </van-button>
-                            <van-button @click="share" type="primary" block round>邀请获取 </van-button>
+                            <van-button style="font-size: 12px;" class="no-btn" v-if="info.vipQuota < 1" block round>
+                                名额为空
+                            </van-button>
+                            <van-button @click="share" v-else type="primary" block round>邀请获取 </van-button>
                         </div>
+                        <van-button
+                            style="font-size: 12px;"
+                            class="no-btn"
+                            v-if="info.vipQuota < 1 || assignments.length >= assignment"
+                            block
+                            round
+                        >
+                            活动名额已被抢光
+                        </van-button>
                         <van-button @click="share" v-else type="primary" block round>邀请获取白名单 </van-button>
                     </template>
 
+                    <template v-else-if="assignment && isSale && info.timeDelay">
+                        <van-button class="no-btn" block round>
+                            <div class="appoint">
+                                <span style="font-size: 12px;">任务完成,即将抢购</span>
+                                <span>{{ saleTime }}</span>
+                            </div>
+                        </van-button>
+                    </template>
+
                     <van-button v-else type="primary" block round @click="buy">
                         {{ info.couponPayment ? '立即兑换' : '立即购买' }}
                     </van-button>
@@ -362,6 +384,7 @@ export default {
     mounted() {
         this.$store.dispatch('getUsedBuy');
         this.$store.dispatch('getTime');
+        this.$store.dispatch('getUserInfo');
         this.getProduct();
         this.$http.get('/order/checkLimit', { collectionId: this.$route.query.id }).then(res => {
             this.limit = res;
@@ -453,6 +476,9 @@ export default {
                         });
                     }
                     this.getTime(res.startTime);
+                    if (res.saleTime) {
+                        this.getTime(res.saleTime, 'saleTime');
+                    }
                     this.$nextTick(() => {
                         if (this.isBuy) {
                             this.btn = this.$refs.btn;