才购物车二次进来
This commit is contained in:
@@ -483,6 +483,9 @@
|
|||||||
if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) {
|
if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) {
|
||||||
this.setNumber()
|
this.setNumber()
|
||||||
}
|
}
|
||||||
|
this.scrollTopSize = 0
|
||||||
|
this.scrollHeight = 1000
|
||||||
|
this.topArr = []
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getElementTop();
|
this.getElementTop();
|
||||||
}, 100);
|
}, 100);
|
||||||
@@ -833,6 +836,7 @@
|
|||||||
|
|
||||||
/* 获取元素顶部信息 */
|
/* 获取元素顶部信息 */
|
||||||
getElementTop() {
|
getElementTop() {
|
||||||
|
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
let view = uni.createSelectorQuery().selectAll('.main-item');
|
let view = uni.createSelectorQuery().selectAll('.main-item');
|
||||||
view.boundingClientRect(async data => {
|
view.boundingClientRect(async data => {
|
||||||
@@ -874,14 +878,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const lastElement = this.topArr[this.topArr.length - 1];
|
const lastElement = this.topArr[this.topArr.length - 1];
|
||||||
const currentElement = this.topArr[this.leftIndex];
|
const currentElement = this.topArr[index];
|
||||||
const diff = lastElement - currentElement;
|
const diff = lastElement - currentElement;
|
||||||
console.log(diff)
|
console.log(diff)
|
||||||
// if (diff > this.scrollHeight) {
|
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
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 左侧导航点击 */
|
/* 左侧导航点击 */
|
||||||
@@ -890,9 +894,7 @@
|
|||||||
scrollTop: this.topArr[index] - this.HeighT,
|
scrollTop: this.topArr[index] - this.HeighT,
|
||||||
duration: 0
|
duration: 0
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
|
||||||
this.leftIndex = index
|
this.leftIndex = index
|
||||||
}, 500)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user