【秒杀商品详情】

1. 接入秒杀状态
pull/1/MERGE
YunaiV 2023-06-10 23:18:33 +08:00
parent 9e74d2a704
commit eab00bf2a6
1 changed files with 35 additions and 61 deletions

View File

@ -26,12 +26,12 @@
<text class='num'>{{ fen2yuan(spu.price) }}</text>
<text class='y-money'>{{ fen2yuan(spu.marketPrice) }}</text>
</view>
<!-- TODO 活动状态 -->
<!-- 活动状态 -->
<view class='acea-row row-middle'>
<view class='time' v-if="status == 2">
<view class='time' v-if="status === 2">
<view>距秒杀结束仅剩</view>
<countDown :bgColor="bgColor" :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '" :minute-text="' : '" :second-text="' '"
:datatime="datatime"></countDown>
<countDown :bgColor="bgColor" :is-day="false" :datatime="activity.endTime / 1000"
:tip-text="' '" :day-text="' '" :hour-text="' : '" :minute-text="' : '" :second-text="' '" />
</view>
</view>
</view>
@ -97,30 +97,30 @@
<view>收藏</view>
</view>
<!-- 购买操作 TODO -->
<view class="bnt acea-row" v-if="dataShow === 0">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">立即购买</view>
</view>
<view class="bnt acea-row" v-if="status == 2 && attribute.productSelect.quota>0 && datatime > new Date().getTime()/1000">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts" @tap="goCat"></view>
</view>
<view class="bnt acea-row" v-if="status == 2 && (attribute.productSelect.quota <= 0) && datatime > new Date().getTime()/1000">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">已售罄</view>
</view>
<view class="bnt acea-row" v-if="status == 0">
<view class="bnt acea-row" v-if="status === 0">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">已关闭</view>
</view>
<view class="bnt acea-row" v-if="status == 1">
<view class="bnt acea-row" v-else-if="status === 1">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">未开始</view>
</view>
<view class="bnt acea-row" v-if="status == 2 && new Date().getTime()/1000 - datatime >=0">
<view class="bnt acea-row" v-else-if="status === 2 && attribute.productSelect.quota > 0">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts" @tap="goCat"></view>
</view>
<view class="bnt acea-row" v-else-if="status === 2 && (attribute.productSelect.quota <= 0)">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">已售罄</view>
</view>
<view class="bnt acea-row" v-else-if="status === 3">
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">已结束</view>
</view>
<view class="bnt acea-row" v-else> <!-- -->
<view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">未开始</view>
</view>
</view>
</view>
<!-- SKU 弹窗 TODO -->
@ -216,6 +216,7 @@
return {
//
activity: {},
status: 1, // 0 - 1 - 2 - 3 -
//
spu: {}, // SPU
@ -229,7 +230,6 @@
'width': '44rpx',
'timeTxtwidth': '16rpx',
},
dataShow: 0,
id: 0,
time: 0,
countDownHour: "00",
@ -252,7 +252,6 @@
isOpen: false,
attr: '请选择',
attrValue: '',
status: 1,
iShidden: false,
iSplus: false,
replyCount: 0, //
@ -273,7 +272,6 @@
table: 'width:100%',
video: 'width:100%'
},
datatime: 0,
navActive: 0,
meunHeight: 0,
backH: '',
@ -413,6 +411,19 @@
this.activity.quota = this.activity.products.reduce((accumulator, product) => {
return accumulator + product.quota;
}, 0);
//
const now = new Date().getTime();
if (this.activity.status !== 0) {
if (this.activity.startTime > now) {
this.status = 1;
} else if (now <= this.activity.endTime) {
this.status = 2;
} else {
this.status = 3;
}
} else {
this.status = this.activity;
}
//
this.getGoodsDetails();
@ -421,12 +432,8 @@
return;
}
getSeckillDetail(that.id).then(res => {
this.dataShow = 1;
this.storeInfo = res.data.storeSeckill;
this.userCollect = res.data.userCollect;
this.status = this.storeInfo.seckillStatus;
this.datatime = Number(this.storeInfo.timeSwap);
this.imgUrls = JSON.parse(res.data.storeSeckill.sliderImage) || [];
this.attribute.productAttr = res.data.productAttr;
this.productValue = res.data.productValue;
this.attribute.productSelect.num = res.data.storeSeckill.num;
@ -487,14 +494,8 @@
// // // TODO
// this.$set(this.sharePacket, 'priceName', res.data.priceName);
// this.$set(this.sharePacket, 'isState', Math.floor(res.data.priceName) === 0);
//
// //
// PromotionActivityApi.getActivityListBySpuId(this.id).then(res => {
// let activityList = res.data;
// activityList = ProductUtil.sortActivityList(activityList);
// this.$set(this, 'activityH5', activityList);
// });
//
// //
// uni.setNavigationBarTitle({
// title: spu.name.substring(0, 7) + "..."
@ -911,33 +912,6 @@
},
});
},
/**
* 获取产品分销二维码
* @param function successFn 下载完成回调
*
*/
downloadFilePromotionCode: function(successFn) {
let that = this;
seckillCode(that.id,{stop_time:that.datatime}).then(res => {
uni.downloadFile({
url: that.setDomain(res.data.code),
success: function(res) {
that.$set(that, 'isDown', false);
if (typeof successFn == 'function')
successFn && successFn(res.tempFilePath);
else
that.$set(that, 'PromotionCode', res.tempFilePath);
},
fail: function() {
that.$set(that, 'isDown', false);
that.$set(that, 'PromotionCode', '');
},
});
}).catch(err => {
that.$set(that, 'isDown', false);
that.$set(that, 'PromotionCode', '');
});
},
getImageBase64:function(images){
let that = this;
imageBase64({url:images}).then(res=>{