This commit is contained in:
Gdpao
2020-07-29 15:04:57 +08:00
parent f21df2f107
commit 8bb1cdfd39
6 changed files with 163 additions and 122 deletions

View File

@@ -1,5 +1,9 @@
import Vue from 'vue'
import Vuex from 'vuex'
import {
mapMutations
} from 'vuex';
Vue.use(Vuex)
const store = new Vuex.Store({
@@ -12,6 +16,8 @@ const store = new Vuex.Store({
pintuangroup_headid: '', // 拼团团长id 有为开团 无为参团
groupbuyInfo: {}, // 秒杀详情
loadmore: {}, // 下拉加载返回的数据
hasLogin: false, // 登录状态
token: "" // 储存token
},
getters: {
getOrderAddress(state) {
@@ -25,6 +31,23 @@ const store = new Vuex.Store({
}
},
mutations: {
// 登录
loginIn(state, token) {
state.hasLogin = true;
state.token = token;
uni.setStorage({
key: "token",
data: token
})
},
// 退出登录
logout(state) {
state.hasLogin = false;
state.token = "";
uni.removeStorage({
key: "token"
})
},
setOrderType(state, type) {
state.orderType = type;
},
@@ -48,7 +71,7 @@ const store = new Vuex.Store({
},
setLoadMore(state, info) {
state.loadmore = info;
},
}
}
})
export default store;
export default store;