update: 模板1商品列表支持一键加购;分类商品加购按钮被挡住问题修复。

This commit is contained in:
mixtan 2025-07-27 11:27:46 +08:00
parent 7d6ef1a603
commit 27e4e817c8
3 changed files with 104 additions and 73 deletions

View File

@ -246,7 +246,6 @@
" "
> >
<view class="m-product-name2"> <view class="m-product-name2">
<label>
<block <block
v-for="(id, idx) in item.activity_type_id_row" v-for="(id, idx) in item.activity_type_id_row"
:key="idx" :key="idx"
@ -254,7 +253,6 @@
<ms-activity-tag :typeId="id" v-if="id"></ms-activity-tag> <ms-activity-tag :typeId="id" v-if="id"></ms-activity-tag>
</block> </block>
{{ item.product_name }} {{ item.product_name }}
</label>
</view> </view>
<view class="m-product-name2" v-if="false"> <view class="m-product-name2" v-if="false">
<uni-tag <uni-tag
@ -280,65 +278,35 @@
></uni-tag> ></uni-tag>
</view> </view>
<view class="m-product-price1"> <view class="m-product-price1">
<view class="money">
<view
v-if="item.product_unit_price_range != '0.00'" <view class="goods_item">
class="goods_name" <block v-if="item.product_unit_points">
> <label
<label>{{ __("¥") }}</label style="margin: 0rpx 10rpx"
>{{ item.product_unit_price_range }} v-if="item.product_unit_price_range != '0.00'"
>+</label
>{{ number_format(item.product_unit_points) }}
<label>{{ __("积分") }}</label>
</block>
<block v-if="item.product_unit_sp">
<label style="margin: 0rpx 10rpx">+</label
>{{ item.product_unit_sp }}
<label>{{ __("众宝") }}</label>
</block>
</view> </view>
<view <view class="goods_item">
v-if="item.product_quantity != 0" <view class="num">
:data-stock="chooseItem.available_quantity"
:data-num="chooseItem.user_cart_quantity"
:data-step="1"
:data-spuid="
chooseItem.product_id ? chooseItem.product_id : 0
"
:data-pname="
chooseItem.item_name ? chooseItem.item_name : ''
"
:data-skuid="item.item_id"
:data-index="chooseIndex"
@click.stop="addCart"
class="btn_addcard"
></view>
<view
v-if="item.product_quantity == 0"
@click.stop="addCart2"
class="btn_addcard disabled"
></view>
<block v-if="item.product_unit_points">
<label
style="margin: 0rpx 10rpx"
v-if="item.product_unit_price_range != '0.00'"
>+</label
>{{ number_format(item.product_unit_points) }}
<label>{{ __("积分") }}</label>
</block>
<block v-if="item.product_unit_sp">
<label style="margin: 0rpx 10rpx">+</label
>{{ item.product_unit_sp }} <label>{{ __("众宝") }}</label>
</block>
</view>
<view
class="num"
v-if="
!plantformInfo.prodcut_addcart_flag &&
plantformInfo.product_salenum_flag &&
item.product_sale_num > 0
"
>
<text>{{ __("已售") }}</text> <text>{{ __("已售") }}</text>
<label style="color: #db384c; margin-left: 2px">{{ <label style="color: #db384c; margin: 0 5px"
item.product_sale_num >{{ item.product_sale_num }}</label
}}</label> >
</view> </view>
<view :class="'c' + 1" v-if="false"> </view>
</view>
<view <view
class="multi-spec-box" class="multi-spec-box"
v-if="plantformInfo.prodcut_addcart_flag" v-if="plantformInfo.prodcut_addcart_flag"
@ -413,7 +381,39 @@
</view> </view>
</view> </view>
<view :class="'c' + 1" v-if="false"> </view> <view class="goods_item">
<view
v-if="item.product_unit_price_range != '0.00'"
class="goods_name"
>
<label>{{ __("¥") }}</label
>{{ item.product_unit_price_range }}
</view>
<view
v-if="item.product_quantity != 0"
:data-stock="chooseItem.available_quantity"
:data-num="chooseItem.user_cart_quantity"
:data-step="1"
:data-spuid="
chooseItem.product_id ? chooseItem.product_id : 0
"
:data-pname="
chooseItem.item_name ? chooseItem.item_name : ''
"
:data-skuid="item.item_id"
:data-index="chooseIndex"
@click.stop="addCart"
class="btn_addcard"
></view>
<view
v-if="item.product_quantity == 0"
@click.stop="addCart2"
class="btn_addcard disabled"
></view>
</view>
</view> </view>
</view> </view>
</navigator> </navigator>
@ -1879,12 +1879,12 @@ export default {
this.onCloseFilter(); this.onCloseFilter();
}, },
addCart2(){ addCart2() {
uni.showToast({ uni.showToast({
icon: 'error', icon: "error",
title: this.$.__("商品库存不足") title: this.$.__("商品库存不足"),
}); });
}, },
// //
addCart: async function (e) { addCart: async function (e) {
@ -2241,10 +2241,20 @@ addCart2(){
} }
} }
.m-product-name2{
line-height: 1 !important;
height: auto !important;
overflow:visible;
}
/*全部商品 end*/ /*全部商品 end*/
.m-product-price1 { .m-product-price1 {
display: flex; display: block;
justify-content: space-between; .goods_item {
position: relative;
display: flex;
justify-content: space-between;
}
label { label {
font-weight: initial; font-weight: initial;
@ -2637,6 +2647,7 @@ addCart2(){
} }
.money { .money {
width: 100%;
font-size: 14px; font-size: 14px;
} }

View File

@ -2,12 +2,12 @@
<view> <view>
<view class="m-supermarket-ad"> <view class="m-supermarket-ad">
<view v-if="(commonTPL.AdContent.F1ProductContents.length>0)"> <view v-if="(commonTPL.AdContent.F1ProductContents.length>0)">
<view class="m-supermarket-tip-list"> <!-- <view class="m-supermarket-tip-list">
<navigator :url="'/pages/product/list?is_store_flag=' + (commonTPL.isStoreFlag) + '&store_category_id=' + (item.store_product_cat_id) + '&cname=' + (item.name)" <navigator :url="'/pages/product/list?is_store_flag=' + (commonTPL.isStoreFlag) + '&store_category_id=' + (item.store_product_cat_id) + '&cname=' + (item.name)"
v-for="(item, i) in commonTPL.smallCategory" :key="i" class="m-supermarket-tip-item"> v-for="(item, i) in commonTPL.smallCategory" :key="i" class="m-supermarket-tip-item">
<label>{{item.name}}</label> <label>{{item.name}}</label>
</navigator> </navigator>
</view> </view> -->
<view class="m-product-list m-listv"> <view class="m-product-list m-listv">
<navigator v-for="(item, i) in commonTPL.AdContent.F1ProductContents" :key="i" :url="'/pages/product/detail?is_store_flag=' + (commonTPL.isStoreFlag) + '&pid=' + (item.ProductContentID)" <navigator v-for="(item, i) in commonTPL.AdContent.F1ProductContents" :key="i" :url="'/pages/product/detail?is_store_flag=' + (commonTPL.isStoreFlag) + '&pid=' + (item.ProductContentID)"
class="m-product-item"> class="m-product-item">
@ -30,6 +30,7 @@
<block v-if="item.product_unit_sp"> <block v-if="item.product_unit_sp">
<label style="margin: 0rpx 10rpx;">+</label><label style="font-size:32rpx">{{item.product_unit_sp}}</label> <label>{{__('众宝')}}</label> <label style="margin: 0rpx 10rpx;">+</label><label style="font-size:32rpx">{{item.product_unit_sp}}</label> <label>{{__('众宝')}}</label>
</block> </block>
<view class="btn_addcard" @click.stop="handleAddcard(item, $event)"></view>
</view> </view>
</view> </view>
</navigator> </navigator>
@ -99,7 +100,11 @@
return {} return {}
}, },
created: function() {}, created: function() {},
methods: {} methods: {
handleAddcard(data, event){
this.$emit('addCart', data)
}
}
} }
</script> </script>
@ -110,4 +115,21 @@
// @import '../../styles/layout.scss'; // @import '../../styles/layout.scss';
// @import '../../styles/store_themes.scss'; // @import '../../styles/store_themes.scss';
// @import '../../styles/store_tpl.scss'; // @import '../../styles/store_tpl.scss';
.m-product-info{
width: auto;
}
.m-product-price{
position: relative;
width: auto;
}
.btn_addcard{
position: absolute;
right: 20rpx;
bottom: 8rpx;
width: 40rpx;
height: 40rpx;
background: url(https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/xcxfile/appicon/pc1.png) center no-repeat;
background-size: cover;
}
</style> </style>

