Commit 3d384c4a by chenwq

经营分析

1 parent cc797ee8
...@@ -195,5 +195,42 @@ class outputApi { ...@@ -195,5 +195,42 @@ class outputApi {
analysisNotUpgradePage(data) { analysisNotUpgradePage(data) {
return api.post({ method: 'dj.api.smartcarlife.data.analysis.notUpgrade.page', ...data }, false, 'dj') return api.post({ method: 'dj.api.smartcarlife.data.analysis.notUpgrade.page', ...data }, false, 'dj')
} }
/** 经营分析 */
/** 经营分析数据概览 */
getOverview(data) {
return api.post({
method: 'scrm.api.busassistant.business.analysis.overview',
...data
})
}
/** 门店引流数据 */
getFlowRank(data) {
return api.post({
method: 'scrm.api.busassistant.business.analysis.flow.rank',
...data
})
}
/** 门店引流数据分页查询 */
getRankList(data) {
return api.post({
method: 'scrm.api.busassistant.business.analysis.flow.rank.page',
...data
})
}
/** 采购数量分页查询 */
getPurchaseList(data) {
return api.post({
method: 'scrm.api.busassistant.business.analysis.purchase.page',
...data
})
}
/** 采购金额走势 */
getPurTendency(data) {
return api.post({
method: 'scrm.api.busassistant.business.analysis.purchase.tendency',
...data
})
}
} }
export default outputApi export default outputApi
...@@ -67,7 +67,8 @@ ...@@ -67,7 +67,8 @@
"pages": [ "pages": [
"pages/openBusiness", "pages/openBusiness",
"pages/summary", "pages/summary",
"pages/newSummary/newSummary" "pages/newSummary/newSummary",
"pages/businessAnalysis/businessAnalysis"
] ]
}, },
{ {
......
// packagesList/packageOutput/pages/businessAnalysis/businessAnalysis.js
import * as echarts from '~/packagesList/packageOutput/components/ec-canvas/echarts'
import constant from './constant/constant'
import echartData from './constant/echartData'
import outputApi from '~/api/outputApi/index'
Page({
/**
* 页面的初始数据
*/
data: {
navStyle: 'background-color: rgba(0,0,0,0);',
navTitleStyle: "font-weight: 600; font- size: 34rpx; color: #282829;",
sceneFormList: constant.sceneFormList,
rankFormList: constant.rankFormList,
totalObj: {
purchaseMoney: 0,
totalMoney: 0
},
flowRankList: [],
pieChartList: [],
rankList: [],
diagramList: [],
rankTotal: '-1',
rankPageCof: {
pageNum: 1,
pageSize: 2
},
purList: [],
purTotal: '-1',
purPageCof: {
pageNum: 1,
pageSize: 10
}
},
onInitChart(id, fnName) {
let ecComponent = this.ecComponent || this.selectComponent('#' + id)
ecComponent &&
ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr
})
this[fnName](chart)
return chart
})
},
setPieOption(chart) {
let { pieChartList } = this.data
var option = echartData.pieOptions
option.title.text = pieChartList.reduce((a, b) => { return a + b.value }, 0) + '人/次'
option.series[0].data = pieChartList
chart.setOption(option)
},
setBarOption(chart) {
let { diagramList } = this.data
console.log(diagramList, 'diagramList-==')
const abscissaDataList = [],
moneyTotalList = [],
stockList = []
diagramList.forEach(element => {
abscissaDataList.push(element.abscissaData)
moneyTotalList.push(element.purchaseMoney)
stockList.push(element.stock)
})
// 使用 Math.max 方法找到数组中的最大值
const max = Math.max(...moneyTotalList)
// console.log(moneyTotalList, 'moneyTotalList')
const colors = ['#3582EE', '#FF9D0A']
var option = {
color: colors,
grid: {
left: max > 100000 ? '25%' : '15%',
right: '15%'
},
tooltip: {
trigger: 'axis',
// formatter: function (params) {
// console.log(params, 'formatter')
// // debugger
// // + '\n'
// var html = params[0].name
// html += '\n'
// for (var i = 0; i < params.length; i++) {
// let unit = i + 1 == params.length ? '' : '\n'
// let template = params[i].marker + params[i].seriesName + ':' + ' ' + params[i].value
// if (option.series[params[i].seriesIndex].name == '转化率') {
// template = template + '%' + unit
// } else {
// template = template + unit
// }
// html += template
// }
// // html += params[0].name
// console.log(html, 'html')
// return html
// }
},
// 滚动设置
dataZoom: [
{
type: 'slider', //隐藏或显示(true)组件
show: false,
showDetail: false, //是否显示detail,即拖拽时候显示详细数值信息
startValue: 0,
endValue: 5,
start: 50,
end: 100,
zoomLoxk: true // 是否锁定选择区域(或叫做数据窗口)的大小
},
{
//没有下面这块的话,只能拖动滚动条,鼠标滚轮在区域内不能控制外部滚动条
type: 'inside',
zoomOnMouseWheel: false, //滚轮是否触发缩放
moveOnMouseMove: true, //鼠标滚轮触发滚动
moveOnMouseWheel: true
}
],
legend: {
data: ['采购价格', '剩余库存'],
top: 'bottom'
},
xAxis: [
{
type: 'category',
axisTick: {
alignWithLabel: true
},
data: abscissaDataList || ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}
],
yAxis: [
{
type: 'value',
name: '元',
position: 'left',
alignTicks: true,
offset: -10,
axisLabel: {
formatter: '{value} 元'
}
},
{
type: 'value',
name: '米',
position: 'right',
alignTicks: true,
offset: -10,
axisLabel: {
formatter: '{value} 米'
}
}
],
series: [
{
name: '采购价格',
type: 'bar',
yAxisIndex: 0,
data: moneyTotalList
},
{
name: '剩余库存',
type: 'line',
yAxisIndex: 1,
data: stockList
}
]
}
chart.setOption(option)
},
navbarReady(e) {
let { height, statusBarHeight, navigationBarHeight } = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight,
tabBoxStyle: `height: ${navigationBarHeight}px`,
statusBarHeight,
navigationBarHeight
})
},
getOverview() {
const params = {
startDate: '2023-01-01',
endDate: '2023-01-31'
}
outputApi.getOverview(params).then(res => {
console.log(res)
this.setData({
totalObj: res || { purchaseMoney: 0, totalMoney: 0 }
})
})
},
getFlowRank() {
const params = {
startDate: '2023-01-01',
endDate: '2023-01-31'
}
outputApi.getFlowRank(params).then(res => {
let _flowRankList = res?.flowRankList || []
_flowRankList = _flowRankList.concat(new Array(3).fill({ flowCount: '', merchantName: '' })).slice(0, 3)
this.setData({
flowRankList: _flowRankList,
pieChartList: res?.pieChartList || []
})
this.onInitChart('mychart-dom-pie', 'setPieOption')
})
},
getRankList() {
const { rankPageCof, rankList } = this.data
const params = {
startDate: '2023-01-01',
endDate: '2023-01-31',
...rankPageCof
}
outputApi.getRankList(params).then(res => {
console.log(res)
let _list = res.list
this.setData({
rankList: rankPageCof.pageNum == 1 ? (_list || []) : rankList.concat(_list),
rankTotal: res.total,
['rankPageCof.pageNum']: rankPageCof.pageNum + 1
})
})
},
getPurchaseList() {
const { purPageCof, purList } = this.data
const params = {
...purPageCof
}
outputApi.getPurchaseList(params).then(res => {
console.log(res)
let _list = res.list
this.setData({
purList: purPageCof.pageNum == 1 ? (_list || []) : purList.concat(_list),
purTotal: res.total,
['purPageCof.pageNum']: purPageCof.pageNum + 1
})
})
},
getPurTendency() {
outputApi.getPurTendency({}).then(res => {
console.log(res, 'getPurTendency--')
this.setData({
diagramList: res?.diagramList || []
})
this.onInitChart('mychart-dom-bar', 'setBarOption')
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getOverview()
this.getFlowRank()
this.getRankList()
this.getPurchaseList()
this.getPurTendency()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"navigationStyle": "custom",
"usingComponents": {
"ec-canvas": "../../components/ec-canvas/ec-canvas"
}
}
\ No newline at end of file \ No newline at end of file
/* packagesList/packageOutput/pages/businessAnalysis/businessAnalysis.wxss */
.bg_iamge {
width: 100%;
position: absolute;
left: 0;
top: 0;
// z-index: -1;
.image_class {
background-color: #fff;
width: 100%;
height: 244rpx;
}
}
.top-tip {
position: absolute;
left: 0;
bottom: 20rpx;
width: 100%;
height: 48rpx;
line-height: 48rpx;
background: #EAEFFE;
font-size: 24rpx;
color: #3666FE;
text-align: center;
}
.business-analysis {
box-sizing: border-box;
height: calc(100vh - 122px);
background-color: #F2F3F7;
padding: 16rpx 16rpx 60rpx;
color: #333333;
.box {
background: #FFFFFF;
padding: 20rpx 24rpx;
box-shadow: 0 2rpx 20rpx 0 #b4bacc52;
border-radius: 16rpx;
margin-bottom: 24rpx;
.title {
font-weight: 600;
font-size: 28rpx;
color: #323436;
margin-bottom: 24rpx;
}
}
.output {
display: flex;
align-items: center;
.cur-block {
width: 50%;
}
.money-symbol {
font-size: 28rpx;
}
.num {
font-family: "ali-bold";
font-weight: 700;
font-size: 40rpx;
color: #3666FE;
margin-top: 12rpx;
}
}
.rank {
position: relative;
.bg {
width: 672rpx;
height: 369.5rpx;
}
.rank-pos {
position: absolute;
}
.num {
font-family: "ali-bold";
font-weight: 700;
font-size: 40rpx;
}
.txt {
width: 144rpx;
font-size: 24rpx;
margin-top: 32rpx;
word-break: break-all;
}
.rank-1 {
top: 120rpx;
left: 264rpx;
color: #C66122;
text-align: center;
.num {
font-size: 44rpx;
}
}
.rank-2 {
top: 174rpx;
left: 40rpx;
text-align: center;
color: #6B6D70;
}
.rank-3 {
top: 174rpx;
left: 488rpx;
text-align: center;
color: #C37647;
}
}
.rank-list {
.list-title {
display: flex;
align-items: center;
height: 76rpx;
line-height: 76rpx;
background-image: linear-gradient(90deg, #FAFAFA 0%, #FFFFFF 100%);
.rank-num {
width: 92rpx;
flex-shrink: 0;
text-align: center;
.rank-icon {
width: 68rpx;
height: 68rpx;
}
.rank-txt {
width: 32rpx;
height: 32rpx;
line-height: 32rpx;
background: #B8B8B8;
border-radius: 6rpx;
font-size: 20rpx;
color: #FFFFFF;
text-align: center;
}
}
}
.list-title.list0 {
background-image: linear-gradient(90deg, #FFFDF5 0%, #FFFFFF 100%);
}
.list-title.list1 {
background-image: linear-gradient(90deg, #F7FBFF 0%, #FFFFFF 100%);
}
.list-title.list2 {
background-image: linear-gradient(90deg, #FCF8F5 0%, #FFFFFF 100%);
}
.list-content {
display: flex;
color: #323436;
padding: 8rpx 0 28rpx 92rpx;
.cur-block {
width: 25%;
}
.num {
font-family: "ali-medium";
font-size: 28rpx;
margin-top: 16rpx;
}
}
}
.rank-list.purchase {
.rank-block {
padding: 25rpx 0;
border-bottom: 1rpx solid #E4E6EE;
;
}
.rank-block:first-child {
padding: 0 0 25rpx;
}
.list-title {
width: 100%;
background-image: none;
justify-content: space-between;
.left {
width: 70%;
display: flex;
align-items: center;
}
.rank-num {
width: 52rpx;
.rank-txt.txt0 {
color: #A86921;
background-image: linear-gradient(180deg, #FFD767 0%, #F7C33F 100%);
}
.rank-txt.txt1 {
color: #8B8585;
background-image: linear-gradient(180deg, #DFE1E5 0%, #CBCCCE 100%);
}
.rank-txt.txt2 {
color: #CF7334;
background-image: linear-gradient(180deg, #F6DAC4 0%, #F0BE98 100%);
}
}
.goods-name {
max-width: calc(100% - 60rpx);
font-weight: 600;
font-size: 28rpx;
color: #333333;
}
.purchase-num {
font-size: 24rpx;
color: #F24724;
.num {
font-family: "ali-bold";
font-weight: 600;
font-size: 36rpx;
}
}
}
}
.img-center {
width: 100%;
text-align: center;
}
.more {
width: 40rpx;
height: 40rpx;
}
.ec-canvas {
width: 675rpx;
height: 415rpx;
}
.ec-canvas.bar {
width: 670rpx;
height: 538rpx;
}
}
\ No newline at end of file \ No newline at end of file
<!--packagesList/packageOutput/pages/businessAnalysis/businessAnalysis.wxml-->
<wxs src="/pages/tab/outputValue/index.wxs" module="filter" />
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady" showBack="{{true}}" bindnavbarReady="navbarReady" navTitleStyle="{{navTitleStyle}}">
经营分析
</navigation-bar>
<view class="bg_iamge" style="height: calc({{statusBarHeight + navigationBarHeight + 34}}px);">
<glsx-image src="{{'output/background.png'}}" class="image_class" />
<view class="top-tip">本页面仅统计太阳膜业务经营数据</view>
</view>
<scroll-view class="business-analysis" id="scroller" scroll-y enable-back-to-top refresher-enabled="{{true}}" style="margin-top:calc({{statusBarHeight + navigationBarHeight + 34}}px);">
<!-- 产值 -->
<view class="box">
<view class="title">精品升级-太阳膜</view>
<view class="output">
<view wx:for="{{sceneFormList}}" wx:for-item="subItem" wx:for-index="idx" wx:key="idx" class="cur-block">
<view class="label">{{subItem.label}}</view>
<view class="num"><text class="money-symbol">¥</text>{{filter.money_three_for_two_thousands(totalObj[subItem.name] || 0)}}</view>
</view>
</view>
</view>
<!-- 门店引流 -->
<view class="box">
<!-- 门店引流排行 -->
<view class="title">门店引流排行</view>
<view class="rank">
<glsx-image src="{{'output/bg-rank.png'}}" class="bg" />
<view wx:for="{{flowRankList}}" wx:key="index" class="rank-pos {{'rank-' + (index + 1)}}">
<view class="num">{{item.flowCount || '-'}}</view>
<view class="text-two-line txt">{{item.merchantName || '-'}}</view>
</view>
</view>
<view class="rank-list">
<view wx:for="{{rankList}}" wx:key="index">
<view class="list-title {{'list' + index}}">
<view class="rank-num">
<glsx-image wx:if="{{index < 3}}" src="output/icon-rank0{{index + 1}}.png" class="rank-icon" />
<view wx:else class="rank-txt">{{index + 1}}</view>
</view>
{{item.merchantName}}
</view>
<view class="list-content">
<view wx:for="{{rankFormList}}" wx:for-item="subItem" wx:for-index="idx" wx:key="idx" class="cur-block">
<view class="label">{{subItem.label}}</view>
<view class="num">{{filter.money_three_for_two_thousands(item[subItem.name] || 0)}}</view>
</view>
</view>
</view>
</view>
<view class="img-center">
<glsx-image wx:if="{{rankList.length != rankTotal}}" src="{{'output/icon-more.png'}}" class="more" bindtap="getRankList" />
</view>
<!-- 引流分析 -->
<view class="title">引流分析</view>
<view class="ec-canvas">
<!-- force-use-old-canvas="true" -->
<ec-canvas class="echart-box" id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas>
</view>
</view>
<!-- 采购金额 -->
<view class="box">
<!-- 采购金额走势 -->
<view class="title">采购金额走势</view>
<view class="ec-canvas bar">
<!-- force-use-old-canvas="true" -->
<ec-canvas class="echart-box" id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
</view>
<!-- 采购数量 -->
<view class="title">采购数量</view>
<view class="rank-list purchase">
<view wx:for="{{purList}}" wx:key="index" class="rank-block">
<view class="list-title">
<view class="left">
<view class="rank-num">
<view class="rank-txt {{'txt' + index}}">{{index + 1}}</view>
</view>
<view class="goods-name text-hide">{{item.goodsName}}</view>
</view>
<view class="purchase-num">已发<text class="num">{{item.purchaseNum}}</text>卷</view>
</view>
<view class="">{{item.merchantName}}</view>
</view>
</view>
<view class="img-center">
<glsx-image wx:if="{{purList.length != purTotal}}" src="{{'output/icon-more.png'}}" class="more" bindtap="getPurchaseList" />
</view>
</view>
</scroll-view>
\ No newline at end of file \ No newline at end of file
const sceneFormList = [{
label: '业务产值',
name: 'totalMoney'
}, {
label: '采购支出',
name: 'purchaseMoney'
}]
const rankFormList = [{
label: '引流人数',
name: 'flowCount'
}, {
label: '无效流量',
name: 'invalidFlowCount'
}, {
label: '升级客户',
name: 'upgradeCount'
}, {
label: '待预约',
name: 'waitToInviteCount'
}]
export default {
sceneFormList,
rankFormList
}
\ No newline at end of file \ No newline at end of file
const pieOptions = {
title: {
show: true, //显示策略,默认值true,可选为:true(显示) | false(隐藏)
// text: chartData.total + '人', //主标题文本,'\n'指定换行
text: '人', //主标题文本,'\n'指定换行
x: 'center', //水平安放位置,默认为'left',可选为:'center' | 'left' | 'right' | {number}(x坐标,单位px)
y: 'center', //垂直安放位置,默认为top,可选为:'top' | 'bottom' | 'center' | {number}(y坐标,单位px)
textAlign: null, //水平对齐方式,默认根据x设置自动调整,可选为: left' | 'right' | 'center
padding: 5, //标题内边距,单位px,默认各方向内边距为5,接受数组分别设定上右下左边距
// itemGap: 10, //主副标题纵向间隔,单位px,默认为10
textStyle: {
//主标题文本样式{"fontSize": 18,"fontWeight": "bolder","color": "#333"}
fontFamily: 'PingFangSC-Medium, Verdana, sans...',
fontSize: 14,
fontStyle: 'normal',
color: '#333333',
fontWeight: '600'
},
zlevel: 0, //一级层叠控制。默认0,每一个不同的zlevel将产生一个独立的canvas,相同zlevel的组件或图标将在同一个canvas上渲染。zlevel越高越靠顶层,canvas对象增多会消耗更多的内存和性能,并不建议设置过多的zlevel,大部分情况可以通过二级层叠控制z实现层叠控制。
z: 6 //二级层叠控制,默认6,同一个canvas(相同zlevel)上z越高约靠顶层。
},
color: ['#35C376', '#655FED', '#F24724', '#3582EE', '#FF9D0A'],
tooltip: {
trigger: 'item'
},
label: {
show: true,
formatter: '{b}\n{c}',
align: 'right',
edgeDistance: '10%' // 可以调整文字与饼图边缘的距离
},
series: [
{
type: 'pie',
radius: ['40%', '70%'],
minAngle: 10,
labelLine: {
//设置提示线的长度
normal: {
length: 10, //第一条线
length2: 15 //第二条线
}
},
emphasis: {
label: {
show: true,
fontSize: 14
}
},
data: []
}
]
}
export default {
pieOptions
}
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,9 @@ Component({ ...@@ -26,7 +26,9 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
jump() {
wx.$router.go('packagesList.businessAnalysis')
}
} }
}) })
...@@ -31,9 +31,31 @@ ...@@ -31,9 +31,31 @@
} }
.box { .box {
position: relative;
font-size: 28rpx; font-size: 28rpx;
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
.busi-btn {
position: absolute;
top: 25rpx;
right: 26rpx;
display: flex;
justify-content: center;
align-items: center;
width: 152rpx;
height: 56rpx;
line-height: 56rpx;
background: #3666FE;
border-radius: 12rpx;
font-size: 24rpx;
color: #FFFFFF;
.busi-icon {
width: 32rpx;
height: 32rpx;
}
}
.total { .total {
height: 154rpx; height: 154rpx;
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<view class="tips">服务商</view> <view class="tips">服务商</view>
</view> </view>
<view class="box"> <view class="box">
<view class="busi-btn" bindtap="jump">
<glsx-image src="{{'output/busi-icon.png'}}" class="busi-icon" />经营分析
</view>
<view class="total"> <view class="total">
<view class="label">总产值</view> <view class="label">总产值</view>
<view class="num"><text class="money-symbol">¥</text>{{filter.money_three_for_two_thousands(totalObj.total || 0)}}</view> <view class="num"><text class="money-symbol">¥</text>{{filter.money_three_for_two_thousands(totalObj.total || 0)}}</view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!