更改左右性能优化
This commit is contained in:
@@ -327,7 +327,6 @@
|
|||||||
fixedtrue: true,
|
fixedtrue: true,
|
||||||
userInfo: uni.cache.get('userInfo'), //个人信息
|
userInfo: uni.cache.get('userInfo'), //个人信息
|
||||||
opacity: false, //是否显示
|
opacity: false, //是否显示
|
||||||
scrollHeight: 1000,
|
|
||||||
scrollTopSize: 0, //距离顶部的高度
|
scrollTopSize: 0, //距离顶部的高度
|
||||||
fillHeight: 0, // 填充高度,用于最后一项低于滚动区域时使用
|
fillHeight: 0, // 填充高度,用于最后一项低于滚动区域时使用
|
||||||
leftArray: [],
|
leftArray: [],
|
||||||
@@ -352,6 +351,7 @@
|
|||||||
salePrice: '', //钱数
|
salePrice: '', //钱数
|
||||||
cartListsdatashow: false, //是否显示购物车
|
cartListsdatashow: false, //是否显示购物车
|
||||||
showCart: false,
|
showCart: false,
|
||||||
|
lastbottom: '' //元素最低端的距离
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPageScroll(e) {
|
onPageScroll(e) {
|
||||||
@@ -368,17 +368,21 @@
|
|||||||
return `left-${this.leftIndex? this.leftIndex:0}`;
|
return `left-${this.leftIndex? this.leftIndex:0}`;
|
||||||
},
|
},
|
||||||
HeighT() { //手机类型的尺寸 导航栏高度
|
HeighT() { //手机类型的尺寸 导航栏高度
|
||||||
|
console.log(this.$store.getters.is_BarHeight)
|
||||||
return this.$store.getters.is_BarHeight.heightBar + this.$store.getters.is_BarHeight.customBar
|
return this.$store.getters.is_BarHeight.heightBar + this.$store.getters.is_BarHeight.customBar
|
||||||
},
|
},
|
||||||
|
scrollHeight() {
|
||||||
|
return this.$store.getters.is_BarHeight.info.windowHeight - this.HeighT
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onReady() {
|
onReady() {
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
uni.getSystemInfo({
|
// uni.getSystemInfo({
|
||||||
success: (data) => {
|
// success: (data) => {
|
||||||
this.scrollHeight = data.windowHeight
|
// this.scrollHeight = data.windowHeight
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}, 100);
|
// }, 100);
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
if (e.q) {
|
if (e.q) {
|
||||||
@@ -402,7 +406,6 @@
|
|||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
duration: 0
|
duration: 0
|
||||||
});
|
});
|
||||||
console.log(!uni.cache.get('token'))
|
|
||||||
if (!uni.cache.get('token')) {
|
if (!uni.cache.get('token')) {
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: 'weixin',
|
provider: 'weixin',
|
||||||
@@ -840,7 +843,6 @@
|
|||||||
this.setNumber()
|
this.setNumber()
|
||||||
}
|
}
|
||||||
this.scrollTopSize = 0
|
this.scrollTopSize = 0
|
||||||
this.scrollHeight = 1000
|
|
||||||
this.topArr = []
|
this.topArr = []
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getElementTop();
|
this.getElementTop();
|
||||||
@@ -859,11 +861,14 @@
|
|||||||
this.scrollTopSize = res.top; //元素距离顶部的距离
|
this.scrollTopSize = res.top; //元素距离顶部的距离
|
||||||
})
|
})
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
|
console.log(res)
|
||||||
let topArr = res.map((item) => {
|
let topArr = res.map((item) => {
|
||||||
return item.top; /* 减去滚动容器距离顶部的距离 加导航栏高度*/
|
return item.top; /* 减去滚动容器距离顶部的距离 加导航栏高度*/
|
||||||
});
|
});
|
||||||
this.scrollHeight = this.scrollHeight - this.HeighT
|
// this.scrollHeight = this.scrollHeight - this.HeighT
|
||||||
this.topArr = topArr;
|
this.topArr = topArr;
|
||||||
|
// 获取最后一个元素最低端的盒子到顶点的距离
|
||||||
|
this.lastbottom = res[res.length - 1].bottom;
|
||||||
/* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */
|
/* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */
|
||||||
let last = res[res.length - 1].height;
|
let last = res[res.length - 1].height;
|
||||||
if (last - 20 < this.scrollHeight) {
|
if (last - 20 < this.scrollHeight) {
|
||||||
@@ -889,12 +894,11 @@
|
|||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// const lastElement = this.topArr[this.topArr.length - 1];
|
||||||
}
|
}
|
||||||
const lastElement = this.topArr[this.topArr.length - 1];
|
|
||||||
const currentElement = this.topArr[index];
|
const currentElement = this.topArr[index];
|
||||||
const diff = lastElement - currentElement;
|
const diff = this.lastbottom - currentElement;
|
||||||
console.log(diff)
|
if (diff > this.scrollHeight - 200) { //200是固定高度
|
||||||
if (diff > this.scrollHeight) {
|
|
||||||
this.leftIndex = (index < 0 ? 0 : index);
|
this.leftIndex = (index < 0 ? 0 : index);
|
||||||
} else {
|
} else {
|
||||||
this.leftIndex = this.leftIndex
|
this.leftIndex = this.leftIndex
|
||||||
@@ -1074,6 +1078,7 @@
|
|||||||
|
|
||||||
.panelfiveitemsex {
|
.panelfiveitemsex {
|
||||||
margin-top: 32rpx;
|
margin-top: 32rpx;
|
||||||
|
|
||||||
.panelfiveitemsex_oen {
|
.panelfiveitemsex_oen {
|
||||||
text:nth-child(1) {
|
text:nth-child(1) {
|
||||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
|
|||||||
Reference in New Issue
Block a user