This commit is contained in:
zpc 2026-03-19 07:38:48 +08:00
parent 304431010e
commit f2e2a5d052

View File

@ -44,7 +44,7 @@
</view> </view>
<!-- 专业测评入口 --> <!-- 专业测评入口 -->
<view class="assessment-section" v-if="navigationList.length > 0"> <view class="section-card" v-if="navigationList.length > 0">
<view class="section-header"> <view class="section-header">
<view class="section-indicator"></view> <view class="section-indicator"></view>
<text class="section-title">专业测评</text> <text class="section-title">专业测评</text>
@ -54,12 +54,13 @@
class="assessment-card" class="assessment-card"
v-for="(item, index) in navigationList" v-for="(item, index) in navigationList"
:key="index" :key="index"
:class="'assessment-card--' + index"
@click="handleNavigationClick(item)" @click="handleNavigationClick(item)"
> >
<!-- 即将上线标签 --> <!-- 即将上线标签 -->
<!-- <view v-if="item.status === 2" class="coming-soon-tag"> <view v-if="item.status === 2" class="coming-soon-tag">
<text>即将上线</text> <text>即将上线</text>
</view> --> </view>
<image <image
:src="item.imageUrl" :src="item.imageUrl"
mode="aspectFit" mode="aspectFit"
@ -70,36 +71,59 @@
</view> </view>
</view> </view>
<!-- 关于我们 - 宣传长图 --> <!-- 学业规划 -->
<view class="promotion-section" v-if="promotionList.length > 0"> <view class="section-card">
<view class="section-header"> <view class="section-header">
<view class="section-indicator"></view> <view class="section-indicator"></view>
<text class="section-title">关于我们</text> <text class="section-title">学业规划</text>
</view> </view>
<view class="planner-btn" @click="goToPlanner">
<text class="planner-btn__text">预约入口</text>
</view>
</view>
<!-- 更多 -->
<view class="section-card">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">更多</text>
</view>
<view class="more-grid">
<view class="more-card more-card--plan" @click="goToStudyPlan">
<text class="more-card__title">学习方案</text>
<image <image
v-for="(item, index) in promotionList" src="/static/icons/study-plan.png"
:key="index" mode="aspectFit"
:src="item.imageUrl" class="more-card__icon"
mode="widthFix"
class="promotion-image"
/> />
</view> </view>
<view class="more-card more-card--consult" @click="goToConsult">
<text class="more-card__title">详细咨询</text>
<image
src="/static/icons/consult.png"
mode="aspectFit"
class="more-card__icon"
/>
</view>
</view>
</view>
<!-- 加载状态 --> <!-- 加载状态 -->
<view class="loading-section" v-if="pageLoading"> <view class="loading-section" v-if="pageLoading">
<Loading type="inline" :loading="true" /> <Loading type="inline" :loading="true" />
</view> </view>
<!-- 底部安全间距 -->
<view class="safe-bottom"></view>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useUserStore } from '@/store/user.js' import { useUserStore } from '@/store/user.js'
import { useNavbar } from '@/composables/useNavbar.js' import { useNavbar } from '@/composables/useNavbar.js'
import { getBannerList, getAssessmentList, getNavigationList, getPromotionList } from '@/api/home.js' import { getBannerList, getNavigationList } from '@/api/home.js'
import Loading from '@/components/Loading/index.vue' import Loading from '@/components/Loading/index.vue'
const userStore = useUserStore() const userStore = useUserStore()
@ -109,11 +133,7 @@ const { statusBarHeight, navbarHeight, totalNavbarHeight } = useNavbar()
const pageLoading = ref(true) const pageLoading = ref(true)
const isRefreshing = ref(false) const isRefreshing = ref(false)
const bannerList = ref([]) const bannerList = ref([])
const assessmentList = ref([])
const navigationList = ref([]) const navigationList = ref([])
const promotionList = ref([])
//
/** /**
* 加载Banner数据 * 加载Banner数据
@ -129,20 +149,6 @@ async function loadBannerList() {
} }
} }
/**
* 加载测评入口数据
*/
async function loadAssessmentList() {
try {
const res = await getAssessmentList()
if (res && res.code === 0 && res.data) {
assessmentList.value = Array.isArray(res.data) ? res.data : (res.data.list || [])
}
} catch (error) {
console.error('加载测评入口失败:', error)
}
}
/** /**
* 加载首页导航入口数据 * 加载首页导航入口数据
*/ */
@ -157,35 +163,16 @@ async function loadNavigationList() {
} }
} }
/**
* 加载宣传图数据
*/
async function loadPromotionList() {
try {
const res = await getPromotionList()
if (res && res.code === 0 && res.data) {
promotionList.value = Array.isArray(res.data) ? res.data : (res.data.list || [])
}
} catch (error) {
console.error('加载宣传图失败:', error)
}
}
/** /**
* 初始化页面数据 * 初始化页面数据
*/ */
async function initPageData() { async function initPageData() {
pageLoading.value = true pageLoading.value = true
try { try {
//
userStore.restoreFromStorage() userStore.restoreFromStorage()
//
await Promise.all([ await Promise.all([
loadBannerList(), loadBannerList(),
loadAssessmentList(), loadNavigationList()
loadNavigationList(),
loadPromotionList()
]) ])
} finally { } finally {
pageLoading.value = false pageLoading.value = false
@ -197,21 +184,14 @@ async function initPageData() {
*/ */
function handleBannerClick(item) { function handleBannerClick(item) {
if (!item.linkUrl) return if (!item.linkUrl) return
// 0= 1= 2= 3=
if (item.linkType === 1) { if (item.linkType === 1) {
//
uni.navigateTo({ uni.navigateTo({
url: item.linkUrl, url: item.linkUrl,
fail: () => { fail: () => {
// tabBar使switchTab uni.switchTab({ url: item.linkUrl })
uni.switchTab({
url: item.linkUrl
})
} }
}) })
} else if (item.linkType === 2) { } else if (item.linkType === 2) {
// webview
uni.navigateTo({ uni.navigateTo({
url: `/pages/webview/index?url=${encodeURIComponent(item.linkUrl)}` url: `/pages/webview/index?url=${encodeURIComponent(item.linkUrl)}`
}) })
@ -222,30 +202,42 @@ function handleBannerClick(item) {
* 处理导航入口点击 * 处理导航入口点击
*/ */
function handleNavigationClick(item) { function handleNavigationClick(item) {
// 线
if (item.status === 2) { if (item.status === 2) {
uni.showToast({ uni.showToast({ title: '该功能即将上线', icon: 'none', duration: 2000 })
title: '该功能即将上线',
icon: 'none',
duration: 2000
})
return return
} }
//
if (!item.linkUrl) return if (!item.linkUrl) return
uni.navigateTo({ uni.navigateTo({
url: item.linkUrl, url: item.linkUrl,
fail: () => { fail: () => {
// tabBar使switchTab
uni.switchTab({ url: item.linkUrl }) uni.switchTab({ url: item.linkUrl })
} }
}) })
} }
/** /**
* scroll-view 下拉刷新 * 跳转学业规划预约
*/
function goToPlanner() {
uni.navigateTo({ url: '/pages/planner/list/index' })
}
/**
* 跳转学习方案业务详情页
*/
function goToStudyPlan() {
uni.navigateTo({ url: '/pages/business/detail/index?type=study-plan' })
}
/**
* 跳转详细咨询业务详情页
*/
function goToConsult() {
uni.navigateTo({ url: '/pages/business/detail/index?type=consult' })
}
/**
* 下拉刷新
*/ */
async function onRefresh() { async function onRefresh() {
isRefreshing.value = true isRefreshing.value = true
@ -253,9 +245,6 @@ async function onRefresh() {
isRefreshing.value = false isRefreshing.value = false
} }
/**
* 页面加载
*/
onMounted(() => { onMounted(() => {
initPageData() initPageData()
}) })
@ -295,7 +284,7 @@ onMounted(() => {
width: 100%; width: 100%;
} }
// scroll-view //
.page-content { .page-content {
height: calc(100vh - var(--navbar-height, 0px)); height: calc(100vh - var(--navbar-height, 0px));
padding-bottom: env(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);
@ -310,7 +299,6 @@ onMounted(() => {
.banner-swiper { .banner-swiper {
width: 100%; width: 100%;
// 750:360 2:1 padding 686rpx 330rpx
height: 330rpx; height: 330rpx;
border-radius: $border-radius-lg; border-radius: $border-radius-lg;
overflow: hidden; overflow: hidden;
@ -323,6 +311,14 @@ onMounted(() => {
} }
} }
//
.section-card {
margin: $spacing-lg $spacing-lg 0;
padding: $spacing-lg;
background-color: $bg-white;
border-radius: $border-radius-xl;
}
// //
.section-header { .section-header {
display: flex; display: flex;
@ -344,10 +340,7 @@ onMounted(() => {
} }
} }
// - // -
.assessment-section {
padding: $spacing-xl $spacing-lg $spacing-lg;
.assessment-grid { .assessment-grid {
display: flex; display: flex;
gap: $spacing-md; gap: $spacing-md;
@ -355,17 +348,31 @@ onMounted(() => {
.assessment-card { .assessment-card {
position: relative; position: relative;
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
width: 200rpx; justify-content: center;
height: 240rpx;
border-radius: $border-radius-xl;
overflow: hidden;
// - /
&--0 {
background: linear-gradient(135deg, #FF7B6B, #FF5B5B);
}
// - /
&--1 {
background: linear-gradient(135deg, #FFD080, #FFB347);
}
.coming-soon-tag { .coming-soon-tag {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
background-color: $warning-color; background-color: rgba(0, 0, 0, 0.3);
padding: 4rpx 16rpx; padding: 6rpx 20rpx;
border-radius: 0 $border-radius-xl 0 $border-radius-lg; border-radius: 0 $border-radius-xl 0 $border-radius-lg;
z-index: 1; z-index: 1;
@ -376,33 +383,68 @@ onMounted(() => {
} }
.assessment-icon { .assessment-icon {
width: 200rpx; width: 100rpx;
height: 200rpx; height: 100rpx;
border-radius: $border-radius-xl; margin-bottom: $spacing-sm;
} }
.assessment-name { .assessment-name {
margin-top: $spacing-sm; font-size: $font-size-md;
font-weight: $font-weight-bold;
color: $text-white;
}
}
// -
.planner-btn {
display: flex;
align-items: center;
justify-content: center;
height: 96rpx;
border-radius: $border-radius-round;
background: linear-gradient(90deg, #FFB347, #FF8C42);
&__text {
font-size: $font-size-lg;
font-weight: $font-weight-bold;
color: $text-white;
letter-spacing: 4rpx;
}
}
// -
.more-grid {
display: flex;
gap: $spacing-md;
}
.more-card {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
height: 160rpx;
padding: 0 $spacing-lg;
border-radius: $border-radius-xl;
overflow: hidden;
&--plan {
background: linear-gradient(135deg, #FFF5EB, #FFE8D5);
}
&--consult {
background: linear-gradient(135deg, #FFE8EC, #FFD5DC);
}
&__title {
font-size: $font-size-md; font-size: $font-size-md;
font-weight: $font-weight-bold; font-weight: $font-weight-bold;
color: $text-color; color: $text-color;
} }
}
}
// - &__icon {
.promotion-section { width: 80rpx;
padding: $spacing-lg $spacing-lg 0; height: 80rpx;
.promotion-image {
width: 100%;
display: block;
margin-bottom: $spacing-md;
border-radius: $border-radius-lg;
&:last-child {
margin-bottom: 0;
}
} }
} }