edu/uniapp/src/pages/index/index.vue

404 lines
10 KiB
Vue
Raw Normal View History

2022-08-26 09:52:43 +00:00
<template>
2024-10-10 06:10:49 +00:00
<page-meta :page-style="$theme.pageStyle">
<!-- #ifndef H5 -->
<navigation-bar :front-color="$theme.navColor" :background-color="$theme.navBgColor" />
2024-10-10 06:10:49 +00:00
<!-- #endif -->
</page-meta>
<view class="index">
2026-03-18 06:37:30 +00:00
<!-- 顶部区域Logo + 欢迎文字 + 首页图片 -->
<view class="header-section">
<image
src="/static/yubaoming/school_logo.png"
mode="aspectFit"
class="school-logo"
/>
<view class="welcome-text">
<view class="title">您好招生老师</view>
<view class="subtitle">祝您招生顺利业绩长虹</view>
</view>
<image
src="/static/yubaoming/home.png"
mode="widthFix"
class="home-image"
/>
<!-- 快捷操作标题 -->
<view class="section-title" v-if="isLogin">
<view class="title-icon"></view>
<text>快捷操作</text>
2022-09-09 03:06:58 +00:00
</view>
</view>
2024-10-10 06:10:49 +00:00
<!-- 主要内容区域 -->
<view class="main-content">
<!-- 快捷操作入口 -->
<view class="quick-actions" v-if="isLogin">
2026-03-18 06:37:30 +00:00
<view class="action-item" @click="goToPreRegistration">
<view class="action-icon blue">
<u-icon name="edit-pen" size="40" color="#FFFFFF"></u-icon>
</view>
2026-03-18 06:37:30 +00:00
<text class="action-text">预报名</text>
</view>
<view class="action-item" @click="goToMyRecruitment">
<view class="action-icon green">
<u-icon name="list" size="40" color="#FFFFFF"></u-icon>
</view>
2026-03-18 06:37:30 +00:00
<text class="action-text">我的招生</text>
</view>
2026-03-24 02:58:18 +00:00
<view class="action-item" @click="goToPayment">
<view class="action-icon orange">
<u-icon name="rmb-circle" size="40" color="#FFFFFF"></u-icon>
</view>
<text class="action-text">缴费</text>
</view>
2026-03-18 06:37:30 +00:00
<view class="action-item" @click="goToUser">
<view class="action-icon purple">
<u-icon name="account" size="40" color="#FFFFFF"></u-icon>
</view>
2026-03-18 06:37:30 +00:00
<text class="action-text">个人中心</text>
</view>
</view>
<!-- 未登录提示 -->
<view class="login-tip" v-if="!isLogin">
<view class="tip-icon">🔒</view>
<view class="tip-text">登录后查看更多功能</view>
<view class="tip-button" @click="goToLogin">立即登录</view>
</view>
2026-02-06 07:42:05 +00:00
</view>
2024-10-10 06:10:49 +00:00
<!-- #ifdef H5 -->
<view class="footer" v-if="isH5">
2024-10-10 06:10:49 +00:00
<router-navigate
class="footer-link"
2024-10-10 06:10:49 +00:00
:to="{
path: '/pages/webview/webview',
query: {
url: item.value
}
}"
v-for="item in appStore.getCopyrightConfig"
:key="item.key"
>
{{ item.key }}
</router-navigate>
</view>
<!-- #endif -->
<!-- 返回顶部按钮 -->
<u-back-top
:scroll-top="scrollTop"
:top="100"
:customStyle="{
backgroundColor: '#FFF',
color: '#000',
boxShadow: '0px 3px 6px rgba(0, 0, 0, 0.1)'
}"
>
</u-back-top>
<!-- #ifdef MP -->
<!-- 微信小程序隐私弹窗 -->
<MpPrivacyPopup></MpPrivacyPopup>
<!-- #endif -->
2022-08-26 09:52:43 +00:00
</view>
</template>
2022-09-07 13:00:03 +00:00
<script setup lang="ts">
import { getIndex } from '@/api/shop'
import { getEnrollmentStatistical } from '@/api/app'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { computed, reactive, ref } from 'vue'
import { useAppStore } from '@/stores/app'
import { useUserStore } from '@/stores/user'
import { storeToRefs } from 'pinia'
2024-10-10 06:10:49 +00:00
// #ifdef MP
import MpPrivacyPopup from './component/mp-privacy-popup.vue'
// #endif
const appStore = useAppStore()
const userStore = useUserStore()
const { isLogin, userInfo } = storeToRefs(userStore)
2022-09-08 08:28:56 +00:00
const state = reactive<{
pages: any[]
2024-10-10 06:10:49 +00:00
meta: any[]
2022-09-09 03:06:58 +00:00
article: any[]
2022-09-08 08:28:56 +00:00
}>({
2022-09-09 03:06:58 +00:00
pages: [],
2024-10-10 06:10:49 +00:00
meta: [],
article: []
2024-10-10 06:10:49 +00:00
})
const scrollTop = ref<number>(0)
const stats = ref({
total: 0,
today: 0,
week: 0
2024-10-10 06:10:49 +00:00
})
const isH5 = ref(false)
// #ifdef H5
isH5.value = true
// #endif
2024-10-10 06:10:49 +00:00
const getData = async () => {
try {
const data = await getIndex()
if (data?.page?.data) {
state.pages = JSON.parse(data.page.data)
}
if (data?.page?.meta) {
state.meta = JSON.parse(data.page.meta)
}
state.article = data?.article || []
} catch (error) {
console.error('获取首页数据失败:', error)
}
2024-10-10 06:10:49 +00:00
}
const getStats = async () => {
if (!isLogin.value) {
return
}
try {
const res = await getEnrollmentStatistical()
// 接口直接返回数据对象,没有 code 包装
if (res && res.total_enroll_count !== undefined) {
stats.value = {
total: res.total_enroll_count,
today: res.today_enroll_count,
week: res.week_enroll_count
}
}
} catch (error) {
console.error('获取招生统计失败:', error)
}
2022-09-07 13:00:03 +00:00
}
2022-09-09 09:58:18 +00:00
2026-02-06 07:42:05 +00:00
const goToPreRegistration = () => {
uni.navigateTo({
url: '/pages/pre_registration/pre_registration'
})
}
const goToMyRecruitment = () => {
uni.navigateTo({
url: '/pages/my_recruitment/my_recruitment'
})
}
const goToUser = () => {
uni.switchTab({
url: '/pages/user/user'
})
}
2026-03-24 02:58:18 +00:00
const goToPayment = () => {
uni.navigateTo({
url: '/pages/payment/payment'
})
}
const goToLogin = () => {
uni.navigateTo({
url: '/pages/login/login'
})
}
const shareQrcode = () => {
uni.switchTab({
url: '/pages/user/user'
})
setTimeout(() => {
uni.$emit('openQrcodeModal')
}, 300)
}
onLoad(() => {
getData()
2024-10-10 06:10:49 +00:00
})
onShow(async () => {
// 等待一下确保登录状态已确定
await new Promise(resolve => setTimeout(resolve, 100))
getStats()
})
2022-09-07 13:00:03 +00:00
</script>
2022-08-26 09:52:43 +00:00
2024-10-10 06:10:49 +00:00
<style lang="scss" scoped>
.index {
min-height: 100vh;
background-color: #F5F7FA;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
}
2026-03-18 06:37:30 +00:00
/* 顶部区域 */
.header-section {
display: flex;
flex-direction: column;
align-items: center;
padding: 40rpx 30rpx;
position: relative;
.school-logo {
width: 350rpx;
height: 350rpx;
margin-top: -40rpx;
margin-bottom: -80rpx;
}
.welcome-text {
2026-03-18 06:37:30 +00:00
text-align: center;
margin-bottom: -100rpx;
.title {
font-size: 40rpx;
font-weight: 600;
2026-03-18 06:37:30 +00:00
color: #000000;
margin-bottom: 12rpx;
}
.subtitle {
font-size: 28rpx;
2026-03-18 06:37:30 +00:00
color: #333333;
}
}
2026-03-18 06:37:30 +00:00
.home-image {
width: calc(100% + 60rpx);
margin-left: -30rpx;
margin-right: -30rpx;
}
}
/* 主要内容区域 */
.main-content {
2026-03-18 06:37:30 +00:00
padding: 0 30rpx 30rpx;
2024-10-10 06:10:49 +00:00
position: relative;
z-index: 1;
}
2026-03-18 06:37:30 +00:00
/* 快捷操作标题 */
.section-title {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: 600;
color: #000000;
padding: 20rpx 0;
position: absolute;
bottom: 50rpx;
left: 30rpx;
z-index: 10;
.title-icon {
margin-right: 12rpx;
width: 10rpx;
height: 32rpx;
background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
border-radius: 3rpx;
}
}
/* 快捷操作 */
.quick-actions {
2026-03-18 06:37:30 +00:00
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 20rpx;
margin-top: -30rpx;
.action-item {
flex: 1;
display: flex;
2026-03-18 06:37:30 +00:00
flex-direction: column;
align-items: center;
2026-03-18 06:37:30 +00:00
background: #FFFFFF;
border-radius: 24rpx;
padding: 30rpx 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
2026-03-18 06:37:30 +00:00
&:active {
opacity: 0.7;
}
2026-03-18 06:37:30 +00:00
.action-icon {
width: 100rpx;
height: 100rpx;
border-radius: 24rpx;
display: flex;
align-items: center;
2026-03-18 06:37:30 +00:00
justify-content: center;
margin-bottom: 16rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
2026-03-18 06:37:30 +00:00
&.blue {
background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
}
2026-03-18 06:37:30 +00:00
&.green {
background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}
2026-03-18 06:37:30 +00:00
&.purple {
background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
}
2026-03-24 02:58:18 +00:00
&.orange {
background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}
}
2026-03-18 06:37:30 +00:00
.action-text {
font-size: 26rpx;
color: #1F2937;
font-weight: 500;
}
}
2024-10-10 06:10:49 +00:00
}
/* 未登录提示 */
.login-tip {
background: #FFFFFF;
border-radius: 24rpx;
padding: 60rpx 40rpx;
text-align: center;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
.tip-icon {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.tip-text {
font-size: 30rpx;
color: #6B7280;
margin-bottom: 30rpx;
}
.tip-button {
display: inline-block;
background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
color: #FFFFFF;
font-size: 30rpx;
font-weight: 500;
padding: 20rpx 60rpx;
border-radius: 40rpx;
&:active {
opacity: 0.9;
}
}
}
/* 底部 */
.footer {
padding: 40rpx 30rpx;
text-align: center;
.footer-link {
font-size: 24rpx;
color: #9CA3AF;
margin: 0 16rpx;
2022-09-09 03:06:58 +00:00
}
}
</style>