This commit is contained in:
parent
b9328d0a1c
commit
529a43903c
File diff suppressed because it is too large
Load Diff
|
|
@ -93,7 +93,7 @@
|
||||||
:scroll-into-view="leftIntoView" :scroll-with-animation="false">
|
:scroll-into-view="leftIntoView" :scroll-with-animation="false">
|
||||||
<view class="item" v-for="(item,index) in shopProductList.productInfo" :key="index"
|
<view class="item" v-for="(item,index) in shopProductList.productInfo" :key="index"
|
||||||
:class="{ 'active':index==leftIndex }" :id="'left-'+index" :data-index="index"
|
:class="{ 'active':index==leftIndex }" :id="'left-'+index" :data-index="index"
|
||||||
@tap="leftTap">{{item.name}}</view>
|
@click="leftTap(index)">{{item.name}}</view>
|
||||||
<view class="items"></view>
|
<view class="items"></view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -517,18 +517,18 @@
|
||||||
* @param {Object} b
|
* @param {Object} b
|
||||||
*/
|
*/
|
||||||
shopAdd(item, index, index1, a, b) {
|
shopAdd(item, index, index1, a, b) {
|
||||||
if ( a == "+" ){
|
if (a == "+") {
|
||||||
if ( this.skuNumber < this.skuSuit) {
|
if (this.skuNumber < this.skuSuit) {
|
||||||
this.amountcartNumber = this.amountcartNumber + (item.suit==0?1:item.suit);
|
this.amountcartNumber = this.amountcartNumber + (item.suit == 0 ? 1 : item.suit);
|
||||||
}else {
|
} else {
|
||||||
this.amountcartNumber++;
|
this.amountcartNumber++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (this.amountcartNumber > 0) {
|
if (this.amountcartNumber > 0) {
|
||||||
console.log(item)
|
console.log(item)
|
||||||
if ( this.skuNumber < this.skuSuit) {
|
if (this.skuNumber < this.skuSuit) {
|
||||||
this.amountcartNumber = this.amountcartNumber - (item.suit==0?1:item.suit);
|
this.amountcartNumber = this.amountcartNumber - (item.suit == 0 ? 1 : item.suit);
|
||||||
} else {
|
} else {
|
||||||
this.amountcartNumber = this.amountcartNumber - 1;
|
this.amountcartNumber = this.amountcartNumber - 1;
|
||||||
}
|
}
|
||||||
|
|
@ -851,7 +851,7 @@
|
||||||
/* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-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) {
|
||||||
this.fillHeight = this.scrollHeight - last + 20; //这是吸到顶部的距离
|
// this.fillHeight = this.scrollHeight - last + 20; //这是吸到顶部的距离
|
||||||
// this.fillHeight = 200;
|
// this.fillHeight = 200;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -876,18 +876,37 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const calculateDeltas = (arr) => {
|
||||||
|
return arr.map((item, index, array) => {
|
||||||
|
if (index === 0) {
|
||||||
|
// 第一个元素前无下标,返回当前元素后下标与第一个元素的差
|
||||||
|
return array[index + 1] - item;
|
||||||
|
} else if (index === array.length - 1) {
|
||||||
|
// 最后一个元素后无下标,返回当前元素前下标与最后一个元素的差
|
||||||
|
return item - array[index - 1];
|
||||||
|
} else {
|
||||||
|
// 计算当前元素前后下标的差
|
||||||
|
return array[index + 1] - item || item - array[index - 1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// 计算前后下标差
|
||||||
|
const deltas = calculateDeltas(this.topArr);
|
||||||
|
console.log(deltas);
|
||||||
this.leftIndex = (index < 0 ? 0 : index);
|
this.leftIndex = (index < 0 ? 0 : index);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 左侧导航点击 */
|
/* 左侧导航点击 */
|
||||||
leftTap(e) {
|
leftTap(index) {
|
||||||
let HeighTdata = null
|
let HeighTdata = null
|
||||||
if (this.opacity) {
|
if (this.opacity) {
|
||||||
HeighTdata = this.HeighT
|
HeighTdata = this.HeighT //一个导航栏高度
|
||||||
} else {
|
} else {
|
||||||
HeighTdata = this.HeighT * 2
|
HeighTdata = this.HeighT * 2 //顶部的时候两个导航栏高度
|
||||||
}
|
}
|
||||||
console.log(this.scrollTopSize + HeighTdata, 11)
|
|
||||||
try {
|
try {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: this.scrollTopSize + HeighTdata, //滑动需要的距离 nav+列表距离的高度
|
scrollTop: this.scrollTopSize + HeighTdata, //滑动需要的距离 nav+列表距离的高度
|
||||||
|
|
@ -897,9 +916,9 @@
|
||||||
//TODO handle the exception
|
//TODO handle the exception
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let index = e.currentTarget.dataset.index;
|
|
||||||
this.scrollInto = `item-${index}`;
|
this.scrollInto = `item-${index}`;
|
||||||
}, 300)
|
this.leftIndex = (index < 0 ? 0 : index);
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue