Merge branch 'master' of https://git.yunzer.cn/yunzerwebsite/yunzerwebsiteallinone
This commit is contained in:
commit
5d7ed43570
16 files changed
+11811
-1008
No files matched your search
+95
-180
@@ -4,34 +4,17 @@
|
||||
<view class="head" :style="headPad">
|
||||
<view class="head-row">
|
||||
<view>
|
||||
<text class="head-title">工作空间</text>
|
||||
<text class="head-caption">选择一个应用,开始今天的工作</text>
|
||||
<text class="head-eyebrow">YUNZE WORKSPACE</text>
|
||||
<text class="head-title">工作台</text>
|
||||
</view>
|
||||
<view class="account-chip"><FaIcon name="user" color="#3478f6" :size="15" /><text>{{ user.account || '我的账号' }}</text></view>
|
||||
</view>
|
||||
<view class="tenant-switcher" :class="{ selectable: tenants.length > 1 }" @tap="openTenantPicker">
|
||||
<view class="tenant-mark"><FaIcon name="building" color="#3689d6" :size="17" /></view>
|
||||
<view class="tenant-current">
|
||||
<text class="tenant-label">当前公司</text>
|
||||
<text class="head-sub">{{ user.tenant || '云泽平台' }}</text>
|
||||
</view>
|
||||
<text v-if="user.account" class="tenant-account">{{ user.account }}</text>
|
||||
<FaIcon v-if="tenants.length > 1" name="chevron-right" color="#83a2be" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="tenantPickerVisible" class="tenant-mask" @tap="closeTenantPicker">
|
||||
<view class="tenant-sheet" @tap.stop>
|
||||
<view class="sheet-head">
|
||||
<text class="sheet-title">切换公司</text>
|
||||
<text class="sheet-close" @tap="closeTenantPicker">完成</text>
|
||||
</view>
|
||||
<text class="sheet-sub">选择后将切换当前工作空间</text>
|
||||
<view v-for="item in tenants" :key="item.tid" class="tenant-option" :class="{ current: Number(item.tid) === currentTid, disabled: switchingTenant }" @tap="changeTenant(item)">
|
||||
<view class="tenant-option-icon"><FaIcon name="building" color="#398fe7" :size="16" /></view>
|
||||
<view class="tenant-option-info"><text class="tenant-option-name">{{ item.tenant_name || `企业${item.tid}` }}</text><text class="tenant-option-meta">{{ Number(item.tid) === currentTid ? '当前工作空间' : '切换到此公司' }}</text></view>
|
||||
<FaIcon v-if="Number(item.tid) === currentTid" name="circle-check" color="#398fe7" :size="18" />
|
||||
</view>
|
||||
<view class="tenant-switch" @tap="chooseTenant">
|
||||
<view class="tenant-mark"><FaIcon name="building" color="#ffffff" :size="19" /></view>
|
||||
<view class="tenant-copy"><text class="tenant-label">当前租户</text><text class="tenant-name">{{ user.tenant || '云泽平台' }}</text></view>
|
||||
<view class="tenant-action"><text>切换</text><FaIcon name="chevron-down" color="#3478f6" :size="12" /></view>
|
||||
</view>
|
||||
<text class="head-sub">选择一个业务系统,开始高效工作</text>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
@@ -78,7 +61,7 @@ import { mpHeadPad } from '@/utils/mpHead.js'
|
||||
|
||||
const headPad = mpHeadPad()
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { isLoggedIn, getTenants, getTid, setAuthTokens, setTid, setTenantName } from '@/utils/auth.js'
|
||||
import { isLoggedIn, getTenants, getTid, setAuthTokens, setTid, setTenantName, getUser, setUser } from '@/utils/auth.js'
|
||||
import { switchTenant } from '@/api/auth.js'
|
||||
import { fetchHome } from '@/api/workspace.js'
|
||||
import { openMenu } from '@/utils/nav.js'
|
||||
@@ -106,9 +89,7 @@ const loadError = ref('')
|
||||
const user = ref({})
|
||||
const modules = ref([])
|
||||
const menus = ref([])
|
||||
const tenants = ref([])
|
||||
const currentTid = ref(0)
|
||||
const tenantPickerVisible = ref(false)
|
||||
const tenants = ref(getTenants())
|
||||
const switchingTenant = ref(false)
|
||||
|
||||
/** 叶子菜单(可直接跳转的功能页),已锁定的过滤掉 */
|
||||
@@ -146,7 +127,6 @@ const cards = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
const enabledCount = computed(() => cards.value.filter((c) => !c.locked).length)
|
||||
|
||||
/* ==================== 数据加载 ==================== */
|
||||
|
||||
@@ -170,6 +150,41 @@ async function load(force = false) {
|
||||
|
||||
/* ==================== 交互 ==================== */
|
||||
|
||||
function chooseTenant() {
|
||||
const list = tenants.value
|
||||
if (list.length <= 1) { uni.showToast({ title: list.length ? '当前账号仅绑定一个租户' : '暂无可切换的租户', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (switchingTenant.value) return
|
||||
uni.showActionSheet({
|
||||
itemList: list.map((tenant) => tenant.tenant_name || `企业${tenant.tid}`),
|
||||
success: async ({ tapIndex }) => {
|
||||
const tenant = list[tapIndex]
|
||||
if (!tenant || String(tenant.tid) === String(getTid())) return
|
||||
switchingTenant.value = true
|
||||
uni.showLoading({ title: '正在切换...', mask: true })
|
||||
try {
|
||||
const res = await switchTenant({ tid: tenant.tid })
|
||||
if (!res || !res.tokens) throw new Error((res && res.msg) || '切换租户失败')
|
||||
setAuthTokens(res.tokens)
|
||||
setTid(tenant.tid)
|
||||
setTenantName(tenant.tenant_name || '')
|
||||
const profile = getUser() || {}
|
||||
const nextUser = { ...profile, tid: tenant.tid, tenant_name: tenant.tenant_name || '' }
|
||||
setUser(nextUser)
|
||||
user.value = { ...user.value, tenant: tenant.tenant_name || '', account: nextUser.account || user.value.account }
|
||||
await load(true)
|
||||
uni.showToast({ title: '已切换租户', icon: 'success' })
|
||||
} catch (e) {
|
||||
uni.showToast({ title: (e && e.message) || '切换失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
switchingTenant.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击子系统卡片 → 进入该子系统独立页面组(带自己的 tabbar)。
|
||||
* 未在 config/subsystems.js 注册的模块,降级为直接打开 Web 端该模块首页。
|
||||
@@ -258,89 +273,80 @@ onShow(() => {
|
||||
/* ============ 顶部信息(融入页面背景) ============ */
|
||||
.head {
|
||||
flex-shrink: 0;
|
||||
padding: calc(var(--status-bar-height, 44px) + 32rpx) $page-padding-x 12rpx;
|
||||
padding: calc(var(--status-bar-height, 44px) + 32rpx) $page-padding-x 28rpx;
|
||||
/* #ifdef MP-WEIXIN */
|
||||
/* 小程序端 --status-bar-height 固定 25px,需真实状态栏(env)+胶囊避让 */
|
||||
padding-top: calc(env(safe-area-inset-top, 25px) + 96rpx);
|
||||
/* #endif */
|
||||
background: $color-bg-page;
|
||||
background: linear-gradient(145deg, #eaf3ff 0%, #f5f9ff 58%, #ffffff 100%);
|
||||
border-bottom: 1rpx solid #e5efff;
|
||||
}
|
||||
|
||||
.head-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.head-title {
|
||||
font-size: 46rpx;
|
||||
.head-eyebrow {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
font-size: 18rpx;
|
||||
font-weight: 700;
|
||||
color: #193d61;
|
||||
letter-spacing: 3rpx;
|
||||
color: #6e9de5;
|
||||
}
|
||||
|
||||
.head-title {
|
||||
display: block;
|
||||
font-size: 44rpx;
|
||||
font-weight: 700;
|
||||
color: #17345f;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.head-caption {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #8aa2b8;
|
||||
}
|
||||
|
||||
.tenant-switcher {
|
||||
margin-top: 28rpx;
|
||||
padding: 20rpx 22rpx;
|
||||
.account-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.92);
|
||||
border-radius: 24rpx;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
box-shadow: 0 12rpx 32rpx rgba(81, 133, 176, 0.08);
|
||||
gap: 9rpx;
|
||||
padding: 12rpx 17rpx;
|
||||
border-radius: 30rpx;
|
||||
background: rgba(255,255,255,.85);
|
||||
color: #526b8d;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
&.selectable:active { background: #f4faff; }
|
||||
.tenant-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 28rpx;
|
||||
padding: 20rpx 22rpx;
|
||||
border: 1rpx solid #dceaff;
|
||||
border-radius: 18rpx;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 8rpx 24rpx rgba(47, 110, 196, .08);
|
||||
}
|
||||
|
||||
.tenant-mark {
|
||||
width: 68rpx;
|
||||
height: 68rpx;
|
||||
flex-shrink: 0;
|
||||
border-radius: 20rpx;
|
||||
background: #eaf5ff;
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(145deg, #69a5ff, #3478f6);
|
||||
}
|
||||
|
||||
.tenant-current {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tenant-label {
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
font-size: 20rpx;
|
||||
color: #94aabe;
|
||||
}
|
||||
.tenant-copy { flex: 1; min-width: 0; margin-left: 16rpx; }
|
||||
.tenant-label { display: block; font-size: 20rpx; color: #8a9bb3; }
|
||||
.tenant-name { display: block; margin-top: 5rpx; font-size: 27rpx; font-weight: 600; color: #203b62; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.tenant-action { display: flex; align-items: center; gap: 8rpx; color: #3478f6; font-size: 22rpx; font-weight: 600; }
|
||||
|
||||
.head-sub {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #294a68;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tenant-account {
|
||||
max-width: 180rpx;
|
||||
font-size: 21rpx;
|
||||
color: #8da3b7;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-top: 22rpx;
|
||||
font-size: 23rpx;
|
||||
color: #8295b0;
|
||||
}
|
||||
|
||||
/* ============ 内容区 ============ */
|
||||
@@ -349,101 +355,8 @@ onShow(() => {
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 8rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.tenant-mask {
|
||||
position: fixed;
|
||||
z-index: 99;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(18, 42, 68, 0.32);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.tenant-sheet {
|
||||
width: 100%;
|
||||
max-height: 72vh;
|
||||
overflow-y: auto;
|
||||
padding: 38rpx 32rpx calc(env(safe-area-inset-bottom, 0px) + 40rpx);
|
||||
box-sizing: border-box;
|
||||
border-radius: 36rpx 36rpx 0 0;
|
||||
background: linear-gradient(180deg, #f5faff 0%, #ffffff 24%);
|
||||
}
|
||||
|
||||
.sheet-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.sheet-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #203b56;
|
||||
}
|
||||
|
||||
.sheet-close {
|
||||
font-size: 25rpx;
|
||||
color: #398fe7;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.sheet-sub {
|
||||
display: block;
|
||||
margin: 8rpx 0 20rpx;
|
||||
font-size: 23rpx;
|
||||
color: #8aa0b4;
|
||||
}
|
||||
|
||||
.tenant-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 20rpx 16rpx;
|
||||
border-radius: 18rpx;
|
||||
border: 1rpx solid #edf3f8;
|
||||
margin-top: 12rpx;
|
||||
|
||||
&.current {
|
||||
background: #f2f8ff;
|
||||
border-color: #cfe5fa;
|
||||
}
|
||||
|
||||
&.disabled { opacity: 0.6; }
|
||||
}
|
||||
|
||||
.tenant-option-icon {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #eaf5ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tenant-option-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tenant-option-name,
|
||||
.tenant-option-meta { display: block; }
|
||||
|
||||
.tenant-option-name {
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
color: #294763;
|
||||
}
|
||||
|
||||
.tenant-option-meta {
|
||||
margin-top: 5rpx;
|
||||
font-size: 22rpx;
|
||||
color: #91a5b8;
|
||||
padding: 20rpx $page-padding-x 0;
|
||||
background: #f5f8fd;
|
||||
}
|
||||
|
||||
/* ============ 失败提示 ============ */
|
||||
@@ -510,7 +423,9 @@ onShow(() => {
|
||||
|
||||
.portal-card {
|
||||
@include card;
|
||||
padding: 40rpx 16rpx 34rpx;
|
||||
padding: 34rpx 16rpx 30rpx;
|
||||
border: 1rpx solid #e6eef9;
|
||||
box-shadow: 0 6rpx 20rpx rgba(38, 86, 150, .045);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
Reference in new issue
Block a user