Commit 92d24e63 by 李伟康

提交代码

1 parent 39b794f6
......@@ -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,48 +2,19 @@
<div class="layout">
<div class="title">左右滑动查看核销凭证</div>
<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
class="img-box test"
class="img-box"
:key="updata"
indicator-color="#FFFFFF"
indicator-color="#FFFFFF"
:width="347"
:loop="false"
@change="change"
:style="swipeStyle"
:show-indicators="false"
ref="swipe"
>
<template v-for="(i,index) in orderList">
<van-swipe-item
:key="index"
>
<van-swipe-item :key="index">
<create-order-img
:orderInfo="i"
:canvasId="`order-${index}`"
......@@ -64,16 +35,14 @@
</template>
</van-swipe>
<!-- <div class="dots x-center text-center">
<div class="dots x-center text-center">
<template v-for="(i,index) in orderList">
<div
:key="index"
:class="['dots-item',{'active':itemIndex == index}]"
>
</div>
:key="index"
></div>
</template>
</div> -->
</div>
</div>
<div class="tips text-center">长按保存图片</div>
</div>
......@@ -82,8 +51,7 @@
<script type='text/ecmascript-6'>
import { shopmallApi } from '@/api'
import { createOrderImg } from './components/index'
import { util } from '@/utils'
let _this = null
const swipeStyle = 'padding-left: 9px;'
export default {
components: { createOrderImg },
name: 'orderList',
......@@ -92,68 +60,30 @@ export default {
orderList: [],
imgList: [],
updata: Date.now(),
lastItemIndex: 0,
itemIndex: 0,
touchFlag: true
swipeStyle
}
},
activated () {
_this = this
this.getOrderList()
},
methods: {
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
this.touchFlag = false
change (e) {
this.itemIndex = e
let { track } = this.$refs.swipe.$refs,
{ orderList } = this
this.$nextTick(() => {
if (e == 0) this.swipeStyle = swipeStyle
else {
let [firstCss, last] = track.style.cssText.split('translateX(-')
let [num, lastCss] = last.split('px)')
num = Number(num) - (e == orderList.length - 1 ? -27 : 9)
track.style.cssText = `${firstCss}translateX(-${num}px)${lastCss}`
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 () {
let { id } = this.getLocalStorage('wx_scrm_link_params')
shopmallApi.getOrderList(id).then(data => {
......@@ -186,6 +116,7 @@ export default {
}
.content {
position: relative;
height: 422px;
.dots {
bottom: 15px;
&-item {
......@@ -200,28 +131,11 @@ export default {
}
}
}
.test{
padding-left: 19px;
}
.img-box {
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;
}
.img-item {
margin-left: 10px;
&:first-of-type {
margin-left: 19px;
}
&:last-of-type {
border-right: 16px solid #fff;
}
/deep/.van-swipe-item {
text-align: right;
}
.img {
width: 337px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!