File was renamed from pages/student/index.js |
| | |
| | | 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门)", |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad() { |
| | | this.getStaticsSum(); |
| | | this.getDataList(false); |
| | | // 检查登录状态 |
| | | 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 = { |
| | | start: 0, |