spike time 8.8

This commit is contained in:
2020-08-08 18:15:07 +08:00
parent 02702bc447
commit cef9296a78
9 changed files with 347 additions and 240 deletions

View File

@@ -9,8 +9,8 @@
</view>
<view class="num">剩余数量{{ groupbuyInfo.inventory - groupbuyInfo.groupbuy_buy_quantity }}</view>
</view>
<view class="right" v-if="!isSpike">
<view class="title">秒杀倒计时</view>
<view class="right" v-if="!isSrartSpike || !isEndSpike">
<view class="title">{{ isSrartSpike ? '结束倒计时' : '秒杀倒计时' }}</view>
<view class="time">{{ spikeTime }}</view>
</view>
<view class="right" v-else>
@@ -171,10 +171,11 @@
<text>客服</text>
</view>
</view>
<view class="btn" v-if="groupbuyInfo.groupbuy_state == 20 && groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity" @click="spikeGoods">立即秒杀</view>
<view class="btn" :class="{'cannot': groupbuyInfo.groupbuy_state == 32 || groupbuyInfo.inventory == groupbuyInfo.groupbuy_buy_quantity}" v-else>
{{ groupbuyInfo.groupbuy_state == 32 ? '时间已结束' : (groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity ? '立即秒杀' : '已售空') }}
</view>
<!-- <view class="btn" v-if="isSrartSpike && !isEndSpike && groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity" @click="spikeGoods">立即秒杀</view> -->
<view class="btn cannot" v-if="!isSrartSpike">秒杀未开始</view>
<view class="btn cannot" v-else-if="isEndSpike">时间已结束</view>
<view class="btn cannot" v-else-if="groupbuyInfo.inventory == groupbuyInfo.groupbuy_buy_quantity">已售空</view>
<view class="btn" v-else @click="spikeGoods">立即秒杀</view>
</view>
<!-- <tloos @buy="buy" @xuanze="xuanze" :id="id" :info="goodsInfo" :type="type"></tloos> -->
<u-toast ref="uToast" />
@@ -191,7 +192,7 @@ export default {
return {
list: [], // 轮播图列表
goodsInfo: {}, // 商品信息
storeInfo: {},
storeInfo: {}, // 店铺信息
glist: [], // 规格列表
id: 0, // 商品id/秒杀id/拼团 id
type: '', // 商品类型 商品详情 1普通 2拼团 3秒杀 4优惠券
@@ -201,16 +202,17 @@ export default {
showInvolvementUser: false, // 参团
involvemenGroupInfo: [], // 参团的人
groupbuyInfo: {}, // 秒杀详情
spikeTime: '00:00:00',
isSpike: false, // 是否超过秒杀时间
spikeTime: '00:00:00', // 秒杀倒计时(距离开始/距离结束)
isSrartSpike: false, // 是否开始秒杀
isEndSpike: false, // 是否超过秒杀时间
timer: '', // 秒杀时间定时器
spec_id: '', // 规格 id, 下单用的
evaluate: {}, // 评价内容
showSpec: false, // 是否显示选择规格
goodsNumber: 1,
goodsNumber: 1, // 购买商品数量
sel: "", // 拼接的规格
quanxuan: false, // 规格是否选择
debounce: true,
debounce: true, // 防止多次提交订单
storeid:0 //店铺id
}
},
@@ -289,11 +291,26 @@ export default {
spikeGoods() {
this.settlementOrder()
},
setSpikeTime(time) {
// const time = this.groupbuyInfo.groupbuy_endtime;
setSpikeTime() {
const startTime = this.groupbuyInfo.groupbuy_starttime;
const endTime = this.groupbuyInfo.groupbuy_endtime;
let time = startTime;
this.timer = setInterval(() => {
// 秒杀是否开始 秒杀开始后开始结束时间的倒计时
if(startTime * 1000 - new Date().getTime() > 0) {
this.isSrartSpike = false;
} else {
this.isSrartSpike = true;
time = endTime;
}
// 秒杀是否结束
if(endTime * 1000 - new Date().getTime() <= 0) {
this.isEndSpike = true;
}
let spikeTime = time * 1000 - new Date().getTime();
if(spikeTime <= 0) this.isSpike = true;
// 计算天数
const days = Math.floor(spikeTime/(24*3600*1000));
//计算出小时数
@@ -312,6 +329,10 @@ export default {
}, 1000)
},
addCart() {
if(!this.showSpec) {
this.showSpec = true;
return false;
}
this.$u.api.addCart({
goods_id: this.id,
quantity: this.goodsNumber,
@@ -393,12 +414,16 @@ export default {
this.evaluate = res.data.goodsInfo.goods_evaluate_info;
this.goodsInfo = res.data.goodsInfo.goods;
this.setSwiperList(res.data.goodsInfo.goods_image);
this.setSpikeTime(res.data.groupbuyInfo.groupbuy_starttime);
this.setSpikeTime();
}
})
},
// 试穿
tryDress() {
if(!this.showSpec) {
this.showSpec = true;
return false;
}
this.$u.route({
url: '/pageB/triedDress/index',
params: {
@@ -413,6 +438,10 @@ export default {
* @params {Number} ifcart 结算方式 1:购物车 0:直接结算(立即购买/拼团/秒杀)
**/
settlementOrder({type, num = this.goodsNumber, ifcart = 0} = {}) {
if(!this.showSpec) {
this.showSpec = true;
return false;
}
if(!this.debounce) return;
this.debounce = false;
let params = {
@@ -609,8 +638,8 @@ export default {
}
font-size: 26rpx;
font-weight: 500;
.title {
margin-bottom: 18rpx;
.time {
margin-top: 18rpx;
}
}
}