Commit 92d24e63 by 李伟康

提交代码

1 parent 39b794f6
...@@ -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,48 +2,19 @@ ...@@ -2,48 +2,19 @@
<div class="layout"> <div class="layout">
<div class="title">左右滑动查看核销凭证</div> <div class="title">左右滑动查看核销凭证</div>
<div class="content"> <div class="content">
<!-- <div
class="img-box flex"
:key="updata"
ref="imgBox"
@touchend="touchEnd"
@scroll="touchEnd"
>
<template v-for="(i,index) in orderList">
<div
:key="index"
class="img-item"
>
<create-order-img
:orderInfo="i"
:canvasId="`order-${index}`"
:ref="`order-${index}`"
/>
<van-image
:src="imgList[index]"
class="img"
>
<template v-slot:loading>
<van-loading
type="spinner"
size="20"
/>
</template>
</van-image>
</div>
</template>
</div> -->
<van-swipe <van-swipe
class="img-box test" class="img-box"
:key="updata" :key="updata"
indicator-color="#FFFFFF" indicator-color="#FFFFFF"
:width="347" :width="347"
:loop="false"
@change="change"
:style="swipeStyle"
:show-indicators="false"
ref="swipe"
> >
<template v-for="(i,index) in orderList"> <template v-for="(i,index) in orderList">
<van-swipe-item <van-swipe-item :key="index">
:key="index"
>
<create-order-img <create-order-img
:orderInfo="i" :orderInfo="i"
:canvasId="`order-${index}`" :canvasId="`order-${index}`"
...@@ -64,16 +35,14 @@ ...@@ -64,16 +35,14 @@
</template> </template>
</van-swipe> </van-swipe>
<!-- <div class="dots x-center text-center"> <div class="dots x-center text-center">
<template v-for="(i,index) in orderList"> <template v-for="(i,index) in orderList">
<div <div
:key="index"
:class="['dots-item',{'active':itemIndex == index}]" :class="['dots-item',{'active':itemIndex == index}]"
> :key="index"
></div>
</div>
</template> </template>
</div> --> </div>
</div> </div>
<div class="tips text-center">长按保存图片</div> <div class="tips text-center">长按保存图片</div>
</div> </div>
...@@ -82,8 +51,7 @@ ...@@ -82,8 +51,7 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import { shopmallApi } from '@/api' import { shopmallApi } from '@/api'
import { createOrderImg } from './components/index' import { createOrderImg } from './components/index'
import { util } from '@/utils' const swipeStyle = 'padding-left: 9px;'
let _this = null
export default { export default {
components: { createOrderImg }, components: { createOrderImg },
name: 'orderList', name: 'orderList',
...@@ -92,68 +60,30 @@ export default { ...@@ -92,68 +60,30 @@ export default {
orderList: [], orderList: [],
imgList: [], imgList: [],
updata: Date.now(), updata: Date.now(),
lastItemIndex: 0,
itemIndex: 0, itemIndex: 0,
touchFlag: true swipeStyle
} }
}, },
activated () { activated () {
_this = this
this.getOrderList() this.getOrderList()
}, },
methods: { methods: {
moveSlow (distance, total, step = 20) { change (e) {
let box = document.getElementsByClassName('img-box')[0] this.itemIndex = e
if (this.lastItemIndex < this.itemIndex) { let { track } = this.$refs.swipe.$refs,
if (distance < total) { { orderList } = this
distance += step this.$nextTick(() => {
box.scrollLeft = distance if (e == 0) this.swipeStyle = swipeStyle
setTimeout(() => { else {
this.moveSlow(distance, total, step) let [firstCss, last] = track.style.cssText.split('translateX(-')
}, 1) let [num, lastCss] = last.split('px)')
} else { num = Number(num) - (e == orderList.length - 1 ? -27 : 9)
box.scrollLeft = total track.style.cssText = `${firstCss}translateX(-${num}px)${lastCss}`
this.touchFlag = false this.swipeStyle = ''
}
}
if (this.lastItemIndex > this.itemIndex) {
if (distance > total) {
distance -= step
box.scrollLeft = distance
setTimeout(() => {
this.moveSlow(distance, total, step)
}, 1)
} else {
box.scrollLeft = total
this.touchFlag = false
}
}
if (this.lastItemIndex == this.itemIndex) {
box.scrollLeft = total
this.touchFlag = false
} }
})
}, },
touchEnd: util.debounce(e => {
_this.lastItemIndex = _this.itemIndex
let box = document.getElementsByClassName('img-box')[0]
let { imgList } = _this
let spacing = imgList.length > 1 ? 10 : 0
let width = document.getElementsByClassName('img-item')[0].offsetWidth
let index = (box.scrollLeft / width).toFixed()
let total = index == 0 ? 0 : width * index + (spacing * index)
_this.itemIndex = index
console.log(e)
if (e.type == 'touchend') {
console.log('触摸离开')
_this.moveSlow(box.scrollLeft, total)
}
if (e.type != 'touchend' && !_this.touchFlag) {
console.log('滑动完')
_this.moveSlow(box.scrollLeft, total)
_this.touchFlag = true
}
}, 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 => {
...@@ -186,6 +116,7 @@ export default { ...@@ -186,6 +116,7 @@ export default {
} }
.content { .content {
position: relative; position: relative;
height: 422px;
.dots { .dots {
bottom: 15px; bottom: 15px;
&-item { &-item {
...@@ -200,28 +131,11 @@ export default { ...@@ -200,28 +131,11 @@ export default {
} }
} }
} }
.test{
padding-left: 19px;
}
.img-box { .img-box {
overflow-x: scroll;
width: 100%; width: 100%;
height: 422px; height: 422px;
flex-wrap: nowrap; /deep/.van-swipe-item {
touch-action: pan-x; text-align: right;
-webkit-overflow-scrolling: touch;
transition: all 0.5s;
&::-webkit-scrollbar {
display: none;
}
.img-item {
margin-left: 10px;
&:first-of-type {
margin-left: 19px;
}
&:last-of-type {
border-right: 16px solid #fff;
}
} }
.img { .img {
width: 337px; width: 337px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!