litian
2024-04-03 b2abfb1740ea996627bbef342c377721083db195
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,24 @@
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    // 检查登录状态
    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);
    }
  },
  /**
@@ -53,6 +73,15 @@
    }
  },
  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 = {
      start: 0,