1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import Api from "../../model/api";
- import {getDataSet, getEventParam} from "../../utils/utils";
- import Route from "../../model/route";
- const app = getApp();
- app.Base({
- data: {
- tabsList: [],
- active: 0,
- textbookClassify: 0,
- },
- async onLoad() {
- const res = await Api.getTextBookDict(true);
- let textbookClassify = 0;
- if (res.data[0]) {
- textbookClassify = res.data[0].dict_value;
- }
- this.data.textbookClassify = textbookClassify
- this.setData({
- tabsList: res.data,
- textbookClassify
- })
- this.selectComponent('#tabs').resize();
- },
- async onChange(e) {
- const index = getEventParam(e, 'index');
- const name = getEventParam(e, 'name');
- this.setData({active: index, textbookClassify: name}, async () => {
- this.changeResetData(this);
- })
- },
- toBookDetail(e) {
- const id = getDataSet(e, "id");
- Route.toBookDetail(id, this.data.tabsList[this.data.active].dict_label)
- },
- async requestData() {
- const res = await Api.getTextBookList(this.data.textbookClassify, {
- pageNum: this.pageNum,
- pageSize: this.pageSize
- });
- res.data.rows = res.data.rows.map(item => {
- return {
- ...item,
- cover: JSON.parse(item.textbook_pictures)[0],
- }
- });
- return res;
- },
- })
|