|
@@ -1,18 +1,37 @@
|
|
|
const app = getApp()
|
|
|
import * as echarts from '../../../commpents/ec-canvas/echarts'
|
|
|
+let chart;
|
|
|
Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '授课情况', leftArrow: true, useBar: false },
|
|
|
- // xdata: []
|
|
|
+ xdata: [],
|
|
|
+ // 学校
|
|
|
+ zhSchool: '',
|
|
|
+ school_id: '',
|
|
|
+ schoolList: [],
|
|
|
},
|
|
|
// 返回
|
|
|
back(e) {
|
|
|
wx.navigateBack({ delta: 1 })
|
|
|
},
|
|
|
+ // 选择学校
|
|
|
+ schoolChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.schoolList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ school_id: data.school_id });
|
|
|
+ that.setData({ zhSchool: data.school_id_name });
|
|
|
+ }
|
|
|
+ that.watchLogin();
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ ec: { onInit: that.initChart } })
|
|
|
+ // 监听用户是否登录
|
|
|
+ await that.watchLogin();
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
@@ -20,21 +39,21 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
- that.setData({ ec: { onInit: that.initChart } })
|
|
|
- that.data.xdata = [
|
|
|
- { value: 2, name: '1月' },
|
|
|
- { value: 10, name: '2月' },
|
|
|
- { value: 19, name: '3月' },
|
|
|
- { value: 20, name: '4月' },
|
|
|
- { value: 70, name: '5月' },
|
|
|
- { value: 9, name: '6月' },
|
|
|
- { value: 12, name: '7月' },
|
|
|
- { value: 41, name: '8月' },
|
|
|
- { value: 31, name: '9月' },
|
|
|
- { value: 13, name: '10月' },
|
|
|
- { value: 16, name: '11月' },
|
|
|
- { value: 10, name: '12月' }
|
|
|
- ];
|
|
|
+ // 学校
|
|
|
+ const school = await app.$get(`/rcs`, { coach_id: res.data.info.id });
|
|
|
+ if (school.errcode == '0' && school.total > 0) {
|
|
|
+ that.setData({ schoolList: school.data })
|
|
|
+ }
|
|
|
+ if (that.data.school_id) {
|
|
|
+ const arr = await app.$get(`/statistics/coachLesson`, { school_id: res.data.info.id, coach_id: res.data.info.id });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ that.setData({ xdata: arr.data })
|
|
|
+ const option = {
|
|
|
+ series: [{ data: arr.data }],
|
|
|
+ }
|
|
|
+ if (chart) chart.setOption(option)
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
@@ -43,9 +62,9 @@ Page({
|
|
|
},
|
|
|
// 饼图
|
|
|
initChart(canvas, width, height, dpr) {
|
|
|
- let that = this;
|
|
|
+ const that = this;
|
|
|
var xdata = that.data.xdata;
|
|
|
- const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr });
|
|
|
+ chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr });
|
|
|
canvas.setChart(chart);
|
|
|
var option = {
|
|
|
tooltip: { trigger: 'item' },
|
|
@@ -56,12 +75,18 @@ Page({
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
- name: '课时',
|
|
|
+ name: '授课情况',
|
|
|
type: 'pie',
|
|
|
radius: '50%',
|
|
|
data: xdata,
|
|
|
emphasis: {
|
|
|
itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' }
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ show: true,
|
|
|
+ formatter: '{b}({c}节课)'
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
]
|
|
@@ -77,9 +102,6 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- const that = this;
|
|
|
- // 监听用户是否登录
|
|
|
- that.watchLogin();
|
|
|
},
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|