74 lines
1.8 KiB
Vue
74 lines
1.8 KiB
Vue
<script setup>
|
|
import { reactive, inject, onMounted } from 'vue';
|
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
|
|
import useUserStore from './stores/useUserStore';
|
|
import useDictStore from './stores/useDictStore';
|
|
const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
|
|
|
|
onLaunch((options) => {
|
|
useDictStore().getDictData();
|
|
uni.onTabBarMidButtonTap(() => {
|
|
uni.navigateTo({
|
|
url: '/pages/chat/chat',
|
|
});
|
|
});
|
|
|
|
let token = uni.getStorageSync('token') || ''; // 同步获取 缓存信息
|
|
if (token) {
|
|
useUserStore()
|
|
.loginSetToken(token)
|
|
.then(() => {
|
|
$api.msg('登录成功');
|
|
});
|
|
} else {
|
|
uni.redirectTo({
|
|
url: '/pages/login/login',
|
|
});
|
|
}
|
|
});
|
|
|
|
onMounted(() => {
|
|
if (process.env.NODE_ENV === 'development') {
|
|
appendScriptTagElement('./static/js/jweixin-1.4.0.js').then(() => {
|
|
console.log('✅ 微信 JSSDK 加载完成');
|
|
});
|
|
} else {
|
|
appendScriptTagElement('/static/js/jweixin-1.4.0.js').then(() => {
|
|
console.log('✅ 微信 JSSDK 加载完成');
|
|
});
|
|
}
|
|
});
|
|
|
|
onShow(() => {
|
|
console.log('App Show');
|
|
});
|
|
onHide(() => {
|
|
console.log('App Hide');
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
/*每个页面公共css */
|
|
@import '@/common/common.css';
|
|
/* 修改pages tabbar样式 H5有效 */
|
|
.uni-tabbar .uni-tabbar__item:nth-child(4) .uni-tabbar__bd .uni-tabbar__icon {
|
|
height: 78rpx !important;
|
|
width: 78rpx !important;
|
|
margin-top: -1rpx;
|
|
}
|
|
.uni-tabbar-border {
|
|
background-color: transparent !important;
|
|
/* background-color: #e4e4e4 !important; */
|
|
}
|
|
.uni-popup {
|
|
z-index: 1001 !important;
|
|
}
|
|
/* 提升toast层级 */
|
|
uni-toast,
|
|
uni-modal,
|
|
.uni-modal,
|
|
.uni-mask {
|
|
z-index: 998;
|
|
}
|
|
</style>
|