YY 2 years ago
parent
commit
690e232f8c
3 changed files with 162 additions and 129 deletions
  1. 28 5
      pages/schAdmin/coachstat/list.js
  2. 2 2
      pages/schAdmin/course/list.wxml
  3. 132 122
      pages/schAdmin/income/list.js

+ 28 - 5
pages/schAdmin/coachstat/list.js

@@ -47,9 +47,14 @@ 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 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 })
                 }
                 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];
@@ -110,7 +115,16 @@ Page({
                     {
                         type: 'line',
                         smooth: true,
-                        data: percentage
+                        if() { },
+                        data: percentage,
+                        itemStyle: {
+                            normal: {
+                                color: '#ff7f50',
+                                lineStyle: {
+                                    color: '#5470C6'
+                                }
+                            }
+                        },
                     }
                 ]
             };
@@ -148,7 +162,16 @@ Page({
                     {
                         type: 'line',
                         smooth: true,
-                        data: money
+                        data: money,
+                        itemStyle: {
+                            normal: {
+                                color: '#ff7f50',
+                                lineStyle: {
+                                    color: '#5470C6'
+                                }
+                            }
+                        },
+
                     }
                 ]
             };

+ 2 - 2
pages/schAdmin/course/list.wxml

@@ -22,10 +22,10 @@
                                 <view class="name textOver">{{item.title||'暂无'}}</view>
                                 <view class="other">课程类型:<text>{{item.zhtype||'暂无'}}</text></view>
                                 <view class="other">课程状态:<text>{{item.zhstatus||'暂无'}}</text></view>
-                                <view class="other">开课时间:{{item.time_start||'暂无'}}
-                                </view>
                                 <view class="other">金额:<text>{{item.money||'0.00'}}</text>元
                                 </view>
+                                <view class="other">开课时间:{{item.time_start||'暂无'}}
+                                </view>
                             </view>
                         </view>
                         <view class="btn">

+ 132 - 122
pages/schAdmin/income/list.js

@@ -1,137 +1,147 @@
 const app = getApp()
 import * as echarts from '../../../commpents/ec-canvas/echarts'
+let chart;
 Page({
-  data: {
-    frameStyle: { useTop: true, name: '收入统计', leftArrow: true, useBar: false },
-    ec: {},
-    date:[],
-    money:[],
-  },
-  // 返回
-  back(e) {
-    wx.navigateBack({ delta: 1 })
-  },
+    data: {
+        frameStyle: { useTop: true, name: '收入统计', leftArrow: true, useBar: false },
+        ec: {},
+        date: [],
+        money: [],
+    },
+    // 返回
+    back(e) {
+        wx.navigateBack({ delta: 1 })
+    },
 
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (options) {
-  },
-  // 监听用户是否登录
-  watchLogin: async function () {
-    const that = this;
-    wx.getStorage({
-      key: 'user',
-      success: async res => {
-         let date = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '12', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'];
-         let money = [900, 270, 340, 400, 600, 700, 310, 300, 270, 340, 344, 300, 320, 310, 300, 270, 340, 344, 300, 500, 310, 300, 270, 340, 344, 300, 320, 310, 300, 270, 340, 344, 300, 320, 310];
-        that.setData({money:money})
-        that.setData({date:date})
-        that.setData({ ec: { onInit: that.initChart } })
-      },
-      fail: async res => {
-        wx.redirectTo({ url: '/pages/index/index' })
-      }
-    })
-  },
-  // 柱状图
-  initChart(canvas, width, height, dpr) {
-    let that = this;
-    var date = that.data.date;
-    var money = that.data.money;
-    const chart = echarts.init(canvas, null, {
-      width: width,
-      height: height,
-      devicePixelRatio: dpr // new
-    });
-    canvas.setChart(chart);
-    var option = {
-      tooltip: {
-        trigger: 'axis',
-        axisPointer: { type: 'shadow' },
-        confine: true
-      },
-      legend: { data: [] },
-      grid: {
-        left: 20,
-        right: 60,
-        bottom: 15,
-        top: 40,
-        containLabel: true
-      },
-      xAxis: [
-        {
-          type: 'value',
-          name: '金额',
-          axisLine: { lineStyle: { color: '#999' } },
-          axisLabel: { color: '#666' }
-        }
-      ],
-      yAxis: [
-        {
-          type: 'category',
-          name: '日期',
-          axisTick: { show: false },
-          data: date,
-          axisLine: { lineStyle: { color: '#999' } },
-          axisLabel: { color: '#666' }
-        }
-      ],
-      series: [
-        {
-          name: '收入',
-          type: 'bar',
-          label: { normal: { show: true, position: 'inside' } },
-          data: money,
-          itemStyle: {}
-        },
-      ],
-
-    };
-    chart.setOption(option, true);
-    return chart;
-  },
-  /**
- * 生命周期函数--监听页面初次渲染完成
- */
-  onReady: function () { },
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-    const that = this;
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        this.setData({ ec: { onInit: this.initChart } })
+    },
     // 监听用户是否登录
-    that.watchLogin();
-  },
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  /**
-   * 生命周期函数--监听页面隐藏
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                const arr = await app.$get(`/statistics/schoolTotalIn`, { school_id: res.data.info.id, time: 'm' });
+                if (arr.errcode == '0') {
+                    that.setData({ date: arr.data.x })
+                    that.setData({ money: arr.data.y })
+                    const option = {
+                        series: [{ data: arr.data.y }],
+                        yAxis: [{ data: arr.data.x }]
+                    }
+                    chart.setOption(option)
+                }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+    // 柱状图
+    initChart(canvas, width, height, dpr) {
+        let that = this;
+        var date = that.data.date;
+        var money = that.data.money;
+        chart = echarts.init(canvas, null, {
+            width: width,
+            height: height,
+            devicePixelRatio: dpr // new
+        });
+        canvas.setChart(chart);
+        var option = {
+            tooltip: {
+                trigger: 'axis',
+                axisPointer: { type: 'shadow' },
+                confine: true
+            },
+            legend: { data: [] },
+            grid: {
+                left: 20,
+                right: 60,
+                bottom: 15,
+                top: 40,
+                containLabel: true
+            },
+            xAxis: [
+                {
+                    type: 'value',
+                    name: '金额',
+                    axisLine: { lineStyle: { color: '#999' } },
+                    axisLabel: { color: '#666' }
+                }
+            ],
+            yAxis: [
+                {
+                    type: 'category',
+                    name: '日期',
+                    axisTick: { show: false },
+                    data: date,
+                    axisLine: { lineStyle: { color: '#999' } },
+                    axisLabel: {
+                        color: '#666',
+                        formatter: '{value} 日'
+                    },
+                }
+            ],
+            series: [
+                {
+                    name: '收入',
+                    type: 'bar',
+                    label: { normal: { show: true, position: 'inside' } },
+                    data: money,
+                    itemStyle: {}
+                },
+            ],
+
+        };
+        chart.setOption(option, true);
+        return chart;
+    },
+    /**
+   * 生命周期函数--监听页面初次渲染完成
    */
-  onHide: function () {
+    onReady: function () { },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+        const that = this;
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
 
-  },
+    },
 
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
 
-  },
+    },
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
 
-  },
+    },
 
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function (res) {
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function (res) {
 
-  },
+    },
 })