Commit 0dcfd574 by 李伟康

提交代码

1 parent aec43fdf
......@@ -22,7 +22,7 @@
客服
</div>
</template>
<!-- <template v-if="showOrderBtn">
<template v-if="showOrderBtn">
<div
class="page-item flex order-move"
@click="to('crowdfunding.orderList')"
......@@ -32,7 +32,7 @@
<div class="sprite-icon icon-order"></div>
订单
</div>
</template> -->
</template>
</div>
<div class="big-img">
<img :src="detail.activityBigImg" />
......
......@@ -2,16 +2,12 @@
<div class="layout">
<div class="title">左右滑动查看核销凭证</div>
<div
class="img-box"
class="img-box flex"
:key="updata"
ref="imgBox"
@touchend="scroll"
@touchstart="scrollstart"
>
<div
:class="['move flex',`test-${tabIndex}`]"
id="img-move"
>
<template v-for="(i,index) in orderList">
<div
:key="index"
......@@ -36,7 +32,6 @@
</div>
</template>
</div>
</div>
<div class="tips text-center">长按保存图片</div>
</div>
</template>
......@@ -54,7 +49,8 @@ export default {
orderList: [],
imgList: [],
updata: Date.now(),
tabIndex: 0
lastItemIndex: 0,
itemIndex: 0
}
},
activated () {
......@@ -62,21 +58,46 @@ export default {
this.getOrderList()
},
methods: {
scrollstart(){
scrollstart () {
this.tabIndex = null
},
moveSlow (distance, total, step = 20) {
let box = document.getElementsByClassName('img-box')[0]
if (this.lastItemIndex < this.itemIndex) {
if (distance < total) {
distance += step
box.scrollLeft = distance
setTimeout(() => {
this.moveSlow(distance, total, step)
}, 1)
} else {
box.scrollLeft = total
}
}
if (this.lastItemIndex > this.itemIndex) {
if (distance > total) {
distance -= step
box.scrollLeft = distance
setTimeout(() => {
this.moveSlow(distance, total, step)
}, 1)
} else {
box.scrollLeft = total
}
}
if(this.lastItemIndex == this.itemIndex) box.scrollLeft = total
},
scroll: util.debounce(e => {
let box = document.getElementsByClassName('img-box')[0],
moveBox = document.getElementById('img-move')
_this.lastItemIndex = _this.itemIndex
let box = document.getElementsByClassName('img-box')[0]
let { imgList } = _this
let spacing = imgList.length > 1 ? (imgList.length - 1) * 10 : 0
let spacing = imgList.length > 1 ? 10 : 0
let width = document.getElementsByClassName('img-item')[0].offsetWidth
let index = (box.scrollLeft / width).toFixed()
let target = index == 0 ? 0 : width * index + spacing
// moveBox.style.width = width * imgList.length + 32 + (spacing * imgList.length)
console.log(index)
_this.tabIndex = index
}),
let total = index == 0 ? 0 : width * index + (spacing * index)
_this.itemIndex = index
_this.moveSlow(box.scrollLeft, total)
},200),
getOrderList () {
let { id } = this.getLocalStorage('wx_scrm_link_params')
shopmallApi.getOrderList(id).then(data => {
......@@ -108,10 +129,13 @@ export default {
padding: 16px 0 8px 20px;
}
.img-box {
position: relative;
overflow-x: scroll;
width: 100%;
height: 422px;
flex-wrap: nowrap;
touch-action: pan-x;
-webkit-overflow-scrolling: touch;
transition: all 0.5s;
&::-webkit-scrollbar {
display: none;
}
......@@ -133,21 +157,8 @@ export default {
position: absolute;
left: 0;
top: 0;
flex-wrap: nowrap;
width: 1103px;
height: 100%;
touch-action: pan-x;
-webkit-overflow-scrolling: touch;
transition: all 0.5s;
}
.test-0 {
transform: translateX(0);
}
.test-1 {
transform: translateX(-366px);
}
.test-2 {
transform: translateX(-703px);
}
}
.tips {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!