This commit is contained in:
2026-01-18 18:03:40 +08:00
parent f038dbab41
commit 9259bda54b
7 changed files with 40 additions and 12 deletions

View File

@@ -78,9 +78,6 @@ class Login extends BaseController {
$user = auth('api')->user(); $user = auth('api')->user();
$user->level = $user->level()->first(); $user->level = $user->level()->first();
$user->social = $user->social()->where('type', $type)->first();
$user->store = $user->store()->first();
$user->pm = $user->pm()->where('status', 1)->first();
$this->data['data'] = $user; $this->data['data'] = $user;
return response()->json($this->data); return response()->json($this->data);
} }

View File

@@ -1,6 +1,4 @@
<script> <script>
import { setCurrentRoute } from '@/utils/auth.js'
export default { export default {
onLaunch: function() { onLaunch: function() {
console.log('App Launch') console.log('App Launch')

View File

@@ -18,8 +18,8 @@ const config = {
{ {
pagePath: "/pages/account/statistics/index", pagePath: "/pages/account/statistics/index",
text: "统计", text: "统计",
icon: "chart", icon: "color-filled",
activeIcon: "chart", activeIcon: "color-filled",
badge: 0 badge: 0
}, },
{ {

View File

@@ -1,8 +1,14 @@
import App from "./App"; import App from "./App";
import { createSSRApp } from "vue"; import { createSSRApp } from "vue";
import boot from './boot'
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App)
app.use(boot)
return { return {
app, app,
}; };

View File

@@ -1,13 +1,26 @@
import { checkLogin, isLogin } from '@/utils/auth.js' import { checkLogin, isLogin } from '@/utils/auth.js'
export default { export default {
data() {
return {
// 记录该页面是否已检查过登录状态
_pageAuthChecked: false
}
},
onLoad() { onLoad() {
// 页面加载时检查登录状态 // 页面加载时检查登录状态
this.checkAuth() this.checkAuth()
}, },
onShow() { onShow() {
// 页面显示时检查登录状态 // 页面显示时检查登录状态,但避免重复检查
this.checkAuth() if (!this._pageAuthChecked) {
this.checkAuth()
this._pageAuthChecked = true
}
},
onHide() {
// 页面隐藏时重置检查标志,下次显示时重新检查
this._pageAuthChecked = false
}, },
methods: { methods: {
/** /**

View File

@@ -138,7 +138,7 @@ export default {
// 跳转到首页 // 跳转到首页
setTimeout(() => { setTimeout(() => {
uni.switchTab({ uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index'
}) })
}, 1500) }, 1500)

View File

@@ -92,10 +92,24 @@ export function checkLogin() {
// 未登录,跳转到登录页 // 未登录,跳转到登录页
if (currentRoute !== '/pages/ucenter/login/index') { if (currentRoute !== '/pages/ucenter/login/index') {
// 保存当前页面路径,登录后可以返回
const pages = getCurrentPages()
if (pages && pages.length > 0) {
const currentPage = pages[pages.length - 1]
try {
uni.setStorageSync('beforLoginUrl', {
route: currentPage.route,
options: currentPage.options
})
} catch (e) {
console.error('保存登录前页面失败:', e)
}
}
uni.showToast({ uni.showToast({
title: '请先登录', title: '请先登录',
icon: 'none', icon: 'none',
duration: 2000 duration: 1500
}) })
setTimeout(() => { setTimeout(() => {