import Api from "../../model/api"; import {formatYMD, getDataSet} from "../../utils/utils"; import {classStatus, logicStatus} from "../../model/enum"; import Route from "../../model/route"; const app = getApp(); app.Base({ type: classStatus.NO_START, dict: { [classStatus.NO_START]: {title: '即将开班', tagTxt: '未开始', tagBg: 'tag-bg1', method: Api.getClassList}, [classStatus.RUNNING]: {title: '正在开班', tagTxt: '进行中', tagBg: 'tag-bg0', method: Api.getClassList}, [classStatus.HISTORY]: {title: '历史开班', tagTxt: '已结束', tagBg: 'tag-bg2', method: Api.getClassList}, [classStatus.MY_HISTORY]: {title: '往期培训', tagTxt: '已结束', tagBg: 'tag-bg2', method: Api.getMyHistoryClass}, }, data: { title: "", tagTxt: '', tagBg: '', }, async onLoad(options) { this.type = options.type; const title = this.dict[this.type].title; wx.setNavigationBarTitle({title}) this.setData({ tagTxt: this.dict[this.type].tagTxt, tagBg: this.dict[this.type].tagBg, }) }, toDetail(e) { if (this.type == classStatus.MY_HISTORY) { const item = getDataSet(e, "item"); Route.toEduDetail(item.id, logicStatus.YES) } }, async requestData() { let res; if (this.type == classStatus.MY_HISTORY) { res = await this.dict[this.type].method(2, { pageNum: this.pageNum, pageSize: this.pageSize }); } else { res = await this.dict[this.type].method({ teamState: this.type, pageNum: this.pageNum, pageSize: this.pageSize }); } res.data.rows.forEach(item => { item.teamStart = formatYMD(item.teamStart); item.teamEnd = formatYMD(item.teamEnd); }) return res; }, })