提交 7952e0df authored 作者: yuanyufei's avatar yuanyufei

首页内容的实现

上级 d4270343
# 开发环境配置 # 开发环境配置
ENV = 'development' ENV = 'development'
# 正式环境 # dev环境
#VUE_APP_BASE_API = 'http://sjapi.jxhh.com' VUE_APP_BASE_API = 'http://192.168.111.240:6605/api/v1'
# 测试环境 # 测试环境
VUE_APP_BASE_API = 'http://192.168.26.179:6605/api/v1' #VUE_APP_BASE_API = 'http://192.168.26.179:6605/api/v1'
# 文档模块 直接调用 sys开放接口 # 文档模块 直接调用 sys开放接口
VUE_APP_BASE_SYS_API = 'http://sysapi.jxhh.com' VUE_APP_BASE_SYS_API = 'http://sysapi.jxhh.com'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true
diff a/.env.development b/.env.development (rejected hunks)
@@ -5,6 +5,7 @@
VUE_APP_BASE_API = 'http://sjapi.jxhh.com'
# 开发环境
#VUE_APP_BASE_API = 'http://192.168.111.36:8200'
+#VUE_APP_BASE_API = 'http://192.168.111.34:8200'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
\ No newline at end of file
import request from '@/utils/request'
//默认首页返回
export function getStatisticalHome(){
return request({
url:'local/statistical/statisticalHome',
method:'get',
})
}
//获取运营数据
export function getOperationalData(query){
return request({
url:'local/statistical/operationalData',
method:'get',
params:query
})
}
//获取店铺数据
export function getStoreData(query){
return request({
url:'local/statistical/storeData',
method:'get',
params:query
})
}
//获取店铺排行数据
export function getGoodsSale(query){
return request({
url:'local/statistical/getGoodsSale',
method:'get',
params:query
})
}
//获取热销类目数据
export function getCategorySale(){
return request({
url:'local/statistical/getCategorySale',
method:'get',
})
}
\ No newline at end of file
...@@ -26,25 +26,34 @@ export default { ...@@ -26,25 +26,34 @@ export default {
type: Boolean, type: Boolean,
default: true default: true
}, },
chartData: { numberData: {
type: Object, type: Object,
required: true required: true
} }
}, },
data() { data() {
return { return {
chart: null dateArr: [],
yAsix:10000,
} }
}, },
watch: { watch: {
chartData: { numberData: {
deep: true, deep: true,
handler(val) { handler(val) {
this.dateArr= val.date
this.numberMax(this.numberData.ordercount,this.numberData.customerprice)
this.setOptions(val) this.setOptions(val)
} }
} }
}, },
created() {
this.$nextTick(() => {
this.initChart()
})
},
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
...@@ -57,43 +66,22 @@ export default { ...@@ -57,43 +66,22 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
moneyMax(num) {
let prec = 2
let ceil = true
const len = String(num).length;
if (len <= prec) {
return num
}
const mult = Math.pow(10, prec);
return ceil ? Math.ceil(num / mult) * mult : Math.floor(num / mult) * mult;
},
numberMax(num1,num2){ numberMax(num1,num2){
let num = '' if(num1,num2){
if (num1 >= num2) { var c = num1.concat(num2)
num = num1 this.yAsix = Math.ceil(Math.max(...c))
} else {
num = num2
}
let prec = 2
let ceil = true
const len = String(num).length;
if (len <= prec) {
return num
} }
const mult = Math.pow(10, prec);
return ceil ? Math.ceil(num / mult) * mult : Math.floor(num / mult) * mult;
}, },
initChart() { initChart() {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
if(this.chartData.months){ this.setOptions(this.numberData)
this.setOptions(this.chartData)
}
}, },
setOptions({ expectedData, actualData, moneyData, months} = {}) { setOptions({ordercount,customerprice,ordertotal,customerArr,dateArr,retentionArr} = {}) {
this.chart.setOption({ this.chart.setOption({
xAxis: { xAxis: {
data: months, data: this.dateArr,
boundaryGap: false, boundaryGap: true,
axisTick: { axisTick: {
show: true show: true
} }
...@@ -115,38 +103,43 @@ export default { ...@@ -115,38 +103,43 @@ export default {
yAxis: [ yAxis: [
{ {
type: 'value', type: 'value',
name: '量', name: '交易量',
min: 0, min: 0,
max: this.numberMax(this.chartData.maxAccountData,this.chartData.maxChannelData)<10?10:this.numberMax(this.chartData.maxAccountData,this.chartData.maxChannelData), max: this.yAsix,
interval: this.numberMax(this.chartData.maxAccountData,this.chartData.maxChannelData)<10?2:(this.numberMax(this.chartData.maxAccountData,this.chartData.maxChannelData))/5, interval: Math.ceil(this.yAsix/5),
axisLabel: { axisLabel: {
formatter: '{value} ' formatter: '{value}'
} }
}, },
{
type: 'value',
name: '收益',
min: 0,
max: this.moneyMax(this.chartData.maxMoneyData),
interval: (this.moneyMax(this.chartData.maxMoneyData) / 5),
axisLabel: {
formatter: '{value} 元'
}
}
], ],
legend: { legend: {
data: [ '订单','收益'] data: ['总订单数','总订单金额','客单价']
}, },
series: [{ series: [{
name: '订单', name: '总订单数', itemStyle: {
normal: {
color: '#4784FF',
lineStyle: {
color: '#4784FF',
width: 2
}
}
},
smooth: true,
type: 'bar',
data: ordercount,
animationDuration: 2800,
animationEasing: 'quadraticOut'
},
{
name: '总订单金额',
smooth: true, smooth: true,
type: 'line', type: 'line',
itemStyle: { itemStyle: {
normal: { normal: {
color: '#3888fa', color: '#EE7945',
lineStyle: { lineStyle: {
color: '#3888fa', color: '#EE7945',
width: 2 width: 2
}, },
areaStyle: { areaStyle: {
...@@ -154,20 +147,20 @@ export default { ...@@ -154,20 +147,20 @@ export default {
} }
} }
}, },
data: actualData, data: ordertotal,
animationDuration: 2800, animationDuration: 2800,
animationEasing: 'quadraticOut' animationEasing: 'cubicInOut'
}, },
{ {
name: '收益', name: '客单价',
smooth: true, smooth: true,
type: 'line', type: 'bar',
yAxisIndex: 1, // yAxisIndex: 1,
itemStyle: { itemStyle: {
normal: { normal: {
color: '#40c9c6', color: '#49D3CE',
lineStyle: { lineStyle: {
color: '#40c9c6', color: '#49D3CE',
width: 2 width: 2
}, },
areaStyle: { areaStyle: {
...@@ -175,7 +168,7 @@ export default { ...@@ -175,7 +168,7 @@ export default {
} }
} }
}, },
data: moneyData, data: customerprice,
animationDuration: 2800, animationDuration: 2800,
animationEasing: 'quadraticOut' animationEasing: 'quadraticOut'
}] }]
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论