2024-11-08 11:55:23 +08:00
|
|
|
|
<script setup>
|
2025-04-07 09:10:55 +08:00
|
|
|
|
import { reactive, inject, onMounted } from 'vue';
|
2024-11-08 11:55:23 +08:00
|
|
|
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
|
2025-03-28 15:19:42 +08:00
|
|
|
|
import useUserStore from './stores/useUserStore';
|
|
|
|
|
import useDictStore from './stores/useDictStore';
|
2025-04-07 09:10:55 +08:00
|
|
|
|
const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
|
2025-07-14 15:38:39 +08:00
|
|
|
|
import config from '@/config.js';
|
2025-03-28 15:19:42 +08:00
|
|
|
|
|
|
|
|
|
onLaunch((options) => {
|
2025-07-22 15:20:21 +08:00
|
|
|
|
useUserStore().initSeesionId(); //更新
|
2025-03-28 15:19:42 +08:00
|
|
|
|
useDictStore().getDictData();
|
2025-06-26 08:56:42 +08:00
|
|
|
|
// uni.hideTabBar();
|
2025-03-28 15:19:42 +08:00
|
|
|
|
|
2025-10-20 11:43:44 +08:00
|
|
|
|
// 尝试从缓存恢复用户信息
|
|
|
|
|
const restored = useUserStore().restoreUserInfo();
|
|
|
|
|
|
|
|
|
|
if (restored) {
|
|
|
|
|
// 如果成功恢复用户信息,验证token是否有效
|
|
|
|
|
let token = uni.getStorageSync('token') || '';
|
|
|
|
|
if (token) {
|
|
|
|
|
useUserStore()
|
|
|
|
|
.loginSetToken(token)
|
|
|
|
|
.then(() => {
|
|
|
|
|
console.log('用户登录状态已恢复');
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
// token无效,清除缓存(不跳转登录页)
|
|
|
|
|
console.log('token已过期,需要重新登录');
|
|
|
|
|
useUserStore().logOut(false);
|
2025-09-29 11:53:10 +08:00
|
|
|
|
});
|
2025-10-20 11:43:44 +08:00
|
|
|
|
}
|
2024-11-08 11:55:23 +08:00
|
|
|
|
}
|
2025-10-20 11:43:44 +08:00
|
|
|
|
// 不再强制跳转到登录页,而是在需要登录时弹出授权弹窗
|
2024-11-08 11:55:23 +08:00
|
|
|
|
});
|
2025-04-07 09:10:55 +08:00
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2025-05-13 11:42:17 +08:00
|
|
|
|
// #ifndef MP-WEIXIN
|
2025-07-14 15:38:39 +08:00
|
|
|
|
appendScriptTagElement('https://qd.zhaopinzao8dian.com/file/csn/jweixin-1.4.0.js').then(() => {
|
|
|
|
|
console.log('✅ 微信 JSSDK 加载完成');
|
2025-07-22 15:20:21 +08:00
|
|
|
|
// signatureFn();
|
2025-07-14 15:38:39 +08:00
|
|
|
|
});
|
2025-05-13 11:42:17 +08:00
|
|
|
|
// #endif
|
2025-04-07 09:10:55 +08:00
|
|
|
|
});
|
|
|
|
|
|
2024-11-08 11:55:23 +08:00
|
|
|
|
onShow(() => {
|
|
|
|
|
console.log('App Show');
|
|
|
|
|
});
|
2025-05-13 11:10:38 +08:00
|
|
|
|
|
2024-11-08 11:55:23 +08:00
|
|
|
|
onHide(() => {
|
|
|
|
|
console.log('App Hide');
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
/*每个页面公共css */
|
2025-06-26 08:56:42 +08:00
|
|
|
|
@import '@/common/animation.css';
|
2024-11-08 11:55:23 +08:00
|
|
|
|
@import '@/common/common.css';
|
2025-10-20 16:15:29 +08:00
|
|
|
|
/* 引入阿里图标库 */
|
|
|
|
|
@import url("/static/iconfont/iconfont.css");
|
2025-03-28 15:19:42 +08:00
|
|
|
|
/* 修改pages tabbar样式 H5有效 */
|
|
|
|
|
.uni-tabbar .uni-tabbar__item:nth-child(4) .uni-tabbar__bd .uni-tabbar__icon {
|
2025-05-15 14:17:51 +08:00
|
|
|
|
height: 110rpx !important;
|
|
|
|
|
width: 122rpx !important;
|
|
|
|
|
margin-top: 6rpx;
|
2025-04-07 09:10:55 +08:00
|
|
|
|
}
|
2025-05-15 14:17:51 +08:00
|
|
|
|
|
2025-04-07 09:10:55 +08:00
|
|
|
|
.uni-tabbar-border {
|
2025-04-16 14:24:06 +08:00
|
|
|
|
background-color: transparent !important;
|
|
|
|
|
/* background-color: #e4e4e4 !important; */
|
|
|
|
|
}
|
|
|
|
|
.uni-popup {
|
|
|
|
|
z-index: 1001 !important;
|
2025-04-07 09:10:55 +08:00
|
|
|
|
}
|
|
|
|
|
/* 提升toast层级 */
|
|
|
|
|
uni-toast,
|
|
|
|
|
uni-modal,
|
|
|
|
|
.uni-modal,
|
|
|
|
|
.uni-mask {
|
2025-04-16 14:24:06 +08:00
|
|
|
|
z-index: 998;
|
2025-03-28 15:19:42 +08:00
|
|
|
|
}
|
2025-05-13 11:10:38 +08:00
|
|
|
|
|
|
|
|
|
@font-face {
|
|
|
|
|
font-family: DingTalk JinBuTi;
|
2025-07-09 15:15:37 +08:00
|
|
|
|
src: url('/static/font/DingTalk JinBuTi_min.woff2') format('woff2');
|
|
|
|
|
font-display: swap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@font-face {
|
|
|
|
|
font-family: PingFangSC-Regular;
|
2025-07-14 15:38:39 +08:00
|
|
|
|
src: url('https://qd.zhaopinzao8dian.com/file/csn/PingFangSC-Regular.woff2') format('woff2');
|
2025-07-09 15:15:37 +08:00
|
|
|
|
font-display: swap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@font-face {
|
|
|
|
|
font-family: PingFangSC-Medium;
|
2025-07-14 15:38:39 +08:00
|
|
|
|
src: url('https://qd.zhaopinzao8dian.com/file/csn/PingFangSC-Medium.woff2') format('woff2');
|
2025-07-09 15:15:37 +08:00
|
|
|
|
font-display: swap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@font-face {
|
|
|
|
|
font-family: DIN-Medium;
|
2025-07-14 15:38:39 +08:00
|
|
|
|
src: url('https://qd.zhaopinzao8dian.com/file/csn/DIN-Medium.woff2') format('woff2');
|
2025-07-09 15:15:37 +08:00
|
|
|
|
font-display: swap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
font-family: 'PingFangSC-Regular', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
2025-05-13 11:10:38 +08:00
|
|
|
|
}
|
2025-04-10 10:59:25 +08:00
|
|
|
|
</style>
|