123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- 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();
- }
- });
|