//引入vue和vuex import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const store = new Vuex.Store({ // 全局变量定义 state: { mainColor: '#ff6e3e', // 主色 customStyle: { // 底部悬浮按钮样式 height: '40px', backgroundColor: '#ff6e3e' }, handleCustomStyle: { // 卡片主要操作按钮样式 backgroundColor: '#ff6e3e', fontSize: '11px', padding: '0 15px' }, handleDefaultCustomStyle: { // 卡片普通操作按钮样式 color: '#ff6e3e', fontSize: '11px', padding: '0 15px', borderColor: '#ff6e3e', }, }, mutations: { // 登录 login(state, provider) { state.userLoginFlag = true; state.userInfo = provider uni.setStorage({ // 异步缓存用户信息 key: "userinfo", data: provider }) console.log(state.userInfo) }, // 退出 logout(state) { state.userLoginFlag = false; state.userInfo = {}; uni.removeStorage({ // 清除用户信息 key: "userinfo" }) } }, getters: { mainColor: state => { return state.mainColor }, customStyle: state => { return state.customStyle }, handleCustomStyle: state => { return state.handleCustomStyle }, handleDefaultCustomStyle: state => { return state.handleDefaultCustomStyle }, } }) export default store