feat:小程序首页白屏问题

This commit is contained in:
dzc committed 2026-06-17 20:21:33 +08:00
1 parent b22de4d6b2
commit 6412d3be5c
10 files changed
+209 -84

No files matched your search

+32 -5
View File
@@ -2,7 +2,7 @@
import { ref, reactive, computed, nextTick, onMounted } from "vue"
import { onHide, onShow } from "@dcloudio/uni-app"
import { router, constant } from "@@/index"
import { router } from "@@/index"
import { noticeApi, appApi } from "@@/api/index"
import { getAppInfo } from "@@/utils/app"
import { SERVICE_IMAGE } from "@@/constant/index"
@@ -48,7 +48,9 @@ onShow(() => {
if (!ceheckLogin()) {
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
uni.navigateTo({ url: "/pages/root/login" })
return
}
getSwiperList()
getNoticeList()
getAppMenuList()
})
@@ -72,6 +74,20 @@ const doMenu = async (v: any) => {
tabbarStore.jumpFirstTabbar()
}
// 获取轮播图
const getSwiperList = async () => {
try {
const { data, code }: any = await noticeApi.getSwiperList()
console.log("获取轮播图,code:", code);
if (code != 0) {
throw new Error()
}
state.swiperList = (data || []).filter(Boolean)
} catch (error) {
console.log("获取轮播图意外的错误error:", error);
}
}
// 获取通知公告列表
const getNoticeList = async () => {
try {
@@ -79,6 +95,7 @@ const getNoticeList = async () => {
current: 1,
size: 9
})
console.log("获取通知公告列表,code:", code);
if (code != 0) {
throw new Error()
}
@@ -97,7 +114,10 @@ const getAppMenuList = async () => {
platformEnum: platform
}
const { data, code }: any = await appApi.appList(params)
if (code != 0) {
console.log("获取应用菜单列表,code:", code);
if (code == 424) {
} else if (code != 0) {
throw new Error()
}
state.appMenuList = (data || []).filter(Boolean)
@@ -105,6 +125,12 @@ const getAppMenuList = async () => {
console.log("获取应用菜单列表意外的错误error:", error);
}
}
const doSwiper = async (v: any) => {
if (!v) return
const target = (v.jumpValue || "").replace(/\s+/g, "")
uni.navigateTo({ url: target })
}
</script>
<template>
@@ -112,8 +138,8 @@ const getAppMenuList = async () => {
<view class="h-20rpx" />
<swiper class="w-full h-280rpx rounded-16rpx overflow-hidden" circular :indicator-dots="true"
indicator-active-color="#0779FD" indicator-color="#ffffff" :autoplay="true">
<swiper-item v-for="(v, i) in state?.swiperList" :key="i">
<image class="w-full h-full" :src="v.image" mode="aspectFill" />
<swiper-item v-for="(v, i) in state?.swiperList" :key="v.id" @tap="doSwiper(v)">
<image class="w-full h-full" :src="v.imageUrl" mode="aspectFill" />
</swiper-item>
</swiper>
<view class="h-20rpx" />
@@ -135,7 +161,8 @@ const getAppMenuList = async () => {
<view class="w-full">
<view
class="h-100rpx flex justify-between items-center p-x-16rpx p-y-20rpx border-b-1 border-color-#f0f0f0"
v-for="(v, idx) in group" :key="idx">
v-for="(v, idx) in group" :key="idx"
@tap="() => router.jump('/pages/integrated/notice/detail', { id: v?.id })">
<view class="flex-1 sub-text-26 font-normal! truncate">{{ v.title }}</view>
<view class="w-250rpx second-text-24 m-l-10rpx">{{ v.createTime }}</view>
</view>