优化启动页

This commit is contained in:
zhouyanli
2026-08-17 15:31:17 +08:00
parent 9d5310e4a7
commit cb885dc1f2
8 changed files with 88 additions and 24 deletions

View File

@@ -18,6 +18,11 @@ onLaunch(() => {
setTimeout(() => {
getPushCID()
}, 2000)
// 安全兜底:正常由首页/引导页 onReady 关闭启动屏;若异常未关闭,5 秒后强制关闭,避免卡在启动屏
setTimeout(() => {
plus.navigator.closeSplashscreen()
}, 5000)
// #endif
})

View File

@@ -9,6 +9,5 @@ if (process.env.NODE_ENV === 'development') {
} else {
baseUrl = 'https://wuyeapi.ckdzkj.com' // 生产环境
// baseUrl = 'https://wuyeapi.bugtc.com' // 生产环境
// baseUrl = 'http://192.168.1.222:8080' // 生产环境
}
export default baseUrl;

View File

@@ -2,17 +2,17 @@
"name" : "花开管家",
"appid" : "__UNI__5F224F3",
"description" : "智慧社区管家端,专为小区物业管理人员打造,支持多小区灵活切换管理。集成账号密码、手机号密码双重登录模式,内置忘记密码找回功能,保障账号安全。涵盖消息通知、日常巡检、故障报修、一键开门、工单流转、投诉处理等核心办公功能,物业人员可在线完成巡检打卡、问题上报、工单派发跟进、投诉对接处理等日常工作,同时支持查看个人上报记录、巡检历史,便捷修改账号信息与登录密码。高效简化社区物业办公流程,提升小区服务与管理效率,打造便捷智能的社区管理服务平台。",
"versionName" : "1.0.6",
"versionCode" : 106,
"versionName" : "1.0.7",
"versionCode" : 107,
"transformPx" : false,
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : false,
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"autoclose" : false,
"delay" : 0,
"useOriginalMsgbox" : true
},

View File

@@ -96,7 +96,7 @@
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onReady } from '@dcloudio/uni-app'
import { getLoginPassword } from '../../api/api.js'
import { clearAccountStorage } from '../../api/request.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
@@ -164,6 +164,13 @@ onLoad(() => {
if (savedRemember) rememberPwd.value = savedRemember
})
onReady(() => {
// 登录页渲染完成后关闭启动屏(登录过但未登录时直接进登录页)
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen()
// #endif
})
// 登录逻辑
const handleLogin = () => {
if (!phoneNumber.value) {

View File

@@ -54,6 +54,7 @@
const selectedItem = ref(null)
const displayedCommunities = ref([])
const isLoading = ref(false)
const isConfirming = ref(false)
let searchTimeout = null
const defaultVillageId = ref('')
@@ -123,10 +124,13 @@
// 确认选择
const handleConfirm = () => {
// 防重复点击
if (isConfirming.value) return
if (!selectedItem.value) {
uni.showToast({ title: '请先选择小区', icon: 'none', duration: 2000 })
return
}
isConfirming.value = true
uni.showLoading({ title: '切换中...', mask: true })
switchVillage({ villageId: selectedItem.value.id }).then((res) =>{
if(res.code === 200){
@@ -137,9 +141,12 @@
uni.navigateBack()
}, 1500)
}else{
isConfirming.value = false
uni.hideLoading()
uni.showToast({ title: res.msg || '切换失败', icon: 'none' })
}
}).catch((err)=>{
isConfirming.value = false
uni.hideLoading()
uni.showToast({title:err.msg || '网络异常',icon:'none'})
})

View File

@@ -1,15 +1,15 @@
{
"pages": [{
"path": "pages/guide/guide",
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "引导页",
"navigationBarTitleText": "工作台",
"navigationStyle": "custom"
}
},
{
"path": "pages/index/index",
"path": "pages/guide/guide",
"style": {
"navigationBarTitleText": "工作台",
"navigationBarTitleText": "引导页",
"navigationStyle": "custom"
}
},

View File

@@ -1,6 +1,7 @@
<template>
<view class="guide-page" v-if="!token">
<view class="status-bar"></view>
<view class="guide-page">
<template v-if="!token">
<view class="status-bar"></view>
<!-- 引导内容滑动容器 -->
<swiper
class="guide-swiper"
@@ -67,11 +68,13 @@
{{ currentStep === 2 ? '立即体验' : '下一步' }}
</button>
</view>
</template>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { onReady } from '@dcloudio/uni-app';
// ========== 已登录直接进首页,跳过引导页 ==========
const token = uni.getStorageSync('token');
@@ -81,6 +84,15 @@ if (token) {
});
}
// 引导页渲染完成后关闭启动屏(仅未登录;已登录由首页 onReady 关闭)
onReady(() => {
if (!token) {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen()
// #endif
}
});
// ========== 响应式数据 ==========
// 当前引导步骤(0/1/2)
const currentStep = ref(0);

