【秒杀商品详情】

1. 接入下单流程
pull/1/MERGE
YunaiV 2023-06-11 22:11:30 +08:00
parent 7bc30ba3eb
commit 80c5617d52
1 changed files with 52 additions and 69 deletions

View File

@ -109,7 +109,7 @@
</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" @tap="goCat"></view>
<view class="buy bnts" @tap="goBuy"></view>
</view>
<view class="bnt acea-row" v-else-if="status === 2 && (attribute.productSelect.quota <= 0)">
<view class="joinCart bnts" @tap="openAlone"></view>
@ -382,28 +382,24 @@
}
}
// TODO
if (this.isLogin) {
this.getSeckillDetail();
} else {
this.$Cache.set('login_back_url',
'/pages/activity/goods_seckill_details/index?id=' + this.id + '&spread=' + app.globalData.spread?app.globalData.spread:0);
toLogin();
}
this.$nextTick(() => {
// #ifdef MP
const menuButton = uni.getMenuButtonBoundingClientRect();
const query = uni.createSelectorQuery().in(this);
query
.select('#home')
.boundingClientRect(data => {
this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
})
.exec();
// #endif
})
silenceBindingSpread();
//
this.getSeckillDetail();
},
onReady() {
this.$nextTick(() => {
// top
// #ifdef MP
const menuButton = uni.getMenuButtonBoundingClientRect();
const query = uni.createSelectorQuery().in(this);
query.select('#home')
.boundingClientRect(data => {
this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
})
.exec();
// #endif
});
silenceBindingSpread();
},
methods: {
// ========== ==========
getSeckillDetail: function() {
@ -437,7 +433,8 @@
this.getProductReplyList();
this.getProductReplyCount();
app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id=' + this.id + '&spread=' + this.uid ;
app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id=' + this.id
+ '&spread=' + this.uid;
}).catch(err => {
that.$util.Tips({
title:err
@ -445,13 +442,6 @@
tab:3
})
});
if (true) {
return;
}
getSeckillDetail(that.id).then(res => {
this.storeInfo = res.data.storeSeckill;
this.attribute.productSelect.num = res.data.storeSeckill.num;
})
},
// ========== ==========
@ -634,6 +624,37 @@
});
}
},
/**
* 单独购买
*/
openAlone: function() {
uni.navigateTo({
url: `/pages/goods_details/index?id=${this.activity.spuId}`
})
},
/**
* 下订单
*/
goBuy: function() {
//
if (!this.isLogin) {
toLogin();
return;
}
// attr
if (!this.attribute.cartAttr) {
this.openAttr();
return;
}
//
let sku = this.attribute.productSelect;
uni.navigateTo({
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
+ '&seckillActivityId=' + this.id
});
},
// TODO
@ -731,7 +752,7 @@
that.topArr = topArr
that.heightArr = heightArr
});
};
}
},
/**
* 收藏商品
@ -748,44 +769,6 @@
})
}
},
/*
* 单独购买
*/
openAlone: function() {
uni.navigateTo({
url: `/pages/goods_details/index?id=${this.storeInfo.productId}`
})
},
/*
* 下订单
*/
goCat: function() {
var that = this;
var productSelect = this.productValue[this.attrValue];
if (that.cart_num > 1) {
return this.$util.Tips({
title: `该商品每人限购1${this.storeInfo.unitName}`
});
}
//
if (this.isOpen)
this.attribute.cartAttr = true
else
this.attribute.cartAttr = !this.attribute.cartAttr
//
if (this.attribute.cartAttr === true && this.isOpen == false) return this.isOpen = true
//,,
if (this.attribute.productAttr.length && productSelect === undefined && this.isOpen == true) return app.$util.Tips({
title: '请选择属性'
});
this.$Order.getPreOrder("buyNow",[{
"attrValueId": parseFloat(this.attribute.productSelect.unique),
"seckillId": parseFloat(this.id),
"productNum": parseFloat(this.cart_num ? this.cart_num : this.attribute.productSelect.cart_num),
"productId": parseFloat(this.storeInfo.productId)
}]);
},
/**
* 分享打开
*