// 页面路径:store/index.js 
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex); //vue的插件机制
//Vuex.Store 构造器选项
const store = new Vuex.Store({
	state: { //存放状态
		config: {},
		city: '',
		popularity: 0,
		// 定位数据
		citydata: {
			city: "",
			userLocation: '',
			city_id: ''
		},
		// 默认数据(当前数据)
		defaultcity: {
			city: "",
			userLocation: '',
			city_id: ''
		}
	},
	getters: {
		config: state => state.config
	},
	mutations: {
		setconfig(state, data) {
			// 变更状态
			state.config = data
		},
		setcity(state, data) {
			// 变更状态
			state.citydata = data
		},
		setdefaultcity(state, data) {
			// 变更状态
			uni.setStorageSync("city", data)
			state.defaultcity = data
		},
		setpopularity(state, data) {
			// 变更状态
			state.popularity = data
		}
	}
})
export default store