View File

@@ -1,11 +1,11 @@
<template>
<view class="content-class">
<template v-if="isLoggedIn">
<!-- 顶部渐变背景层 -->
<view class="bg-gradient"></view>
<!-- 页面内容区 -->
<view class="page-content">
<!-- 粘性顶部区域(状态栏 + 导航栏 + 小区选择) -->
<view class="sticky-header">
<!-- 状态栏占位 -->
<view class="status_bar" :style="{ height: statusBarHeight + 'px' }"></view>
@@ -118,12 +118,14 @@
</view>
</view>
</view>
</template>
<view v-else class="launch-placeholder"></view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onUnload, onShow } from '@dcloudio/uni-app'
import { onLoad, onUnload, onShow, onReady } from '@dcloudio/uni-app'
import {
getCurrentVillage,
getTodayInspection,
@@ -136,7 +138,10 @@ import { usePermStore } from '@/stores/usePermStore'
const permStore = usePermStore()
// 首次加载标记:onLoad 和 onShow 在首次进入时都会触发,用此标记避免重复请求
// 登录状态:未登录时启动跳引导页
const isLoggedIn = ref(!!uni.getStorageSync('token'))
// 首次加载标记
const hasInit = ref(false)
// banner 缓存 key 和缓存时长(30分钟)
@@ -302,7 +307,6 @@ const handleFunctionClick = item => {
}
// 获取当前小区
const currentVillageData = () => {
// 先重置,避免新账号无小区时仍显示旧账号的小区
currentCommunity.value = '请先绑定房屋'
getCurrentVillage()
.then(res => {
@@ -313,7 +317,9 @@ const currentVillageData = () => {
getNoticeData()
}
})
.catch(() => {})
.catch(() => {
currentCommunity.value = '请先绑定房屋'
})
}
// 获取今日巡检数据
const getInspectionData = () => {
@@ -339,17 +345,16 @@ const getInspectionData = () => {
}
// 获取消息通知
const getNoticeData = () => {
getNewNoticeData()
.then(res => {
if (res.code === 200 && res.data) {
noticeText.value = res.data.notice || ''
} else {
noticeText.value = '暂无公告'
getNewNoticeData().then(res => {
const notice = res.code === 200 && res.data ? (res.data.notice || '') : '暂无公告'
// 仅在内容真正变化时才更新
if (noticeText.value !== notice) {
noticeText.value = notice
}
})
.catch(() => {})
}
// 获取bannar图(带缓存:30分钟内优先用缓存,请求成功后更新缓存)
// 获取bannar图
function getbannarData(forceRefresh = false) {
// 非强制刷新时,优先读缓存
if (!forceRefresh) {
@@ -414,6 +419,7 @@ const slelctHomeData = data => {
}
onShow(() => {
if (!isLoggedIn.value) return
if (!hasInit.value) {
// 首次加载:onLoad 已触发过核心数据请求,这里只补 onLoad 没调的和需要每次都刷新的
hasInit.value = true
@@ -434,11 +440,33 @@ onShow(() => {
})
onLoad(() => {
// 未登录:登录过→登录页;首次下载→引导页
if (!isLoggedIn.value) {
const hasShowGuide = uni.getStorageSync('hasShowGuide')
uni.hideTabBar({ animation: false })
uni.reLaunch({
url: hasShowGuide ? '/pageSubPack/loginSub/pwd-login' : '/pages/guide/guide',
animationType: 'none',
animationDuration: 0
})
return
}
// 已登录:确保 tabBar 显示(未登录启动时曾被 hideTabBar 隐藏,switchTab 不会自动恢复)
uni.showTabBar({ animation: false })
uni.$on('confirm', slelctHomeData)
currentVillageData()
getInspectionData()
})
onReady(() => {
// 已登录:首页即最终页,渲染完成后关闭启动屏(未登录由引导页 onReady 关闭)
if (isLoggedIn.value) {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen()
// #endif
}
})
onUnload(() => {
uni.$off('confirm', slelctHomeData)
})
@@ -465,6 +493,12 @@ onUnload(() => {
position: relative;
}
/* 未登录启动占位:背景与引导页一致,过渡不闪烁 */
.launch-placeholder {
min-height: 100vh;
background: linear-gradient(to bottom, #e2f0ff, #f6faff);
}
/* 顶部渐变背景 - 增加高度确保覆盖粘性头部区域 */
.bg-gradient {
position: absolute;