Commit 85dbd38b authored by Jenny_1007's avatar Jenny_1007

feat: detail 分包

parent 14afb33d
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
data () { data () {
return { return {
ec: { ec: {
lazyLoad:true lazyLoad:true,
option: {}
}, },
changeTimer: null changeTimer: null
} }
...@@ -27,40 +28,42 @@ ...@@ -27,40 +28,42 @@
components: { components: {
uniEcCanvas uniEcCanvas
}, },
onHide() { beforeDestroy() {
clearInterval(this.changeTimer) clearInterval(this.changeTimer)
}, },
destroyed() {
clearInterval(this.changeTimer)
},
mounted() {
this.$refs['barMixMapCanvas'].init(this.inited)
},
methods: { methods: {
initChart() { inited(canvas, width, height, canvasDpr) {
const that = this chart = this.$echarts.init(canvas, null, {
that.$nextTick(() => {
clearInterval(that.changeTimer)
that.$refs['barMixMapCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
let options = that.setMapOption() this.ec.option = this.setMapOption()
const { mapMixBarShow, mapMixBarChangeInterval} = that.elementInfo.option.mapMix chart.setOption(this.ec.option, true)
let flag = true
chart.setOption(options, true)
chart.on('click', event => { chart.on('click', event => {
that.handleEchartsClick(event) this.handleEchartsClick(event)
}) })
return chart
},
initChart() {
this.ec.option = this.setMapOption()
clearInterval(this.changeTimer)
const { mapMixBarShow, mapMixBarChangeInterval} = this.elementInfo.option.mapMix
let flag = true
// 柱状图 地图 切换 // 柱状图 地图 切换
if(mapMixBarShow && mapMixBarChangeInterval) { if(mapMixBarShow && mapMixBarChangeInterval) {
clearInterval(that.changeTimer) this.changeTimer = setInterval(() => {
that.changeTimer = setInterval(() => { this.ec.option = flag ? this.setBarOption() : this.setMapOption()
options = flag ? that.setBarOption() : that.setMapOption()
flag = !flag flag = !flag
chart.setOption(options, true)
}, mapMixBarChangeInterval * 1000) }, mapMixBarChangeInterval * 1000)
} }
return chart
})
})
}, },
setBarOption() { setBarOption() {
const { dataList: { series } } = this.elementData const { dataList: { series } } = this.elementData
......
...@@ -19,25 +19,60 @@ ...@@ -19,25 +19,60 @@
data () { data () {
return { return {
ec: { ec: {
lazyLoad:true lazyLoad:true,
option: {}
} }
} }
}, },
components: { components: {
uniEcCanvas uniEcCanvas
}, },
mounted() {
this.$refs['chinaMapCanvas'].init(this.inited)
},
methods: { methods: {
initChart() { inited(canvas, width, height, canvasDpr) {
const that = this chart = this.$echarts.init(canvas, null, {
that.$nextTick(() => {
that.$refs['chinaMapCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
const { dataList } = that.elementData const { dataList } = this.elementData
this.ec.option = {
title: {
...this.elementInfo.option.title
},
legend: {
...this.elementInfo.option.legend
},
geo: {
map: 'china',
zoom: 1.2,
roam: false,
itemStyle: {
areaColor: 'rgba(34, 70, 168, 0.7)',
borderColor: '#0692a4'
},
emphasis: {
itemStyle: {
areaColor: 'rgba(119, 139, 224, 0.548)'
}
}
},
series: this.dealSeriesData(dataList)
}
chart.setOption(this.ec.option)
chart.on('click', event => {
this.handleEchartsClick(event)
})
return chart
},
initChart() {
const { dataList } = this.elementData
this.$set(this.ec.option, 'series', this.dealSeriesData(dataList))
},
dealSeriesData(dataList) {
const seriesData = dataList.chinaMapAreas || [] const seriesData = dataList.chinaMapAreas || []
// 处理成地图所需的数据格式 // 处理成地图所需的数据格式
const finalData = []; const finalData = [];
...@@ -61,7 +96,6 @@ ...@@ -61,7 +96,6 @@
show: true, show: true,
period: 4, period: 4,
trailLength: 0.02, trailLength: 0.02,
// symbol: 'arrow', // 箭头图标
symbolSize: 5 // 图标大小 symbolSize: 5 // 图标大小
}, },
lineStyle: { lineStyle: {
...@@ -72,7 +106,7 @@ ...@@ -72,7 +106,7 @@
curveness: 0.2 curveness: 0.2
} }
}, },
data: that.convertData(item[1]) data: this.convertData(item[1])
}, { }, {
name: item[0], name: item[0],
type: 'effectScatter', type: 'effectScatter',
...@@ -85,15 +119,15 @@ ...@@ -85,15 +119,15 @@
show: true, show: true,
position: 'right', position: 'right',
formatter: value => { formatter: value => {
if(that.elementInfo.option.dataset.formatter) { if(this.elementInfo.option.dataset.formatter) {
return that.$u.common.converFunction(that.elementInfo.option.dataset.formatter, value) return this.$u.common.converFunction(this.elementInfo.option.dataset.formatter, value)
} else { } else {
return that.elementInfo.option.dataset.show ? `${value.data.name}:${value.data.value[2]}` : value.data.name return this.elementInfo.option.dataset.show ? `${value.data.name}:${value.data.value[2]}` : value.data.name
} }
}, },
fontSize: that.elementInfo.option.dataset.fontSize, fontSize: this.elementInfo.option.dataset.fontSize,
color: that.elementInfo.option.dataset.color, color: this.elementInfo.option.dataset.color,
fontWeight: that.elementInfo.option.dataset.fontWeight fontWeight: this.elementInfo.option.dataset.fontWeight
}, },
symbolSize: 4, symbolSize: 4,
itemStyle: { itemStyle: {
...@@ -107,37 +141,7 @@ ...@@ -107,37 +141,7 @@
}) })
}) })
}) })
return series
const options = {
title: {
...that.elementInfo.option.title
},
legend: {
...that.elementInfo.option.legend
},
geo: {
map: 'china',
zoom: 1.2,
roam: false,
itemStyle: {
areaColor: 'rgba(34, 70, 168, 0.7)',
borderColor: '#0692a4'
},
emphasis: {
itemStyle: {
areaColor: 'rgba(119, 139, 224, 0.548)'
}
}
},
series: series
}
chart.setOption(options)
chart.on('click', event => {
that.handleEchartsClick(event)
})
return chart
})
})
}, },
convertData(data) { convertData(data) {
const res = [] const res = []
......
...@@ -57,14 +57,21 @@ ...@@ -57,14 +57,21 @@
"onReachBottomDistance": 50 "onReachBottomDistance": 50
} }
},{ }
"path" : "pages/details/details", ],
"subpackages": [
{
"root": "subPages",
"pages": [
{
"path" : "details/details",
"style" : "style" :
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}
]
} }
], ],
"globalStyle": { "globalStyle": {
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
// 点击查看 // 点击查看
onClick(item) { onClick(item) {
const url = "/pages/details/details?id=" + item.id const url = "/subPages/details/details?id=" + item.id
uni.navigateTo({ uni.navigateTo({
url: url url: url
}) })
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
<template v-for="(element, index) in reportInfo.list"> <template v-for="(element, index) in reportInfo.list">
<view <view
class="view-element" class="view-element"
v-show="!element.hide" v-if="!element.hide"
:key="element.id" :key="element.id"
:style="{ :style="{
width: `${element.width * scale}px`, width: `${parseInt(element.width * scale)}px`,
height: `${element.height * scale}px`, height: `${parseInt(element.height * scale)}px`,
left: `${element.left * scale}px`, left: `${parseInt(element.left * scale)}px`,
top: `${element.top * scale}px`, top: `${parseInt(element.top * scale)}px`,
zIndex: index + 1 zIndex: index + 1
}" }"
> >
......
...@@ -305,6 +305,8 @@ ...@@ -305,6 +305,8 @@
}, },
beforeDestroy() { beforeDestroy() {
this.$curChart.dispose() this.$curChart.dispose()
this.$curChart.clear()
this.$curChart = {}
} }
}; };
</script> </script>
......
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