import Vue from "vue";
import api from "@/api/index.js";

export default {
  namespaced: true,
  state: {
    businessList: [],
    systemList: [],
    systemDetail: {

    }
  },
  actions: {
    findDetailOnCAPP( { commit, state }, params) {
      return api.request("get", api.getURL("systemMsg/findDetailOnCAPP"), params).then(res => {
        if(res) {
          commit("SET_SYSTEM_DETAIL_INFO", res.data.data);
        }
        return res;
      });
    },
    findAllOnCAPP( { commit, state }, noCache) {
      // if(state.businessList.length > 0 && !noCache) {
      // 	return;
      // }
      return api.request("get", api.getURL("systemMsg/findAllOnCAPP"), {
				 pn: 1,
				 pageSize: 10000
      }).then(res => {
        if(res) {
					  commit("SET_SYSTEM_LIST", res.data.data.list);
        }
        return res;
      });
    },
    businessFindPage({ commit, state }, noCache) {
      // if(state.systemList.length > 0 && !noCache) {
      // 	return;
      // }
      return api.request("get", api.getURL("UserMessageRecord/businessFindPage"), {
        pageNo: 1,
        pageSize: 1000
      }).then(res => {
        //
        if(res) {
					    commit("SET_BUSINESS_LIST", res.data.data.list);
        }
        return res;
      });
    },
  },
  mutations: {
    INIT_DATA_STATUS(state, data) {
			
    },
    SET_SYSTEM_DETAIL_INFO(state, data) {
      Vue.set(state, "systemDetail", data);
    },
    SET_BUSINESS_LIST(state, list) {
      Vue.set(state, "businessList", list);
    },
    SET_SYSTEM_LIST(state, list) {
      Vue.set(state, "systemList", list);
    }
  },
  getters: {}
};