1 Star 0 Fork 64

王丽/夜成都-优雅草科技开源-前端模板

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
央千澈 提交于 2024-09-25 14:23 . 夜成都开始
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import {
User,
Config,
GuestLogin
} from '@/common/api.js'
import { getUser, getToken } from '@/common/common.js'
import { getClientId } from '@/common/getClientId.js'
Vue.use(Vuex)
const store = new Vuex.Store({
getters,
state: {
systemInfo: null,
appHide: false,
userinfo: getUser(),
path: '/pages/home/home',
pusherMode: 0,
config: null,
video_list: [],
nav_index: 0,
token: getToken()
},
mutations: {
SET_NAV_INDEX(state, index) {
state.nav_index = index
},
setSystemInfo(state, data) {
state.systemInfo = data
},
setAppHide(state, data) {
state.appHide = data
},
setUserinfo(state, data) {
console.log('aa',data)
state.userinfo = data
uni.setStorage({
key: 'userinfo',
data,
success: () => {}
})
},
setPath(state, path) {
state.path = path
},
setPusherMode(state, data) {
state.pusherMode = data
},
setConfig(state, data) {
state.config = data
},
setVideoList(state, data) {
state.video_list = data
}
},
actions: {
async updateUserinfo({ commit }) {
//获取客户端ID
let did = await getClientId();
GuestLogin({device_id:did}).then(({ code, data }) => {
console.log(code,data)
uni.setStorageSync('TOKEN',data)
User().then(({ code, data }) => {
if (code === 200) {
commit('setUserinfo', data)
uni.setStorageSync('userinfo',data)
}
})
})
},
getConfig({ commit }, key = 'base') {
Config({ key }).then(({ code, data }) => {
if (code === 200) {
console.log('config',data)
commit('setConfig', data)
}
})
}
}
})
export default store
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ghjjgdhjkj/yechengdu-uniapp.git
git@gitee.com:ghjjgdhjkj/yechengdu-uniapp.git
ghjjgdhjkj
yechengdu-uniapp
夜成都-优雅草科技开源-前端模板
master

搜索帮助