import {formatYMD, getEventParam, showLoading} from "../../utils/utils"; import Api from "../../model/api"; import {logicStatus} from "../../model/enum"; const app = getApp(); app.Base({ data: { teamId: '', isPre: logicStatus.NO, topClass: 'top', active: 0, stuPageNum: 1, stuPageSize: 5, courseStart: '', item: {}, stuData: [], courseList: [], }, async selectDate(e) { let courseStart = getEventParam(e, "date"); this.data.courseStart = courseStart; await this.getCourseDate(this.data.item.eduStuId, true); }, async getCourseDate(studentId, isLoading = false) { const res3 = await Api.getCourseSchedule({ teamId: this.data.teamId, studentId, courseStart: this.data.courseStart, }, isLoading); res3.rows.forEach(item => { if (item.isOnline == logicStatus.YES) { item.isQuestion = item.suitangUpper; } else { item.isQuestion = item.suitangLower; } }) this.setData({ courseList: res3.rows, }) }, onLoad: async function (options) { const teamId = options.teamId; this.data.teamId = teamId; const isPre = options.isPre || logicStatus.NO; this.data.isPre = isPre; if (isPre == logicStatus.YES) { wx.setNavigationBarTitle({title: "往期培训"}) } else { wx.setNavigationBarTitle({title: "培训"}) } await this.init(isPre); }, async init(isPre) { showLoading(); const [res1, res2] = await Api.promiseAllSettled([ Api.getProjectsWithTeam(this.data.teamId), Api.getStudentList({ teamId: this.data.teamId, pageNum: this.data.stuPageNum, pageSize: this.data.stuPageSize }), ]) wx.hideLoading(); res1.data.forEach(item => { item.itemStart = formatYMD(item.itemStart); item.itemEnd = formatYMD(item.itemEnd); }) this.setData({ teamId: this.data.teamId, isPre, item: res1.data[0], stuData: res2.data.rows, }) await this.getCourseDate(res1.data[0].eduStuId); }, async onPullDownRefresh() { await this.init(this.data.isPre); }, onChange(e) { wx.createSelectorQuery().select('.container').boundingClientRect(function (rect) { wx.pageScrollTo({ scrollTop: 0 }) }).exec() if ("介绍" == getEventParam(e, "title")) { this.setData({ topClass: 'top', active: getEventParam(e, "index"), disableLoadMore: false, }) } else { this.setData({ topClass: 'top-bg', active: getEventParam(e, "index"), disableLoadMore: true }) } }, async requestData() { const res = await Api.getTeamInteraction({ teamId: this.data.teamId, pageNum: this.pageNum, pageSize: this.pageSize }); return res; }, onHandlePublish(e) { const isSuccess = getEventParam(e, "isSuccess"); if (isSuccess) { this.onPullDownRefresh(); } }, refreshData() { this.onPullDownRefresh(); } });