From 3ce43e880db58bf11a058f259201d166430c4717 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 17 Jun 2025 18:43:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=88=86=E6=94=AF=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E8=AF=B7=E6=B1=822222?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 9 ++++++--- utils/logcheck.js | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 6e5db1c..c3a6696 100644 --- a/app.js +++ b/app.js @@ -1,8 +1,11 @@ -const { checkLogin } = require('./utils/logcheck'); +const { checkLogin, checkLogin2 } = require('./utils/logcheck'); App({ onLaunch: function () { - checkLogin(); - checkLogin(); + checkLogin2() + checkLogin2() + checkLogin2() + checkLogin2() + checkLogin2() } }); diff --git a/utils/logcheck.js b/utils/logcheck.js index cdde082..75d25e3 100644 --- a/utils/logcheck.js +++ b/utils/logcheck.js @@ -20,6 +20,31 @@ function checkLogin() { } } + +function checkLogin2() { + try { + const user = wx.getStorageSync('usermessage'); + if (!user || (typeof user === 'object' && Object.keys(user).length === 0)) { + wx.showToast({ + title: '您未登录请先登录', + icon:'error', + duration:2000 + }) + setTimeout(() => { + wx.navigateTo({ + url: '/pages/logain/logain', + }); + }, 2000); + } + } catch (e) { + wx.navigateTo({ + url: '/pages/logain/logain', + }); + } +} + + + module.exports = { - checkLogin + checkLogin, checkLogin2 };