123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import Api from "../../model/api";
- import {formatTime, getEventParam, toast} from "../../utils/utils";
- import {communityDetailTypes, logicStatus, uploadResTypes} from "../../model/enum";
- import Route from "../../model/route";
- const app = getApp();
- app.Base({
- data: {
- blur: '',
- info: {
- trains: 0,
- focus: 0,
- examples: 0,
- count: 0,
- },
- show: false,
- },
- async onLoad() {
- const data = await Api.getTrainIndex(true);
- this.setData({
- info: data.data
- })
- },
- async onPullDownRefresh() {
- const data = await Api.getTrainIndex(true);
- this.setData({
- info: data.data
- })
- },
- publishInfo() {
- this.setData({
- show: true,
- blur: 'community-content',
- })
- },
- onClickHide() {
- this.setData({
- show: false,
- blur: '',
- })
- },
- onHandlePublish(e) {
- const isSuccess = getEventParam(e, "isSuccess");
- if (isSuccess) {
- this.onPullDownRefresh();
- }
- },
- toDetail(e) {
- const res = getEventParam(e, "res");
- Route.tocCommunityDetail(communityDetailTypes.COMMUNITY, "详细", res.id, res.trainType,
- "", "", logicStatus.NO, {
- comment: () => {
- this.onPullDownRefresh();
- }
- });
- },
- toCommunityMessage() {
- if (this.data.info.count == 0) {
- toast('没有更多消息哦')
- return;
- }
- Route.toCommunityMessage();
- },
- async requestData() {
- let res = await Api.getTrainList({
- 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;
- }
- })
|