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