feat:首页和案例库功能
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { getBannerList } from '@/api/banner'
|
||||
import { getProjectSubmissionList } from '@/api/project-submission'
|
||||
import AppTabBar from '@/components/AppTabBar.vue'
|
||||
import { useGreeting } from '@/hooks/use-greeting'
|
||||
import { useQuickEntries } from '@/hooks/use-quick-entries'
|
||||
import type { BannerItem } from '@/types/banner'
|
||||
import type { ProjectItem, QuickEntryItem, ServiceItem } from '@/types/home'
|
||||
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||
import { mapProjectSubmissionsToServices } from '@/utils/map-project-submission'
|
||||
import { navigateQuickEntry } from '@/utils/quick-entry-navigate'
|
||||
import headerBg from '@/static/icons/1.png'
|
||||
import softwareIllus from '@/static/icons/software.png'
|
||||
import hardwareIllus from '@/static/icons/hardware.png'
|
||||
import iotIllus from '@/static/icons/iot.png'
|
||||
import productionIllus from '@/static/icons/production.png'
|
||||
import HomeBanner from './components/HomeBanner.vue'
|
||||
import HomeFloatingActions from './components/HomeFloatingActions.vue'
|
||||
import ProjectCard from './components/ProjectCard.vue'
|
||||
import QuickEntryEditor from './components/QuickEntryEditor.vue'
|
||||
@@ -27,41 +29,37 @@ const {
|
||||
addToPinned,
|
||||
} = useQuickEntries()
|
||||
|
||||
onShow(() => {
|
||||
ensureLoggedIn()
|
||||
})
|
||||
const banners = ref<BannerItem[]>([])
|
||||
const services = ref<ServiceItem[]>([])
|
||||
|
||||
const services: ServiceItem[] = [
|
||||
{
|
||||
id: '1',
|
||||
title: '互联网软件',
|
||||
desc: 'Web/小程序/APP/二次开发/桌面工具等',
|
||||
theme: 'blue',
|
||||
illus: softwareIllus,
|
||||
detailId: 'software',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
title: '硬件电路',
|
||||
desc: '原理图设计/PCB设计/电气校验等',
|
||||
theme: 'green',
|
||||
illus: hardwareIllus,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
title: '物联网全案',
|
||||
desc: '软硬件开发+云端一体化/定制化开发等',
|
||||
theme: 'pink',
|
||||
illus: iotIllus,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
title: '生产制造',
|
||||
desc: 'PCB制版/SMT/整机装配/定制生产等',
|
||||
theme: 'orange',
|
||||
illus: productionIllus,
|
||||
},
|
||||
]
|
||||
async function loadBanners() {
|
||||
try {
|
||||
const list = await getBannerList()
|
||||
banners.value = (list ?? [])
|
||||
.filter(item => item.enabled === 1 || item.enabled === undefined)
|
||||
.sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0))
|
||||
}
|
||||
catch {
|
||||
banners.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProjectSubmissions() {
|
||||
try {
|
||||
const list = await getProjectSubmissionList()
|
||||
services.value = await mapProjectSubmissionsToServices(list ?? [])
|
||||
}
|
||||
catch {
|
||||
services.value = []
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
if (!ensureLoggedIn())
|
||||
return
|
||||
loadBanners()
|
||||
loadProjectSubmissions()
|
||||
})
|
||||
|
||||
function handleQuickEntryTap(entry: QuickEntryItem) {
|
||||
navigateQuickEntry(entry.id, entry.label)
|
||||
@@ -148,17 +146,28 @@ const projects: ProjectItem[] = [
|
||||
:show-scrollbar="false"
|
||||
>
|
||||
<view class="home__content">
|
||||
<HomeBanner :list="banners" />
|
||||
|
||||
<view class="home__section">
|
||||
<text class="home__section-title">
|
||||
业务服务
|
||||
</text>
|
||||
<view class="home__service-grid">
|
||||
<view
|
||||
v-if="services.length"
|
||||
class="home__service-grid"
|
||||
>
|
||||
<ServiceCard
|
||||
v-for="item in services"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-else
|
||||
class="home__service-empty"
|
||||
>
|
||||
暂无业务服务
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="home__sections">
|
||||
|
||||
Reference in New Issue
Block a user