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

export default {
  namespaced: true,
  state: {
    collectionRegionInfo:[], //获取收藏项目
    collectionLayoutInfo:[] //获取收藏户型

  },
  actions: {
    addCollection({ commit, state }, payload) { // 项目户型收藏
      return api.request("get", api.getURL("collectionRecord/addCollection"), payload).then(res => {				
				
        if(res) {					
          //
        }
        return res;
      });
    },
    cancelCollection({ commit, state }, payload) { // 取消项目户型收藏
      return api.request("get", api.getURL("collectionRecord/cancelCollection"), payload).then(res => {				
				
        if(res) {					
          //
        }
        return res;
      });
    },
    getCollectionInfo({ commit, state }, payload) { // 获取收藏项目户型
      return api.request("get", api.getURL("collectionRecord/findUserCollection"), payload).then(res => {				
				
        if(res) {					
          //
          if(payload.type === 1) {
            commit("SET_COLLECTION_REGION_INFO", res.data.data.list);
          }else {
					    commit("SET_COLLECTION_LAYOUT_INFO", res.data.data.list);
          }
        }
				
        return res;
      });
    }

  },
  mutations: {
    INIT_DATA_STATUS(state, data) {
			
    },
    SET_COLLECTION_REGION_INFO(state, data) {
      Vue.set(state,"collectionRegionInfo",data);
    },
    SET_COLLECTION_LAYOUT_INFO(state, data) {
      Vue.set(state,"collectionLayoutInfo",data);
    }
		

  },
  getters: {}
};