批量优化
This commit is contained in:
1 parent
e3db229f41
commit
aa92ca40a2
79 files changed
+7495
-1104
No files matched your search
+3
-2
@@ -17,14 +17,15 @@
|
||||
<style lang="scss">
|
||||
@import 'uview-plus/index.scss';
|
||||
@import './src/styles/theme.scss';
|
||||
@import './src/styles/tint.scss';
|
||||
@import './src/styles/fontawesome.scss';
|
||||
@import './src/styles/rich-content.scss';
|
||||
|
||||
page {
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
background-color: #f5f7fa;
|
||||
color: #303133;
|
||||
background-color: $color-bg-page;
|
||||
color: $color-text;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
+79
-2
@@ -13,9 +13,10 @@ export function login(data) {
|
||||
}
|
||||
|
||||
/* ==================== 统一认证中心(UAC) ====================
|
||||
* APP 不走浏览器跳转,直接用密码直连模式:
|
||||
* APP / 小程序不走浏览器跳转,直接用密码直连模式:
|
||||
* POST /auth/login 拿 access + refresh,多企业时再调 switch-tenant。
|
||||
* 开关:VITE_AUTH_MODE=sso 时启用(见 utils/auth.js 的 isSSOEnabled)
|
||||
* 开关:默认即为统一认证,VITE_AUTH_MODE=legacy 时回退旧直登
|
||||
* (见 utils/auth.js 的 isSSOEnabled)
|
||||
* ============================================================ */
|
||||
|
||||
/** 统一认证:账号密码登录 */
|
||||
@@ -36,6 +37,82 @@ export function switchTenant(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 统一认证:拉取当前登录用户(userinfo,返回扁平结构无 code 包装) */
|
||||
export function fetchUserInfo() {
|
||||
return request({
|
||||
url: '/auth/userinfo',
|
||||
method: 'GET',
|
||||
silent: true
|
||||
})
|
||||
}
|
||||
|
||||
/** 统一认证:登录人机验证配置(极验 captcha_id 等) */
|
||||
export function getAuthVerifyConfig(params = {}) {
|
||||
return request({
|
||||
url: '/auth/verify-config',
|
||||
method: 'GET',
|
||||
data: params,
|
||||
silent: true,
|
||||
timeout: 8000
|
||||
})
|
||||
}
|
||||
|
||||
/** 统一认证:单点登出(吊销会话与令牌) */
|
||||
export function logoutUAC() {
|
||||
return request({
|
||||
url: '/auth/logout',
|
||||
method: 'POST',
|
||||
silent: true,
|
||||
timeout: 5000
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请「移动端免登录票据」:用当前登录态换一个一次性票据,
|
||||
* Web 端拿它换自己的令牌,实现移动端打开 Web 功能页时不二次登录。
|
||||
* 票据一次性、60 秒有效。
|
||||
*/
|
||||
export function createAppTicket(clientId = 'yz-backend') {
|
||||
return request({
|
||||
url: '/auth/app-ticket',
|
||||
method: 'POST',
|
||||
data: { client_id: clientId },
|
||||
silent: true,
|
||||
timeout: 8000
|
||||
})
|
||||
}
|
||||
|
||||
/* ==================== 微信小程序一键登录 ====================
|
||||
* 仅小程序端可用:uni.login 拿 code + getPhoneNumber 拿动态 code,
|
||||
* 由服务端换取 openid / 手机号并定位统一身份,签发同一套 UAC 令牌。
|
||||
* ============================================================ */
|
||||
|
||||
/** 小程序登录是否已开通(未开通时前端隐藏一键登录入口) */
|
||||
export function getMiniappLoginConfig() {
|
||||
return request({
|
||||
url: '/auth/wechat/miniapp/config',
|
||||
method: 'GET',
|
||||
silent: true,
|
||||
timeout: 8000
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序一键登录
|
||||
* @param {{ code: string, phoneCode?: string }} params code=uni.login 的 code;phoneCode=getPhoneNumber 的动态 code
|
||||
*/
|
||||
export function loginByMiniapp({ code, phoneCode = '' } = {}) {
|
||||
return request({
|
||||
url: '/auth/wechat/miniapp/login',
|
||||
method: 'POST',
|
||||
data: {
|
||||
client_id: 'yz-miniapp',
|
||||
code,
|
||||
phone_code: phoneCode
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 统一认证:刷新访问令牌 */
|
||||
export function refreshTokenUAC(data) {
|
||||
return request({
|
||||
|
||||
@@ -59,3 +59,57 @@ export function resolveBaseURL() {
|
||||
export function getBaseURL() {
|
||||
return resolveBaseURL()
|
||||
}
|
||||
|
||||
/**
|
||||
* 租户 Web 端(管理后台)地址。
|
||||
*
|
||||
* 移动端作为 ERP/OA/CRM/CMS 的聚合入口,绝大多数业务功能仍在 Web 端实现,
|
||||
* 端上通过 webview 容器打开对应页面。Web 端已统一认证:首次打开会跳
|
||||
* /auth/login 登录页,在 webview 内登录一次后会话保持。
|
||||
*
|
||||
* 可用环境变量 VITE_WEB_CONSOLE_BASE 覆盖(本地联调指向开发域名)。
|
||||
*/
|
||||
export function getWebConsoleBase() {
|
||||
let base = ''
|
||||
try {
|
||||
base =
|
||||
(typeof import.meta !== 'undefined' &&
|
||||
import.meta.env &&
|
||||
import.meta.env.VITE_WEB_CONSOLE_BASE) ||
|
||||
''
|
||||
} catch (e) {
|
||||
base = ''
|
||||
}
|
||||
if (!base || base === 'undefined' || base === 'null') {
|
||||
base = 'https://back.yunzer.cn'
|
||||
}
|
||||
return String(base).replace(/\/$/, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* 由菜单 path 拼出 Web 端深链。
|
||||
* Web 端是 hash 路由(createWebHashHistory),因此形如 https://back.yunzer.cn/#/apps/crm/clue
|
||||
*/
|
||||
export function resolveWebConsoleURL(path) {
|
||||
const p = String(path || '').trim()
|
||||
if (!p) return ''
|
||||
return `${getWebConsoleBase()}/#${p.startsWith('/') ? p : `/${p}`}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼出「移动端免登录」深链。
|
||||
*
|
||||
* Web 端只认自己 localStorage 里的令牌,移动端登录态传不过去,
|
||||
* 直接跳业务路径会再次弹出统一登录页。因此先跳 /app-login 兑换页,
|
||||
* 由它用票据换发 Web 端令牌后再回跳到 redirect 指定的业务页。
|
||||
*
|
||||
* @param {string} path 菜单 path,如 /apps/oa/dashboard
|
||||
* @param {string} ticket 一次性票据(由 /auth/app-ticket 签发)
|
||||
*/
|
||||
export function resolveWebSSOURL(path, ticket) {
|
||||
const p = String(path || '').trim()
|
||||
if (!p) return ''
|
||||
const target = p.startsWith('/') ? p : `/${p}`
|
||||
if (!ticket) return resolveWebConsoleURL(target)
|
||||
return `${getWebConsoleBase()}/#/app-login?ticket=${encodeURIComponent(ticket)}&redirect=${encodeURIComponent(target)}`
|
||||
}
|
||||
@@ -121,7 +121,11 @@ export function request(options = {}) {
|
||||
if (status < 200 || status >= 300) {
|
||||
const msg = body.msg || `请求失败(${status})`
|
||||
if (!silent) uni.showToast({ title: msg, icon: 'none' })
|
||||
reject(new Error(msg))
|
||||
const err = new Error(msg)
|
||||
// 保留响应体:登录等接口用 reason 等字段做差异化引导
|
||||
err.code = typeof body.code !== 'undefined' ? body.code : status
|
||||
err.response = body
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 移动端「工作台」接口
|
||||
*
|
||||
* /app/home 一次返回首屏所需的全部数据(应用模块卡片 + 可见菜单 + KPI),
|
||||
* 避免移动端首屏多次往返。
|
||||
*/
|
||||
import { request } from '@/api/request.js'
|
||||
|
||||
/**
|
||||
* 内存缓存:nav.vue 与 dashboard 都会拉同一份数据,
|
||||
* 30 秒内复用,避免切页反复请求。登出/切换企业时由 clearHomeCache 失效。
|
||||
*/
|
||||
const CACHE_TTL = 30 * 1000
|
||||
let cache = null
|
||||
let cacheAt = 0
|
||||
|
||||
/** 工作台聚合数据:{ user, modules, menus, stats } */
|
||||
export async function fetchHome(force = false) {
|
||||
if (!force && cache && Date.now() - cacheAt < CACHE_TTL) return cache
|
||||
const data = await request({
|
||||
url: '/app/home',
|
||||
method: 'GET',
|
||||
silent: true,
|
||||
timeout: 15000
|
||||
})
|
||||
cache = data
|
||||
cacheAt = Date.now()
|
||||
return data
|
||||
}
|
||||
|
||||
/** 登出 / 切换企业后调用,避免脏数据留在内存缓存里 */
|
||||
export function clearHomeCache() {
|
||||
cache = null
|
||||
cacheAt = 0
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<view class="app-tabbar">
|
||||
<view class="tabbar-inner">
|
||||
<view
|
||||
@@ -10,8 +10,8 @@
|
||||
>
|
||||
<FaIcon
|
||||
:name="tab.icon"
|
||||
:color="current === tab.name ? '#3c9cff' : '#909399'"
|
||||
:size="22"
|
||||
:color="current === tab.name ? '#3973ff' : '#8a94ad'"
|
||||
:size="20"
|
||||
/>
|
||||
<text class="tab-text">{{ tab.text }}</text>
|
||||
</view>
|
||||
@@ -21,44 +21,52 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* 子系统内底部 tabbar。
|
||||
*
|
||||
* 每个子系统(crm / erp / oa / cms / toolbox)都有独立的页面组与独立的 tabbar,
|
||||
* 通过 group(子系统目录名)解析路由;导航页 nav.vue 不使用本组件。
|
||||
*/
|
||||
const props = defineProps({
|
||||
group: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
current: {
|
||||
type: String,
|
||||
default: 'dashboard'
|
||||
default: 'home'
|
||||
}
|
||||
})
|
||||
|
||||
const tabs = [
|
||||
{ name: 'dashboard', text: '仪表盘', icon: 'table-cells' },
|
||||
{ name: 'features', text: '功能', icon: 'grip' },
|
||||
{ name: 'profile', text: '我的', icon: 'user' }
|
||||
{ name: 'home', text: '概览', icon: 'gauge' },
|
||||
{ name: 'functions', text: '功能', icon: 'table-cells' },
|
||||
{ name: 'todo', text: '待办', icon: 'circle-check' },
|
||||
{ name: 'mine', text: '我的', icon: 'user' }
|
||||
]
|
||||
|
||||
const routes = {
|
||||
dashboard: '/pages/dashboard/dashboard',
|
||||
features: '/pages/features/features',
|
||||
profile: '/pages/profile/profile'
|
||||
}
|
||||
|
||||
function onChange(name) {
|
||||
if (name === props.current) return
|
||||
uni.redirectTo({ url: routes[name] })
|
||||
// 子系统内部页面与 tab 一一对应,用 redirectTo 避免页面栈堆积
|
||||
uni.redirectTo({ url: `/pages/${props.group}/${name}/${name}` })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/theme.scss';
|
||||
|
||||
.app-tabbar {
|
||||
flex-shrink: 0;
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #ebeef5;
|
||||
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
background: $color-card;
|
||||
border-top: 1rpx solid $color-border;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.tabbar-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
padding: 12rpx 0 8rpx;
|
||||
padding: 10rpx 0 6rpx;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
@@ -70,14 +78,14 @@ function onChange(name) {
|
||||
padding: 8rpx 0;
|
||||
|
||||
&.active .tab-text {
|
||||
color: #3c9cff;
|
||||
font-weight: 500;
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 22rpx;
|
||||
color: #909399;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.safe-area {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<view class="app-tabbar">
|
||||
<view class="tabbar-inner">
|
||||
<view
|
||||
v-for="tab in tabs"
|
||||
:key="tab.name"
|
||||
class="tab-item"
|
||||
:class="{ active: current === tab.name }"
|
||||
@tap="onChange(tab.name)"
|
||||
>
|
||||
<FaIcon
|
||||
:name="tab.icon"
|
||||
:color="current === tab.name ? '#3973ff' : '#8a94ad'"
|
||||
:size="20"
|
||||
/>
|
||||
<text class="tab-text">{{ tab.text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="safe-area" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* 主 tabbar —— 工作台 / 应用 / 我的。
|
||||
* 仅这三个页面使用;子系统内部页面请用 AppTabbar(带 group 参数)。
|
||||
*/
|
||||
const props = defineProps({
|
||||
current: {
|
||||
type: String,
|
||||
default: 'dashboard'
|
||||
}
|
||||
})
|
||||
|
||||
const tabs = [
|
||||
{ name: 'dashboard', text: '工作台', icon: 'grip' },
|
||||
{ name: 'features', text: '应用', icon: 'th-large' },
|
||||
{ name: 'profile', text: '我的', icon: 'user' }
|
||||
]
|
||||
|
||||
const routes = {
|
||||
dashboard: '/pages/dashboard/dashboard',
|
||||
features: '/pages/features/features',
|
||||
profile: '/pages/profile/profile'
|
||||
}
|
||||
|
||||
function onChange(name) {
|
||||
if (name === props.current) return
|
||||
uni.redirectTo({ url: routes[name] })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/theme.scss';
|
||||
|
||||
.app-tabbar {
|
||||
flex-shrink: 0;
|
||||
background: $color-card;
|
||||
border-top: 1rpx solid $color-border;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.tabbar-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
padding: 10rpx 0 6rpx;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
padding: 8rpx 0;
|
||||
|
||||
&.active .tab-text {
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.safe-area {
|
||||
height: constant(safe-area-inset-bottom);
|
||||
height: env(safe-area-inset-bottom);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,315 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="head">
|
||||
<view class="head-row" @tap="goBackNav">
|
||||
<FaIcon name="chevron-left" color="#1f2b48" :size="18" />
|
||||
<text class="head-back">返回导航</text>
|
||||
</view>
|
||||
<view class="head-title-row">
|
||||
<text class="head-title">{{ sub.title }}</text>
|
||||
<text class="head-count">{{ filteredMenus.length }} 个功能</text>
|
||||
</view>
|
||||
<view class="search-bar">
|
||||
<FaIcon name="magnifying-glass" color="#8a94ad" :size="15" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
type="text"
|
||||
placeholder="搜索功能名称"
|
||||
placeholder-class="search-placeholder"
|
||||
confirm-type="search"
|
||||
/>
|
||||
<view v-if="keyword" class="search-clear" @tap="keyword = ''">
|
||||
<FaIcon name="circle-xmark" color="#c0c4cc" :size="15" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<view v-if="loadError" class="err-box" @tap="load(true)">
|
||||
<FaIcon name="triangle-exclamation" color="#f04438" :size="18" />
|
||||
<view class="err-body">
|
||||
<text class="err-title">加载失败</text>
|
||||
<text class="err-msg">{{ loadError }},点击重试</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block v-else>
|
||||
<view v-if="filteredMenus.length === 0" class="empty-box">
|
||||
<FaIcon name="magnifying-glass" color="#c0c4cc" :size="30" />
|
||||
<text class="empty-text">{{ keyword.trim() ? '没有匹配的功能' : '该子系统下暂无你可见的功能' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 功能卡片:两列宫格,与子系统导航页保持一致的视觉语言 -->
|
||||
<view v-else class="card-grid">
|
||||
<view
|
||||
v-for="(item, index) in filteredMenus"
|
||||
:key="item.id"
|
||||
class="fn-card"
|
||||
:class="{ locked: item.locked }"
|
||||
@tap="openMenu(item, item.title)"
|
||||
>
|
||||
<view class="tint-icon fn-icon" :class="item.locked ? 'tint-off' : 'tint-' + (index % 8)">
|
||||
<FaIcon :name="item.icon || fallbackIcon" color="#ffffff" :size="20" />
|
||||
</view>
|
||||
<text class="fn-name">{{ item.title }}</text>
|
||||
<text class="fn-sub">{{ item.leaf === false ? (item.docs || 0) + ' 个下级' : shortPath(item.path) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
|
||||
<AppTabbar :group="slug" current="functions" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import { useSubsystem } from '@/utils/subsystem.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
slug: { type: String, required: true }
|
||||
})
|
||||
|
||||
const { sub, loading, loadError, allMenus, load } = useSubsystem(props.slug)
|
||||
const keyword = ref('')
|
||||
|
||||
/** 模块 code → 图标,用于菜单自身没配图标时的兜底 */
|
||||
const fallbackIcon = computed(() => {
|
||||
const map = {
|
||||
crm: 'handshake',
|
||||
erp: 'boxes-stacked',
|
||||
oa: 'clipboard-check',
|
||||
cms: 'globe',
|
||||
bianjiegongju: 'wrench'
|
||||
}
|
||||
return map[String(sub.module || '').toLowerCase()] || 'file-lines'
|
||||
})
|
||||
|
||||
const filteredMenus = computed(() => {
|
||||
const q = keyword.value.trim().toLowerCase()
|
||||
const list = allMenus.value.slice().sort((a, b) => a.sort - b.sort)
|
||||
if (!q) return list
|
||||
return list.filter((m) => String(m.title || '').toLowerCase().indexOf(q) > -1)
|
||||
})
|
||||
|
||||
/** 摘要行:去掉模块前缀,只留相对路径,太长时截断 */
|
||||
function shortPath(path) {
|
||||
const p = String(path || '')
|
||||
if (!p) return '功能'
|
||||
const parts = p.split('/').filter(Boolean)
|
||||
if (parts.length <= 2) return p
|
||||
return '…/' + parts.slice(-2).join('/')
|
||||
}
|
||||
|
||||
function goBackNav() {
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
.head {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 24rpx;
|
||||
background: $color-card;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.head-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.head-back {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.head-title-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
|
||||
.head-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.head-count {
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 74rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 0 24rpx;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-full;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 74rpx;
|
||||
font-size: 27rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.search-placeholder {
|
||||
color: $color-text-muted;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8rpx;
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
@include card;
|
||||
padding: 80rpx 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.err-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
padding: 24rpx 22rpx;
|
||||
background: #fef3f2;
|
||||
border: 1rpx solid #fdd8d4;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
.err-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.err-title {
|
||||
display: block;
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.err-msg {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: #b42318;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ============ 功能卡片:两列宫格 ============
|
||||
与 nav.vue 一致用 flex 换行而非 grid,避免小程序端 wxss 对 grid 支持不稳。 */
|
||||
.card-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.fn-card {
|
||||
@include card;
|
||||
width: calc(50% - 10rpx);
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 24rpx 20rpx 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:nth-child(2n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
&.locked {
|
||||
.fn-name,
|
||||
.fn-sub {
|
||||
color: $color-text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fn-icon {
|
||||
@include tint-icon(76rpx, 20rpx);
|
||||
}
|
||||
|
||||
.fn-name {
|
||||
margin-top: 18rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.fn-sub {
|
||||
margin-top: 6rpx;
|
||||
font-size: 21rpx;
|
||||
color: $color-text-muted;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 48rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 顶部标识条 -->
|
||||
<view class="hero" :class="sub.tint">
|
||||
<view class="hero-row" @tap="goBackNav">
|
||||
<FaIcon name="chevron-left" color="#ffffff" :size="18" />
|
||||
<text class="hero-back">返回导航</text>
|
||||
</view>
|
||||
<view class="hero-main">
|
||||
<view class="hero-icon">
|
||||
<FaIcon :name="sub.icon" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
<view class="hero-meta">
|
||||
<text class="hero-name">{{ sub.title }}</text>
|
||||
<text class="hero-desc">{{ sub.desc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<!-- 未开通 -->
|
||||
<view v-if="!enabled" class="lock-box">
|
||||
<FaIcon name="lock" color="#f04438" :size="28" />
|
||||
<text class="lock-title">该子系统未开通</text>
|
||||
<text class="lock-desc">当前租户套餐未包含「{{ sub.name }}」,请联系管理员开通后使用。</text>
|
||||
</view>
|
||||
|
||||
<block v-else>
|
||||
<!-- 加载失败 -->
|
||||
<view v-if="loadError" class="err-box" @tap="load(true)">
|
||||
<FaIcon name="triangle-exclamation" color="#f04438" :size="18" />
|
||||
<view class="err-body">
|
||||
<text class="err-title">子系统加载失败</text>
|
||||
<text class="err-msg">{{ loadError }},点击重试</text>
|
||||
</view>
|
||||
<FaIcon name="rotate" color="#f04438" :size="16" />
|
||||
</view>
|
||||
|
||||
<block v-else>
|
||||
<!-- 常用功能 -->
|
||||
<view class="block">
|
||||
<view class="block-head">
|
||||
<text class="block-title">常用功能</text>
|
||||
<text class="block-sub">{{ leafMenus.length }} 个功能</text>
|
||||
</view>
|
||||
<view v-if="leafMenus.length === 0" class="empty-box">
|
||||
<text class="empty-text">该子系统下暂无你可见的功能</text>
|
||||
</view>
|
||||
<view v-else class="grid">
|
||||
<view
|
||||
v-for="item in leafMenus.slice(0, 8)"
|
||||
:key="item.id"
|
||||
class="grid-item"
|
||||
@tap="openMenu(item, item.title)"
|
||||
>
|
||||
<view class="tint-icon grid-icon" :class="sub.tint">
|
||||
<FaIcon name="circle-check" color="#ffffff" :size="20" />
|
||||
</view>
|
||||
<text class="grid-name">{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 子系统目录 -->
|
||||
<view v-if="dirMenus.length" class="block">
|
||||
<view class="block-head">
|
||||
<text class="block-title">功能分组</text>
|
||||
</view>
|
||||
<view class="list-card">
|
||||
<view
|
||||
v-for="item in dirMenus"
|
||||
:key="item.id"
|
||||
class="list-item"
|
||||
@tap="goFunctions"
|
||||
>
|
||||
<view class="dot" />
|
||||
<view class="list-body">
|
||||
<text class="list-title">{{ item.title }}</text>
|
||||
<text class="list-meta">{{ item.docs || 0 }} 个功能</text>
|
||||
</view>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 打开 Web 端完整系统(仅该子系统在 Web 端确有对应系统时展示,见 config/subsystems.js 的 webEntry) -->
|
||||
<view v-if="sub.webEntry" class="block">
|
||||
<view class="enter-card" @tap="enterSystem">
|
||||
<view class="tint-icon enter-icon" :class="sub.tint">
|
||||
<FaIcon name="display" color="#ffffff" :size="22" />
|
||||
</view>
|
||||
<view class="enter-meta">
|
||||
<text class="enter-title">进入完整{{ sub.name }}系统</text>
|
||||
<text class="enter-desc">在浏览器中打开,支持全部功能</text>
|
||||
</view>
|
||||
<FaIcon name="arrow-right" color="#c8cfdf" :size="14" />
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
|
||||
<AppTabbar :group="slug" current="home" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { openMenu, openWebPage } from '@/utils/nav.js'
|
||||
import { useSubsystem } from '@/utils/subsystem.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
slug: { type: String, required: true }
|
||||
})
|
||||
|
||||
const { sub, loading, loadError, enabled, leafMenus, dirMenus, moduleMeta, load } = useSubsystem(props.slug)
|
||||
const entered = ref(false)
|
||||
|
||||
function goBackNav() {
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
|
||||
function goFunctions() {
|
||||
uni.redirectTo({ url: `/pages/${props.slug}/functions/functions` })
|
||||
}
|
||||
|
||||
/** 打开 Web 端该模块首页(模块 path 优先,否则用第一个功能页),走票据免登录 */
|
||||
async function enterSystem() {
|
||||
if (entered.value) return
|
||||
const target =
|
||||
(moduleMeta.value && moduleMeta.value.path) ||
|
||||
(leafMenus.value[0] && leafMenus.value[0].path) ||
|
||||
''
|
||||
if (!target) {
|
||||
uni.showToast({ title: '该系统暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
entered.value = true
|
||||
try {
|
||||
await openWebPage(target, sub.name)
|
||||
} finally {
|
||||
entered.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
.hero {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 40rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.hero-back {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.hero-icon {
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border-radius: 24rpx;
|
||||
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;
|
||||
}
|
||||
|
||||
.hero-name {
|
||||
display: block;
|
||||
font-size: 38rpx;
|
||||
font-weight: 600;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.hero-desc {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.block-head {
|
||||
@include block-head;
|
||||
}
|
||||
|
||||
.block-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.block-sub {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
@include card;
|
||||
padding: 56rpx 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 25rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.err-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
padding: 24rpx 22rpx;
|
||||
background: #fef3f2;
|
||||
border: 1rpx solid #fdd8d4;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
.err-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.err-title {
|
||||
display: block;
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.err-msg {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: #b42318;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.lock-box {
|
||||
@include card;
|
||||
padding: 60rpx 32rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.lock-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.lock-desc {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.grid {
|
||||
@include card;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
padding: 28rpx 8rpx 20rpx;
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
padding: 12rpx 0;
|
||||
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.grid-icon {
|
||||
@include tint-icon(84rpx, 22rpx);
|
||||
}
|
||||
|
||||
.grid-name {
|
||||
font-size: 23rpx;
|
||||
color: $color-text-secondary;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
@include card;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
|
||||
& + & {
|
||||
border-top: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.list-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.list-meta {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.enter-card {
|
||||
@include card;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
|
||||
&:active {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
.enter-icon {
|
||||
@include tint-icon(76rpx, 20rpx);
|
||||
}
|
||||
|
||||
.enter-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.enter-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.enter-desc {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,485 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="head">
|
||||
<view class="head-row" @tap="goBackNav">
|
||||
<FaIcon name="chevron-left" color="#ffffff" :size="18" />
|
||||
<text class="head-back">返回导航</text>
|
||||
</view>
|
||||
<view class="user">
|
||||
<view class="avatar">
|
||||
<text class="avatar-text">{{ avatarText }}</text>
|
||||
</view>
|
||||
<view class="user-meta">
|
||||
<text class="user-name">{{ user.name || '云泽用户' }}</text>
|
||||
<text class="user-sub">{{ user.tenant || '云泽平台' }}<text v-if="user.account"> · {{ user.account }}</text></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<view v-if="loadError" class="err-box" @tap="load(true)">
|
||||
<FaIcon name="triangle-exclamation" color="#f04438" :size="18" />
|
||||
<view class="err-body">
|
||||
<text class="err-title">加载失败</text>
|
||||
<text class="err-msg">{{ loadError }},点击重试</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 当前子系统 -->
|
||||
<view class="block">
|
||||
<view class="block-head"><text class="block-title">当前子系统</text></view>
|
||||
<view class="card-row">
|
||||
<view class="tint-icon row-icon" :class="sub.tint">
|
||||
<FaIcon :name="sub.icon" color="#ffffff" :size="22" />
|
||||
</view>
|
||||
<view class="row-meta">
|
||||
<text class="row-title">{{ sub.title }}</text>
|
||||
<text class="row-sub">{{ allMenus.length }} 个功能 · {{ enabled ? '已开通' : '未开通' }}</text>
|
||||
</view>
|
||||
<text v-if="!enabled" class="lock-tag">未开通</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的数据 -->
|
||||
<view class="block">
|
||||
<view class="block-head"><text class="block-title">我的数据</text></view>
|
||||
<view class="kpi">
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ pendingCount }}</text>
|
||||
<text class="kpi-label">待办</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ overdue }}</text>
|
||||
<text class="kpi-label">已逾期</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value">{{ doneCount }}</text>
|
||||
<text class="kpi-label">已完成</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value">{{ allMenus.length }}</text>
|
||||
<text class="kpi-label">可用功能</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作 -->
|
||||
<view class="block">
|
||||
<view class="block-head"><text class="block-title">操作</text></view>
|
||||
<view class="list-card">
|
||||
<!-- 仅该子系统在 Web 端确有对应系统时展示(config/subsystems.js 的 webEntry) -->
|
||||
<view v-if="sub.webEntry" class="list-item" @tap="enterSystem">
|
||||
<view class="item-icon"><FaIcon name="display" color="#3973ff" :size="16" /></view>
|
||||
<text class="item-text">进入完整系统(Web 端)</text>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
<view class="list-item" @tap="goFunctions">
|
||||
<view class="item-icon"><FaIcon name="table-cells" color="#3973ff" :size="16" /></view>
|
||||
<text class="item-text">全部功能</text>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
<view class="list-item" @tap="goProfile">
|
||||
<view class="item-icon"><FaIcon name="user" color="#3973ff" :size="16" /></view>
|
||||
<text class="item-text">账号与安全</text>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
<view class="list-item" @tap="goBackNav">
|
||||
<view class="item-icon"><FaIcon name="table-cells" color="#3973ff" :size="16" /></view>
|
||||
<text class="item-text">切换子系统</text>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="logout" @tap="handleLogout">
|
||||
<text class="logout-text">退出登录</text>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
|
||||
<AppTabbar :group="slug" current="mine" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn, logout, isSSOEnabled, getToken, clearPendingAuth } from '@/utils/auth.js'
|
||||
import { openWebPage } from '@/utils/nav.js'
|
||||
import { logoutUAC, logoutApi } from '@/api/auth.js'
|
||||
import { request } from '@/api/request.js'
|
||||
import { clearHomeCache } from '@/api/workspace.js'
|
||||
import { useSubsystem } from '@/utils/subsystem.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
slug: { type: String, required: true }
|
||||
})
|
||||
|
||||
const { sub, loading, loadError, user, allMenus, enabled, moduleMeta, load } = useSubsystem(props.slug)
|
||||
|
||||
const pendingCount = ref(0)
|
||||
const overdue = ref(0)
|
||||
const doneCount = ref(0)
|
||||
const entering = ref(false)
|
||||
|
||||
const avatarText = computed(() => {
|
||||
const name = user.value.name || user.value.account || '云'
|
||||
return String(name).charAt(0).toUpperCase()
|
||||
})
|
||||
|
||||
async function loadStats() {
|
||||
try {
|
||||
const [p, d] = await Promise.all([
|
||||
request({ url: '/app/schedule/list', data: { status: 'pending', pageSize: 50 } }),
|
||||
request({ url: '/app/schedule/list', data: { status: 'done', pageSize: 50 } })
|
||||
])
|
||||
const pending = (p && p.list) || []
|
||||
pendingCount.value = pending.length
|
||||
overdue.value = pending.filter((s) => isOverdue(s)).length
|
||||
doneCount.value = ((d && d.list) || []).length
|
||||
} catch (e) {
|
||||
pendingCount.value = 0
|
||||
overdue.value = 0
|
||||
doneCount.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function isOverdue(item) {
|
||||
const t = String(item.schedule_time || item.created_at || '')
|
||||
return t.length >= 10 && t.slice(0, 10) < todayStr()
|
||||
}
|
||||
|
||||
function todayStr() {
|
||||
const d = new Date()
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
|
||||
}
|
||||
|
||||
function goBackNav() {
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
|
||||
function goFunctions() {
|
||||
uni.redirectTo({ url: `/pages/${props.slug}/functions/functions` })
|
||||
}
|
||||
|
||||
function goProfile() {
|
||||
uni.redirectTo({ url: '/pages/profile/profile' })
|
||||
}
|
||||
|
||||
/** 打开 Web 端该模块首页(走票据免登录) */
|
||||
async function enterSystem() {
|
||||
if (entering.value) return
|
||||
const target =
|
||||
(moduleMeta.value && moduleMeta.value.path) ||
|
||||
(allMenus.value[0] && allMenus.value[0].path) ||
|
||||
''
|
||||
if (!target) {
|
||||
uni.showToast({ title: '该系统暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
entering.value = true
|
||||
try {
|
||||
await openWebPage(target, sub.name)
|
||||
} finally {
|
||||
entering.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleLogout() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
confirmText: '退出',
|
||||
cancelText: '取消',
|
||||
success(res) {
|
||||
if (!res.confirm) return
|
||||
// 统一认证:先吊销服务端会话与令牌
|
||||
if (isSSOEnabled() && getToken()) {
|
||||
logoutUAC().catch(() => {})
|
||||
} else {
|
||||
logoutApi().catch(() => {})
|
||||
}
|
||||
clearPendingAuth()
|
||||
clearHomeCache()
|
||||
logout()
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
loadStats()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) {
|
||||
load()
|
||||
loadStats()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
/* ============ 顶部用户区 ============ */
|
||||
.head {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 40rpx;
|
||||
background: $hero-gradient;
|
||||
}
|
||||
|
||||
.head-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.head-back {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.36);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.avatar-text {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user-sub {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 23rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ============ 内容区 ============ */
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.block {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.block-head {
|
||||
@include block-head;
|
||||
}
|
||||
|
||||
.block-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.err-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 24rpx;
|
||||
padding: 24rpx 22rpx;
|
||||
background: #fef3f2;
|
||||
border: 1rpx solid #fdd8d4;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
.err-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.err-title {
|
||||
display: block;
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.err-msg {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: #b42318;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 当前子系统行 */
|
||||
.card-row {
|
||||
@include card;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
}
|
||||
|
||||
.row-icon {
|
||||
@include tint-icon(80rpx, 20rpx);
|
||||
}
|
||||
|
||||
.row-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.row-title {
|
||||
display: block;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.row-sub {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.lock-tag {
|
||||
@include chip(#fef3f2, $color-danger);
|
||||
}
|
||||
|
||||
/* 数据概览 */
|
||||
.kpi {
|
||||
@include card;
|
||||
display: flex;
|
||||
padding: 28rpx 0;
|
||||
}
|
||||
|
||||
.kpi-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
position: relative;
|
||||
|
||||
& + &::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6rpx;
|
||||
bottom: 6rpx;
|
||||
width: 1rpx;
|
||||
background: $color-divider;
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
|
||||
&.warn {
|
||||
color: $color-danger;
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-label {
|
||||
font-size: 21rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
/* 操作列表 */
|
||||
.list-card {
|
||||
@include card;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
|
||||
& + & {
|
||||
border-top: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
@include icon-box(56rpx);
|
||||
}
|
||||
|
||||
.item-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
/* 退出 */
|
||||
.logout {
|
||||
@include card;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 12rpx;
|
||||
background: linear-gradient(135deg, rgba(240, 68, 56, 0.08) 0%, rgba(240, 68, 56, 0.04) 100%);
|
||||
border: 1rpx solid rgba(240, 68, 56, 0.2);
|
||||
}
|
||||
|
||||
.logout-text {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 48rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,297 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="head">
|
||||
<view class="head-row" @tap="goBackNav">
|
||||
<FaIcon name="chevron-left" color="#1f2b48" :size="18" />
|
||||
<text class="head-back">返回导航</text>
|
||||
</view>
|
||||
<text class="head-title">{{ sub.title }} · 待办</text>
|
||||
<view class="kpi">
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ pending.length }}</text>
|
||||
<text class="kpi-label">待处理</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value" :class="{ warn: overdue > 0 }">{{ overdue }}</text>
|
||||
<text class="kpi-label">已逾期</text>
|
||||
</view>
|
||||
<view class="kpi-item">
|
||||
<text class="kpi-value">{{ done }}</text>
|
||||
<text class="kpi-label">已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<view class="block-head">
|
||||
<text class="block-title">日程待办</text>
|
||||
<view class="block-more" @tap="goSchedules">
|
||||
<text class="block-more-text">全部日程</text>
|
||||
<FaIcon name="chevron-right" color="#8a94ad" :size="11" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list-card">
|
||||
<view v-if="pending.length === 0" class="empty-box">
|
||||
<FaIcon name="circle-check" color="#c0c4cc" :size="28" />
|
||||
<text class="empty-text">暂无待办事项</text>
|
||||
</view>
|
||||
<view v-for="item in pending" :key="item.id" class="list-item" @tap="goSchedules">
|
||||
<view class="dot" :class="{ warn: isOverdue(item) }" />
|
||||
<view class="list-body">
|
||||
<text class="list-title">{{ item.content || item.title || '日程' }}</text>
|
||||
<text class="list-time" :class="{ warn: isOverdue(item) }">{{ item.schedule_time }}</text>
|
||||
</view>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
|
||||
<AppTabbar :group="slug" current="todo" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { request } from '@/api/request.js'
|
||||
import { useSubsystem } from '@/utils/subsystem.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
slug: { type: String, required: true }
|
||||
})
|
||||
|
||||
const { sub, loading, load } = useSubsystem(props.slug)
|
||||
const pending = ref([])
|
||||
const finished = ref([])
|
||||
|
||||
const overdue = computed(() => pending.value.filter((s) => isOverdue(s)).length)
|
||||
const done = computed(() => finished.value.length)
|
||||
|
||||
async function loadTodo() {
|
||||
try {
|
||||
const [p, f] = await Promise.all([
|
||||
request({ url: '/app/schedule/list', data: { status: 'pending', pageSize: 50 } }),
|
||||
request({ url: '/app/schedule/list', data: { status: 'done', pageSize: 50 } })
|
||||
])
|
||||
pending.value = (p && p.list) || []
|
||||
finished.value = (f && f.list) || []
|
||||
} catch (e) {
|
||||
pending.value = []
|
||||
finished.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function isOverdue(item) {
|
||||
const t = String(item.schedule_time || item.created_at || '')
|
||||
return t.length >= 10 && t.slice(0, 10) < todayStr()
|
||||
}
|
||||
|
||||
function todayStr() {
|
||||
const d = new Date()
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
|
||||
}
|
||||
|
||||
function goBackNav() {
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
|
||||
function goSchedules() {
|
||||
uni.navigateTo({ url: '/pages/tools/schedule/index' })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
loadTodo()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) loadTodo()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
.head {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 28rpx;
|
||||
background: $color-card;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.head-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.head-back {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.head-title {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.kpi {
|
||||
display: flex;
|
||||
margin-top: 26rpx;
|
||||
padding: 24rpx 0;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
.kpi-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
position: relative;
|
||||
|
||||
& + &::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 4rpx;
|
||||
bottom: 4rpx;
|
||||
width: 1rpx;
|
||||
background: $color-border;
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
|
||||
&.warn {
|
||||
color: $color-danger;
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-label {
|
||||
font-size: 21rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.block-head {
|
||||
@include block-head;
|
||||
}
|
||||
|
||||
.block-title {
|
||||
@include section-title;
|
||||
}
|
||||
|
||||
.block-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.block-more-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
padding: 60rpx 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 25rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
@include card;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
|
||||
& + & {
|
||||
border-top: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.warn {
|
||||
background: $color-danger;
|
||||
}
|
||||
}
|
||||
|
||||
.list-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.list-time {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
|
||||
&.warn {
|
||||
color: $color-danger;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* 子系统注册表
|
||||
*
|
||||
* nav.vue(导航页,无 tabbar)按这里配置渲染子系统宫格;
|
||||
* 点击卡片进入 pages/{slug}/home.vue,该子系统拥有自己的页面组与 tabbar。
|
||||
*
|
||||
* module 对应后端 yz_system_modules.code(菜单归属靠 path 前缀匹配),
|
||||
* slug 是端上路由目录名,务必与 pages/{slug}/ 保持一致。
|
||||
*/
|
||||
export const SUBSYSTEMS = [
|
||||
{
|
||||
slug: 'crm',
|
||||
module: 'crm',
|
||||
name: '客户关系',
|
||||
title: '客户关系管理',
|
||||
icon: 'handshake',
|
||||
tint: 'tint-0',
|
||||
desc: '线索 · 客户 · 商机 · 合同 · 回款',
|
||||
// 该子系统在 Web 端有完整系统,概览页展示「进入完整系统」入口
|
||||
webEntry: true
|
||||
},
|
||||
{
|
||||
slug: 'erp',
|
||||
module: 'erp',
|
||||
name: '进销存',
|
||||
title: '进销存管理',
|
||||
icon: 'boxes-stacked',
|
||||
tint: 'tint-1',
|
||||
desc: '客户 · 供应商 · 账套 · 通讯录',
|
||||
webEntry: true
|
||||
},
|
||||
{
|
||||
slug: 'oa',
|
||||
module: 'oa',
|
||||
name: 'OA 办公',
|
||||
title: '协同办公',
|
||||
icon: 'clipboard-check',
|
||||
tint: 'tint-2',
|
||||
desc: '日程 · 通知 · 文档 · 报销 · 人事',
|
||||
webEntry: true
|
||||
},
|
||||
{
|
||||
slug: 'cms',
|
||||
module: 'cms',
|
||||
name: '网站管理',
|
||||
title: '网站内容管理',
|
||||
icon: 'globe',
|
||||
tint: 'tint-3',
|
||||
desc: '文章 · 产品 · 解决方案 · 站点',
|
||||
webEntry: true
|
||||
},
|
||||
{
|
||||
slug: 'toolbox',
|
||||
module: 'bianjiegongju',
|
||||
name: '便捷工具',
|
||||
title: '便捷工具',
|
||||
icon: 'wrench',
|
||||
tint: 'tint-4',
|
||||
desc: '记事本 · 日程 · 密码库',
|
||||
// 便捷工具的记事本 / 日程 / 密码库在端上都有原生页面,
|
||||
// Web 端没有对应系统,因此不展示「进入完整系统」入口
|
||||
webEntry: false
|
||||
}
|
||||
]
|
||||
|
||||
/** 按 slug 取子系统配置 */
|
||||
export function getSubsystem(slug) {
|
||||
return SUBSYSTEMS.find((s) => s.slug === slug) || null
|
||||
}
|
||||
|
||||
/** 按后端模块 code 取子系统配置(menus[].module 与 yz_system_modules.code 对应) */
|
||||
export function getSubsystemByModule(module) {
|
||||
const key = String(module || '').toLowerCase()
|
||||
return SUBSYSTEMS.find((s) => String(s.module).toLowerCase() === key) || null
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入某子系统的概览页。
|
||||
* 后端模块没有对应端上页面时(未在 SUBSYSTEMS 注册),返回 false 让调用方自行降级。
|
||||
*/
|
||||
export function goSubsystem(slug) {
|
||||
if (!getSubsystem(slug)) return false
|
||||
uni.redirectTo({ url: `/pages/${slug}/home/home` })
|
||||
return true
|
||||
}
|
||||
@@ -55,6 +55,8 @@
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
/* 微信小程序 AppID:需与平台端「微信小程序配置」(/platform/wechatMini/config)中的 AppID 一致,
|
||||
否则「微信手机号一键登录」会因 jscode2session 报 40029 而失败 */
|
||||
"appid" : "",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
|
||||
+156
-1
@@ -8,6 +8,153 @@
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/nav/nav",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "选择子系统"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/crm/home/home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "客户关系管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/crm/functions/functions",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "客户关系 · 功能"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/crm/todo/todo",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "客户关系 · 待办"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/crm/mine/mine",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "客户关系 · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/erp/home/home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "进销存管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/erp/functions/functions",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "进销存 · 功能"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/erp/todo/todo",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "进销存 · 待办"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/erp/mine/mine",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "进销存 · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/oa/home/home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "协同办公"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/oa/functions/functions",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "OA · 功能"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/oa/todo/todo",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "OA · 待办"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/oa/mine/mine",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "OA · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cms/home/home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "网站内容管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cms/functions/functions",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "网站管理 · 功能"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cms/todo/todo",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "网站管理 · 待办"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cms/mine/mine",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "网站管理 · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/toolbox/home/home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "便捷工具"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/toolbox/functions/functions",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "便捷工具 · 功能"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/toolbox/todo/todo",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "便捷工具 · 待办"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/toolbox/mine/mine",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "便捷工具 · 我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
@@ -54,7 +201,15 @@
|
||||
"path": "pages/features/features",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "功能"
|
||||
"navigationBarTitleText": "全部应用"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/apps/webview",
|
||||
"style": {
|
||||
"navigationBarTitleText": "功能",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!--
|
||||
小程序端 web-view 组件会自动铺满整屏(不受样式约束),
|
||||
因此该端使用原生导航栏(pages.json 里 navigationStyle 保持 default);
|
||||
H5 / App 端 web-view 渲染为 iframe,需要自绘标题栏。
|
||||
-->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="bar">
|
||||
<view class="bar-btn" @tap="goBack">
|
||||
<FaIcon name="chevron-left" color="#1f2b48" :size="20" />
|
||||
</view>
|
||||
<text class="bar-title">{{ title }}</text>
|
||||
<view class="bar-btn" @tap="onReload">
|
||||
<FaIcon name="rotate" color="#5b6780" :size="18" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<web-view v-if="url" :src="url" @message="onMessage" />
|
||||
|
||||
<view v-else class="empty">
|
||||
<FaIcon name="triangle-exclamation" color="#c0c4cc" :size="40" />
|
||||
<text class="empty-text">没有可打开的页面地址</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { resolveWebConsoleURL, resolveWebSSOURL } from '@/api/config.js'
|
||||
|
||||
const url = ref('')
|
||||
const title = ref('功能')
|
||||
|
||||
/**
|
||||
* 参数解码。
|
||||
* 各端行为不一致:H5(vue-router)会先解一次码,小程序不会。
|
||||
* 这里对纯 ASCII 参数(path / ticket)重复解码是幂等的,安全;
|
||||
* 含中文的 title 解码一次后已无可解字符,再解也是空操作。
|
||||
*/
|
||||
function decodeParam(v) {
|
||||
if (!v) return ''
|
||||
try {
|
||||
return decodeURIComponent(v)
|
||||
} catch (e) {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
const opt = options || {}
|
||||
const raw = decodeParam(opt.p || opt.url)
|
||||
const ticket = decodeParam(opt.k)
|
||||
title.value = decodeParam(opt.t || opt.title) || '功能'
|
||||
|
||||
if (!raw) {
|
||||
uni.setNavigationBarTitle({ title: title.value })
|
||||
return
|
||||
}
|
||||
|
||||
// 带票据 → 走 Web 端免登录兑换页;否则按普通深链打开
|
||||
if (ticket) {
|
||||
url.value = resolveWebSSOURL(raw, ticket)
|
||||
} else if (/^https?:\/\//i.test(raw)) {
|
||||
url.value = raw
|
||||
} else {
|
||||
url.value = resolveWebConsoleURL(raw)
|
||||
}
|
||||
|
||||
uni.setNavigationBarTitle({ title: title.value })
|
||||
})
|
||||
|
||||
function goBack() {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/nav/nav' })
|
||||
}
|
||||
}
|
||||
|
||||
// 重新加载:改 src 强制 webview/iframe 刷新
|
||||
function onReload() {
|
||||
const cur = url.value
|
||||
if (!cur) return
|
||||
const sep = cur.includes('?') ? '&' : '?'
|
||||
url.value = cur + sep + '_t=' + Date.now()
|
||||
}
|
||||
|
||||
function onMessage() {
|
||||
// 预留:Web 端 postMessage 回传(如通知外层刷新数据)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
.bar {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 88rpx;
|
||||
padding: 0 16rpx;
|
||||
background: $color-card;
|
||||
border-bottom: 1rpx solid $color-border;
|
||||
}
|
||||
|
||||
.bar-btn {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.bar-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubFunctions slug="cms" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* cms 子系统 · functions 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubHome slug="cms" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* cms 子系统 · home 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubMine slug="cms" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* cms 子系统 · 我的页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubMine.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubMine from '@/components/sub/SubMine.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubTodo slug="cms" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* cms 子系统 · todo 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubTodo from '@/components/sub/SubTodo.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubFunctions slug="crm" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* crm 子系统 · functions 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubHome slug="crm" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* crm 子系统 · home 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubMine slug="crm" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* crm 子系统 · 我的页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubMine.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubMine from '@/components/sub/SubMine.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubTodo slug="crm" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* crm 子系统 · todo 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubTodo from '@/components/sub/SubTodo.vue'
|
||||
</script>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubFunctions slug="erp" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* erp 子系统 · functions 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubHome slug="erp" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* erp 子系统 · home 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubMine slug="erp" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* erp 子系统 · 我的页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubMine.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubMine from '@/components/sub/SubMine.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubTodo slug="erp" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* erp 子系统 · todo 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubTodo from '@/components/sub/SubTodo.vue'
|
||||
</script>
|
||||
+343
-201
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 吸顶搜索 -->
|
||||
<view class="search-wrap">
|
||||
<view class="search-bar">
|
||||
<FaIcon name="magnifying-glass" color="#909399" :size="16" />
|
||||
<FaIcon name="magnifying-glass" color="#8a94ad" :size="16" />
|
||||
<input
|
||||
class="search-input"
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
type="text"
|
||||
placeholder="搜索功能名称"
|
||||
placeholder="搜索应用或功能名称"
|
||||
placeholder-class="search-placeholder"
|
||||
confirm-type="search"
|
||||
/>
|
||||
@@ -18,33 +19,106 @@
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<view class="sidebar">
|
||||
<view
|
||||
v-for="(cat, index) in categories"
|
||||
:key="cat.id"
|
||||
class="category-item"
|
||||
:class="{ active: activeIndex === index }"
|
||||
@tap="selectCategory(index)"
|
||||
>
|
||||
<text class="category-text">{{ cat.title }}</text>
|
||||
<!-- 搜索结果:跨模块扁平列表 -->
|
||||
<block v-if="keyword.trim()">
|
||||
<view class="result-hint">
|
||||
<text class="result-hint-text">找到 {{ searchResults.length }} 个结果</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="content">
|
||||
<view v-if="displayItems.length === 0" class="empty">
|
||||
<view v-if="searchResults.length === 0" class="empty-box">
|
||||
<FaIcon name="magnifying-glass" color="#c0c4cc" :size="32" />
|
||||
<text class="empty-text">未找到相关功能</text>
|
||||
<text class="empty-text">没有找到「{{ keyword.trim() }}」相关功能</text>
|
||||
</view>
|
||||
<view
|
||||
v-for="item in displayItems"
|
||||
:key="item.id"
|
||||
class="item-card"
|
||||
:class="{ active: activeItemId === item.id }"
|
||||
@tap="onItemTap(item)"
|
||||
>
|
||||
<text class="item-name">{{ item.name }}</text>
|
||||
<view v-else class="list-card">
|
||||
<view
|
||||
v-for="item in searchResults"
|
||||
:key="item.menu.id"
|
||||
class="list-item"
|
||||
@tap="openMenu(item.menu, item.menu.title)"
|
||||
>
|
||||
<view class="row-icon" :class="item.locked ? 'tint-off' : item.tint">
|
||||
<FaIcon :name="item.icon" color="#ffffff" :size="16" />
|
||||
</view>
|
||||
<view class="row-body">
|
||||
<text class="row-title">{{ item.menu.title }}</text>
|
||||
<text class="row-sub">{{ item.moduleName }}</text>
|
||||
</view>
|
||||
<text v-if="item.locked" class="row-lock">未开通</text>
|
||||
<FaIcon v-else name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 默认:按业务域分组浏览 -->
|
||||
<block v-else>
|
||||
<view v-if="groups.length === 0" class="empty-box">
|
||||
<FaIcon name="cube" color="#c0c4cc" :size="32" />
|
||||
<text class="empty-text">尚未配置应用模块</text>
|
||||
</view>
|
||||
|
||||
<view v-for="group in groups" :key="group.code || group.id" class="group">
|
||||
<view class="group-head">
|
||||
<view class="tint-icon group-icon" :class="group.tint">
|
||||
<FaIcon :name="group.icon" color="#ffffff" :size="18" />
|
||||
</view>
|
||||
<view class="group-meta">
|
||||
<view class="group-title-row">
|
||||
<text class="group-name">{{ group.name }}</text>
|
||||
<text v-if="group.locked" class="group-lock">未开通</text>
|
||||
</view>
|
||||
<text class="group-count">{{ group.items.length }} 个功能</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list-card">
|
||||
<view
|
||||
v-for="item in group.items"
|
||||
:key="item.id"
|
||||
class="list-item"
|
||||
@tap="openMenu(item, item.title)"
|
||||
>
|
||||
<view class="dot" :class="item.locked ? 'off' : 'primary'" />
|
||||
<view class="row-body">
|
||||
<text class="row-title">{{ item.title }}</text>
|
||||
<text v-if="item.path" class="row-sub">{{ item.path }}</text>
|
||||
</view>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
<view v-if="group.items.length === 0" class="group-empty">
|
||||
<text class="group-empty-text">该模块下暂无你可见的功能</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="commonMenus.length" class="group">
|
||||
<view class="group-head">
|
||||
<view class="tint-icon group-icon tint-3">
|
||||
<FaIcon name="wrench" color="#ffffff" :size="18" />
|
||||
</view>
|
||||
<view class="group-meta">
|
||||
<view class="group-title-row">
|
||||
<text class="group-name">协作工具</text>
|
||||
</view>
|
||||
<text class="group-count">{{ commonMenus.length }} 个功能</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-card">
|
||||
<view
|
||||
v-for="item in commonMenus"
|
||||
:key="item.id"
|
||||
class="list-item"
|
||||
@tap="openMenu(item, item.title)"
|
||||
>
|
||||
<view class="dot primary" />
|
||||
<view class="row-body">
|
||||
<text class="row-title">{{ item.title }}</text>
|
||||
</view>
|
||||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
|
||||
<AppTabbar current="features" />
|
||||
@@ -53,115 +127,124 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import AppTabbar from '@/components/MainTabbar.vue'
|
||||
|
||||
const keyword = ref('')
|
||||
const activeIndex = ref(0)
|
||||
const activeItemId = ref('')
|
||||
|
||||
const routeMap = {
|
||||
notepad: '/pages/tools/notepad/index',
|
||||
schedule: '/pages/tools/schedule/index'
|
||||
const MODULE_ICONS = {
|
||||
crm: 'handshake',
|
||||
erp: 'boxes-stacked',
|
||||
oa: 'clipboard-check',
|
||||
cms: 'globe',
|
||||
ai: 'robot',
|
||||
system: 'gear',
|
||||
tool: 'wrench'
|
||||
}
|
||||
|
||||
const categories = ref([
|
||||
{
|
||||
id: 'handy',
|
||||
title: '便捷工具',
|
||||
items: [
|
||||
{ id: 'notepad', name: '记事本', route: routeMap.notepad },
|
||||
{ id: 'schedule', name: '日程提醒', route: routeMap.schedule }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'tools',
|
||||
title: '常用工具',
|
||||
items: [
|
||||
{ id: 't1', name: '扫一扫' },
|
||||
{ id: 't2', name: '收付款' },
|
||||
{ id: 't3', name: '卡包管理' },
|
||||
{ id: 't4', name: '出行服务' },
|
||||
{ id: 't5', name: '二维码生成' },
|
||||
{ id: 't6', name: '发票助手' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'life',
|
||||
title: '生活服务',
|
||||
items: [
|
||||
{ id: 'l1', name: '外卖订餐' },
|
||||
{ id: 'l2', name: '电影购票' },
|
||||
{ id: 'l3', name: '酒店预订' },
|
||||
{ id: 'l4', name: '快递查询' },
|
||||
{ id: 'l5', name: '家政预约' },
|
||||
{ id: 'l6', name: '更多服务' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'office',
|
||||
title: '办公效率',
|
||||
items: [
|
||||
{ id: 'o1', name: '文档协作' },
|
||||
{ id: 'o2', name: '日程管理' },
|
||||
{ id: 'o3', name: '云盘存储' },
|
||||
{ id: 'o4', name: '视频会议' },
|
||||
{ id: 'o5', name: '任务看板' },
|
||||
{ id: 'o6', name: '审批流程' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'data',
|
||||
title: '数据报表',
|
||||
items: [
|
||||
{ id: 'd1', name: '销售统计' },
|
||||
{ id: 'd2', name: '用户分析' },
|
||||
{ id: 'd3', name: '访问趋势' },
|
||||
{ id: 'd4', name: '转化报表' },
|
||||
{ id: 'd5', name: '导出数据' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'system',
|
||||
title: '系统设置',
|
||||
items: [
|
||||
{ id: 's1', name: '账号管理' },
|
||||
{ id: 's2', name: '权限配置' },
|
||||
{ id: 's3', name: '消息通知' },
|
||||
{ id: 's4', name: '安全中心' },
|
||||
{ id: 's5', name: '关于系统' }
|
||||
]
|
||||
const keyword = ref('')
|
||||
const loading = ref(true)
|
||||
const modules = ref([])
|
||||
const menus = ref([])
|
||||
|
||||
/** 按模块 code 归组的全部菜单(含目录与锁定项,便于浏览) */
|
||||
const groups = computed(() => {
|
||||
const byCode = {}
|
||||
menus.value.forEach((m) => {
|
||||
if (!m.module) return
|
||||
if (!byCode[m.module]) byCode[m.module] = []
|
||||
byCode[m.module].push(m)
|
||||
})
|
||||
|
||||
// 这里展示全部模块(含 type=2 系统设置),与工作台首页只展示业务模块形成分工
|
||||
const list = modules.value.map((mod, index) => ({
|
||||
id: mod.id,
|
||||
code: mod.code,
|
||||
name: mod.name || '未命名应用',
|
||||
icon: mod.type === 2 ? 'gear' : MODULE_ICONS[String(mod.code || '').toLowerCase()] || 'cube',
|
||||
tint: mod.enabled === false ? 'tint-off' : 'tint-' + (index % 8),
|
||||
locked: mod.enabled === false,
|
||||
items: (byCode[mod.code] || []).slice().sort((a, b) => a.sort - b.sort)
|
||||
}))
|
||||
|
||||
// 兜底:模块表里没有对应记录(或已删除)的菜单
|
||||
const known = {}
|
||||
list.forEach((g) => {
|
||||
known[String(g.code || '').toLowerCase()] = true
|
||||
})
|
||||
const orphan = []
|
||||
menus.value.forEach((m) => {
|
||||
const code = String(m.module || '').toLowerCase()
|
||||
if (code && !known[code]) orphan.push(m)
|
||||
})
|
||||
if (orphan.length) {
|
||||
list.push({
|
||||
id: 'other',
|
||||
code: 'other',
|
||||
name: '其他功能',
|
||||
icon: 'file-lines',
|
||||
tint: 'tint-7',
|
||||
locked: false,
|
||||
items: orphan
|
||||
})
|
||||
}
|
||||
])
|
||||
|
||||
const currentCategory = computed(() => categories.value[activeIndex.value])
|
||||
|
||||
const displayItems = computed(() => {
|
||||
const items = currentCategory.value?.items || []
|
||||
const q = keyword.value.trim().toLowerCase()
|
||||
if (!q) return items
|
||||
return items.filter(item => item.name.toLowerCase().includes(q))
|
||||
return list
|
||||
})
|
||||
|
||||
const commonMenus = computed(() => menus.value.filter((m) => !m.module))
|
||||
|
||||
/** 跨模块搜索:应用名 + 模块名 + 菜单标题 */
|
||||
const searchResults = computed(() => {
|
||||
const q = keyword.value.trim().toLowerCase()
|
||||
if (!q) return []
|
||||
const moduleName = {}
|
||||
modules.value.forEach((m) => {
|
||||
moduleName[String(m.code || '').toLowerCase()] = m.name
|
||||
})
|
||||
|
||||
return menus.value
|
||||
.filter((m) => {
|
||||
const mod = modules.value.find((x) => x.code === m.module)
|
||||
const hay = [m.title, m.path, mod && mod.name].join(' ').toLowerCase()
|
||||
return hay.indexOf(q) > -1
|
||||
})
|
||||
.map((m, i) => {
|
||||
const mod = modules.value.find((x) => x.code === m.module)
|
||||
return {
|
||||
menu: m,
|
||||
moduleName: (mod && mod.name) || '协作工具',
|
||||
icon: MODULE_ICONS[String(m.module || '').toLowerCase()] || 'file-lines',
|
||||
tint: mod && mod.enabled === false ? 'tint-off' : 'tint-' + (i % 8),
|
||||
locked: m.locked === true || (mod && mod.enabled === false)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await fetchHome()
|
||||
modules.value = Array.isArray(data.modules) ? data.modules : []
|
||||
menus.value = Array.isArray(data.menus) ? data.menus : []
|
||||
} catch (e) {
|
||||
console.error('[apps] load failed:', e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
}
|
||||
})
|
||||
|
||||
function selectCategory(index) {
|
||||
activeIndex.value = index
|
||||
activeItemId.value = ''
|
||||
}
|
||||
|
||||
function onItemTap(item) {
|
||||
activeItemId.value = item.id
|
||||
if (item.route) {
|
||||
uni.navigateTo({ url: item.route })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: item.name, icon: 'none' })
|
||||
}
|
||||
load()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -173,15 +256,16 @@ function onItemTap(item) {
|
||||
|
||||
.search-wrap {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 16rpx) 24rpx 20rpx;
|
||||
padding: calc(var(--status-bar-height, 44px) + 16rpx) $page-padding-x 20rpx;
|
||||
background: $color-card;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 72rpx;
|
||||
height: 76rpx;
|
||||
padding: 0 24rpx;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-full;
|
||||
@@ -189,7 +273,8 @@ function onItemTap(item) {
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
min-width: 0;
|
||||
height: 76rpx;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
@@ -207,98 +292,155 @@ function onItemTap(item) {
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: $color-card;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 200rpx;
|
||||
flex-shrink: 0;
|
||||
background: $color-bg-page;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
position: relative;
|
||||
padding: 32rpx 16rpx;
|
||||
text-align: center;
|
||||
|
||||
&.active {
|
||||
background: $color-card;
|
||||
|
||||
.category-text {
|
||||
color: $color-primary;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 6rpx;
|
||||
height: 36rpx;
|
||||
background: linear-gradient(180deg, #4facfe 0%, #00f2fe 100%);
|
||||
border-radius: 0 4rpx 4rpx 0;
|
||||
}
|
||||
}
|
||||
.result-hint {
|
||||
padding: 0 4rpx 16rpx;
|
||||
}
|
||||
|
||||
.category-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
line-height: 1.4;
|
||||
.result-hint-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 20rpx 24rpx;
|
||||
background: $color-card;
|
||||
}
|
||||
|
||||
.item-card {
|
||||
padding: 28rpx 24rpx;
|
||||
margin-bottom: 16rpx;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-md;
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, rgba(79, 172, 254, 0.08) 0%, rgba(0, 242, 254, 0.08) 100%);
|
||||
|
||||
.item-name {
|
||||
color: #4facfe;
|
||||
}
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.empty {
|
||||
.empty-box {
|
||||
@include card;
|
||||
margin-top: 24rpx;
|
||||
padding: 80rpx 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 120rpx 0;
|
||||
gap: 20rpx;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.group {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 0 4rpx;
|
||||
}
|
||||
|
||||
.group-icon {
|
||||
@include tint-icon(72rpx, 18rpx);
|
||||
}
|
||||
|
||||
.group-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.group-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.group-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.group-lock {
|
||||
@include chip(#fef3f2, $color-danger);
|
||||
}
|
||||
|
||||
.group-count {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
@include card;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
|
||||
& + & {
|
||||
border-top: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.row-icon {
|
||||
@include tint-icon(60rpx, 16rpx);
|
||||
}
|
||||
|
||||
.row-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.row-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.row-sub {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.row-lock {
|
||||
@include chip(#fef3f2, $color-danger);
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
background: $color-text-muted;
|
||||
|
||||
&.primary { background: $color-primary; }
|
||||
&.off { background: $color-border; }
|
||||
}
|
||||
|
||||
.group-empty {
|
||||
padding: 40rpx 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.group-empty-text {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
+742
-554
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,369 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 顶部信息:融入页面背景,不再单独做彩色抬头 -->
|
||||
<view class="head">
|
||||
<view class="head-row">
|
||||
<text class="head-title">选择子系统</text>
|
||||
<text class="head-count">{{ enabledCount }}/{{ cards.length }} 已开通</text>
|
||||
</view>
|
||||
<text class="head-sub">{{ user.tenant || '云泽平台' }}<text v-if="user.account"> · {{ user.account }}</text></text>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<!-- 加载失败 -->
|
||||
<view v-if="loadError" class="err-box" @tap="load(true)">
|
||||
<FaIcon name="triangle-exclamation" color="#f04438" :size="18" />
|
||||
<view class="err-body">
|
||||
<text class="err-title">子系统加载失败</text>
|
||||
<text class="err-msg">{{ loadError }},点击重试</text>
|
||||
</view>
|
||||
<FaIcon name="rotate" color="#f04438" :size="16" />
|
||||
</view>
|
||||
|
||||
<!-- 子系统宫格 -->
|
||||
<view v-else-if="!loading && cards.length === 0" class="empty-box">
|
||||
<FaIcon name="cube" color="#c0c4cc" :size="32" />
|
||||
<text class="empty-text">暂无子系统,请联系管理员开通</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="card-grid">
|
||||
<view
|
||||
v-for="card in cards"
|
||||
:key="card.code || card.id"
|
||||
class="sub-card"
|
||||
:class="{ locked: card.locked }"
|
||||
@tap="enter(card)"
|
||||
>
|
||||
<view class="tint-icon sub-icon" :class="card.tint">
|
||||
<FaIcon :name="card.icon" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
<text class="sub-name">{{ card.name }}</text>
|
||||
<text class="sub-desc">{{ card.desc }}</text>
|
||||
<view class="sub-go">
|
||||
<text class="sub-go-text">进入</text>
|
||||
<FaIcon name="arrow-right" color="#ffffff" :size="11" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
import { getSubsystemByModule, goSubsystem } from '@/config/subsystems.js'
|
||||
|
||||
/** 模块 code → 子系统 slug → 进入其概览页;未注册返回 false */
|
||||
function goSubsystemByModule(code) {
|
||||
const sub = getSubsystemByModule(code)
|
||||
return sub ? goSubsystem(sub.slug) : false
|
||||
}
|
||||
|
||||
/** 模块 code → 端上图标(后端 icon 存的是 Element Plus 图标名,端上用不了) */
|
||||
const MODULE_ICONS = {
|
||||
crm: 'handshake',
|
||||
erp: 'boxes-stacked',
|
||||
oa: 'clipboard-check',
|
||||
cms: 'globe',
|
||||
ai: 'robot',
|
||||
system: 'gear',
|
||||
tool: 'wrench'
|
||||
}
|
||||
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
const user = ref({})
|
||||
const modules = ref([])
|
||||
const menus = ref([])
|
||||
|
||||
/** 叶子菜单(可直接跳转的功能页),已锁定的过滤掉 */
|
||||
const leafMenus = computed(() => menus.value.filter((m) => m.leaf !== false && !m.locked))
|
||||
|
||||
/** 子系统卡片:每个业务模块一张卡 */
|
||||
const cards = computed(() => {
|
||||
const byCode = {}
|
||||
leafMenus.value.forEach((m) => {
|
||||
if (!m.module) return
|
||||
if (!byCode[m.module]) byCode[m.module] = []
|
||||
byCode[m.module].push(m)
|
||||
})
|
||||
|
||||
return modules.value
|
||||
.filter((m) => m.type !== 2) // 2=系统配置,不作为子系统入口
|
||||
.map((mod, index) => {
|
||||
const code = String(mod.code || '').toLowerCase()
|
||||
const items = byCode[mod.code] || []
|
||||
const locked = mod.enabled === false
|
||||
return {
|
||||
id: mod.id,
|
||||
code: mod.code,
|
||||
path: mod.path || '',
|
||||
name: mod.name || '未命名系统',
|
||||
desc: locked
|
||||
? '未开通该模块'
|
||||
: mod.description || (items.length ? items.length + ' 个功能' : '暂无功能'),
|
||||
icon: MODULE_ICONS[code] || 'cube',
|
||||
tint: locked ? 'tint-off' : 'tint-' + (index % 8),
|
||||
locked,
|
||||
items,
|
||||
total: items.length
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const enabledCount = computed(() => cards.value.filter((c) => !c.locked).length)
|
||||
|
||||
/* ==================== 数据加载 ==================== */
|
||||
|
||||
async function load(force = false) {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await fetchHome(force)
|
||||
user.value = data.user || {}
|
||||
modules.value = Array.isArray(data.modules) ? data.modules : []
|
||||
menus.value = Array.isArray(data.menus) ? data.menus : []
|
||||
loadError.value = ''
|
||||
} catch (e) {
|
||||
console.error('[nav] load failed:', e)
|
||||
loadError.value = (e && e.message) || '接口请求失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== 交互 ==================== */
|
||||
|
||||
/**
|
||||
* 点击子系统卡片 → 进入该子系统独立页面组(带自己的 tabbar)。
|
||||
* 未在 config/subsystems.js 注册的模块,降级为直接打开 Web 端该模块首页。
|
||||
*/
|
||||
function enter(card) {
|
||||
if (card.locked) {
|
||||
openMenu({ locked: true, title: card.name })
|
||||
return
|
||||
}
|
||||
if (goSubsystemByModule(card.code)) return
|
||||
if (card.items.length) {
|
||||
openMenu(card.items[0], card.name)
|
||||
return
|
||||
}
|
||||
if (card.path) {
|
||||
openMenu({ title: card.name, path: card.path, leaf: true }, card.name)
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: card.name + '暂未开放', icon: 'none' })
|
||||
}
|
||||
|
||||
/* ==================== 生命周期 ==================== */
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
load()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
if (isLoggedIn() && !loading.value) load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
@include page-shell;
|
||||
}
|
||||
|
||||
/* ============ 顶部信息(融入页面背景) ============ */
|
||||
.head {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 32rpx) $page-padding-x 12rpx;
|
||||
background: $color-bg-page;
|
||||
}
|
||||
|
||||
.head-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.head-title {
|
||||
font-size: 42rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.head-count {
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.head-sub {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ============ 内容区 ============ */
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 8rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
/* ============ 失败提示 ============ */
|
||||
.err-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
padding: 24rpx 22rpx;
|
||||
background: #fef3f2;
|
||||
border: 1rpx solid #fdd8d4;
|
||||
border-radius: $radius-md;
|
||||
}
|
||||
|
||||
.err-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.err-title {
|
||||
display: block;
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
color: $color-danger;
|
||||
}
|
||||
|
||||
.err-msg {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: #b42318;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
@include card;
|
||||
margin-top: 24rpx;
|
||||
padding: 80rpx 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
/* ============ 子系统宫格 ============
|
||||
用 flex 换行而不是 grid:小程序端 wxss 对 grid 的支持不稳定,
|
||||
用 flex-wrap + 百分比宽度才能保证任何屏宽都稳定两列,
|
||||
且同一行卡片高度自动拉齐(align-items 默认 stretch)。 */
|
||||
.card-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.sub-card {
|
||||
@include card;
|
||||
width: calc(50% - 10rpx);
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 26rpx 22rpx 22rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: transform 0.15s ease, box-shadow 0.2s ease;
|
||||
|
||||
/* 每行第 2 个不右边距,保证 50%-10rpx + 20rpx + 50%-10rpx = 100% */
|
||||
&:nth-child(2n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
/* 未开通:靠灰色图标与灰色文字表达,不使用角标 */
|
||||
&.locked {
|
||||
.sub-name,
|
||||
.sub-desc {
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.sub-go {
|
||||
background: $color-border;
|
||||
}
|
||||
|
||||
.sub-go-text {
|
||||
color: $color-text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sub-icon {
|
||||
@include tint-icon(88rpx, 24rpx);
|
||||
}
|
||||
|
||||
.sub-name {
|
||||
margin-top: 20rpx;
|
||||
font-size: 31rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sub-desc {
|
||||
margin-top: 8rpx;
|
||||
/* 按钮用 margin-top:auto 吸底,这里保证内容短时也有最小间距 */
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 进入按钮:吸底 + 撑满宽度,同一行的卡片按钮位置自动对齐 */
|
||||
.sub-go {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6rpx;
|
||||
height: 58rpx;
|
||||
margin-top: auto;
|
||||
border-radius: $radius-md;
|
||||
background: $color-primary;
|
||||
}
|
||||
|
||||
.sub-go-text {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 48rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubFunctions slug="oa" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* oa 子系统 · functions 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubHome slug="oa" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* oa 子系统 · home 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubMine slug="oa" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* oa 子系统 · 我的页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubMine.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubMine from '@/components/sub/SubMine.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubTodo slug="oa" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* oa 子系统 · todo 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubTodo from '@/components/sub/SubTodo.vue'
|
||||
</script>
|
||||
@@ -32,7 +32,7 @@
|
||||
>
|
||||
<view class="menu-left">
|
||||
<view class="menu-icon">
|
||||
<FaIcon :name="item.icon" color="#3c9cff" :size="18" />
|
||||
<FaIcon :name="item.icon" color="#3973ff" :size="18" />
|
||||
</view>
|
||||
<text class="menu-title">{{ item.title }}</text>
|
||||
</view>
|
||||
@@ -56,9 +56,9 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { getUser, setUser, logout, isLoggedIn } from '@/utils/auth.js'
|
||||
import { getCurrentUser, logoutApi } from '@/api/auth.js'
|
||||
import AppTabbar from '@/components/AppTabbar.vue'
|
||||
import { getUser, setUser, logout, isLoggedIn, isSSOEnabled, getToken } from '@/utils/auth.js'
|
||||
import { getCurrentUser, logoutApi, logoutUAC } from '@/api/auth.js'
|
||||
import AppTabbar from '@/components/MainTabbar.vue'
|
||||
|
||||
const user = ref(null)
|
||||
|
||||
@@ -148,10 +148,14 @@ function handleLogout() {
|
||||
cancelText: '取消',
|
||||
success(res) {
|
||||
if (!res.confirm) return
|
||||
// 先清本地并跳转,避免接口超时/失败导致“退出无效”
|
||||
// 统一认证:先吊销服务端会话与令牌(默认 1 号 1 机,不吊销会占着名额)
|
||||
if (isSSOEnabled() && getToken()) {
|
||||
logoutUAC().catch(() => {})
|
||||
} else {
|
||||
logoutApi().catch(() => {})
|
||||
}
|
||||
// 再清本地并跳转,避免接口超时/失败导致“退出无效”
|
||||
logout()
|
||||
// 后端无状态退出,失败可忽略(不阻塞)
|
||||
logoutApi().catch(() => {})
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
}
|
||||
})
|
||||
@@ -168,7 +172,7 @@ function handleLogout() {
|
||||
.profile-header {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 24rpx) $page-padding-x 40rpx;
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
background: $hero-gradient;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -332,7 +336,7 @@ function handleLogout() {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 12rpx;
|
||||
background: linear-gradient(135deg, rgba(79, 172, 254, 0.1) 0%, rgba(0, 242, 254, 0.1) 100%);
|
||||
background: linear-gradient(135deg, rgba(57, 115, 255, 0.12) 0%, rgba(82, 168, 255, 0.14) 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -356,13 +360,13 @@ function handleLogout() {
|
||||
font-size: 20rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
background: linear-gradient(135deg, #3973ff 0%, #52a8ff 100%);
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 12rpx;
|
||||
min-width: 36rpx;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
box-shadow: 0 4rpx 12rpx rgba(79, 172, 254, 0.3);
|
||||
box-shadow: 0 4rpx 12rpx rgba(57, 115, 255, 0.3);
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubFunctions slug="toolbox" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* tools 子系统 · functions 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubFunctions from '@/components/sub/SubFunctions.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubHome slug="toolbox" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* tools 子系统 · home 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubHome from '@/components/sub/SubHome.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubMine slug="toolbox" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* toolbox 子系统 · 我的页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubMine.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubMine from '@/components/sub/SubMine.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<SubTodo slug="toolbox" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* tools 子系统 · todo 页。
|
||||
* 页面逻辑全部收敛在 components/sub/SubXxx.vue,这里只做 slug 绑定,
|
||||
* 便于统一维护;该子系统拥有独立的页面目录与独立 tabbar。
|
||||
*/
|
||||
import SubTodo from '@/components/sub/SubTodo.vue'
|
||||
</script>
|
||||
@@ -38,3 +38,34 @@
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 区块标题行(左侧标题 + 右侧「更多」)
|
||||
@mixin block-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
// 应用模块卡片的彩色渐变图标底
|
||||
@mixin tint-icon($size: 96rpx, $radius: 24rpx) {
|
||||
width: $size;
|
||||
height: $size;
|
||||
border-radius: $radius;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 小标签(功能 chip / 状态徽标)
|
||||
@mixin chip($bg: $color-primary-bg, $color: $color-primary) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: $radius-full;
|
||||
background: $bg;
|
||||
color: $color;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -1,18 +1,45 @@
|
||||
// 标准商务主题(蓝色系 + 灰阶)
|
||||
$color-primary: #4facfe;
|
||||
$color-primary-dark: #00f2fe;
|
||||
$color-primary-bg: #e0f7ff;
|
||||
$color-bg-page: #f5f7fa;
|
||||
// =============================================================
|
||||
// 云泽统一主题(与 Web 端统一认证中心 /auth/login 同一套蓝色系)
|
||||
// 品牌主色 #3973ff,浅色 #52a8ff,深色 #2560a9
|
||||
// =============================================================
|
||||
|
||||
// 品牌色
|
||||
$color-primary: #3973ff;
|
||||
$color-primary-dark: #2560a9;
|
||||
$color-primary-light: #52a8ff;
|
||||
$color-primary-bg: #eef4ff;
|
||||
|
||||
// 背景与卡片
|
||||
$color-bg-page: #f4f7fc;
|
||||
$color-card: #ffffff;
|
||||
$color-text: #303133;
|
||||
$color-text-secondary: #606266;
|
||||
$color-text-muted: #909399;
|
||||
$color-border: #ebeef5;
|
||||
$color-divider: #f2f3f5;
|
||||
$shadow-card: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
|
||||
$shadow-header: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
|
||||
// 文字
|
||||
$color-text: #1f2b48;
|
||||
$color-text-secondary: #5b6780;
|
||||
$color-text-muted: #8a94ad;
|
||||
|
||||
// 线条
|
||||
$color-border: #e3e9f5;
|
||||
$color-divider: #f2f4f8;
|
||||
|
||||
// 语义色
|
||||
$color-success: #17b26a;
|
||||
$color-warning: #f79009;
|
||||
$color-danger: #f04438;
|
||||
|
||||
// 阴影
|
||||
$shadow-card: 0 4rpx 24rpx rgba(31, 43, 72, 0.06);
|
||||
$shadow-float: 0 8rpx 28rpx rgba(31, 43, 72, 0.1);
|
||||
$shadow-header: 0 2rpx 12rpx rgba(31, 43, 72, 0.04);
|
||||
|
||||
// 圆角
|
||||
$radius-sm: 8rpx;
|
||||
$radius-md: 12rpx;
|
||||
$radius-lg: 16rpx;
|
||||
$radius-lg: 20rpx;
|
||||
$radius-full: 999rpx;
|
||||
|
||||
// 间距
|
||||
$page-padding-x: 32rpx;
|
||||
|
||||
// Hero 渐变(登录页 / 工作台头部共用)
|
||||
$hero-gradient: linear-gradient(135deg, #1b3b8f 0%, #2f6fe4 52%, #52a8ff 100%);
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 应用模块图标色板(全局)
|
||||
*
|
||||
* 工作台/应用中心按模块 code 轮换取色,避免所有卡片都是同一个蓝色。
|
||||
* 用法:<view class="tint-icon tint-2"><FaIcon .../></view>
|
||||
* .tint-icon 的尺寸/圆角/居中定义在 page-common.scss 的 @mixin tint-icon 中,
|
||||
* 这里只提供背景渐变。
|
||||
*/
|
||||
.tint-0 { background: linear-gradient(135deg, #3973ff 0%, #52a8ff 100%); }
|
||||
.tint-1 { background: linear-gradient(135deg, #17b26a 0%, #4ade80 100%); }
|
||||
.tint-2 { background: linear-gradient(135deg, #f79009 0%, #fbbf24 100%); }
|
||||
.tint-3 { background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%); }
|
||||
.tint-4 { background: linear-gradient(135deg, #f04438 0%, #fb7185 100%); }
|
||||
.tint-5 { background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%); }
|
||||
.tint-6 { background: linear-gradient(135deg, #db2777 0%, #f472b6 100%); }
|
||||
.tint-7 { background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%); }
|
||||
|
||||
/** 未开通(套餐锁定)时的灰色底 */
|
||||
.tint-off { background: linear-gradient(135deg, #b9c2d4 0%, #d5dbe7 100%); }
|
||||
+47
-3
@@ -4,13 +4,20 @@ const TENANT_KEY = 'app_tenant_name'
|
||||
const TID_KEY = 'app_tid'
|
||||
const REFRESH_KEY = 'app_refresh_token'
|
||||
const SID_KEY = 'app_sid'
|
||||
const TENANTS_KEY = 'app_tenants'
|
||||
|
||||
/** 是否启用统一认证:.env 中配置 VITE_AUTH_MODE=sso */
|
||||
/**
|
||||
* 是否启用统一认证(UAC)。
|
||||
* 统一认证是默认形态(与 Web 端 /auth/login 同一套账号体系);
|
||||
* 仅在 .env 中显式配置 VITE_AUTH_MODE=legacy 时才回退旧的「租户名 + 账号」直登。
|
||||
*/
|
||||
export function isSSOEnabled() {
|
||||
try {
|
||||
return (typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.VITE_AUTH_MODE) === 'sso'
|
||||
const mode =
|
||||
(typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.VITE_AUTH_MODE) || ''
|
||||
return String(mode).toLowerCase() !== 'legacy'
|
||||
} catch (e) {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +43,28 @@ export function setTid(tid) {
|
||||
export function getTid() {
|
||||
return Number(uni.getStorageSync(TID_KEY) || 0)
|
||||
}
|
||||
|
||||
/** 统一认证:缓存「该账号可进入的企业」列表,供登录后展示/切换企业 */
|
||||
export function setTenants(list) {
|
||||
uni.setStorageSync(TENANTS_KEY, Array.isArray(list) ? list : [])
|
||||
}
|
||||
|
||||
export function getTenants() {
|
||||
const list = uni.getStorageSync(TENANTS_KEY)
|
||||
return Array.isArray(list) ? list : []
|
||||
}
|
||||
|
||||
/**
|
||||
* 取「当前登录的那一家企业」的名称。
|
||||
* 登录返回的 tenants 是该账号可进入的全部企业,顶部展示必须是当前会话选中的企业。
|
||||
*/
|
||||
export function resolveTenantName(info = {}, tid = 0) {
|
||||
if (info && info.tenant_name) return info.tenant_name
|
||||
const list = (info && info.tenants) || getTenants()
|
||||
const hit = list.find((t) => String(t.tid) === String(info.tid || tid))
|
||||
if (hit) return hit.tenant_name || ''
|
||||
return list.length ? list[0].tenant_name || '' : ''
|
||||
}
|
||||
const REMEMBER_KEY = 'app_remember_me'
|
||||
const REMEMBER_TENANT_KEY = 'app_remember_tenant'
|
||||
const REMEMBER_ACCOUNT_KEY = 'app_remember_account'
|
||||
@@ -74,6 +103,21 @@ export function logout() {
|
||||
uni.removeStorageSync(USER_KEY)
|
||||
uni.removeStorageSync(REFRESH_KEY)
|
||||
uni.removeStorageSync(SID_KEY)
|
||||
uni.removeStorageSync(TID_KEY)
|
||||
uni.removeStorageSync(TENANTS_KEY)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除「待选企业」阶段的临时登录态。
|
||||
* 一人多企业时 /auth/login 先签发一枚 tid=0、有效期 10 分钟的待选令牌,
|
||||
* 用户若放弃选择或切换账号,必须清掉,避免半登录态残留去访问业务接口。
|
||||
*/
|
||||
export function clearPendingAuth() {
|
||||
uni.removeStorageSync(TOKEN_KEY)
|
||||
uni.removeStorageSync(REFRESH_KEY)
|
||||
uni.removeStorageSync(SID_KEY)
|
||||
uni.removeStorageSync(TID_KEY)
|
||||
uni.removeStorageSync(TENANTS_KEY)
|
||||
}
|
||||
|
||||
/** 是否开启记住账号登录信息 */
|
||||
|
||||
@@ -116,10 +116,11 @@ function showGeetest4App(captchaId) {
|
||||
|
||||
/**
|
||||
* 弹出极验 4.0 验证
|
||||
* @param {string} [captchaIdOverride] 已从统一认证 /auth/verify-config 拿到 captcha_id 时直接传入
|
||||
* @returns {Promise<{ captcha_id, lot_number, pass_token, gen_time, captcha_output }>}
|
||||
*/
|
||||
export async function showGeetest4() {
|
||||
const captchaId = await fetchGeetest4CaptchaId()
|
||||
export async function showGeetest4(captchaIdOverride = '') {
|
||||
const captchaId = captchaIdOverride || (await fetchGeetest4CaptchaId())
|
||||
if (!captchaId) {
|
||||
throw new Error('未配置极验 captcha_id')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* 菜单 → 页面 的跳转分发
|
||||
*
|
||||
* 聚合平台里绝大多数业务功能(ERP / OA / CRM / CMS)目前只有 Web 端实现,
|
||||
* 端上没有对应页面;少数功能(记事本、日程提醒)已有原生页面。
|
||||
* 这里统一判定:能走原生就走原生,否则丢进 webview 容器打开 Web 端深链。
|
||||
*/
|
||||
import { createAppTicket } from '@/api/auth.js'
|
||||
|
||||
/** 移动端已有原生页面的功能。匹配顺序即优先级。 */
|
||||
const NATIVE_RULES = [
|
||||
{ pattern: /记事本|笔记|便签|notebook/i, route: '/pages/tools/notepad/index' },
|
||||
{ pattern: /日程|提醒|待办|calendar|schedule/i, route: '/pages/tools/schedule/index' }
|
||||
]
|
||||
|
||||
/** Web 端容器页 */
|
||||
const WEBVIEW_PAGE = '/pages/apps/webview'
|
||||
|
||||
/** 菜单是否命中移动端原生页面 */
|
||||
export function resolveNativeRoute(menu = {}) {
|
||||
const haystack = (menu.title || '') + ' ' + (menu.path || '')
|
||||
const hit = NATIVE_RULES.find((r) => r.pattern.test(haystack))
|
||||
return hit ? hit.route : ''
|
||||
}
|
||||
|
||||
/** 该功能是否在租户套餐内 */
|
||||
export function isMenuLocked(menu = {}) {
|
||||
return menu.locked === true || menu.locked === 1
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开一个菜单功能
|
||||
* @param {object} menu /app/home 返回的菜单项
|
||||
* @param {string} [fallbackTitle] 没有菜单时用于提示的功能名
|
||||
*/
|
||||
export function openMenu(menu, fallbackTitle = '') {
|
||||
const name = (menu && (menu.title || menu.name)) || fallbackTitle || '该功能'
|
||||
|
||||
if (!menu) {
|
||||
uni.showToast({ title: name + '暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
if (isMenuLocked(menu)) {
|
||||
uni.showModal({
|
||||
title: '功能未开通',
|
||||
content: '「' + name + '」不在当前套餐范围内,请联系管理员开通后再使用。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 目录节点(还有下级)不直接跳转
|
||||
if (menu.leaf === false) {
|
||||
uni.showToast({ title: '请选择「' + name + '」下的具体功能', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const native = resolveNativeRoute(menu)
|
||||
if (native) {
|
||||
uni.navigateTo({ url: native })
|
||||
return
|
||||
}
|
||||
|
||||
if (!menu.path) {
|
||||
uni.showToast({ title: name + '暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 走 Web 端:先换一次性票据实现免登录,失败则降级为直接打开(用户手动登录一次)
|
||||
openWebPage(menu.path, name)
|
||||
}
|
||||
|
||||
/**
|
||||
* 用 Web 端打开指定业务页。
|
||||
*
|
||||
* 关键:这里不传「完整 URL」,而是拆成 path + ticket 两个参数传给容器页。
|
||||
* 原因是 uniapp 各端对 query 的编解码行为不一致 —— H5 端 vue-router 会先解码一次
|
||||
* 并在序列化时把 % 转成 %25,小程序端则不解码;一旦传完整 URL(含 %、#、&),
|
||||
* 就会出现「双重编码」或被截断。path 与 ticket 都是纯 ASCII 无特殊字符,
|
||||
* 任何端都安全。
|
||||
*
|
||||
* @param {string} path 菜单 path,如 /apps/oa/dashboard
|
||||
* @param {string} title 页面标题
|
||||
*/
|
||||
export async function openWebPage(path, title = '') {
|
||||
const name = title || '功能'
|
||||
const target = String(path || '').trim()
|
||||
if (!target) {
|
||||
uni.showToast({ title: name + '暂未开放', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
let ticket = ''
|
||||
try {
|
||||
const data = await createAppTicket()
|
||||
ticket = (data && data.ticket) || ''
|
||||
} catch (e) {
|
||||
// 票据失败不影响打开,只是需要在 webview 内登录一次
|
||||
console.warn('[nav] 获取免登录票据失败,降级为直接打开:', e)
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url:
|
||||
WEBVIEW_PAGE +
|
||||
'?p=' +
|
||||
encodeURIComponent(target) +
|
||||
'&k=' +
|
||||
encodeURIComponent(ticket) +
|
||||
'&t=' +
|
||||
encodeURIComponent(name)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开 webview 容器页并直接指定完整地址(通用兜底,非免登录场景)。
|
||||
* @param {string} url 完整地址(未编码)
|
||||
* @param {string} title 页面标题
|
||||
*/
|
||||
export function openRawUrl(url, title = '') {
|
||||
if (!url) return
|
||||
uni.navigateTo({
|
||||
url:
|
||||
WEBVIEW_PAGE +
|
||||
'?p=' +
|
||||
encodeURIComponent(url) +
|
||||
'&t=' +
|
||||
encodeURIComponent(title || '功能')
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 子系统数据获取(共享逻辑)
|
||||
*
|
||||
* 三个子系统页面(概览 / 功能 / 待办)都需要:
|
||||
* 1. 该子系统的配置(config/subsystems.js)
|
||||
* 2. 该子系统下的菜单(/app/home → menus 按 module 归组)
|
||||
* 这里统一封装,避免三个页面各写一遍。
|
||||
*/
|
||||
import { ref, computed } from 'vue'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { getSubsystem } from '@/config/subsystems.js'
|
||||
|
||||
/**
|
||||
* @param {string} slug 子系统目录名(crm / erp / oa / cms / tools)
|
||||
* @param {import('vue').Ref<string>} currentTab 当前 tab,用于按需拉数据
|
||||
*/
|
||||
export function useSubsystem(slug) {
|
||||
const sub = getSubsystem(slug)
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
const user = ref({})
|
||||
const menus = ref([])
|
||||
const moduleMeta = ref(null)
|
||||
|
||||
/** 该子系统下所有菜单(含目录) */
|
||||
const allMenus = computed(() => menus.value.filter((m) => m.module === sub.module))
|
||||
|
||||
/** 可直接跳转的叶子菜单,未开通/锁定的排除 */
|
||||
const leafMenus = computed(() =>
|
||||
allMenus.value.filter((m) => m.leaf !== false && !m.locked)
|
||||
)
|
||||
|
||||
/** 目录(有下级,不能直接跳) */
|
||||
const dirMenus = computed(() => allMenus.value.filter((m) => m.leaf === false))
|
||||
|
||||
/** 是否已被租户套餐开通 */
|
||||
const enabled = ref(true)
|
||||
|
||||
async function load(force = false) {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await fetchHome(force)
|
||||
user.value = data.user || {}
|
||||
menus.value = Array.isArray(data.menus) ? data.menus : []
|
||||
const hit = (Array.isArray(data.modules) ? data.modules : []).find(
|
||||
(m) => String(m.code || '').toLowerCase() === String(sub.module).toLowerCase()
|
||||
)
|
||||
moduleMeta.value = hit || null
|
||||
enabled.value = hit ? hit.enabled !== false : true
|
||||
loadError.value = ''
|
||||
} catch (e) {
|
||||
console.error('[subsystem] load failed:', e)
|
||||
loadError.value = (e && e.message) || '接口请求失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { sub, loading, loadError, user, menus, moduleMeta, enabled, allMenus, leafMenus, dirMenus, load }
|
||||
}
|
||||
@@ -19,8 +19,9 @@ export default defineConfig({
|
||||
proxy: {
|
||||
// H5 开发:api/config.js 默认 baseURL 为 /proxy-api,转发到 Go 后端
|
||||
'/proxy-api': {
|
||||
// target: 'http://127.0.0.1:9000',
|
||||
target: 'https://api.yunzer.cn',
|
||||
// 本地联调统一认证(/app/home 等新接口生产未部署时用本地)
|
||||
target: 'http://127.0.0.1:9000',
|
||||
// target: 'https://api.yunzer.cn',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/proxy-api/, ''),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user