From 31dc706eeda69f2c90e885210110e92612689544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Fri, 17 Oct 2025 11:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=93=E8=B4=AD=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E9=A1=B5=E9=9D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/shop/index/index.css | 8 ++++---- packages/shop/index/index.vue | 35 ++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/shop/index/index.css b/packages/shop/index/index.css index 725bc42b..3bfad84c 100644 --- a/packages/shop/index/index.css +++ b/packages/shop/index/index.css @@ -315,11 +315,11 @@ page { } .CateList_Box { - width: 71.5%; + width: 95%; display: flex; overflow: hidden; - /* position: relative; */ - position: fixed; + position: relative; + /* position: fixed; */ z-index: 15; padding: 20rpx 10rpx; background-color: #ffffff; @@ -368,7 +368,7 @@ page { } .CateIte { - margin-top: 80rpx; + /* margin-top: 80rpx; */ } .CateInfo { diff --git a/packages/shop/index/index.vue b/packages/shop/index/index.vue index 3dbeca47..59be660b 100644 --- a/packages/shop/index/index.vue +++ b/packages/shop/index/index.vue @@ -63,7 +63,8 @@ {{ item.category_name }} - + - 选择规格 - 收起 @@ -152,7 +153,8 @@ - + 当日达 @@ -227,6 +229,7 @@ export default { search: "", value: "1", cateListShow: false, + scrollTop: 0, conRightElement: null, iconList: [ { @@ -325,6 +328,20 @@ export default { //顶部分类点击 changeCateListShow() { this.cateListShow = !this.cateListShow; + // 当cateListShow展开时,禁止Con_right滚动 + if (this.conRightRef) { + if (this.cateListShow) { + // 保存当前滚动位置 + this.scrollTop = this.conRightRef.scrollTop; + } else { + // 恢复滚动位置 + setTimeout(() => { + if (this.conRightRef) { + this.conRightRef.scrollTop = this.scrollTop || 0; + } + }, 0); + } + } }, //选择右下角分类 checkItem(index) { @@ -338,7 +355,7 @@ export default { this.topShow = !this.topShow; }, // 选择商品规格 - chooseGG(item,targetItems) { + chooseGG(item, targetItems) { // 根据两个参数的id判断点击的数据 if (item && targetItems && item.id) { for (let i = 1; i < this.tagList.length; i++) { @@ -362,7 +379,7 @@ export default { NavgateTo("../search/index"); }, //商品详情页 - goods(ite,items) { + goods(ite, items) { NavgateTo(`../goods/index?item=${JSON.stringify(ite)}`); }, @@ -447,7 +464,7 @@ export default { let currentQuantity = 0; let stockQuantity = 0; let goodsToUpdate = null; - + // 对于有规格的主商品(绑定到items.commodity_goods_info_list[0].quantity) if ( item.commodity_goods_info_list && @@ -465,7 +482,7 @@ export default { stockQuantity = item.stock_quantity || 0; goodsToUpdate = item; } - + // 判断是否增加数量且库存不足 if (quantity > currentQuantity && currentQuantity >= stockQuantity) { uni.showToast({ @@ -474,7 +491,7 @@ export default { }); return; } - + // 使用$set确保响应式更新 this.$set(goodsToUpdate, 'quantity', quantity);