Commit 02580396 authored by Jenny's avatar Jenny

feat: 柱状图弹窗修改

parent 3c393b43
...@@ -91,11 +91,20 @@ export default { ...@@ -91,11 +91,20 @@ export default {
current: event.dataIndex, current: event.dataIndex,
urls: urls urls: urls
}) })
} else if (popup) { } else if (popup) {
uni.$emit('showBarDetail', { let routes = getCurrentPages()
let curRoute = routes[routes.length - 1].route
let eventName = ''
if (curRoute === 'pages/index/index') {
eventName = 'indexShowBar'
} else {
eventName = 'detailShowBar'
}
uni.$emit(eventName, {
page: curRoute,
popupShow: true, popupShow: true,
popupData: data, popupData: data,
currentIndex: event.dataIndex, currentIndex: event.dataIndex,
customRender customRender
}) })
} else { } else {
......
<template> <template>
<u-modal class="model-data" v-model="popupShow" :closeOnClickOverlay="true" title="明细" @close="close" <u-modal class="model-data" v-model="show" title="明细" @close="close"
@confirm="close"> @confirm="close">
<view class="slot-content" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd" <view class="slot-content" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd"
:animation="animationData"> :animation="animationData">
<view v-for="(val, key) in popupObject" class="data-view"> <view v-for="(val, key) in popupObject" :key="key" class="data-view">
<view class="data-key ellipsis">{{ key }}</view> <view class="data-key ellipsis">{{ key }}</view>
<template v-if="customRender[key] === 'picture'"> <template v-if="customRender[key] === 'picture'">
<u-image :height="100" mode="aspectFit" :src="val" crossOrigin="anonymous" style="width: 100%" <u-image :height="100" mode="aspectFit" :src="val" crossOrigin="anonymous" style="width: 100%"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
export default { export default {
name: 'ModelData', name: 'ModelData',
data() { data() {
return { return {
// popupObject: {}, // popupObject: {},
startX: 0, //滑动开始x轴位置 startX: 0, //滑动开始x轴位置
startY: 0, //滑动开始y轴位置 startY: 0, //滑动开始y轴位置
...@@ -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: 0,
} }
}, },
props: { props: {
...@@ -47,30 +47,35 @@ ...@@ -47,30 +47,35 @@
type: Object, type: Object,
default: () => {} default: () => {}
} }
}, },
created() { created() {
this.animation = uni.createAnimation({ this.animation = uni.createAnimation({
timingFunction: 'ease', timingFunction: 'ease',
duration: 120 duration: 120
}) })
}, },
computed: { computed: {
popupObject: { popupObject: {
get() { get() {
this.index = this.currentIndex this.index = this.currentIndex
return this.popupData[this.currentIndex] return this.popupData[this.currentIndex]
}, },
set(val) { set(val) {
return val return val
} }
} },
show: {
get() {
return this.popupShow
},
set(val) {
return val
}
}
}, },
methods: { methods: {
close() { close() {
uni.$emit('showBarDetail', { this.$emit('close')
popupShow: false,
popupData: []
})
}, },
seeImage(key) { seeImage(key) {
var images = [] var images = []
...@@ -124,7 +129,7 @@ ...@@ -124,7 +129,7 @@
setTimeout(() => { setTimeout(() => {
this.animationData = {} this.animationData = {}
}, 250) }, 250)
this.index += 1 this.index += 1
} }
if (state === -1 && this.index > 0) { if (state === -1 && this.index > 0) {
this.animation.translateX('100%').step() this.animation.translateX('100%').step()
...@@ -142,8 +147,8 @@ ...@@ -142,8 +147,8 @@
this.animationData = {} this.animationData = {}
}, 250) }, 250)
this.index -= 1 this.index -= 1
} }
this.$set(this.popupObject, '', this.popupData[this.index]) this.$set(this.popupObject, '', this.popupData[this.index])
} }
} }
} }
...@@ -175,4 +180,4 @@ ...@@ -175,4 +180,4 @@
margin-right: 10px; margin-right: 10px;
border-right: 1px solid #eee; border-right: 1px solid #eee;
} }
</style> </style>
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
:popupData="popupData" :popupData="popupData"
:currentIndex="currentIndex" :currentIndex="currentIndex"
:customRender="customRender" :customRender="customRender"
@close="popupShow=false"
></ModelData> ></ModelData>
</view> </view>
</template> </template>
...@@ -161,7 +162,7 @@ ...@@ -161,7 +162,7 @@
uni.$on('handleUpdateHeight', (height) => { uni.$on('handleUpdateHeight', (height) => {
that.horizontalBarHeight = height that.horizontalBarHeight = height
}), }),
uni.$on('showBarDetail', data => { uni.$on('detailShowBar', data => {
const { popupShow, popupData, customRender, currentIndex } = data const { popupShow, popupData, customRender, currentIndex } = data
that.popupShow = popupShow that.popupShow = popupShow
that.popupData = popupData that.popupData = popupData
...@@ -171,15 +172,13 @@ ...@@ -171,15 +172,13 @@
}, },
onUnload() { onUnload() {
// 如何监听页面卸载时候隐藏弹窗 // 如何监听页面卸载时候隐藏弹窗
uni.$on('showBarDetail', data => { this.popupShow = false
that.popupShow = false
})
// 移除监听事件 // 移除监听事件
uni.$off('handleLinkParams') uni.$off('handleLinkParams')
uni.$off('handleLinkComp') uni.$off('handleLinkComp')
uni.$off('handleDataZoomParams') uni.$off('handleDataZoomParams')
uni.$off('handleUpdateHeight') uni.$off('handleUpdateHeight')
uni.$off('showBarDetail') uni.$off('detailShowBar')
clearInterval(this.timename) clearInterval(this.timename)
}, },
methods: { methods: {
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
:popupData="popupData" :popupData="popupData"
:currentIndex="currentIndex" :currentIndex="currentIndex"
:customRender="customRender" :customRender="customRender"
@close="popupShow=false"
></ModelData> ></ModelData>
</view> </view>
</template> </template>
...@@ -157,7 +158,7 @@ ...@@ -157,7 +158,7 @@
uni.$on('handleUpdateHeight', (height) => { uni.$on('handleUpdateHeight', (height) => {
that.horizontalBarHeight = height that.horizontalBarHeight = height
}) })
uni.$on('showBarDetail', data => { uni.$on('indexShowBar', data => {
const { popupShow, popupData, customRender, currentIndex } = data const { popupShow, popupData, customRender, currentIndex } = data
that.popupShow = popupShow that.popupShow = popupShow
that.popupData = popupData that.popupData = popupData
...@@ -166,11 +167,13 @@ ...@@ -166,11 +167,13 @@
}) })
}, },
onHide() { onHide() {
this.popupShow = false
// 移除监听事件 // 移除监听事件
uni.$off('handleLinkParams') uni.$off('handleLinkParams')
uni.$off('handleLinkComp') uni.$off('handleLinkComp')
uni.$off('handleDataZoomParams') uni.$off('handleDataZoomParams')
uni.$off('handleUpdateHeight') uni.$off('handleUpdateHeight')
uni.$off('indexShowBar')
clearInterval(this.timename) clearInterval(this.timename)
}, },
methods: { methods: {
......
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