feat: 实现装修秒杀活动购物车;联调秒杀活动加购。

This commit is contained in:
mixtan 2025-08-11 11:04:02 +08:00
parent 601d49f812
commit 3f46bf31e8
2 changed files with 103 additions and 20 deletions

View File

@ -1051,12 +1051,12 @@ export default {
]),
getGoodsStatus (item){
return item?.product_quantity == 0 || item?.item_quantity == 0 || typeof item.product_quantity == 'undefined' || typeof item.item_quantity == 'undefined'
return item?.product_quantity == 0 || item?.item_quantity == 0
},
async addCart(item) {
if (item?.product_quantity == 0 || item?.item_quantity == 0 || typeof item.product_quantity == 'undefined' || typeof item.item_quantity == 'undefined') {
if (item?.product_quantity == 0 || item?.item_quantity == 0) {
uni.showToast({
icon: 'error',
title: this.$.__("商品库存不足")

View File

@ -7,26 +7,20 @@
<!-- #ifdef APP-PLUS -->
<share-box-app :shareDataDefault="shareData" ref="shareBoxApp"></share-box-app>
<!-- #endif -->
<view
class="diy_goods_carts"
@click="gopage(`/pages/index/cart?category_id=${shopInfo.category_id}&store_id=${shopInfo.store_id}`)"
>
<view class="box">
<image class="icon" src="https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/icon/icon_shop.png" />
<text class="icon_badge">{{ goodsNum }}</text>
</view>
</view>
</view>
</template>
<style lang="scss">
@import '../../styles/_variables.scss';
@import '../../styles/layout.scss';
.page {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: 100%;
/* background-size: cover !important; */
background-position: top center !important;
}
</style>
<script>
import statusBar from '../../components/status-bar.vue';
@ -45,6 +39,7 @@ export default {
*/
data: function() {
return {
goodsNum: 0,
options: {},
PageData: {},
PageContent: [],
@ -83,8 +78,17 @@ export default {
'plantformInfo',
'shopInfo',
'userInfo',
'hasLogin'
'hasLogin',
"cartNum",
]),
watch: {
cartNum: {
handler(newVal) {
this.goodsNum = newVal;
},
immediate: true,
},
},
/**
* 生命周期函数--监听页面加载
*/
@ -225,6 +229,12 @@ export default {
methods: {
...mapMutations(['login', 'logout', 'getPlantformInfo', 'forceUserInfo', 'getUserInfo']),
gopage(url){
this.$.navigateTo({
url
});
},
getPageInfo: function(force_refresh) {
var that = this,
params = {
@ -360,3 +370,76 @@ export default {
}
};
</script>
<style lang="scss">
@import '../../styles/_variables.scss';
@import '../../styles/layout.scss';
.page {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: 100%;
/* background-size: cover !important; */
background-position: top center !important;
}
.diy_goods_carts {
position: fixed;
right: 24rpx;
bottom: 240rpx;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
flex: 1;
color: #666;
text-align: center;
background: #fff;
border-radius: 100%;
padding: 12rpx;
box-shadow: 2rpx 4rpx 20rpx rgba(0,0,0,0.3);
.icon {
width: 48rpx;
height: 48rpx;
display: block;
}
.desc {
font-size: 24rpx;
line-height: 14rpx;
}
.icon_badge {
display: block;
position: absolute;
right: -5px;
top: -5px;
text-align: center;
line-height: 24rpx;
font-size: 24rpx;
padding: 4rpx 10rpx;
border-radius: 20rpx;
color: #fff;
background: #dd524d;
}
.box {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 10rpx;
}
&.current {
color: #dd524d;
font-weight: 900;
}
}
</style>