Commit 41aa6707 authored by leon's avatar leon

feat: popup data view style

parent 02580396
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
eventName = 'indexShowBar' eventName = 'indexShowBar'
} else { } else {
eventName = 'detailShowBar' eventName = 'detailShowBar'
} }
uni.$emit(eventName, { uni.$emit(eventName, {
page: curRoute, page: curRoute,
popupShow: true, popupShow: true,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
moveY: 0, //滑动的y轴距离 moveY: 0, //滑动的y轴距离
like_state: 0, //-1:左滑,0:没滑动,1:右滑 like_state: 0, //-1:左滑,0:没滑动,1:右滑
animationData: {}, animationData: {},
index: 0, index: -1,
} }
}, },
props: { props: {
...@@ -53,11 +53,10 @@ ...@@ -53,11 +53,10 @@
timingFunction: 'ease', timingFunction: 'ease',
duration: 120 duration: 120
}) })
}, },
computed: { computed: {
popupObject: { popupObject: {
get() { get() {
this.index = this.currentIndex
return this.popupData[this.currentIndex] return this.popupData[this.currentIndex]
}, },
set(val) { set(val) {
...@@ -72,22 +71,33 @@ ...@@ -72,22 +71,33 @@
return val return val
} }
} }
}, },
methods: { methods: {
close() { close() {
this.index = -1
this.$emit('close') this.$emit('close')
}, },
seeImage(key) { seeImage(key) {
if(this.index === -1) {
this.index = this.currentIndex
}
var images = [] var images = []
this.popupData.forEach(item => { this.popupData.forEach(item => {
images.push(item[key]) images.push(item[key])
}) })
uni.previewImage({ uni.previewImage({
current: this.index, current: this.index,
urls: images urls: images
}) })
// 图片查看弹窗会使页面close,所以需要把index置为-1
this.index = -1
}, },
touchStart(event) { touchStart(event) {
if(this.index === -1) {
this.index = this.currentIndex
}
this.startX = event.touches[0].pageX; this.startX = event.touches[0].pageX;
this.startY = event.touches[0].pageY; this.startY = event.touches[0].pageY;
}, },
...@@ -99,9 +109,9 @@ ...@@ -99,9 +109,9 @@
var state = 0; //-1:左滑,0:没滑动,1:右滑 var state = 0; //-1:左滑,0:没滑动,1:右滑
// //左右方向滑动 // //左右方向滑动
if (Math.abs(moveX) > Math.abs(moveY)) { if (Math.abs(moveX) > Math.abs(moveY)) {
if (moveX < -10) { if (moveX < -40) {
state = 1; state = 1;
} else if (moveX > 10) { } else if (moveX > 40) {
state = -1; state = -1;
} }
} }
...@@ -110,17 +120,18 @@ ...@@ -110,17 +120,18 @@
this.moveY = moveY; this.moveY = moveY;
}, },
touchEnd(event) { touchEnd(event) {
if (Math.abs(this.moveX) > 60 && this.like_state != -100) { if (Math.abs(this.moveX) > 40 && this.like_state != -100) {
console.log("this index = " , this.index)
var state = this.like_state var state = this.like_state
this.like_state = -100 //设置这个数是为了避免滑动之后点击不走touchMove而产生的不正常滑动 this.like_state = -100 //设置这个数是为了避免滑动之后点击不走touchMove而产生的不正常滑动
//这里放需要进行的业务逻辑 //这里放需要进行的业务逻辑
if (state === 1 && this.index < this.popupData.length - 1) { if (state === 1 && this.index < this.popupData.length - 1) {
this.animation.translateX('-100%').step() this.animation.translateX('-100%').step()
.opacity(0).step({ .opacity(0).step({
duration: 10 duration: 50
}) })
.translateX('100%').step({ .translateX('100%').step({
duration: 10 duration: 50
}) })
.translateX(0).opacity(1).step() .translateX(0).opacity(1).step()
...@@ -129,15 +140,18 @@ ...@@ -129,15 +140,18 @@
setTimeout(() => { setTimeout(() => {
this.animationData = {} this.animationData = {}
}, 250) }, 250)
this.index += 1 this.index += 1
// this.popupObject = this.popupData[this.index]
this.$set(this.popupObject, '', this.popupData[this.index])
console.log("end this index = " , this.index)
} }
if (state === -1 && this.index > 0) { if (state === -1 && this.index > 0) {
this.animation.translateX('100%').step() this.animation.translateX('100%').step()
.opacity(0).step({ .opacity(0).step({
duration: 10 duration: 50
}) })
.translateX('-100%').step({ .translateX('-100%').step({
duration: 10 duration: 50
}) })
.translateX(0).opacity(1).step() .translateX(0).opacity(1).step()
...@@ -147,8 +161,11 @@ ...@@ -147,8 +161,11 @@
this.animationData = {} this.animationData = {}
}, 250) }, 250)
this.index -= 1 this.index -= 1
} // this.popupObject = this.popupData[this.index]
this.$set(this.popupObject, '', this.popupData[this.index]) this.$set(this.popupObject, '', this.popupData[this.index])
console.log("end this index = " , this.index)
}
console.log("popupObject = ", this.popupObject)
} }
} }
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment