This commit is contained in:
dzc committed 2026-05-07 10:06:56 +08:00
1 parent e3eb6d9b77
commit cc39f190d0
7 files changed
+34 -8

No files matched your search

+6 -1
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, reactive, computed, defineAsyncComponent, nextTick, onMounted } from "vue"
import { ref, reactive, computed, nextTick, onMounted } from "vue"
import { onHide, onShow } from "@dcloudio/uni-app"
import { router } from "@@/index"
@@ -8,6 +8,7 @@ import { getAppInfo } from "@@/utils/app"
import { SERVICE_IMAGE } from "@@/constant/index"
import { filePath } from "@@/utils/file"
import { useTabbarStore } from "@@/stores/tabbar"
import { ceheckLogin } from "@@/utils/app"
import Empty from "@@/components/empty/empty.vue"
@@ -42,6 +43,10 @@ const groupedNoticeList = computed(() => {
})
onShow(() => {
if (!ceheckLogin()) {
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
uni.navigateTo({ url: "/pages/root/login" })
}
getNoticeList()
getAppMenuList()
})
+5
View File
@@ -24,6 +24,10 @@ const serviceTextRef = ref<any>(null)
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO
state.userInfo = uni.getStorageSync(userInfoKey)
const storageIsAgree = uni.getStorageSync(constant.storageConstant.LOGIN_IS_AGREE)
if (storageIsAgree) {
state.isAgree = storageIsAgree
}
})
// 小程序获取手机号
@@ -57,6 +61,7 @@ const minAppGetphone = async (e) => {
// 查询用户信息
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(constant.storageConstant.USERINFO, userData)
uni.setStorageSync(constant.storageConstant.LOGIN_IS_AGREE, true)
await createWallet()
uni.hideLoading()
uni.showToast({ title: "登录成功", icon: "success" })
+5
View File
@@ -34,6 +34,10 @@ onLoad(() => {
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO
state.userInfo = uni.getStorageSync(userInfoKey)
const storageIsAgree = uni.getStorageSync(constant.storageConstant.LOGIN_IS_AGREE)
if (storageIsAgree) {
state.isAgree = storageIsAgree
}
})
@@ -70,6 +74,7 @@ const doSubmit = async () => {
username: applyForm.username,
password: applyForm.password,
} as GlobalSetting.RememberUser)
uni.setStorageSync(constant.storageConstant.LOGIN_IS_AGREE, true)
await createWallet()
uni.hideLoading()
uni.showToast({ title: "登录成功", icon: "none" })
@@ -100,9 +100,9 @@ async function checkVerifyDevice() {
const userInfo = uni.getStorageSync(constant.storageConstant.USERINFO)
if (!userInfo || !userInfo.sysUser || !userInfo.sysUser.userId) return
// 是否在白名单中
// if (constant.DEVICE_VERIFY_WRITE_LIST.includes(userInfo.sysUser.phone)) {
// return
// }
if (constant.DEVICE_VERIFY_WRITE_LIST.includes(userInfo.sysUser.phone)) {
return
}
const _params = {
mobile: userInfo.sysUser.phone,
userId: userInfo.sysUser.userId,
+1
View File
@@ -7,4 +7,5 @@ export default {
USER_SETTING: "user_setting",
REMEMBER_USER: "remember_user",
UNIQUE_CODE: "unique_code",
LOGIN_IS_AGREE: "login_is_agree",
}
+11 -1
View File
@@ -1,4 +1,4 @@
import { APPENV } from "../constant"
import { APPENV, storageConstant } from "../constant"
export const isDevEnv = (): boolean => process.env.NODE_ENV === "development"
@@ -64,3 +64,13 @@ export const createCooldown = (cooldownMs: number = 300) => {
return true
}
}
export const ceheckLogin = () => {
const token = uni.getStorageSync(storageConstant.TOKEN)
const userInfo = uni.getStorageSync(storageConstant.USERINFO)
if (!token || !userInfo) {
return false
}
return true
}
+3 -3
View File
@@ -25,7 +25,7 @@ console.log("getBaseApiUrl:", getBaseApiUrl())
const https = new Request({
baseURL: getBaseApiUrl(),
timeout: 10 * 1000,
timeout: 15 * 1000,
method: "GET",
header: {
Accept: "*/*",
@@ -94,9 +94,9 @@ https.interceptors.response.use(
if (currentRoute === "pages/root/login" || currentRoute === "/pages/root/login") {
return
}
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
runLoginRedirect(() => {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
uni.navigateTo({ url: "/pages/root/login" })
})