123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import {formatTime, formatYMD, getEventParam, showLoading, toast} from "../../utils/utils";
- import Api from "../../model/api";
- import User from "../../model/user";
- import {logicStatus, teamState, uploadResTypes} from "../../model/enum";
- import Route from "../../model/route";
- const app = getApp();
- app.Base({
- data: {
- teamId: '',
- isPre: logicStatus.NO,
- topClass: 'top',
- active: 0,
- stuPageNum: 1,
- stuPageSize: 5,
- courseStart: '',
- item: {},
- stuData: [],
- courseList: [],
- //点击课程提醒进入到的页面课程计划id
- scheduleId: null,
- },
- async bindLogin(e){
- const isLogin = getEventParam(e,"isLogin")
- if (isLogin) {
- this.resetData(this);
- await this.init();
- if (this.data.scheduleId) {
- //如果是从课程提醒中打开的页面,跳转到课程详情页
- this.jumpToCourseDetail();
- }
- }
- },
- 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) {
- this.noInit = true;
- let {teamId, scheduleId} = options;
- this.data.teamId = teamId;
- this.data.scheduleId = scheduleId;
- if (scheduleId) {
- this.switchPageTab(true);
- }
- },
- jumpToCourseDetail(){
- let scheduleId = this.data.scheduleId;
- const scheduleInfo = this.data.courseList.find(item => item.id == scheduleId);
- if (!scheduleInfo) {
- toast('课程不存在!');
- return;
- }
- // console.log(scheduleInfo);
- let $eduPlan = this.selectComponent('#eduPlan');
- // console.log('$eduPlan', $eduPlan);
- wx.nextTick(() => {
- $eduPlan.toLive(scheduleInfo);
- });
- //页面跳转后,置空
- this.data.scheduleId = null;
- // wx.nextTick(() =>{
- // // $eduPlan.scrollToSchedule(scheduleInfo);
- // // setTimeout(() => {
- // // $eduPlan.toLive(scheduleInfo);
- // // }, 1000);
- // });
- },
- async init() {
- 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
- // }),
- Api.getStudentAvatorList({
- 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);
- item.teamStart = formatYMD(item.teamStart),
- item.teamEnd = formatYMD(item.teamEnd)
- })
- const isPre = res1.data[0]['teamState'] == teamState.END ? logicStatus.YES : logicStatus.NO;
- const currentPages = getCurrentPages();
- if (currentPages[currentPages.length - 1] === "pages/eduDetail/eduDetail"){
- if (isPre == logicStatus.YES) {
- wx.setNavigationBarTitle({title: "往期培训"})
- } else {
- wx.setNavigationBarTitle({title: "培训"})
- }
- }
- this.setData({
- teamId: this.data.teamId,
- isPre,
- item: res1.data[0],
- stuData: res2.data,
- })
- await this.getCourseDate(res1.data[0].eduStuId, true);
- // if (this.data.scheduleId) {
- // this.jumpToCourseDetail();
- // }
- },
- async onPullDownRefresh() {
- await this.init();
- },
- onChange(e) {
- wx.createSelectorQuery().select('.container').boundingClientRect(function (rect) {
- wx.pageScrollTo({
- scrollTop: 0
- })
- }).exec()
- if ("介绍" == getEventParam(e, "title")) {
- this.switchPageTab(false, e);
- } else {
- this.switchPageTab(true, e);
- }
- },
- switchPageTab(isSchedule, e){
- let active;
- if (e) {
- active = getEventParam(e, "index");
- } else {
- active = isSchedule? 1 : 0;
- }
- this.setData({
- topClass: isSchedule? 'top-bg' : 'top',
- disableLoadMore: !!isSchedule,
- active,
- }, () => {
- this.selectComponent("#tabs")?.resize()
- });
- },
- async requestData() {
- const res = await Api.getTeamInteraction({
- teamId: this.data.teamId,
- pageNum: this.pageNum,
- pageSize: this.pageSize
- });
- res.data.rows.forEach(item => {
- if (item.attachmentUrlList && item.attachmentType == uploadResTypes.IMAGE) {
- let attachmentUrlList = item.attachmentUrlList || [];
- item.attachmentUrlList = attachmentUrlList.map(item => {
- return {
- url: item,
- isImage: true
- }
- })
- item.createTime = formatTime(item.createTime);
- }
- })
- return res;
- },
- onHandlePublish(e) {
- const isSuccess = getEventParam(e, "isSuccess");
- if (isSuccess) {
- this.onPullDownRefresh();
- }
- },
- refreshData() {
- console.log('refreshData');
- this.onPullDownRefresh();
- }
- });
|