123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import Api from "../../model/api";
- import {getDataSet, getEventParam} from "../../utils/utils";
- import {htmlTypes} from "../../model/enum";
- import Route from "../../model/route";
- const app = getApp();
- app.Base({
- data: {
- tabsList: {
- "线上课程": [],
- "线下课程": []
- },
- active: 0,
- activeFirstName: '',
- leftActive: 0,
- dictType: '',
- dictValue: '',
- },
- async onLoad() {
- const res = await Api.getCourseMngDict(true);
- const activeFirstName = Object.keys(res.data)[0];
- const dictType = res.data[activeFirstName][0].dictType;
- const dictValue = res.data[activeFirstName][0].dictValue;
- this.setData({
- tabsList: res.data,
- activeFirstName: activeFirstName,
- dictType, dictValue
- })
- },
- async onChangeCategory(e) {
- const dictType = this.data.tabsList[this.data.activeFirstName][getEventParam(e)].dictType;
- const dictValue = this.data.tabsList[this.data.activeFirstName][getEventParam(e)].dictValue;
- this.setData({
- leftActive: getEventParam(e),
- dictType, dictValue
- }, async () => {
- this.changeResetData(this);
- })
- },
- async onChange(e) {
- const dictType = this.data.tabsList[getEventParam(e, 'title')][0].dictType;
- const dictValue = this.data.tabsList[getEventParam(e, "title")][0].dictValue;
- this.setData({
- active: getEventParam(e, "index"),
- activeFirstName: getEventParam(e, "title"),
- leftActive: 0,
- dictType, dictValue
- }, async () => {
- this.changeResetData(this);
- })
- },
- toNewsDetail(e) {
- const item = getDataSet(e, "item");
- Route.toNews(htmlTypes.COURSE, item.id, item.courseName, "")
- },
- async requestData() {
- const res = await Api.getCourseMngList({
- courseModel: this.data.dictType,
- courseType: this.data.dictValue,
- pageNum: this.pageNum,
- pageSize: this.pageSize
- })
- return res;
- },
- })
|