|
@@ -1,5 +1,6 @@
|
|
|
const app = getApp()
|
|
|
import * as echarts from '../../../commpents/ec-canvas/echarts'
|
|
|
+let chart;
|
|
|
Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '教练统计', leftArrow: true, useBar: false },
|
|
@@ -11,8 +12,11 @@ Page({
|
|
|
{ title: '教练收入情况', active: '1' },
|
|
|
]
|
|
|
},
|
|
|
+ // 教练
|
|
|
+ zhcoach: '',
|
|
|
+ coach_id: '',
|
|
|
coachList: [],
|
|
|
- percentage: [],
|
|
|
+ value: [],
|
|
|
date: [],
|
|
|
money: [],
|
|
|
},
|
|
@@ -25,20 +29,28 @@ Page({
|
|
|
const that = this;
|
|
|
let data = e.detail;
|
|
|
that.setData({ 'tabs.active': data.active })
|
|
|
+ console.log(data.active);
|
|
|
},
|
|
|
// 选择教练
|
|
|
coachChange: function (e) {
|
|
|
const that = this;
|
|
|
let data = that.data.coachList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.coach_id': data.coach_id });
|
|
|
- that.setData({ 'form.zhcoach': data.coach_id_name });
|
|
|
+ that.setData({ coach_id: data.coach_id });
|
|
|
+ that.setData({ zhcoach: data.coach_id_name });
|
|
|
}
|
|
|
+ that.watchLogin();
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
+ const that = this;
|
|
|
+ // 监听用户是否登录
|
|
|
+ await that.watchLogin();
|
|
|
+ that.setData({ ec: { onInit: that.initChart } })
|
|
|
+
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
@@ -47,22 +59,35 @@ Page({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
// 教练
|
|
|
- // const abb = await app.$get(`/rcs`, { school_id: res.data.info.id });
|
|
|
- // if (abb.errcode == '0' && abb.total > 0) {
|
|
|
- // that.setData({ coachList: abb.data })
|
|
|
- // }
|
|
|
- const arr = await app.$get(`/statistics/schoolTotalIn`, { school_id: res.data.info.id, time: 'm' });
|
|
|
- if (arr.errcode == '0') {
|
|
|
- console.log(arr.data);
|
|
|
- // that.setData({ coachList: arr.data })
|
|
|
+ const abb = await app.$get(`/rcs`, { school_id: res.data.info.id });
|
|
|
+ if (abb.errcode == '0' && abb.total > 0) {
|
|
|
+ that.setData({ coachList: abb.data })
|
|
|
+ }
|
|
|
+ if (that.data.coach_id) {
|
|
|
+ if (that.data.tabs.activa == 0) {
|
|
|
+ const arr = await app.$get(`/statistics/schoolSignCoach`, { school_id: res.data.info.id, coach_id: that.data.coach_id });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ var date = []
|
|
|
+ var value = []
|
|
|
+ arr.data.map(function (item) {
|
|
|
+ var m = ''; m = item.m; date.push(m)
|
|
|
+ var sevm = '';
|
|
|
+ sevm = item.value.split('%').join('')
|
|
|
+ value.push(sevm)
|
|
|
+ })
|
|
|
+ that.setData({ date: date })
|
|
|
+ that.setData({ value: value })
|
|
|
+ console.log(date);
|
|
|
+ console.log(value);
|
|
|
+ const option = {
|
|
|
+ series: [{ data: date }],
|
|
|
+ yAxis: [{ data: value }]
|
|
|
+ }
|
|
|
+ if (chart) chart.setOption(option)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- let date = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
|
|
|
- let percentage = [18, 36, 65, 30, 78, 40, 33, 99, 80, 67, 55, 79];
|
|
|
- let money = [11218, 5316, 6165, 8810, 3178, 5140, 2133, 6199, 4180, 6167, 7115, 1719];
|
|
|
- that.setData({ money: money })
|
|
|
- that.setData({ date: date })
|
|
|
- that.setData({ percentage: percentage })
|
|
|
- that.setData({ ec: { onInit: that.initChart } })
|
|
|
+
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
@@ -73,109 +98,57 @@ Page({
|
|
|
initChart(canvas, width, height, dpr) {
|
|
|
let that = this;
|
|
|
var date = that.data.date;
|
|
|
- var percentage = that.data.percentage;
|
|
|
- var money = that.data.money;
|
|
|
- var active = that.data.tabs.activa
|
|
|
+ var value = that.data.value;
|
|
|
const chart = echarts.init(canvas, null, {
|
|
|
width: width,
|
|
|
height: height,
|
|
|
devicePixelRatio: dpr
|
|
|
});
|
|
|
canvas.setChart(chart);
|
|
|
- if (active == 0) {
|
|
|
- var option = {
|
|
|
- grid: {
|
|
|
- left: 20,
|
|
|
- right: 20,
|
|
|
- bottom: 145,
|
|
|
- top: 60,
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- tooltip: {
|
|
|
- show: true,
|
|
|
- trigger: 'axis',
|
|
|
- formatter: '{b}:{c}%' // 格式化数值百分比输出
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- boundaryGap: false,
|
|
|
- data: date,
|
|
|
- // 设置x轴线的属性
|
|
|
- //使x轴文字显示全
|
|
|
- axisLabel: { show: true, interval: 0, },
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- x: 'center',
|
|
|
- type: 'value',
|
|
|
- splitLine: {
|
|
|
- lineStyle: { type: 'dashed' }
|
|
|
- }
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- type: 'line',
|
|
|
- smooth: true,
|
|
|
- if() { },
|
|
|
- data: percentage,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: '#ff7f50',
|
|
|
- lineStyle: {
|
|
|
- color: '#5470C6'
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
- ]
|
|
|
- };
|
|
|
- } else {
|
|
|
- var option = {
|
|
|
- grid: {
|
|
|
- left: 20,
|
|
|
- right: 20,
|
|
|
- bottom: 145,
|
|
|
- top: 60,
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- tooltip: {
|
|
|
- show: true,
|
|
|
- trigger: 'axis',
|
|
|
- // trigger: 'item',
|
|
|
- formatter: '{b}:{c}元' // 格式化数值百分比输出
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- boundaryGap: false,
|
|
|
- data: date,
|
|
|
- // 设置x轴线的属性
|
|
|
- //使x轴文字显示全
|
|
|
- axisLabel: { show: true, interval: 0, },
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- x: 'center',
|
|
|
- type: 'value',
|
|
|
- splitLine: {
|
|
|
- lineStyle: { type: 'dashed' }
|
|
|
- }
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- type: 'line',
|
|
|
- smooth: true,
|
|
|
- data: money,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: '#ff7f50',
|
|
|
- lineStyle: {
|
|
|
- color: '#5470C6'
|
|
|
- }
|
|
|
+ var option = {
|
|
|
+ grid: {
|
|
|
+ left: 20,
|
|
|
+ right: 20,
|
|
|
+ bottom: 145,
|
|
|
+ top: 60,
|
|
|
+ containLabel: true
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ show: true,
|
|
|
+ trigger: 'axis',
|
|
|
+ formatter: '{b}:{c}%' // 格式化数值百分比输出
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ boundaryGap: false,
|
|
|
+ data: date,
|
|
|
+ // 设置x轴线的属性
|
|
|
+ //使x轴文字显示全
|
|
|
+ axisLabel: { show: true, interval: 0, },
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ x: 'center',
|
|
|
+ type: 'value',
|
|
|
+ splitLine: {
|
|
|
+ lineStyle: { type: 'dashed' }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'line',
|
|
|
+ smooth: true,
|
|
|
+ data: value,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#ff7f50',
|
|
|
+ lineStyle: {
|
|
|
+ color: '#5470C6'
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- }
|
|
|
- ]
|
|
|
- };
|
|
|
- }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
chart.setOption(option, true);
|
|
|
return chart;
|
|
|
},
|
|
@@ -187,9 +160,7 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- const that = this;
|
|
|
- // 监听用户是否登录
|
|
|
- that.watchLogin();
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|