闫增涛
2024-04-03 5e649be819c7297c79c21c6dc120b4b6b362db9e
pages/study/index.js
File was renamed from pages/student/index.js
@@ -2,14 +2,18 @@
import {
  getPublicImage
} from "../../assets/js/middleGround/tool.js";
import {
  loginInfo
} from '../../assets/js/login';
import moment from 'moment'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    learningDuration: 0,
    lastLoginTime: '2024-03-25 20:00:09',
    learningDuration: "0小时",
    lastLoginTime: '-',
    active: 0,
    titleBook: "图书(0本)",
    titleCourse: "课程(0门)",
@@ -31,8 +35,9 @@
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getStaticsSum();
    this.getDataList(false);
    // 检查登录状态
  },
  /**
@@ -51,7 +56,31 @@
        active: 2
      })
    }
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserInfo()
          this.getStaticsSum();
          this.getDataList(false);
        }
      })
    } else {
      this.getUserInfo()
      this.getStaticsSum();
      this.getDataList(false);
    }
  },
  getUserInfo() {
    app.MG.identity.getCurrentAppUser().then(res => {
      if (res) {
        this.setData({
          lastLoginTime: res.lastLoginTime != null ? moment(res.lastLoginTime).format('YYYY-MM-DD HH:mm:ss') : '-'
        })
      }
    })
  },
  getStaticsSum() {
    const data = {