261 lines
5.2 KiB
Vue
Raw Normal View History

2024-12-31 10:58:07 +08:00
<route lang="json5" type="home">
{
style: {
navigationStyle: 'custom',
navigationBarTitleText: '首页'
}
}
</route>
<template>
2025-01-03 18:14:33 +08:00
<view v-if="systemInfo" :style="{ marginTop: systemInfo.safeAreaInsets?.top + 'px' }">
<view v-if="$user.loginStatus">
2025-01-03 18:14:33 +08:00
<view class="h-12 pt-1 flex flex-items-center flex-justify-between mx-4">
<view>
<view>19104656的互联</view>
</view>
</view>
<CustomTab class="mt-10" :list="featuresList" @clickItem="clickItem"></CustomTab>
2025-01-03 18:14:33 +08:00
<button class="mt-12" @click="logout">退出登录</button>
2024-12-31 10:58:07 +08:00
</view>
</view>
</template>
<script lang="ts" setup>
import CustomTab from '@/pages/home/CustomTab.vue'
2025-01-03 18:14:33 +08:00
import { useBasicStore, useUserStore } from '@/store'
2025-01-02 19:26:12 +08:00
import { Result } from '@/constants/result'
2025-01-03 18:14:33 +08:00
import { HomeTab, TabBarItem } from '@/typings'
2024-12-31 10:58:07 +08:00
2025-01-02 19:26:12 +08:00
const $user = useUserStore()
2025-01-03 18:14:33 +08:00
const $basic = useBasicStore()
const systemInfo = ref(null)
2025-01-02 19:26:12 +08:00
2024-12-31 10:58:07 +08:00
const list = ref<Array<TabBarItem>>([
{
title: '首页',
isDot: true,
icon: 'home'
},
{
title: '我的',
value: 0,
icon: '/static/tabbar/home.png'
},
{
title: '最大值',
value: 200,
icon: '/static/tabbar/home.png'
},
{
title: '客服',
value: 3,
icon: '/static/tabbar/home.png'
}
])
const featuresList = ref<Array<HomeTab>>([
{
title: '视频',
list: [
{
id: 0,
title: '视频中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '视频中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '视频中心',
icon: '/static/logo.png'
},
{
id: 3,
title: '视频中心',
icon: '/static/logo.png'
},
{
id: 4,
title: '视频中心',
icon: '/static/logo.png'
}
]
},
{
title: '音频',
list: [
{
id: 0,
title: '音频中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '音频中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '音频中心',
icon: '/static/logo.png'
}
]
},
{
title: '图文',
list: [
{
id: 0,
title: '图文中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '图文中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '图文中心',
icon: '/static/logo.png'
}
]
},
{
title: '直播',
list: [
{
id: 0,
title: '直播中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '直播中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '直播中心',
icon: '/static/logo.png'
}
]
},
{
title: '其他',
list: [
{
id: 0,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '其他中心',
icon: '/static/logo.png'
}
]
},
{
title: '其他',
list: [
{
id: 0,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '其他中心',
icon: '/static/logo.png'
}
]
},
{
title: '其他',
list: [
{
id: 0,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '其他中心',
icon: '/static/logo.png'
}
]
},
{
title: '其他',
list: [
{
id: 0,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 1,
title: '其他中心',
icon: '/static/logo.png'
},
{
id: 2,
title: '其他中心',
icon: '/static/logo.png'
}
]
}
])
2025-01-02 19:26:12 +08:00
onMounted(async () => {
2025-01-03 18:14:33 +08:00
systemInfo.value = await $basic.getSystemInfo()
2025-01-02 19:26:12 +08:00
const tokenStorage: string = uni.getStorageSync('token')
if (tokenStorage) {
2025-01-03 18:14:33 +08:00
const result: Result = await $user.getUserInfo()
2025-01-02 19:26:12 +08:00
if (result.code === Result.Success.code) {
console.log('获取用户信息成功')
} else {
await uni.showToast({
title: result.message,
icon: 'none'
})
}
2025-01-03 18:14:33 +08:00
} else {
uni.navigateTo({
url: '/pages/login/login'
})
2025-01-02 19:26:12 +08:00
}
2024-12-31 10:58:07 +08:00
})
const clickItem = item => {
console.log(item)
}
2025-01-03 18:14:33 +08:00
const logout = async () => {
await $user.logout()
uni.navigateTo({
url: '/pages/login/login'
})
2024-12-31 10:58:07 +08:00
}
2025-01-03 18:14:33 +08:00
</script>