Commit 0dcfd574 by 李伟康

提交代码

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