才购物车二次进来

This commit is contained in:
魏啾
2024-08-03 16:38:35 +08:00
parent 5fb9871900
commit 93c3e70e98

View File

@@ -483,6 +483,9 @@
if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) {
this.setNumber()
}
this.scrollTopSize = 0
this.scrollHeight = 1000
this.topArr = []
setTimeout(() => {
this.getElementTop();
}, 100);
@@ -833,6 +836,7 @@
/* 获取元素顶部信息 */
getElementTop() {
new Promise((resolve, reject) => {
let view = uni.createSelectorQuery().selectAll('.main-item');
view.boundingClientRect(async data => {
@@ -874,14 +878,14 @@
}
}
const lastElement = this.topArr[this.topArr.length - 1];
const currentElement = this.topArr[this.leftIndex];
const currentElement = this.topArr[index];
const diff = lastElement - currentElement;
console.log(diff)
// if (diff > this.scrollHeight) {
this.leftIndex = (index < 0 ? 0 : index);
// } else {
// this.leftIndex = this.leftIndex
// }
if (diff > this.scrollHeight) {
this.leftIndex = (index < 0 ? 0 : index);
} else {
this.leftIndex = this.leftIndex
}
}
},
/* 左侧导航点击 */
@@ -890,9 +894,7 @@
scrollTop: this.topArr[index] - this.HeighT,
duration: 0
});
setTimeout(() => {
this.leftIndex = index
}, 500)
this.leftIndex = index
}
}
}