import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		obj: {
			base_id: '',
			base_name: "",
			flag: null,
			massif_id: '',
			massif_name: "",
			task_content: "",
			task_id: '',
			task_type: "",
		},
		versionNumber:'',//版本号
		pushMessage: {},
		cid:''
	},
	getters: {
		getState(state) {
			let obj = state.obj
			if (obj.base_id == '') {
				 obj = JSON.parse(uni.getStorageSync('taskInfo'))
			}
			return obj
		},
		getVersion(state){
			
		}
	},
	mutations: {
		modify(state, payload) { // payload是接收的参数
			console.log(payload);
			state.obj = payload
		},
		mVersion(state, payload) { // payload是接收的参数
			console.log(payload);
			state.versionNumber = payload
		},
		mCid(state,payload){
			console.log(payload);
			state.cid = payload
		},
		updatePushMessage(state, message) {
			/**
			 * 注意：这里为了方便预览查看效果，始终对 payload 做了序列化的处理。
			 * 实际开发期中，请自行调整代码并注意发送的 payload 消息格式。
			 */ 
			console.log(message)
			let payload = message.payload;
			// if (typeof payload !== 'string') {
			// 	message.payload = JSON.stringify(payload);
			// }
			// state.pushMessage = message || {};
		}
	},
	actions: {

	}
})

export default store
