386 lines
8.4 KiB
Vue
386 lines
8.4 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view v-if="sub" class="hero" :class="sub.tint" :style="headPad">
|
|
<view class="hero-main">
|
|
<view class="hero-icon">
|
|
<FaIcon :name="sub.icon" color="#ffffff" :size="24" />
|
|
</view>
|
|
<view class="hero-meta">
|
|
<text class="hero-name">{{ sub.title }}</text>
|
|
<text class="hero-desc">{{ sub.desc }}</text>
|
|
</view>
|
|
<view v-if="isOa" class="hero-notice" hover-class="hero-notice-on" @tap="openNotices">
|
|
<FaIcon name="bell" color="#ffffff" :size="20" />
|
|
<view v-if="noticeCount > 0" class="notice-badge">{{ noticeCount > 99 ? '99+' : noticeCount }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view v-if="sub" class="content">
|
|
<scroll-view v-if="visited.home" v-show="activeTab === 'home'" class="pane" scroll-y>
|
|
<SubHome :slug="slug" embedded @switch-tab="switchByIndex" @back="goBackNav" />
|
|
<view class="pane-bottom" />
|
|
</scroll-view>
|
|
<scroll-view v-if="visited.functions" v-show="activeTab === 'functions'" class="pane" scroll-y>
|
|
<SubFunctions :slug="slug" embedded @switch-tab="switchByIndex" @back="goBackNav" />
|
|
<view class="pane-bottom" />
|
|
</scroll-view>
|
|
<scroll-view v-if="visited.mine" v-show="activeTab === 'mine'" class="pane" scroll-y>
|
|
<SubMine :slug="slug" embedded @switch-tab="switchByIndex" @back="goBackNav" />
|
|
<view class="pane-bottom" />
|
|
</scroll-view>
|
|
</view>
|
|
|
|
<view v-if="noticeVisible" class="popup-mask" @tap="closeNotices">
|
|
<view class="notice-sheet" @tap.stop>
|
|
<view class="notice-head">
|
|
<text class="notice-sheet-title">最新公告</text>
|
|
<view class="notice-more" @tap="goNoticeList">
|
|
<text class="notice-more-text">全部</text>
|
|
<FaIcon name="chevron-right" color="#8a94ad" :size="11" />
|
|
</view>
|
|
</view>
|
|
<scroll-view class="notice-body" scroll-y :show-scrollbar="false">
|
|
<view v-if="notices.length === 0" class="notice-empty">
|
|
<FaIcon name="bullhorn" color="#c0c4cc" :size="26" />
|
|
<text class="notice-empty-text">暂无公告</text>
|
|
</view>
|
|
<view
|
|
v-for="item in notices"
|
|
:key="item.id"
|
|
class="notice-item"
|
|
@tap="goNoticeDetail(item.id)"
|
|
>
|
|
<view class="notice-dot" :class="{ 'notice-dot-top': item.is_top }" />
|
|
<view class="notice-item-body">
|
|
<text class="notice-item-title">{{ item.title }}</text>
|
|
<text class="notice-item-time">{{ item.publish_time || item.publisher_name || '' }}</text>
|
|
</view>
|
|
<FaIcon name="chevron-right" color="#c0c4cc" :size="11" />
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
|
|
<AppTabbar variant="switch" :current="activeTab" :tabs="tabs" @change="onTabChange" />
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, computed } from 'vue'
|
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
|
import { getSubsystem } from '@/config/subsystems.js'
|
|
import { mpHeadPad } from '@/utils/mpHead.js'
|
|
import { fetchNotices } from '@/api/oa.js'
|
|
import { isLoggedIn } from '@/utils/auth.js'
|
|
import { getGuestToken } from '@/utils/guest.js'
|
|
import AppTabbar from '@/components/AppTabbar.vue'
|
|
import SubHome from '@/components/sub/SubHome.vue'
|
|
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
|
import SubMine from '@/components/sub/SubMine.vue'
|
|
|
|
const TAB_ORDER = ['home', 'functions', 'mine']
|
|
const tabs = [
|
|
{ name: 'home', text: '首页', icon: 'house' },
|
|
{ name: 'functions', text: '功能', icon: 'table-cells' },
|
|
{ name: 'mine', text: '回平台', icon: 'arrow-left' }
|
|
]
|
|
|
|
const slug = ref('')
|
|
const sub = ref(null)
|
|
const activeTab = ref('home')
|
|
const visited = ref({ home: true, functions: false, mine: false })
|
|
|
|
const headPad = mpHeadPad()
|
|
|
|
const isOa = computed(() => String((sub.value && sub.value.module) || '').toLowerCase() === 'oa')
|
|
|
|
const notices = ref([])
|
|
const noticeTotal = ref(0)
|
|
const noticeVisible = ref(false)
|
|
|
|
const noticeCount = computed(() => Number(noticeTotal.value) || notices.value.length)
|
|
|
|
async function loadNotices() {
|
|
if (!isOa.value) return
|
|
if (!isLoggedIn() && !getGuestToken()) return
|
|
try {
|
|
const res = await fetchNotices({ pageSize: 10 })
|
|
notices.value = res.list || []
|
|
noticeTotal.value = res.total || 0
|
|
} catch (e) {
|
|
notices.value = []
|
|
noticeTotal.value = 0
|
|
}
|
|
}
|
|
|
|
function openNotices() {
|
|
noticeVisible.value = true
|
|
if (!notices.value.length && noticeTotal.value > 0) loadNotices()
|
|
}
|
|
|
|
function closeNotices() {
|
|
noticeVisible.value = false
|
|
}
|
|
|
|
function goNoticeList() {
|
|
closeNotices()
|
|
uni.navigateTo({ url: '/pages/oa/notice/index' })
|
|
}
|
|
|
|
function goNoticeDetail(id) {
|
|
closeNotices()
|
|
uni.navigateTo({ url: `/pages/oa/notice/detail?id=${id}` })
|
|
}
|
|
|
|
onLoad((options) => {
|
|
slug.value = options && options.slug ? options.slug : 'crm'
|
|
sub.value = getSubsystem(slug.value)
|
|
if (!sub.value) uni.reLaunch({ url: '/pages/nav/nav' })
|
|
})
|
|
|
|
onShow(() => {
|
|
loadNotices()
|
|
})
|
|
|
|
function onTabChange(name) {
|
|
activeTab.value = name
|
|
if (!visited.value[name]) visited.value[name] = true
|
|
}
|
|
|
|
function switchByIndex(i) {
|
|
onTabChange(TAB_ORDER[i] || 'home')
|
|
}
|
|
|
|
function goBackNav() {
|
|
uni.navigateBack({ fail: () => uni.reLaunch({ url: '/pages/nav/nav' }) })
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/src/styles/page-common.scss';
|
|
|
|
.page {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100vh;
|
|
background: $color-bg-page;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.hero {
|
|
flex-shrink: 0;
|
|
position: relative;
|
|
z-index: 0;
|
|
padding: calc(var(--status-bar-height, 44px) + 32rpx) $page-padding-x 72rpx;
|
|
}
|
|
|
|
.hero-main {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 22rpx;
|
|
margin-top: 44rpx;
|
|
}
|
|
|
|
.hero-icon {
|
|
width: 88rpx;
|
|
height: 88rpx;
|
|
border-radius: 26rpx;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border: 1rpx solid rgba(255, 255, 255, 0.32);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.hero-meta {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.hero-name {
|
|
font-size: 38rpx;
|
|
font-weight: 700;
|
|
letter-spacing: 1rpx;
|
|
color: #ffffff;
|
|
}
|
|
|
|
.hero-desc {
|
|
margin-top: 10rpx;
|
|
font-size: 22rpx;
|
|
line-height: 1.4;
|
|
color: rgba(255, 255, 255, 0.82);
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
min-height: 0;
|
|
position: relative;
|
|
z-index: 1;
|
|
margin-top: -44rpx;
|
|
border-radius: 32rpx 32rpx 0 0;
|
|
background: $color-bg-page;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.pane {
|
|
height: 100%;
|
|
}
|
|
|
|
.pane-bottom {
|
|
height: 32rpx;
|
|
}
|
|
|
|
.hero-notice {
|
|
position: relative;
|
|
margin-left: auto;
|
|
flex-shrink: 0;
|
|
width: 64rpx;
|
|
height: 64rpx;
|
|
border-radius: 50%;
|
|
background: rgba(255, 255, 255, 0.18);
|
|
border: 1rpx solid rgba(255, 255, 255, 0.28);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
&.hero-notice-on {
|
|
opacity: 0.7;
|
|
}
|
|
}
|
|
|
|
.notice-badge {
|
|
position: absolute;
|
|
top: -10rpx;
|
|
right: -10rpx;
|
|
min-width: 32rpx;
|
|
height: 32rpx;
|
|
padding: 0 8rpx;
|
|
box-sizing: border-box;
|
|
border-radius: $radius-full;
|
|
background: #f04438;
|
|
color: #ffffff;
|
|
font-size: 20rpx;
|
|
line-height: 32rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
.popup-mask {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
z-index: 999;
|
|
background: rgba(15, 23, 42, 0.5);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 60rpx;
|
|
}
|
|
|
|
.notice-sheet {
|
|
width: 100%;
|
|
max-height: 900rpx;
|
|
background: $color-card;
|
|
border-radius: $radius-lg;
|
|
box-shadow: $shadow-float;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
@include sheet-responsive(560px);
|
|
}
|
|
|
|
.notice-head {
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 26rpx 28rpx 18rpx;
|
|
border-bottom: 1rpx solid $color-divider;
|
|
}
|
|
|
|
.notice-sheet-title {
|
|
font-size: 30rpx;
|
|
font-weight: 600;
|
|
color: $color-text;
|
|
}
|
|
|
|
.notice-more {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4rpx;
|
|
}
|
|
|
|
.notice-more-text {
|
|
font-size: 24rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.notice-body {
|
|
flex: 1;
|
|
height: 0;
|
|
padding: 8rpx 28rpx 20rpx;
|
|
}
|
|
|
|
.notice-empty {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 12rpx;
|
|
padding: 80rpx 0;
|
|
}
|
|
|
|
.notice-empty-text {
|
|
font-size: 24rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.notice-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14rpx;
|
|
padding: 22rpx 0;
|
|
border-bottom: 1rpx solid $color-divider;
|
|
|
|
&:last-child {
|
|
border-bottom: none;
|
|
}
|
|
}
|
|
|
|
.notice-dot {
|
|
flex-shrink: 0;
|
|
width: 12rpx;
|
|
height: 12rpx;
|
|
border-radius: 50%;
|
|
background: $color-primary-light;
|
|
|
|
&.notice-dot-top {
|
|
background: #f04438;
|
|
}
|
|
}
|
|
|
|
.notice-item-body {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6rpx;
|
|
}
|
|
|
|
.notice-item-title {
|
|
font-size: 28rpx;
|
|
color: $color-text;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.notice-item-time {
|
|
font-size: 22rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
</style> |