优化服务分类操作逻辑

This commit is contained in:
TOP糯米 2023-03-09 02:48:49 +08:00
parent 035d0c68a4
commit 28e1d7717d
2 changed files with 17 additions and 2 deletions

View File

@ -157,6 +157,7 @@ export default {
updateMenuStatus(index) { updateMenuStatus(index) {
this.currentLeftIndex = index; this.currentLeftIndex = index;
this.scrollLeftTop = index * this.menuHeight - this.wrapHeight / 2; this.scrollLeftTop = index * this.menuHeight - this.wrapHeight / 2;
this.$emit("onScroll", this.data[index].id);
}, },
/** /**
* 滚动监听 * 滚动监听

View File

@ -4,7 +4,14 @@
<widget-search /> <widget-search />
</view> </view>
<view class="cate"> <view class="cate">
<app-cate :offsetHeight="95" :data="data" cateType="cate" @clickItem="clickItem" :activeId="currentId" /> <app-cate
:offsetHeight="95"
:data="data"
cateType="cate"
:activeId="currentId"
@clickItem="clickItem"
@onScroll="onScroll"
/>
</view> </view>
<movable-area class="cart-icon-box"> <movable-area class="cart-icon-box">
<movable-view <movable-view
@ -37,6 +44,7 @@ export default {
utils: this.$utils, utils: this.$utils,
position: { x: 300, y: 1000 }, position: { x: 300, y: 1000 },
currentId: 0, currentId: 0,
newId: 0,
data: [], data: [],
}; };
}, },
@ -76,6 +84,9 @@ export default {
this.currentId = this.indexCateId; this.currentId = this.indexCateId;
}, },
onReady() {}, onReady() {},
onHide() {
this.currentId = this.newId;
},
onReachBottom() {}, onReachBottom() {},
onPullDownRefresh() {}, onPullDownRefresh() {},
methods: { methods: {
@ -125,8 +136,11 @@ export default {
}) })
.catch((e) => {}); .catch((e) => {});
}, },
onScroll(id) {
this.newId = id;
this.$store.commit("system/indexCateId", id);
},
clickItem(parentId, id) { clickItem(parentId, id) {
this.$store.commit("system/indexCateId", parentId);
this.$utils.toPage("/pages/service/list?id=" + id); this.$utils.toPage("/pages/service/list?id=" + id);
}, },
}, },