fix:换回uniapp自带tabbar

This commit is contained in:
MJ 2025-08-06 16:00:58 +08:00
parent 973c4f5ab6
commit 549e25155c
6 changed files with 139 additions and 48 deletions

View File

@ -33,7 +33,7 @@ export const responseInterceptor = async <T>(
response: ResponseData<T>, response: ResponseData<T>,
): Promise<ResponseData<T>> => { ): Promise<ResponseData<T>> => {
const { statusCode, data } = response as any const { statusCode, data } = response as any
console.log('response', response) // console.log('response', response)
// 处理成功响应 // 处理成功响应
if (statusCode === HTTP_STATUS.SUCCESS && data.code === 200) { if (statusCode === HTTP_STATUS.SUCCESS && data.code === 200) {

View File

@ -375,11 +375,36 @@
} }
], ],
"tabBar": { "tabBar": {
"color": "#333333", "color": "#8E8D9D",
"selectedColor": "#333333", "selectedColor": "#625EFF",
"borderStyle": "white", "borderStyle": "white",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"list": [] "list": [
{
"pagePath": "pages/home/index",
"iconPath": "static/tabBar/homeno.png",
"selectedIconPath": "static/tabBar/home.png",
"text": "首页"
},
{
"pagePath": "pages/academicReport/index",
"iconPath": "static/tabBar/studyReportNo.png",
"selectedIconPath": "static/tabBar/studyReport.png",
"text": "学情报告"
},
{
"pagePath": "pages/applicationManagement/index",
"iconPath": "static/tabBar/applicationNo.png",
"selectedIconPath": "static/tabBar/application.png",
"text": "应用管控"
},
{
"pagePath": "pages/mine/index",
"iconPath": "static/tabBar/mineno.png",
"selectedIconPath": "static/tabBar/mine.png",
"text": "我的"
}
]
}, },
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",

View File