View File

@ -103,7 +103,7 @@
</view> </view>
</view> </view>
<shoptheme1 v-if="commonTPL.tapindex == 1 && commonTPL.TemplateKey == 'shop1'" :commonTPL="commonTPL"> <shoptheme1 v-if="commonTPL.tapindex == 1 && commonTPL.TemplateKey == 'shop1'" :commonTPL="commonTPL" @addCart="addCart">
</shoptheme1> </shoptheme1>
<shoptheme2 v-if="commonTPL.tapindex == 1 && commonTPL.TemplateKey == 'shop2'" :commonTPL="commonTPL"> <shoptheme2 v-if="commonTPL.tapindex == 1 && commonTPL.TemplateKey == 'shop2'" :commonTPL="commonTPL">
</shoptheme2> </shoptheme2>
@ -683,7 +683,7 @@ export default {
this.$.gopage(url) this.$.gopage(url)
}, },
async addCart(item, event) { async addCart(item) {
var that = this; var that = this;
var params = { var params = {
item_id: item.item_id, item_id: item.item_id,
@ -693,8 +693,6 @@ export default {
SKU_Id: item.item_id, SKU_Id: item.item_id,
}; };
event.stopPropagation()
await this.$store.dispatch(`addCart`, { await this.$store.dispatch(`addCart`, {
params: params, params: params,
callback: (data, status, msg, code) => { callback: (data, status, msg, code) => {