|
@@ -18,7 +18,6 @@ Page({
|
|
|
coachList: [],
|
|
|
value: [],
|
|
|
date: [],
|
|
|
- money: [],
|
|
|
},
|
|
|
// 返回
|
|
|
back(e) {
|
|
@@ -29,28 +28,26 @@ Page({
|
|
|
const that = this;
|
|
|
let data = e.detail;
|
|
|
that.setData({ 'tabs.active': data.active })
|
|
|
- console.log(data.active);
|
|
|
+ that.watchLogin();
|
|
|
},
|
|
|
// 选择教练
|
|
|
- coachChange: function (e) {
|
|
|
+ coachChange: async function (e) {
|
|
|
const that = this;
|
|
|
let data = that.data.coachList[e.detail.value];
|
|
|
if (data) {
|
|
|
that.setData({ coach_id: data.coach_id });
|
|
|
that.setData({ zhcoach: data.coach_id_name });
|
|
|
}
|
|
|
- that.watchLogin();
|
|
|
-
|
|
|
+ await that.watchLogin();
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: async function (options) {
|
|
|
const that = this;
|
|
|
+ that.setData({ ec: { onInit: that.initChart } })
|
|
|
// 监听用户是否登录
|
|
|
await that.watchLogin();
|
|
|
- that.setData({ ec: { onInit: that.initChart } })
|
|
|
-
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
@@ -64,7 +61,7 @@ Page({
|
|
|
that.setData({ coachList: abb.data })
|
|
|
}
|
|
|
if (that.data.coach_id) {
|
|
|
- if (that.data.tabs.activa == 0) {
|
|
|
+ if (that.data.tabs.active == '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 = []
|
|
@@ -77,17 +74,57 @@ Page({
|
|
|
})
|
|
|
that.setData({ date: date })
|
|
|
that.setData({ value: value })
|
|
|
- console.log(date);
|
|
|
- console.log(value);
|
|
|
const option = {
|
|
|
- series: [{ data: date }],
|
|
|
- yAxis: [{ data: value }]
|
|
|
+ xAxis: [{ data: date, }],
|
|
|
+ yAxis: [{
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}%',
|
|
|
+ },
|
|
|
+ }],
|
|
|
+ series: [{
|
|
|
+ data: value,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ label: { show: true, formatter: '{c}%', }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }],
|
|
|
+ tooltip: [{ formatter: '{b}月:出勤率{c}%' }]
|
|
|
+ }
|
|
|
+ if (chart) chart.setOption(option)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const arr = await app.$get(`/statistics/schoolCoachIn`, { 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.total; value.push(sevm)
|
|
|
+ })
|
|
|
+ that.setData({ date: date })
|
|
|
+ that.setData({ value: value })
|
|
|
+ const option = {
|
|
|
+ xAxis: [{ data: date, }],
|
|
|
+ yAxis: [{
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}元',
|
|
|
+ },
|
|
|
+ }],
|
|
|
+ series: [{
|
|
|
+ data: value,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ label: { show: true, formatter: '{c}元', }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }],
|
|
|
+ tooltip: [{ formatter: '{b}月:收入{c}元' }]
|
|
|
}
|
|
|
if (chart) chart.setOption(option)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
@@ -96,10 +133,10 @@ Page({
|
|
|
},
|
|
|
// 折线图
|
|
|
initChart(canvas, width, height, dpr) {
|
|
|
- let that = this;
|
|
|
+ const that = this;
|
|
|
var date = that.data.date;
|
|
|
var value = that.data.value;
|
|
|
- const chart = echarts.init(canvas, null, {
|
|
|
+ chart = echarts.init(canvas, null, {
|
|
|
width: width,
|
|
|
height: height,
|
|
|
devicePixelRatio: dpr
|
|
@@ -116,7 +153,7 @@ Page({
|
|
|
tooltip: {
|
|
|
show: true,
|
|
|
trigger: 'axis',
|
|
|
- formatter: '{b}:{c}%' // 格式化数值百分比输出
|
|
|
+ formatter: '{b}:{c}' // 格式化数值百分比输出
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: 'category',
|
|
@@ -124,14 +161,17 @@ Page({
|
|
|
data: date,
|
|
|
// 设置x轴线的属性
|
|
|
//使x轴文字显示全
|
|
|
- axisLabel: { show: true, interval: 0, },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}月',
|
|
|
+ show: true, interval: 0,
|
|
|
+ },
|
|
|
},
|
|
|
yAxis: {
|
|
|
x: 'center',
|
|
|
type: 'value',
|
|
|
splitLine: {
|
|
|
lineStyle: { type: 'dashed' }
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
@@ -141,9 +181,8 @@ Page({
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
color: '#ff7f50',
|
|
|
- lineStyle: {
|
|
|
- color: '#5470C6'
|
|
|
- }
|
|
|
+ lineStyle: { color: '#5470C6' },
|
|
|
+ label: { show: true }
|
|
|
}
|
|
|
},
|
|
|
}
|