scrollview定位

This commit is contained in:
1154079537 2024-05-25 11:20:18 +08:00
parent 50409cd8c4
commit 011fcbc2e4
4 changed files with 33 additions and 16 deletions

View File

@ -27,11 +27,11 @@
<!-- 商品大分类 -->
<view class="category">
<scroll-view scroll-x="true">
<scroll-view scroll-x="true" :scroll-into-view="scrollIndex">
<view class="category-wrap">
<block v-for="(item,index) in store_category" :key="index">
<view class="category-item" :class="{'category-item-active': index==cate_change}"
@click="changeCate(index)">
<view class="category-item" :id="'scroll' + index"
:class="{'category-item-active': index==cate_change}" @click="changeCate(index)">
<u--image class="category-item-img" width="108rpx" :src="item.pic" height="108rpx"
shape="circle">
<template v-slot:loading>
@ -80,7 +80,8 @@
<view class="popup-wrap-category">
<view class="popup-wrap-category-wrap">
<block v-for="(item,index) in store_category" :key="index">
<view class="popup-wrap-category-item" :class="{'category-item-active': index==cate_change}"
<view class="popup-wrap-category-item"
:class="{'popup-wrap-category-item-active': index==cate_change}"
@click="changeCate(index)">
<u--image class="popup-wrap-category-item-img" width="108rpx" :src="item.pic"
height="108rpx" shape="circle">
@ -130,7 +131,8 @@
rand: 1
},
wrapHeight: 300,
touchstarty: 0
touchstarty: 0,
scrollIndex: ''
}
},
onLoad(option) {
@ -205,6 +207,9 @@
if (this.where.cate_pid) this.wrapHeight = 360;
else this.wrapHeight = 300;
// scrollView
this.scrollIndex = 'scroll' + e;
this.$refs.popup && this.$refs.popup.close();
},

View File

@ -44,11 +44,11 @@
<!-- 商品大分类 -->
<view class="category">
<scroll-view scroll-x="true">
<scroll-view scroll-x="true" :scroll-into-view="scrollIndex">
<view class="category-wrap">
<block v-for="(item,index) in store_category" :key="index">
<view class="category-item" :class="{'category-item-active': index==cate_change}"
@click="changeCate(index)">
<view class="category-item" :id="'scroll' + index"
:class="{'category-item-active': index==cate_change}" @click="changeCate(index)">
<u--image class="category-item-img" width="108rpx" :src="item.background"
height="108rpx" shape="circle">
<template v-slot:loading>
@ -192,6 +192,7 @@
},
wrapHeight: 300,
touchstarty: 0,
scrollIndex: ''
}
},
computed: {
@ -280,6 +281,9 @@
this.where.merchant_category_id = this.store_category[e].merchant_category_id;
this.storeMerchantList(true);
// scrollView
this.scrollIndex = 'scroll' + e;
this.$refs.popup && this.$refs.popup.close();
this.$forceUpdate();
},

View File

@ -26,11 +26,11 @@
<!-- 商品大分类 -->
<view class="category">
<scroll-view scroll-x="true">
<scroll-view scroll-x="true" :scroll-into-view="scrollIndex">
<view class="category-wrap">
<block v-for="(item,index) in store_category" :key="index">
<view class="category-item" :class="{'category-item-active': index==cate_change}"
@click="changeCate(index)">
<view class="category-item" :id="'scroll' + index"
:class="{'category-item-active': index==cate_change}" @click="changeCate(index)">
<u--image class="category-item-img" width="108rpx" :src="item.pic" height="108rpx"
shape="circle">
<template v-slot:loading>
@ -129,7 +129,8 @@
sale_type: 1, //1-, 2-
},
wrapHeight: 300,
touchstarty: 0
touchstarty: 0,
scrollIndex: ''
}
},
@ -206,6 +207,9 @@
this.where.cate_pid = this.store_category[e].store_category_id;
this.getProductslist(true);
// scrollView
this.scrollIndex = 'scroll' + e;
this.$refs.popup && this.$refs.popup.close();
this.$forceUpdate();
},

View File

@ -41,11 +41,11 @@
<!-- 商品大分类 -->
<view class="category">
<scroll-view scroll-x="true">
<scroll-view scroll-x="true" :scroll-into-view="scrollIndex">
<view class="category-wrap">
<block v-for="(item,index) in store_category" :key="index">
<view class="category-item" :class="{'category-item-active': index==cate_change}"
@click="changeCate(index)">
<view class="category-item" :id="'scroll' + index"
:class="{'category-item-active': index==cate_change}" @click="changeCate(index)">
<block v-if="subCurr!=1 || (subCurr==1 && tabsCurr!=2)">
<u--image class="category-item-img" width="108rpx" :src="item.pic" height="108rpx"
shape="circle">
@ -315,7 +315,8 @@
smallTypeDomInfo: null,
categoryWrapHeight: 0,
wrapHeight: 360,
touchstarty: 0
touchstarty: 0,
scrollIndex: ''
}
},
computed: {
@ -527,6 +528,9 @@
this.getHeight();
// scrollView
this.scrollIndex = 'scroll' + e;
// popup
this.$refs.popup && this.$refs.popup.close();
},