提交 6b123254 authored 作者: lidongxu's avatar lidongxu

style(bi/cmm/lineandbar): 修复移动端显示问题

蝉妈妈图表可以根据网页宽度改变自适应,图表也自适应等
上级 36f67c0c
...@@ -59,18 +59,10 @@ export default { ...@@ -59,18 +59,10 @@ export default {
}; };
}, },
created() { created() {
this.clientWidth = document.documentElement.clientWidth; this.resize()
this.clientHeight = document.documentElement.clientHeight;
this.left = this.clientWidth - this.itemWidth - this.gapWidth;
this.top = this.clientHeight * this.coefficientHeight;
}, },
mounted() { mounted() {
window.addEventListener('resize', () => { window.addEventListener('resize', this.resize)
this.clientWidth = document.documentElement.clientWidth;
this.clientHeight = document.documentElement.clientHeight;
this.left = this.clientWidth - this.itemWidth - this.gapWidth;
this.top = this.clientHeight * this.coefficientHeight;
})
this.$nextTick(() => { this.$nextTick(() => {
const sphereBtn = this.$refs.levitatedSphere; const sphereBtn = this.$refs.levitatedSphere;
let isDown = false let isDown = false
...@@ -109,9 +101,17 @@ export default { ...@@ -109,9 +101,17 @@ export default {
}); });
}); });
}, },
beforeDestroy() {
window.removeEventListener('resize', this.resize)
},
methods: { methods: {
resize() {
this.clientWidth = document.documentElement.clientWidth;
this.clientHeight = document.documentElement.clientHeight;
this.left = this.clientWidth - this.itemWidth - this.gapWidth;
this.top = this.clientHeight * this.coefficientHeight;
},
handleClick() { handleClick() {
console.log(this.downPoint.x,this.upPoint.x,this.downPoint.y,this.upPoint.y)
if (this.downPoint.x === this.upPoint.x && this.downPoint.y === this.upPoint.y) { if (this.downPoint.x === this.upPoint.x && this.downPoint.y === this.upPoint.y) {
this.drawer = !this.drawer this.drawer = !this.drawer
} }
......
...@@ -32,7 +32,7 @@ const props = defineProps({ ...@@ -32,7 +32,7 @@ const props = defineProps({
const echartsRef = ref(null) const echartsRef = ref(null)
const chart = shallowRef(null) const chart = shallowRef(null)
const myThousand = ref(false) // 是否显示万单位 let myThousand = false // 是否显示万单位
const setOptions = () => { const setOptions = () => {
// 计算 y 轴显示 // 计算 y 轴显示
...@@ -45,13 +45,13 @@ const setOptions = () => { ...@@ -45,13 +45,13 @@ const setOptions = () => {
}, },
axisLabel: { axisLabel: {
formatter(value) { formatter(value) {
return formatNumberWithUnit(value, '元', myThousand.value, true) return formatNumberWithUnit(value, '元', myThousand, true)
} }
}, },
axisPointer: { axisPointer: {
label: { label: {
formatter: (params) => { formatter: (params) => {
return formatNumberWithUnit(params.value, '元', myThousand.value, true) return formatNumberWithUnit(params.value, '元', myThousand, true)
} }
} }
} }
...@@ -64,13 +64,13 @@ const setOptions = () => { ...@@ -64,13 +64,13 @@ const setOptions = () => {
}, },
axisLabel: { axisLabel: {
formatter(value) { formatter(value) {
return formatNumberWithUnit(value, '人', myThousand.value, true) return formatNumberWithUnit(value, '人', myThousand, true)
} }
}, },
axisPointer: { axisPointer: {
label: { label: {
formatter: (params) => { formatter: (params) => {
return formatNumberWithUnit(params.value, '人', myThousand.value, true) return formatNumberWithUnit(params.value, '人', myThousand, true)
} }
} }
} }
...@@ -113,7 +113,7 @@ const setOptions = () => { ...@@ -113,7 +113,7 @@ const setOptions = () => {
title: '切换万单位', title: '切换万单位',
icon: 'path://M50,50 L100,50 L100,100 L150,100 L150,150 L100,150 L100,200 L50,200 L50,150 L0,150 L0,100 L50,100 Z', icon: 'path://M50,50 L100,50 L100,100 L150,100 L150,150 L100,150 L100,200 L50,200 L50,150 L0,150 L0,100 L50,100 Z',
onclick: () => { onclick: () => {
myThousand.value = !myThousand.value myThousand = !myThousand
setOptions() setOptions()
} }
} }
...@@ -134,9 +134,9 @@ const setOptions = () => { ...@@ -134,9 +134,9 @@ const setOptions = () => {
var color = item.color; var color = item.color;
// 拼接提示内容 // 拼接提示内容
if (item.seriesName.split('-')[1] === '销售额') { if (item.seriesName.split('-')[1] === '销售额') {
tooltip += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + color + ';"></span>' + item.seriesName + ': ' + formatNumberWithUnit(item.value, '元', myThousand.value) + '<br>'; tooltip += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + color + ';"></span>' + item.seriesName + ': ' + formatNumberWithUnit(item.value, '元', myThousand) + '<br>';
} else if (item.seriesName.split('-')[1] === '观看人次') { } else if (item.seriesName.split('-')[1] === '观看人次') {
tooltip += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + color + ';"></span>' + item.seriesName + ': ' + formatNumberWithUnit(item.value, '人', myThousand.value) + '<br>'; tooltip += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + color + ';"></span>' + item.seriesName + ': ' + formatNumberWithUnit(item.value, '人', myThousand) + '<br>';
} }
}); });
return tooltip; return tooltip;
...@@ -161,8 +161,8 @@ const setOptions = () => { ...@@ -161,8 +161,8 @@ const setOptions = () => {
} }
watchEffect(() => { watchEffect(() => {
if (!chart.value) return if (!chart.value || props.chartData.series.length === 0) return
myThousand.value = props.chartData.series?.some(o => { myThousand = props.chartData.series?.some(o => {
return o.data.some(num => num >= 10000) return o.data.some(num => num >= 10000)
}) })
setOptions() setOptions()
...@@ -170,18 +170,23 @@ watchEffect(() => { ...@@ -170,18 +170,23 @@ watchEffect(() => {
const initChart = () => { const initChart = () => {
chart.value = echarts.init(echartsRef.value) chart.value = echarts.init(echartsRef.value)
setOptions() }
const resize = () => {
chart.value.resize()
} }
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
initChart() initChart()
window.addEventListener('resize', resize)
}) })
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (!chart.value) { if (!chart.value) {
return return
} }
window.removeEventListener('resize', resize)
chart.value.dispose() chart.value.dispose()
chart.value = null chart.value = null
}) })
......
...@@ -252,7 +252,7 @@ const reset = async () => { ...@@ -252,7 +252,7 @@ const reset = async () => {
<style scoped <style scoped
lang="scss"> lang="scss">
.tabs-container { .tabs-container {
height: 100%; min-height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
...@@ -30,20 +30,20 @@ const activeName = ref(list.value[0].name) ...@@ -30,20 +30,20 @@ const activeName = ref(list.value[0].name)
<style scoped <style scoped
lang="scss"> lang="scss">
.app-container { .app-container {
height: calc(100vh - 84px); min-height: calc(100vh - 84px);
.tabs { .tabs {
background: var(--el-bg-color-overlay); background: var(--el-bg-color-overlay);
padding: 20px; padding: 20px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; min-height: 100%;
::v-deep(.el-tabs__content) { ::v-deep(.el-tabs__content) {
flex: 1; flex: 1;
.el-tab-pane { .el-tab-pane {
height: 100%; min-height: 100%;
} }
} }
......
...@@ -200,7 +200,6 @@ const filterData = () => { ...@@ -200,7 +200,6 @@ const filterData = () => {
// // 初始化时间 // // 初始化时间
// allChartData.xAxis = generatorDayList(queryParams.date[0], queryParams.date[1]) // allChartData.xAxis = generatorDayList(queryParams.date[0], queryParams.date[1])
const data = await getList() const data = await getList()
console.log(data)
// 直播间列表 // 直播间列表
brandList.value = data.map(list => list[0].platformStore) brandList.value = data.map(list => list[0].platformStore)
// 初始化筛选条件(默认请求第一个店铺的第一类型数据) // 初始化筛选条件(默认请求第一个店铺的第一类型数据)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论