59 lines
1004 B
Vue
59 lines
1004 B
Vue
<script setup>
|
|
import {
|
|
onLaunch,
|
|
} from '@dcloudio/uni-app'
|
|
// 工具库
|
|
import util from '@/common/js/util';
|
|
//
|
|
import api from '@/api/index.js'
|
|
// vuex
|
|
import store from '@/store/index.js'
|
|
|
|
onLaunch(() => {
|
|
// 获取用户信息
|
|
getUserinfo()
|
|
// 获取系统配置
|
|
getConfig()
|
|
})
|
|
|
|
// 获取用户信息
|
|
function getUserinfo() {
|
|
// 登录令牌
|
|
const token = uni.getStorageSync('token')
|
|
// 用户信息
|
|
const userinfo = uni.getStorageSync('userinfo')
|
|
|
|
// 如果登录保活
|
|
if (token) {
|
|
// 用户信息
|
|
if (userinfo) store.commit('setState', {
|
|
key: 'userinfo',
|
|
value: userinfo
|
|
})
|
|
|
|
//
|
|
util.getUserinfo().then(rs => {
|
|
// 腾讯im登录
|
|
util.loginTencent(userinfo)
|
|
})
|
|
}
|
|
}
|
|
|
|
// 获取系统配置
|
|
function getConfig() {
|
|
api.getConfig().then(rs => {
|
|
if (rs.code == 200) {
|
|
store.commit('setState', {
|
|
key: 'config',
|
|
value: rs.data
|
|
})
|
|
return
|
|
}
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
/*每个页面公共css */
|
|
@import "./common/css/style.scss";
|
|
</style> |