389 lines
8.0 KiB
Vue
389 lines
8.0 KiB
Vue
<template>
|
||
<view class="page" :class="{ embedded }">
|
||
<view v-if="!embedded" class="head" :style="headPad">
|
||
<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 v-if="embedded" class="user-card" @tap="goProfile">
|
||
<view class="avatar avatar-light">
|
||
<text class="avatar-text avatar-text-dark">{{ avatarText }}</text>
|
||
</view>
|
||
<view class="user-meta">
|
||
<text class="user-name user-name-dark">{{ user.name || '温新云用户' }}</text>
|
||
<text class="user-sub">{{ user.tenant || '温新云平台' }}<text v-if="user.account"> · {{ user.account }}</text></text>
|
||
</view>
|
||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||
</view>
|
||
|
||
<view class="menu-card">
|
||
<view class="menu-row" @tap="onSubscribe">
|
||
<view class="tint-icon row-icon tint-0">
|
||
<FaIcon name="bell" color="#ffffff" :size="16" />
|
||
</view>
|
||
<view class="row-main">
|
||
<text class="row-title">订阅消息提醒</text>
|
||
<text class="row-sub">审批、日程与公告的微信通知</text>
|
||
</view>
|
||
<text class="row-value">去开启</text>
|
||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="menu-card">
|
||
<view class="menu-row" @tap="goChangePassword">
|
||
<view class="tint-icon row-icon tint-1">
|
||
<FaIcon name="key" color="#ffffff" :size="16" />
|
||
</view>
|
||
<view class="row-main">
|
||
<text class="row-title">修改密码</text>
|
||
<text class="row-sub">定期更换密码,保障账号安全</text>
|
||
</view>
|
||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="menu-card">
|
||
<view class="menu-row" @tap="goHelp">
|
||
<view class="tint-icon row-icon tint-2">
|
||
<FaIcon name="circle-question" color="#ffffff" :size="16" />
|
||
</view>
|
||
<view class="row-main">
|
||
<text class="row-title">帮助中心</text>
|
||
</view>
|
||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||
</view>
|
||
<view class="menu-row" @tap="goSettings">
|
||
<view class="tint-icon row-icon tint-3">
|
||
<FaIcon name="gear" color="#ffffff" :size="16" />
|
||
</view>
|
||
<view class="row-main">
|
||
<text class="row-title">设置</text>
|
||
</view>
|
||
<FaIcon name="chevron-right" color="#c8cfdf" :size="12" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="logout" @tap="handleLogout">
|
||
<text class="logout-text">退出登录</text>
|
||
</view>
|
||
|
||
<view class="bottom-space" />
|
||
</view>
|
||
|
||
<AppTabbar v-if="!embedded" :group="slug" current="mine" />
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, onMounted } from 'vue'
|
||
import { mpHeadPad } from '@/utils/mpHead.js'
|
||
|
||
const headPad = mpHeadPad()
|
||
import { onShow } from '@dcloudio/uni-app'
|
||
import { isLoggedIn, logout, isSSOEnabled, getToken, clearPendingAuth } from '@/utils/auth.js'
|
||
import { logoutUAC, logoutApi } from '@/api/auth.js'
|
||
import { clearHomeCache } from '@/api/workspace.js'
|
||
import { requestSubscribeNotice } from '@/utils/subscribe.js'
|
||
import { useSubsystem } from '@/utils/subsystem.js'
|
||
import AppTabbar from '@/components/AppTabbar.vue'
|
||
|
||
const props = defineProps({
|
||
slug: { type: String, required: true },
|
||
embedded: { type: Boolean, default: false }
|
||
})
|
||
|
||
const { loading, loadError, user, load } = useSubsystem(props.slug)
|
||
|
||
const avatarText = computed(() => {
|
||
const name = user.value.name || user.value.account || '云'
|
||
return String(name).charAt(0).toUpperCase()
|
||
})
|
||
|
||
function goProfile() {
|
||
uni.redirectTo({ url: '/pages/profile/profile' })
|
||
}
|
||
|
||
function onSubscribe() {
|
||
requestSubscribeNotice({ tip: '已开启消息提醒' })
|
||
}
|
||
|
||
function goChangePassword() {
|
||
uni.navigateTo({ url: '/pages/profile/changePassword' })
|
||
}
|
||
|
||
function goHelp() {
|
||
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('帮助中心') })
|
||
}
|
||
|
||
function goSettings() {
|
||
uni.navigateTo({ url: '/pages/common/developing?t=' + encodeURIComponent('设置') })
|
||
}
|
||
|
||
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()) return
|
||
load()
|
||
})
|
||
|
||
onShow(() => {
|
||
if (isLoggedIn() && !loading.value) {
|
||
load()
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@import '@/src/styles/page-common.scss';
|
||
|
||
.page {
|
||
@include page-shell;
|
||
|
||
&.embedded {
|
||
height: auto;
|
||
}
|
||
}
|
||
|
||
.head {
|
||
flex-shrink: 0;
|
||
padding: calc(var(--status-bar-height, 44px) + 20rpx) $page-padding-x 40rpx;
|
||
/* #ifdef MP-WEIXIN */
|
||
padding-top: calc(env(safe-area-inset-top, 25px) + 84rpx);
|
||
/* #endif */
|
||
background: $hero-gradient;
|
||
}
|
||
|
||
.user {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 20rpx;
|
||
margin-top: 42rpx;
|
||
}
|
||
|
||
.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: 38rpx;
|
||
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: 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: 28rpx $page-padding-x 0;
|
||
}
|
||
|
||
.user-card {
|
||
@include card;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 20rpx;
|
||
padding: 28rpx 24rpx;
|
||
margin-bottom: 32rpx;
|
||
|
||
&:active {
|
||
background: $color-bg-page;
|
||
}
|
||
}
|
||
|
||
.avatar-light {
|
||
width: 88rpx;
|
||
height: 88rpx;
|
||
background: $color-primary-bg;
|
||
border: none;
|
||
}
|
||
|
||
.avatar-text-dark {
|
||
font-size: 34rpx;
|
||
color: $color-primary;
|
||
}
|
||
|
||
.user-name-dark {
|
||
font-size: 32rpx;
|
||
color: $color-text;
|
||
}
|
||
|
||
.user-card .user-sub {
|
||
color: $color-text-muted;
|
||
}
|
||
|
||
.menu-card {
|
||
@include card;
|
||
padding: 0 24rpx;
|
||
margin-bottom: 24rpx;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.menu-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 18rpx;
|
||
padding: 26rpx 0;
|
||
|
||
& + & {
|
||
border-top: 1rpx solid $color-divider;
|
||
}
|
||
|
||
&:active {
|
||
opacity: 0.75;
|
||
}
|
||
}
|
||
|
||
.row-icon {
|
||
@include tint-icon(64rpx, 18rpx);
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.row-main {
|
||
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: 6rpx;
|
||
font-size: 22rpx;
|
||
color: $color-text-muted;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.row-value {
|
||
flex-shrink: 0;
|
||
font-size: 24rpx;
|
||
color: $color-primary;
|
||
}
|
||
|
||
.logout {
|
||
@include card;
|
||
margin-top: 40rpx;
|
||
padding: 28rpx 0;
|
||
text-align: center;
|
||
|
||
&:active {
|
||
background: $color-bg-page;
|
||
}
|
||
}
|
||
|
||
.logout-text {
|
||
font-size: 28rpx;
|
||
color: $color-danger;
|
||
}
|
||
|
||
.err-box {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16rpx;
|
||
padding: 24rpx 22rpx;
|
||
margin-bottom: 24rpx;
|
||
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;
|
||
}
|
||
|
||
.bottom-space {
|
||
height: 32rpx;
|
||
}
|
||
</style>
|