购物车联动优化
This commit is contained in:
parent
360b0c1ade
commit
8cb92dc6f5
|
|
@ -35,7 +35,7 @@
|
|||
本店招牌菜
|
||||
</view>
|
||||
<view class="panelfive">
|
||||
<scroll-view :scroll-x="true" :scroll-into-view="leftIntoView" :scroll-with-animation="false">
|
||||
<scroll-view :scroll-into-view="leftIntoView" :scroll-with-animation="false">
|
||||
<view class="panelfive_list">
|
||||
<view class="panelfiveitem" @click="clickspecifications(item,index,index,'热销')"
|
||||
v-for="(item,index) in shopProductList.hots" :key="index">
|
||||
|
|
@ -92,7 +92,8 @@
|
|||
<view class="scroll-panel" id="scroll-panel">
|
||||
<view class="list-box">
|
||||
<view class="left" :style="{top: `${HeighT}px`}">
|
||||
<scroll-view :scroll-into-view="leftIntoView" :scroll-with-animation="false">
|
||||
<scroll-view :scroll-into-view="leftIntoView" :scroll-with-animation="false" :scroll-y="scrollxleft"
|
||||
:style="{height:`${scrollHeight - 90}px`}">
|
||||
<view class="item" v-for="(item,index) in shopProductList.productInfo" :key="index"
|
||||
:class="{ 'active':index==leftIndex }" :id="'left-'+index" :data-index="index"
|
||||
@click="leftTap(index)"><text>{{item.name}}</text></view>
|
||||
|
|
@ -108,7 +109,7 @@
|
|||
</view>
|
||||
<view class="goods" @click="clickspecifications(item1,index,index1)"
|
||||
v-for="(item1,index1) in item.products" :key="index1">
|
||||
<!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||
<!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_150,h_150`" mode="aspectFill"></image> -->
|
||||
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||
:src="`${item1.coverImg}`" mode="aspectFill"></image>
|
||||
|
|
@ -353,7 +354,8 @@
|
|||
salePrice: '', //钱数
|
||||
cartListsdatashow: false, //是否显示购物车
|
||||
showCart: false,
|
||||
lastbottom: '' //元素最低端的距离
|
||||
lastbottom: '', //元素最低端的距离
|
||||
scrollxleft: false
|
||||
}
|
||||
},
|
||||
onPageScroll(e) {
|
||||
|
|
@ -870,7 +872,7 @@
|
|||
// this.scrollHeight = this.scrollHeight - this.HeighT
|
||||
this.topArr = topArr;
|
||||
// 获取最后一个元素最低端的盒子到顶点的距离
|
||||
this.lastbottom = res[res.length - 1].bottom;
|
||||
this.lastbottom = res[res.length - 1].bottom - 20;
|
||||
/* 获取最后一项的高度,设置填充高度。判断和填充时做了 +-20 的操作,是为了滚动时更好的定位 */
|
||||
let last = res[res.length - 1].height;
|
||||
if (last - 20 < this.scrollHeight) {
|
||||
|
|
@ -889,21 +891,25 @@
|
|||
let scrollFn = () => {
|
||||
let top = e.scrollTop;
|
||||
let index = 0;
|
||||
/* 查找当前滚动距离 */
|
||||
for (let i = (this.topArr.length - 1); i >= 0; i--) {
|
||||
/* 在部分安卓设备上,因手机逻辑分辨率与rpx单位计算不是整数,滚动距离与有误差,增加2px来完善该问题 */
|
||||
if ((top + 2) >= this.topArr[i] - this.HeighT) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
// const lastElement = this.topArr[this.topArr.length - 1];
|
||||
}
|
||||
const currentElement = this.topArr[index];
|
||||
const diff = this.lastbottom - currentElement;
|
||||
if (diff > this.scrollHeight - 200) { //200是固定高度
|
||||
this.leftIndex = (index < 0 ? 0 : index);
|
||||
// 判断左边是否可以滑动
|
||||
if (top + 2 > this.topArr[0]) {
|
||||
this.scrollxleft = true
|
||||
} else {
|
||||
this.scrollxleft = false
|
||||
}
|
||||
/* 查找当前滚动距离 */
|
||||
if (this.scrollHeight - 200 >= (this.topArr[this.topArr.length - 1] - this.topArr[this
|
||||
.leftIndex])) { //4109
|
||||
this.leftIndex = this.leftIndex
|
||||
} else {
|
||||
for (let i = (this.topArr.length - 1); i >= 0; i--) {
|
||||
/* 在部分安卓设备上,因手机逻辑分辨率与rpx单位计算不是整数,滚动距离与有误差,增加2px来完善该问题 */
|
||||
if ((top + 2) >= this.topArr[i] - this.HeighT) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.leftIndex = (index < 0 ? 0 : index);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1700,7 +1706,7 @@
|
|||
}
|
||||
|
||||
.items {
|
||||
height: 180rpx;
|
||||
height: 90px;
|
||||
position: relative;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
|
|
|
|||
Loading…
Reference in New Issue