|
|
@ -12,8 +12,8 @@
|
|
|
|
<strong class="home-sckill-title">限时秒杀</strong>
|
|
|
|
<strong class="home-sckill-title">限时秒杀</strong>
|
|
|
|
<div class="home-sckill-wrap">
|
|
|
|
<div class="home-sckill-wrap">
|
|
|
|
<div class="home-sckill-wrap__tip">
|
|
|
|
<div class="home-sckill-wrap__tip">
|
|
|
|
<strong>10:00</strong>
|
|
|
|
<strong>{{ data.activityTimeVO.timeName }}</strong>
|
|
|
|
<span>点场 距结束</span>
|
|
|
|
<span>{{ seckillText }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="home-sckill-wrap__countdown flex flex-middle flex-center">
|
|
|
|
<div class="home-sckill-wrap__countdown flex flex-middle flex-center">
|
|
|
|
<div class="sckill-wrap-countdown__time">{{ countdown.hour }}</div>
|
|
|
|
<div class="sckill-wrap-countdown__time">{{ countdown.hour }}</div>
|
|
|
@ -66,6 +66,7 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import _ from "lodash";
|
|
|
|
import _ from "lodash";
|
|
|
|
|
|
|
|
import { FormatDate } from "@/plugins/utils";
|
|
|
|
|
|
|
|
|
|
|
|
const CAROUSEL_COUNT = 5; // 走马灯每页展示商品数
|
|
|
|
const CAROUSEL_COUNT = 5; // 走马灯每页展示商品数
|
|
|
|
|
|
|
|
|
|
|
@ -81,6 +82,9 @@ export default {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
bkgUrl: require("~/assets/img/sckill/bkg-small.png"),
|
|
|
|
bkgUrl: require("~/assets/img/sckill/bkg-small.png"),
|
|
|
|
goodsList: [],
|
|
|
|
goodsList: [],
|
|
|
|
|
|
|
|
seckillTime: 0, // 秒杀时间
|
|
|
|
|
|
|
|
seckillText: "", // 秒杀文案
|
|
|
|
|
|
|
|
timeInterval: null, // 倒计时定时器
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
@ -88,22 +92,37 @@ export default {
|
|
|
|
deep: true,
|
|
|
|
deep: true,
|
|
|
|
immediate: true,
|
|
|
|
immediate: true,
|
|
|
|
handler(val) {
|
|
|
|
handler(val) {
|
|
|
|
const { activityProductListVO: products } = val;
|
|
|
|
const {
|
|
|
|
|
|
|
|
currentTime,
|
|
|
|
|
|
|
|
activityProductListVO: products,
|
|
|
|
|
|
|
|
activityTimeVO: { activityEndTime, activityStartTime },
|
|
|
|
|
|
|
|
} = val;
|
|
|
|
if (products && products.length > 0) {
|
|
|
|
if (products && products.length > 0) {
|
|
|
|
this.getFormatData(products);
|
|
|
|
this.getFormatData(products);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getSeckillData({
|
|
|
|
|
|
|
|
currentTime,
|
|
|
|
|
|
|
|
startTime: activityStartTime,
|
|
|
|
|
|
|
|
endTime: activityEndTime,
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
|
|
|
|
|
// 秒杀活动倒计时
|
|
|
|
countdown() {
|
|
|
|
countdown() {
|
|
|
|
|
|
|
|
const date = FormatDate(this.seckillTime, "hh:mm:ss");
|
|
|
|
|
|
|
|
const [hour, minute, second] = date.split(":");
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
hour: "01",
|
|
|
|
hour,
|
|
|
|
minute: "32",
|
|
|
|
minute,
|
|
|
|
second: "09",
|
|
|
|
second,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
destroyed() {
|
|
|
|
|
|
|
|
clearInterval(this.timeInterval);
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
// 走马灯商品列表,五个商品为一组
|
|
|
|
// 走马灯商品列表,五个商品为一组
|
|
|
|
getFormatData(list) {
|
|
|
|
getFormatData(list) {
|
|
|
@ -118,6 +137,32 @@ export default {
|
|
|
|
this.goodsList.push(goodsListItem);
|
|
|
|
this.goodsList.push(goodsListItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// 获取秒杀时间数据
|
|
|
|
|
|
|
|
getSeckillData({ current, startTime, endTime }) {
|
|
|
|
|
|
|
|
current = new Date(current);
|
|
|
|
|
|
|
|
startTime = new Date(startTime);
|
|
|
|
|
|
|
|
endTime = new Date(endTime);
|
|
|
|
|
|
|
|
if (current > startTime && current < endTime) {
|
|
|
|
|
|
|
|
// 活动进行中
|
|
|
|
|
|
|
|
this.seckillText = "距结束";
|
|
|
|
|
|
|
|
this.seckillTime = endTime - current;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 活动未开始
|
|
|
|
|
|
|
|
this.seckillText = "距开始";
|
|
|
|
|
|
|
|
this.seckillTime = startTime - current;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setCountDownInterval();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 秒杀倒计时
|
|
|
|
|
|
|
|
setCountDownInterval() {
|
|
|
|
|
|
|
|
this.timeInterval = setInterval(() => {
|
|
|
|
|
|
|
|
if (this.seckillTime <= 0) {
|
|
|
|
|
|
|
|
clearInterval(this.timeInterval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.seckillTime -= 1000;
|
|
|
|
|
|
|
|
}, 1e3);
|
|
|
|
|
|
|
|
},
|
|
|
|
onJumpSeckill() {
|
|
|
|
onJumpSeckill() {
|
|
|
|
this.$router.push("/seckill");
|
|
|
|
this.$router.push("/seckill");
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -149,6 +194,7 @@ export default {
|
|
|
|
font-size: 0;
|
|
|
|
font-size: 0;
|
|
|
|
strong {
|
|
|
|
strong {
|
|
|
|
font-size: 18px;
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
span {
|
|
|
|
span {
|
|
|
|
font-size: 14px;
|
|
|
|
font-size: 14px;
|
|
|
|