【秒杀商品详情】

1. 完成秒杀详情
pull/1/MERGE
YunaiV 2023-06-11 23:18:54 +08:00
parent 4e756482ce
commit 6fcb8196c3
1 changed files with 104 additions and 124 deletions

View File

@ -58,7 +58,7 @@
<view class='title acea-row row-between-wrapper' <view class='title acea-row row-between-wrapper'
:style="replyCount ===0?'border-bottom-left-radius:14rpx;border-bottom-right-radius:14rpx;':''"> :style="replyCount ===0?'border-bottom-left-radius:14rpx;border-bottom-right-radius:14rpx;':''">
<view>用户评价({{ replyCount }})</view> <view>用户评价({{ replyCount }})</view>
<navigator class='praise' hover-class='none' :url="'/pages/users/goods_comment_list/index?productId='+ storeInfo.productId"> <navigator class='praise' hover-class='none' :url="'/pages/users/goods_comment_list/index?productId='+ activity.spuId">
<text class='font-color'>{{ replyChance }}%</text>好评率 <text class='font-color'>{{ replyChance }}%</text>好评率
<text class='iconfont icon-jiantou'></text> <text class='iconfont icon-jiantou'></text>
</navigator> </navigator>
@ -108,11 +108,11 @@
<view class="joinCart bnts" @tap="openAlone"></view> <view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">未开始</view> <view class="buy bnts bg-color-hui">未开始</view>
</view> </view>
<view class="bnt acea-row" v-else-if="status === 2 && attribute.productSelect.quota > 0"> <view class="bnt acea-row" v-else-if="status === 2 && attr.productSelect.quota > 0">
<view class="joinCart bnts" @tap="openAlone"></view> <view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts" @tap="goBuy"></view> <view class="buy bnts" @tap="goBuy"></view>
</view> </view>
<view class="bnt acea-row" v-else-if="status === 2 && (attribute.productSelect.quota <= 0)"> <view class="bnt acea-row" v-else-if="status === 2 && (attr.productSelect.quota <= 0)">
<view class="joinCart bnts" @tap="openAlone"></view> <view class="joinCart bnts" @tap="openAlone"></view>
<view class="buy bnts bg-color-hui">已售罄</view> <view class="buy bnts bg-color-hui">已售罄</view>
</view> </view>
@ -128,7 +128,7 @@
</view> </view>
<!-- SKU 弹窗 --> <!-- SKU 弹窗 -->
<product-window <product-window
:attr='attribute' :attr='attr'
:limitNum='1' :limitNum='1'
@ChangeAttr="ChangeAttr" @ChangeAttr="ChangeAttr"
@ChangeCartNum="ChangeCartNum" @ChangeCartNum="ChangeCartNum"
@ -157,7 +157,7 @@
</view> </view>
<view class="mask" v-if="posters" @click="closePosters"></view> <view class="mask" v-if="posters" @click="closePosters"></view>
<view class="mask" v-if="canvasStatus" @click="closePosters"></view> <view class="mask" v-if="canvasStatus" @click="closePosters"></view>
<!-- 海报展示 TODO --> <!-- 海报展示 -->
<view class='poster-pop' v-if="canvasStatus"> <view class='poster-pop' v-if="canvasStatus">
<image src='/static/images/poster-close.png' class='close' @click="posterImageClose"></image> <image src='/static/images/poster-close.png' class='close' @click="posterImageClose"></image>
<image :src='posterImage'></image> <image :src='posterImage'></image>
@ -210,85 +210,69 @@
data() { data() {
return { return {
// //
activity: {}, id: 0, //
activity: {}, //
status: 1, // 0 - 1 - 2 - 3 - status: 1, // 0 - 1 - 2 - 3 -
bgColor: {
'bgColor': '#333333',
'Color': '#fff',
'isDay': true,
'width': '44rpx',
'timeTxtwidth': '16rpx',
},
// //
spu: {}, // SPU spu: {}, // SPU
skuMap: [], // SKU Map skuMap: [], // SKU Map
attribute: { // productWindow 使 attrValue: '', // ,
attr: { // productWindow 使
cartAttr: false, cartAttr: false,
// id = name = values[].id = values[].name = index = // id = name = values[].id = values[].name = index =
properties: [], properties: [],
productSelect: {} // SKU productSelect: {} // SKU
}, },
tagStyle: {
img: 'width:100%;display:block;',
table: 'width:100%',
video: 'width:100%'
},
// TODO : // ========== ==========
replyCount: 0, //
replyChance: 0, //
reply: [], //
bgColor: { // ========== ==========
'bgColor': '#333333', userCollect: false,
'Color': '#fff',
'isDay': true, // ========== ==========
'width': '44rpx', qrcodeSize: 600, //
'timeTxtwidth': '16rpx', promotionCode: '', //
}, imgTop: '', // base64
id: 0, errT: '', //
time: 0, posters: false, //
countDownHour: "00", weixinStatus: false, //
countDownMinute: "00", canvasStatus: false, //
countDownSecond: "00", imagePath: '', //
storeInfo: [], H5ShareBox: false, //
imgUrls: [], posterbackgd: '/static/images/posterbackgd.png', //
parameter: { storeImage: '', //
'navbar': '1', actionSheetHidden: true, //
'return': '1', posterImage: '', //
'title': '抢购详情页',
'color': false // ========== nav + scroll ==========
}, returnShow: true, // []
productValue: [], homeTop: 20, // top
isOpen: false, height: 0, // height
attr: '请选择', scrollY: 0, // Y
attrValue: '', scrollTop: 0, // top
iShidden: false, lock: false, // scroll
iSplus: false, topArr: [], // nav top
replyCount: 0, // heightArr: [], // nav height
reply: [], // navH: "", // nav
replyChance: 0, opacity: 0, // nav
navH: "", navList: ['商品', '评价', '详情'],
navList: ['商品', '评价', '详情'], navActive: 0, // navList
opacity: 0,
scrollY: 0,
topArr: [],
height: 0,
heightArr: [],
lock: false,
scrollTop: 0,
tagStyle: {
img: 'width:100%;display:block;',
table: 'width:100%',
video: 'width:100%'
},
navActive: 0,
meunHeight: 0,
backH: '',
posters: false,
weixinStatus: false,
posterImageStatus: false,
canvasStatus: false, //
storeImage: '', //
promotionCode: '', //
posterImage: '', //
posterbackgd: '/static/images/posterbackgd.png',
actionSheetHidden: false,
cart_num:'',
qrcodeSize: 600,
imagePath:'',//
imgTop:'',
H5ShareBox: false, //
errT: '',
returnShow: true,
homeTop: 20,
userCollect: false
} }
}, },
components: { components: {
@ -304,7 +288,7 @@
watch:{ watch:{
isLogin:{ isLogin:{
handler:function(newV,oldV){ handler:function(newV,oldV){
if(newV){ if (newV) {
this.getSeckillDetail(); this.getSeckillDetail();
} }
}, },
@ -312,14 +296,11 @@
} }
}, },
onLoad(options) { onLoad(options) {
let that = this; this.$store.commit("PRODUCT_TYPE", 'normal');
that.$store.commit("PRODUCT_TYPE", 'normal'); //
let statusBarHeight = '';
//
uni.getSystemInfo({ uni.getSystemInfo({
success: function(res) { success: res => {
that.height = res.windowHeight this.height = res.windowHeight
statusBarHeight = res.statusBarHeight
//res.windowHeight:px*2rpx98 //res.windowHeight:px*2rpx98
}, },
}); });
@ -329,24 +310,20 @@
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.navH = 90 this.navH = 90
// #endif // #endif
// #ifdef MP
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.meunHeight = menuButtonInfo.height
this.backH = (that.navH / 2) + (this.meunHeight / 2)
// #ifdef MP || APP-NVUE // #ifdef MP || APP-NVUE
// id // id
// if(options.spread) app.globalData.spread = options.spread; // TODO
setTimeout(()=>{ setTimeout(()=>{
if(options.spread){ if (options.spread) {
app.globalData.spread = options.spread; app.globalData.spread = options.spread;
spread(options.spread).then(res => {}) spread(options.spread).then(res => {})
} }
},2000) },2000)
// #endif // #endif
that.$set(that,'theme',that.$Cache.get('theme')); //
// #endif //
if (!options.scene && !options.id){ if (!options.scene && !options.id){
this.$util.Tips({ this.$util.Tips({
title: '缺少参数无法查看商品' title: '缺少参数无法查看商品'
}, { }, {
@ -354,16 +331,19 @@
}); });
return; return;
} }
if (options.hasOwnProperty('id') || options.scene){ // id
if (options.hasOwnProperty('id') || options.scene){
if (options.scene) { // if (options.scene) { //
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene)); // TODO code
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue); let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
app.globalData.spread = mapeMpQrCodeValue.spread; app.globalData.spread = mapeMpQrCodeValue.spread;
this.id = mapeMpQrCodeValue.id; this.id = mapeMpQrCodeValue.id;
setTimeout(()=>{ // TODO code
setTimeout(()=>{
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {}) spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
},2000) },2000)
}else{ } else {
this.id = options.id; this.id = options.id;
} }
} }
@ -448,7 +428,7 @@
let spu = res.data; let spu = res.data;
let skus = res.data.skus; let skus = res.data.skus;
this.$set(this, 'spu', spu); this.$set(this, 'spu', spu);
this.$set(this.attribute, 'properties', ProductUtil.convertProductPropertyList(skus)); this.$set(this.attr, 'properties', ProductUtil.convertProductPropertyList(skus));
this.$set(this, 'skuMap', ProductUtil.convertProductSkuMap(skus)); this.$set(this, 'skuMap', ProductUtil.convertProductSkuMap(skus));
// SKU // SKU
this.activity.products.forEach(product => { this.activity.products.forEach(product => {
@ -500,7 +480,7 @@
* 默认选中属性 * 默认选中属性
*/ */
selectDefaultSku: function() { selectDefaultSku: function() {
const properties = this.attribute.properties; const properties = this.attr.properties;
// "," skuKey = ["", ""] // "," skuKey = ["", ""]
let skuKey = undefined; let skuKey = undefined;
for (let key in this.skuMap) { for (let key in this.skuMap) {
@ -521,28 +501,28 @@
if (!sku) { if (!sku) {
return return
} }
this.$set(this.attribute.productSelect, "spuName", this.spu.name); this.$set(this.attr.productSelect, "spuName", this.spu.name);
this.$set(this.attribute.productSelect, "id", sku.id); this.$set(this.attr.productSelect, "id", sku.id);
this.$set(this.attribute.productSelect, "picUrl", sku.picUrl); this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
this.$set(this.attribute.productSelect, "price", sku.price); this.$set(this.attr.productSelect, "price", sku.price);
this.$set(this.attribute.productSelect, "stock", sku.stock); this.$set(this.attr.productSelect, "stock", sku.stock);
this.$set(this.attribute.productSelect, "cart_num", 1); this.$set(this.attr.productSelect, "cart_num", 1);
// //
this.$set(this.attribute.productSelect, "quota", sku.quota); this.$set(this.attr.productSelect, "quota", sku.quota);
this.$set(this.attribute.productSelect, "limitCount", sku.limitCount); this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
this.$set(this, "attrValue", skuKey.join(",")); this.$set(this, "attrValue", skuKey.join(","));
}, },
/** /**
* 打开 SKU 属性的选择 * 打开 SKU 属性的选择
*/ */
openAttr: function() { openAttr: function() {
this.$set(this.attribute, 'cartAttr', true); this.$set(this.attr, 'cartAttr', true);
}, },
/** /**
* 关闭 productWindow 弹窗 * 关闭 productWindow 弹窗
*/ */
closeAttr: function() { closeAttr: function() {
this.$set(this.attribute, 'cartAttr', false); this.$set(this.attr, 'cartAttr', false);
}, },
/** /**
* 属性变动赋值 * 属性变动赋值
@ -557,16 +537,16 @@
if (!sku) { if (!sku) {
return; return;
} }
this.$set(this.attribute.productSelect, "id", sku.id); this.$set(this.attr.productSelect, "id", sku.id);
this.$set(this.attribute.productSelect, "picUrl", sku.picUrl); this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
this.$set(this.attribute.productSelect, "price", sku.price); this.$set(this.attr.productSelect, "price", sku.price);
this.$set(this.attribute.productSelect, "stock", sku.stock); this.$set(this.attr.productSelect, "stock", sku.stock);
this.$set(this.attribute.productSelect, "quota", sku.quota); this.$set(this.attr.productSelect, "quota", sku.quota);
this.$set(this.attribute.productSelect, "limitCount", sku.limitCount); this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
this.$set(this.attribute.productSelect, "cart_num", 1); this.$set(this.attr.productSelect, "cart_num", 1);
// SKU // SKU
this.$set(this.attribute.properties[propertyIndex], 'index', this.$set(this.attr.properties[propertyIndex], 'index',
this.attribute.properties[propertyIndex].values[valueIndex].name); this.attr.properties[propertyIndex].values[valueIndex].name);
this.$set(this, "attrValue", newSkuKey); this.$set(this, "attrValue", newSkuKey);
}, },
/** /**
@ -576,7 +556,7 @@
*/ */
ChangeCartNum: function(changeValue) { ChangeCartNum: function(changeValue) {
// sku // sku
let sku = this.attribute.productSelect; let sku = this.attr.productSelect;
if (!sku) { if (!sku) {
return; return;
} }
@ -588,17 +568,17 @@
if (changeValue) { if (changeValue) {
sku.cart_num++; sku.cart_num++;
if (limitCount !== undefined && sku.cart_num > limitCount) { if (limitCount !== undefined && sku.cart_num > limitCount) {
this.$set(this.attribute.productSelect, "cart_num", limitCount); this.$set(this.attr.productSelect, "cart_num", limitCount);
this.$util.Tips({ this.$util.Tips({
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}` title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
}); });
} else if (sku.cart_num > stock || sku.cart_num > quota) { } else if (sku.cart_num > stock || sku.cart_num > quota) {
this.$set(this.attribute.productSelect, "cart_num", Math.min(stock, quota)); this.$set(this.attr.productSelect, "cart_num", Math.min(stock, quota));
} }
} else { } else {
sku.cart_num--; sku.cart_num--;
if (sku.cart_num < 1) { if (sku.cart_num < 1) {
this.$set(this.attribute.productSelect, "cart_num", 1); this.$set(this.attr.productSelect, "cart_num", 1);
} }
} }
}, },
@ -608,12 +588,12 @@
* @param number 数量 * @param number 数量
*/ */
iptCartNum: function (number) { iptCartNum: function (number) {
this.$set(this.attribute.productSelect, 'cart_num', number ? number : 1); this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
// //
let sku = this.attribute.productSelect; let sku = this.attr.productSelect;
let limitCount = sku.limitCount; let limitCount = sku.limitCount;
if (limitCount !== undefined && number > limitCount) { if (limitCount !== undefined && number > limitCount) {
this.$set(this.attribute.productSelect, "cart_num", limitCount); this.$set(this.attr.productSelect, "cart_num", limitCount);
this.$util.Tips({ this.$util.Tips({
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}` title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
}); });
@ -638,13 +618,13 @@
} }
// attr // attr
if (!this.attribute.cartAttr) { if (!this.attr.cartAttr) {
this.openAttr(); this.openAttr();
return; return;
} }
// //
let sku = this.attribute.productSelect; let sku = this.attr.productSelect;
uni.navigateTo({ uni.navigateTo({
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
+ '&seckillActivityId=' + this.id + '&seckillActivityId=' + this.id