feat: 修复 H5 底部导航覆盖 + 更新项目进度文档
## H5 底部导航修复 (Bug #10) - 精简 App.vue,移除重复 tabbar,仅保留全局样式 - uni-page 设置 height: calc(100% - 50px) + overflow-y: auto - 内容区域精确停在底部导航上方,独立滚动不再叠加 - 恢复 custom-tab-bar 组件 ## 项目进度文档 - PROGRESS.md 更新至 10 个 Bug 修复 - 新增 H5 底部导航修复记录 - 新增历史变更条目
This commit is contained in:
+40
-105
@@ -1,110 +1,45 @@
|
||||
<script setup>
|
||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||
import CustomTabbar from '@/components/tabbar/custom-tabbar.vue'
|
||||
import pushService from '@/utils/push.js'
|
||||
|
||||
onLaunch(() => {
|
||||
console.log('App Launch')
|
||||
const token = uni.getStorageSync('token')
|
||||
if (token) {
|
||||
uni.setStorageSync('hasLogin', true)
|
||||
initPush()
|
||||
}
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
console.log('App Show')
|
||||
checkSilentCustomers()
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
console.log('App Hide')
|
||||
})
|
||||
|
||||
async function initPush() {
|
||||
try {
|
||||
await pushService.init()
|
||||
|
||||
// 监听接收消息
|
||||
pushService.onMessage((msg) => {
|
||||
console.log('Received push message:', msg)
|
||||
showNotification(msg)
|
||||
})
|
||||
|
||||
// 监听点击消息
|
||||
pushService.onClick((payload) => {
|
||||
console.log('Push clicked:', payload)
|
||||
handlePushClick(payload)
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Push init failed:', err)
|
||||
}
|
||||
}
|
||||
|
||||
function showNotification(msg) {
|
||||
uni.showModal({
|
||||
title: msg.title,
|
||||
content: msg.content,
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
if (msg.payload) {
|
||||
handlePushClick(msg.payload)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handlePushClick(payload) {
|
||||
if (!payload) return
|
||||
|
||||
switch (payload.type) {
|
||||
case 'silent_customer':
|
||||
uni.switchTab({ url: '/pages/customers/customers' })
|
||||
break
|
||||
case 'quotation':
|
||||
uni.switchTab({ url: '/pages/quotation/quotation' })
|
||||
break
|
||||
case 'reply':
|
||||
uni.switchTab({ url: '/pages/translate/translate' })
|
||||
break
|
||||
default:
|
||||
uni.switchTab({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
|
||||
async function checkSilentCustomers() {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) return
|
||||
|
||||
try {
|
||||
const { customerApi } = require('@/utils/api.js')
|
||||
const silentData = await customerApi.getSilent(3)
|
||||
|
||||
if (silentData.count > 0) {
|
||||
// 创建本地通知提醒
|
||||
pushService.createLocalNotification({
|
||||
title: '跟进提醒',
|
||||
content: `您有 ${silentData.count} 个客户已沉默3天以上`,
|
||||
payload: { type: 'silent_customer', count: silentData.count }
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Check silent customers failed:', err)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view id="app">
|
||||
<router-view />
|
||||
<CustomTabbar />
|
||||
</view>
|
||||
<!-- Uni-app manages its own page/tabbar structure. App.vue only provides global styles. -->
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@import '@/static/common.css';
|
||||
<script setup>
|
||||
// App root - uni-app framework handles page layout and tab bar
|
||||
</script>
|
||||
|
||||
#app {
|
||||
padding-bottom: 100rpx;
|
||||
<style>
|
||||
/* Global reset */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
|
||||
html, body, #app {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Fix: make uni-page scrollable and properly sized for fixed tabbar */
|
||||
uni-page {
|
||||
height: calc(100% - 50px) !important;
|
||||
overflow-y: auto !important;
|
||||
overflow-x: hidden !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
}
|
||||
uni-page-body, uni-page-wrapper {
|
||||
overflow-y: auto !important;
|
||||
overflow-x: hidden !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
}
|
||||
|
||||
/* Ensure the page head doesn't block scrolling */
|
||||
uni-page-head {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* The uni-tabbar is already position:fixed by the framework */
|
||||
uni-tabbar {
|
||||
z-index: 999 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user