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 class="assessment-section" v-if="navigationList.length > 0">
<view class="section-card" v-if="navigationList.length > 0">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">专业测评</text>
@ -54,12 +54,13 @@
class="assessment-card"
v-for="(item, index) in navigationList"
:key="index"
:class="'assessment-card--' + index"
@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>
</view> -->
</view>
<image
:src="item.imageUrl"
mode="aspectFit"
@ -70,19 +71,41 @@
</view>
</view>
<!-- 关于我们 - 宣传长图 -->
<view class="promotion-section" v-if="promotionList.length > 0">
<!-- 学业规划 -->
<view class="section-card">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">关于我们</text>
<text class="section-title">学业规划</text>
</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
src="/static/icons/study-plan.png"
mode="aspectFit"
class="more-card__icon"
/>
</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>
<image
v-for="(item, index) in promotionList"
:key="index"
:src="item.imageUrl"
mode="widthFix"
class="promotion-image"
/>
</view>
<!-- 加载状态 -->
@ -90,16 +113,17 @@
<Loading type="inline" :loading="true" />
</view>
<!-- 底部安全间距 -->
<view class="safe-bottom"></view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { ref, onMounted } from 'vue'
import { useUserStore } from '@/store/user.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'
const userStore = useUserStore()
@ -109,11 +133,7 @@ const { statusBarHeight, navbarHeight, totalNavbarHeight } = useNavbar()
const pageLoading = ref(true)
const isRefreshing = ref(false)
const bannerList = ref([])
const assessmentList = ref([])
const navigationList = ref([])
const promotionList = ref([])
//
/**
* 加载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() {
pageLoading.value = true
try {
//
userStore.restoreFromStorage()
//
await Promise.all([
loadBannerList(),
loadAssessmentList(),
loadNavigationList(),
loadPromotionList()
loadNavigationList()
])
} finally {
pageLoading.value = false
@ -197,21 +184,14 @@ async function initPageData() {
*/
function handleBannerClick(item) {
if (!item.linkUrl) return
// 0= 1= 2= 3=
if (item.linkType === 1) {
//
uni.navigateTo({
url: item.linkUrl,
fail: () => {
// tabBar使switchTab
uni.switchTab({
url: item.linkUrl
})
uni.switchTab({ url: item.linkUrl })
}
})
} else if (item.linkType === 2) {
// webview
uni.navigateTo({
url: `/pages/webview/index?url=${encodeURIComponent(item.linkUrl)}`
})
@ -222,30 +202,42 @@ function handleBannerClick(item) {
* 处理导航入口点击
*/
function handleNavigationClick(item) {
// 线
if (item.status === 2) {
uni.showToast({
title: '该功能即将上线',
icon: 'none',
duration: 2000
})
uni.showToast({ title: '该功能即将上线', icon: 'none', duration: 2000 })
return
}
//
if (!item.linkUrl) return
uni.navigateTo({
url: item.linkUrl,
fail: () => {
// tabBar使switchTab
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() {
isRefreshing.value = true
@ -253,9 +245,6 @@ async function onRefresh() {
isRefreshing.value = false
}
/**
* 页面加载
*/
onMounted(() => {
initPageData()
})
@ -277,12 +266,12 @@ onMounted(() => {
right: 0;
background-color: $bg-white;
z-index: 999;
.navbar-content {
display: flex;
align-items: center;
justify-content: center;
.navbar-title {
font-size: 34rpx;
font-weight: $font-weight-medium;
@ -295,7 +284,7 @@ onMounted(() => {
width: 100%;
}
// scroll-view
//
.page-content {
height: calc(100vh - var(--navbar-height, 0px));
padding-bottom: env(safe-area-inset-bottom);
@ -307,14 +296,13 @@ onMounted(() => {
padding: 0 $spacing-lg;
box-sizing: border-box;
margin-top: $spacing-sm;
.banner-swiper {
width: 100%;
// 750:360 2:1 padding 686rpx 330rpx
height: 330rpx;
border-radius: $border-radius-lg;
overflow: hidden;
.banner-image {
width: 100%;
height: 100%;
@ -323,12 +311,20 @@ onMounted(() => {
}
}
//
.section-card {
margin: $spacing-lg $spacing-lg 0;
padding: $spacing-lg;
background-color: $bg-white;
border-radius: $border-radius-xl;
}
//
.section-header {
display: flex;
align-items: center;
margin-bottom: $spacing-lg;
.section-indicator {
width: 8rpx;
height: 36rpx;
@ -336,7 +332,7 @@ onMounted(() => {
border-radius: $border-radius-xs;
margin-right: $spacing-sm;
}
.section-title {
font-size: $font-size-xl;
font-weight: $font-weight-bold;
@ -344,65 +340,111 @@ onMounted(() => {
}
}
// -
.assessment-section {
padding: $spacing-xl $spacing-lg $spacing-lg;
.assessment-grid {
display: flex;
gap: $spacing-md;
// -
.assessment-grid {
display: flex;
gap: $spacing-md;
}
.assessment-card {
position: relative;
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 240rpx;
border-radius: $border-radius-xl;
overflow: hidden;
// - /
&--0 {
background: linear-gradient(135deg, #FF7B6B, #FF5B5B);
}
.assessment-card {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
width: 200rpx;
.coming-soon-tag {
position: absolute;
top: 0;
right: 0;
background-color: $warning-color;
padding: 4rpx 16rpx;
border-radius: 0 $border-radius-xl 0 $border-radius-lg;
z-index: 1;
text {
font-size: $font-size-xs;
color: $text-white;
}
}
.assessment-icon {
width: 200rpx;
height: 200rpx;
border-radius: $border-radius-xl;
}
.assessment-name {
margin-top: $spacing-sm;
font-size: $font-size-md;
font-weight: $font-weight-bold;
color: $text-color;
// - /
&--1 {
background: linear-gradient(135deg, #FFD080, #FFB347);
}
.coming-soon-tag {
position: absolute;
top: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.3);
padding: 6rpx 20rpx;
border-radius: 0 $border-radius-xl 0 $border-radius-lg;
z-index: 1;
text {
font-size: $font-size-xs;
color: $text-white;
}
}
.assessment-icon {
width: 100rpx;
height: 100rpx;
margin-bottom: $spacing-sm;
}
.assessment-name {
font-size: $font-size-md;
font-weight: $font-weight-bold;
color: $text-white;
}
}
// -
.promotion-section {
padding: $spacing-lg $spacing-lg 0;
.promotion-image {
width: 100%;
display: block;
margin-bottom: $spacing-md;
border-radius: $border-radius-lg;
&:last-child {
margin-bottom: 0;
}
// -
.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-weight: $font-weight-bold;
color: $text-color;
}
&__icon {
width: 80rpx;
height: 80rpx;
}
}