mutations.js 1.18 KB
import * as Types from './types';

export default {
[Types.FETCH_NOTICE_LIST_REQUEST](state, { page }) {
  console.log("page:"+page+"==="+state.fetchNoticeList)
    state.fetchNoticeList = false;
    if (page === 1) {
      state.fetchNoticeLastedTime = 0;
      state.fetchNoticePage = 1;
      // state.noticeList.length = 0;
    }
  },
  [Types.FETCH_NOTICE_LIST_SUCCESS](state, { data }) {
    state.fetchNoticeList = false;
    state.fetchNoticePage += 1;
    state.fetchNoticeLastedTime = data.lastedTime;

    const noticeList = data.noticeList || [];

    if (noticeList.length) {
      noticeList.forEach(val => {
        // if (/imageView/.test(val.topicImageUrl) && !/format/.test(val.topicImageUrl)) {
        //   val.topicImageUrl += '/format/jpg';
        // }
        state.noticeList.push(val);

        if (!state.noticeInfo[val.id]) {
          state.noticeInfo[val.id] = {
            //根据接口key 修改
            topicId: val.id,
            topicName: val.topicName,
            topicImageUrl: val.topicImageUrl,
            topicDesc: val.topicDesc
          };
        }
      });
    }
  },
  [Types.FETCH_NOTICE_LIST_FAILD](state) {
    state.fetchNoticeList = false;
  },
}