123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- Vue.use(Vuex)
- const store = new Vuex.Store({
- state: {
- hasLogin: false,
- userInfo: {},
- storageId: -1,
- spread: 0,
- cartNum: 0,
- storageObj: {},
- InvitationCode: '',
- $deviceType: null,
- headerTop: '',
- isWeixin: false
- },
- mutations: {
- login(state, provider) {
- state.hasLogin = true;
- state.userInfo = provider;
- uni.setStorageSync('userInfo', provider)
- },
- logout(state) {
- state.hasLogin = false;
- state.userInfo = {};
- uni.removeStorageSync('userInfo')
- },
- setStorage(state, id) {
- state.storageId = id
- },
- setSpread(state, id) {
- state.spread = id
- },
- setStorageCode(state, InvitationCode) {
- state.InvitationCode = InvitationCode
- },
- setStorageObj(state, obj) {
- state.storageObj = obj
- },
- updateDevicetype(state, $deviceType) {
- state.$deviceType = $deviceType
- },
- addCart(state, num) {
- state.cartNum = num
- },
- setIsWeixin(state) {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.match(/MicroMessenger/i) == "micromessenger") {
- state.isWeixin = true
- } else {
- state.isWeixin = false
- }
- }
- },
- actions: {
- },
- getters: {
- getUserInfo(state) {
- return state.userInfo
- }
- }
- })
- export default store
|