@ -6,52 +6,25 @@
@updateShowItem="handleUpdateShowChild" @updateShowItem="handleUpdateShowChild"
/> />
<Empty v-if="empty" content="暂无学情报告数据哦~" /> <Empty v-if="empty" content="暂无学情报告数据哦~" />
<template v-if="subjectList?.length">
<view class="single_box filter_box">
<view class="title">学科选择</view>
<subjectFilter
:userId="showChildrenInfo?.childId"
:tabsList="subjectList"
@handleFilter="tapFilterSubject"
/>
</view>
<StudyTime :subjectId="chooseSubject?.subjectId" :userId="showChildrenInfo?.childId" />
<VideoTime :subjectId="chooseSubject?.subjectId" :userId="showChildrenInfo?.childId" />
<KnowledgeChart :subjectId="chooseSubject?.subjectId" :userId="showChildrenInfo?.childId" />
<ExerciseStatistics
:subjectId="chooseSubject?.subjectId"
:userId="showChildrenInfo?.childId"
/>
<LanguageStatistics
:show="chooseSubject?.subjectId === 3"
:userId="showChildrenInfo?.childId"
/>
</template>
<TabBar :selectedIndex="1" />
</mj-page> </mj-page>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import Empty from '@/components/Empty/index.vue' import Empty from '@/components/Empty/index.vue'
import ChildrenBox from './components/childrenBox.vue' import ChildrenBox from './components/childrenBox.vue'
import SubjectFilter from './components/subjectFilter.vue'
import TabBar from '@/components/Tabbar/index.vue'
import StudyTime from './components/studyTime.vue'
import VideoTime from './components/videoTime.vue'
import KnowledgeChart from './components/knowledgeChart.vue'
import ExerciseStatistics from './components/exerciseStatistics.vue'
import LanguageStatistics from './components/languageStatistics.vue'
import type { ChildrenType } from '@/pages/mine/interface' import type { ChildrenType } from '@/pages/mine/interface'
import type { SubjectType } from './interface' import type { SubjectType } from './interface'
import './index.scss' import './index.scss'
import { getParentBindChildApi, subjectApi } from '@/api' import { getParentBindChildApi, subjectApi } from '@/api'
import { userStore } from '@/store' import { userStore, bindApplyStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import db from '@/utils/db'
import hud from '@/utils/hud' import hud from '@/utils/hud'
const { userInfo } = storeToRefs(userStore()) const { userInfo } = storeToRefs(userStore())
const { getApplyBindInfoList } = bindApplyStore()
const childrenList = ref<ChildrenType[]>() // const childrenList = ref<ChildrenType[]>() //
const empty = ref(false) const empty = ref(false)
@ -98,11 +71,33 @@ async function getSubject() {
subjectList.value = data subjectList.value = data
chooseSubject.value = data[0] chooseSubject.value = data[0]
} }
//
async function handleTabBarBadge() {
await getApplyBindInfoList()
const hasApplyMsg = db.get('applyBindMsg')
if (hasApplyMsg) {
uni.setTabBarBadge({
index: 3, // ""tabBar
text: '●',
})
} else {
uni.removeTabBarBadge({
index: 3,
})
}
}
onShow(() => {
handleTabBarBadge()
})
onMounted(async () => { onMounted(async () => {
try { try {
hud.loading() hud.loading()
await getParentBindChild() await getParentBindChild()
await getSubject() await getSubject()
handleTabBarBadge()
} finally { } finally {
hud.hide() hud.hide()
} }

View File

@ -118,7 +118,7 @@
safe-area-inset-bottom safe-area-inset-bottom
position="bottom" position="bottom"
custom-style="border-radius: 20px 20px 0 0;padding-bottom: 30px;" custom-style="border-radius: 20px 20px 0 0;padding-bottom: 30px;"
@click-modal="() => (hideTabBar = false)" @click-modal="() => {}"
> >
<view class="bottom_popup"> <view class="bottom_popup">
<view class="header_title"> 选择使用方式 </view> <view class="header_title"> 选择使用方式 </view>
@ -132,21 +132,24 @@
</view> </view>
</view> </view>
</wd-popup> </wd-popup>
<view v-if="!hideTabBar"> <TabBar :selectedIndex="2" /></view>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted } from 'vue' import { ref, reactive, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { studentHeadImage } from '@/hooks/useImage' import { studentHeadImage } from '@/hooks/useImage'
import { getParentBindDeviceApi, parentDeviceCurrentLoginApi, queryAppRecordApi } from '@/api' import { getParentBindDeviceApi, parentDeviceCurrentLoginApi, queryAppRecordApi } from '@/api'
import TabBar from '@/components/Tabbar/index.vue'
import CustomPopup from '@/components/CustomPopup/index.vue' import CustomPopup from '@/components/CustomPopup/index.vue'
import Empty from '@/components/Empty/index.vue' import Empty from '@/components/Empty/index.vue'
import { userStore } from '@/store' import { userStore, bindApplyStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import db from '@/utils/db'
const { userInfo } = storeToRefs(userStore()) const { userInfo } = storeToRefs(userStore())
const { getApplyBindInfoList } = bindApplyStore()
const OSS_URL = import.meta.env.VITE_OSS_HOST const OSS_URL = import.meta.env.VITE_OSS_HOST
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png` const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
const arrow = `${OSS_URL}/iconfont/down_arrow.png` const arrow = `${OSS_URL}/iconfont/down_arrow.png`
@ -154,7 +157,7 @@ const checked = `${OSS_URL}/iconfont/checked.png`
const unchecked = `${OSS_URL}/iconfont/unchecked.png` const unchecked = `${OSS_URL}/iconfont/unchecked.png`
const showAllEquipment = ref(false) const showAllEquipment = ref(false)
const showCustomPopup = ref(false) const showCustomPopup = ref(false)
const hideTabBar = ref(false)
const methodPopup = ref(false) const methodPopup = ref(false)
const methodList = ref([ const methodList = ref([
@ -220,13 +223,11 @@ function swicthNav(i) {
} }
// //
function handleControl() { function handleControl() {
hideTabBar.value = true
methodPopup.value = true methodPopup.value = true
} }
function handleConfirmControl() { function handleConfirmControl() {
methodPopup.value = false methodPopup.value = false
hideTabBar.value = false
setTimeout(() => { setTimeout(() => {
methodPopup.value = false methodPopup.value = false
}, 200) }, 200)
@ -287,9 +288,31 @@ async function fetchAppRecord() {
uni.hideLoading() uni.hideLoading()
} }
} }
//
async function handleTabBarBadge() {
await getApplyBindInfoList()
const hasApplyMsg = db.get('applyBindMsg')
if (hasApplyMsg) {
uni.setTabBarBadge({
index: 3, // ""tabBar
text: '●'
})
} else {
uni.removeTabBarBadge({
index: 3
})
}
}
onShow(() => {
handleTabBarBadge()
})
onMounted(async () => { onMounted(async () => {
await getParentBindDevice() await getParentBindDevice()
fetchAppRecord() fetchAppRecord()
handleTabBarBadge()
}) })
</script> </script>

View File

@ -71,14 +71,17 @@
</view> </view>
</template> </template>
</view> </view>
<TabBar :selectedIndex="0" />
</mj-page> </mj-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getParentBindDeviceApi, parentDeviceCurrentLoginApi } from '@/api' import { getParentBindDeviceApi, parentDeviceCurrentLoginApi } from '@/api'
import TabBar from '@/components/Tabbar/index.vue' import { bindApplyStore } from '@/store'
import db from '@/utils/db'
import { userStore } from '@/store' import { userStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import hud from '@/utils/hud' import hud from '@/utils/hud'
@ -86,7 +89,8 @@ import router from '@/router/router'
const store = userStore() const store = userStore()
const { getUserInfo } = store const { getUserInfo } = store
const { userInfo } = storeToRefs(store) const { userInfo } = storeToRefs(userStore())
const { getApplyBindInfoList } = bindApplyStore()
const OSS_URL = import.meta.env.VITE_OSS_HOST const OSS_URL = import.meta.env.VITE_OSS_HOST
const scanQr = `${OSS_URL}/iconfont/scan_qr.png` const scanQr = `${OSS_URL}/iconfont/scan_qr.png`
const arrow = `${OSS_URL}/iconfont/down_arrow.png` const arrow = `${OSS_URL}/iconfont/down_arrow.png`
@ -206,9 +210,31 @@ async function getParentBindDevice() {
}, },
}) })
} }
//
async function handleTabBarBadge() {
await getApplyBindInfoList()
const hasApplyMsg = db.get('applyBindMsg')
if (hasApplyMsg) {
uni.setTabBarBadge({
index: 3, // ""tabBar
text: '●'
})
} else {
uni.removeTabBarBadge({
index: 3
})
}
}
onShow(() => {
handleTabBarBadge()
})
onMounted(async () => { onMounted(async () => {
await getUserInfo() await getUserInfo()
getParentBindDevice() getParentBindDevice()
handleTabBarBadge()
}) })
</script> </script>

View File

@ -2,14 +2,36 @@
<view class="content"> <view class="content">
<PatriarchCard /> <PatriarchCard />
<AbountMine /> <AbountMine />
<TabBar :selectedIndex="3" />
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import TabBar from '@/components/Tabbar/index.vue'; import { onShow } from '@dcloudio/uni-app'
import { bindApplyStore } from '@/store'
import db from '@/utils/db'
import PatriarchCard from './patriarchCard.vue'; import PatriarchCard from './patriarchCard.vue';
import AbountMine from './aboutMine.vue'; import AbountMine from './aboutMine.vue';
const { getApplyBindInfoList } = bindApplyStore()
onShow(async () => {
//
await getApplyBindInfoList()
const hasApplyMsg = db.get('applyBindMsg')
if (hasApplyMsg) {
uni.setTabBarBadge({
index: 3, // ""tabBar
text: '●'
})
} else {
uni.removeTabBarBadge({
index: 3
})
}
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">