540 行
12 KiB
Plaintext
540 行
12 KiB
Plaintext
<template>
|
||
<view class="profile-page">
|
||
<scroll-view class="profile-scroll" :scroll-y="true">
|
||
<view class="profile-content">
|
||
<!-- 1. Minimal Profile Identity Header -->
|
||
<view class="profile-header">
|
||
<view class="avatar-wrap">
|
||
<image
|
||
v-if="state.account.avatar !== ''"
|
||
class="avatar-img"
|
||
:src="state.account.avatar"
|
||
mode="aspectFill"
|
||
@click="onAvatarClick"
|
||
/>
|
||
<view
|
||
v-else
|
||
class="avatar-empty"
|
||
@click="onAvatarChoose"
|
||
>
|
||
<text class="avatar-add-icon">+</text>
|
||
</view>
|
||
<view
|
||
v-if="state.account.avatar !== ''"
|
||
class="avatar-remove-badge"
|
||
@click="onAvatarDelete"
|
||
>
|
||
<text class="avatar-remove-icon">×</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="identity-info">
|
||
<text class="identity-name">{{ state.account.name }}</text>
|
||
<text class="identity-company">{{ state.account.company }}</text>
|
||
<text class="identity-dept">{{ state.account.department }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 2. Operational Hardware & Team Group -->
|
||
<view class="menu-group">
|
||
<view class="menu-row" @click="openPage('/pages/owner/nfc/scan')">
|
||
<text class="menu-title">{{ t('nfcScan') }}</text>
|
||
<text class="menu-arrow">›</text>
|
||
</view>
|
||
<view class="menu-divider"></view>
|
||
<view class="menu-row" @click="openPage('/pages/owner/nfc/mode')">
|
||
<text class="menu-title">{{ t('nfcMode') }}</text>
|
||
<text class="menu-arrow">›</text>
|
||
</view>
|
||
<view class="menu-divider"></view>
|
||
<view class="menu-row" @click="openPage('/pages/owner/nfc/security')">
|
||
<text class="menu-title">{{ t('nfcSecurity') }}</text>
|
||
<text class="menu-arrow">›</text>
|
||
</view>
|
||
<view class="menu-divider"></view>
|
||
<view class="menu-row" @click="openPage('/pages/owner/team/overview')">
|
||
<text class="menu-title">{{ t('teamBriefing') }}</text>
|
||
<text class="menu-arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 3. Plan & Quota Group -->
|
||
<view class="menu-group">
|
||
<view class="menu-row">
|
||
<text class="menu-title">{{ t('quotaCards') }}</text>
|
||
<text class="menu-value">{{ quotaLine }}</text>
|
||
</view>
|
||
<view v-if="quotaExceeded" class="quota-tip-row">
|
||
<text class="quota-tip-text">{{ t('quotaUpgrade') }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 4. Notifications & Switches Group -->
|
||
<view class="menu-group">
|
||
<view class="menu-row menu-row-switch">
|
||
<view class="switch-label-wrap">
|
||
<text class="menu-title">{{ t('radarPushTitle') }}</text>
|
||
<text class="menu-subtitle">{{ t('radarPushDesc') }}</text>
|
||
</view>
|
||
<view class="switch-touch-area">
|
||
<switch
|
||
:checked="state.notifications.radarPush"
|
||
color="#0B5CFF"
|
||
@change="onRadarPushChange"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="menu-divider"></view>
|
||
<view class="menu-row menu-row-switch">
|
||
<view class="switch-label-wrap">
|
||
<text class="menu-title">{{ t('leadNoticeTitle') }}</text>
|
||
<text class="menu-subtitle">{{ t('leadNoticeDesc') }}</text>
|
||
</view>
|
||
<view class="switch-touch-area">
|
||
<switch
|
||
:checked="state.notifications.leadNotice"
|
||
color="#0B5CFF"
|
||
@change="onLeadNoticeChange"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 5. Display Language Preferences Group -->
|
||
<view class="menu-group">
|
||
<view class="language-header">
|
||
<text class="menu-title">{{ t('languageSection') }}</text>
|
||
</view>
|
||
<view class="language-chip-list">
|
||
<view
|
||
v-for="item in languageList"
|
||
:key="item.code"
|
||
class="lang-pill"
|
||
:class="{ 'lang-pill-active': item.code === state.locale }"
|
||
@click="onSelectLocale(item.code)"
|
||
>
|
||
<text
|
||
class="lang-pill-text"
|
||
:class="{ 'lang-pill-text-active': item.code === state.locale }"
|
||
>
|
||
{{ item.label }}
|
||
</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 6. Minimal Sign Out -->
|
||
<view class="signout-section">
|
||
<view class="signout-btn" @click="onLogout">
|
||
<text class="signout-text">{{ t('logout') }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- System error notification if any -->
|
||
<view v-if="state.errorMessage !== ''" class="error-notice">
|
||
<text class="error-notice-text">{{ state.errorMessage }}</text>
|
||
</view>
|
||
|
||
<view class="bottom-safe-space"></view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup lang="uts">
|
||
import {
|
||
ProfileState,
|
||
loadProfileSettings,
|
||
saveProfileSettings,
|
||
toggleRadarPush,
|
||
toggleLeadNotice,
|
||
setPreferredLocale,
|
||
resolveProfileText,
|
||
previewAccountAvatar,
|
||
removeAccountAvatar,
|
||
} from './useProfile.uts';
|
||
import { OmniLocale } from '../../../common/locale.uts';
|
||
import { fetchCardQuota } from '../../../common/api.uts';
|
||
import { getTenantId, clearAuthToken } from '../../../common/request.uts';
|
||
|
||
type LangOption = {
|
||
code: OmniLocale;
|
||
label: string;
|
||
};
|
||
|
||
const state = reactive<ProfileState>(loadProfileSettings());
|
||
const quotaLine = ref('--');
|
||
const quotaExceeded = ref(false);
|
||
|
||
function onAvatarClick(): void {
|
||
if (state.account.avatar !== '') {
|
||
previewAccountAvatar(state);
|
||
} else {
|
||
onAvatarChoose();
|
||
}
|
||
}
|
||
|
||
function onAvatarChoose(): void {
|
||
uni.chooseImage({
|
||
count: 1,
|
||
sourceType: ['album', 'camera'],
|
||
success: (res: { tempFilePaths: string[] }) => {
|
||
if (res.tempFilePaths && res.tempFilePaths.length > 0) {
|
||
state.account.avatar = res.tempFilePaths[0];
|
||
saveProfileSettings(state);
|
||
}
|
||
},
|
||
});
|
||
}
|
||
|
||
function onAvatarDelete(): void {
|
||
removeAccountAvatar(state);
|
||
saveProfileSettings(state);
|
||
}
|
||
|
||
const languageList: LangOption[] = [
|
||
{ code: 'zh-CN', label: '简体中文' },
|
||
{ code: 'en-US', label: 'English' },
|
||
{ code: 'ar-SA', label: 'العربية' },
|
||
{ code: 'es-ES', label: 'Español' },
|
||
{ code: 'de-DE', label: 'Deutsch' },
|
||
{ code: 'fr-FR', label: 'Français' },
|
||
{ code: 'ja-JP', label: '日本語' },
|
||
];
|
||
|
||
function t(key: string): string {
|
||
return resolveProfileText(key);
|
||
}
|
||
|
||
function onRadarPushChange(e: UniSwitchChangeEvent): void {
|
||
toggleRadarPush(state, e.detail.value);
|
||
}
|
||
|
||
function onLeadNoticeChange(e: UniSwitchChangeEvent): void {
|
||
toggleLeadNotice(state, e.detail.value);
|
||
}
|
||
|
||
function onSelectLocale(code: OmniLocale): void {
|
||
setPreferredLocale(state, code);
|
||
saveProfileSettings(state);
|
||
}
|
||
|
||
function openPage(url: string): void {
|
||
uni.navigateTo({
|
||
url,
|
||
});
|
||
}
|
||
|
||
async function loadQuota(): Promise<void> {
|
||
try {
|
||
const tenantId = getTenantId();
|
||
const quota = await fetchCardQuota(tenantId !== '' ? tenantId : 1);
|
||
quotaLine.value = `${quota.used} / ${quota.limit}`;
|
||
quotaExceeded.value = quota.exceeded === true;
|
||
} catch (_e) {
|
||
quotaLine.value = '1 / 5';
|
||
quotaExceeded.value = false;
|
||
}
|
||
}
|
||
|
||
function onLogout(): void {
|
||
uni.showModal({
|
||
title: resolveProfileText('confirmLogoutTitle'),
|
||
content: resolveProfileText('confirmLogoutContent'),
|
||
success: (res: { confirm?: boolean }) => {
|
||
if (res.confirm === true) {
|
||
clearAuthToken();
|
||
uni.showToast({
|
||
title: resolveProfileText('logout'),
|
||
icon: 'none',
|
||
});
|
||
// #ifdef H5
|
||
if (typeof window !== 'undefined') {
|
||
window.location.hash = '#/pages/common/login';
|
||
return;
|
||
}
|
||
// #endif
|
||
uni.reLaunch({
|
||
url: '/pages/common/login',
|
||
});
|
||
}
|
||
},
|
||
});
|
||
}
|
||
|
||
onShow(() => {
|
||
const loaded = loadProfileSettings();
|
||
state.account = loaded.account;
|
||
state.notifications = loaded.notifications;
|
||
state.locale = loaded.locale;
|
||
loadQuota();
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.profile-page {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
background-color: #F7F8FA;
|
||
}
|
||
|
||
.profile-scroll {
|
||
flex: 1;
|
||
}
|
||
|
||
.profile-content {
|
||
padding: 24px 16px 32px 16px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
/* 1. Minimal Identity Header */
|
||
.profile-header {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
margin-bottom: 20px;
|
||
padding: 4px 4px;
|
||
}
|
||
|
||
.avatar-wrap {
|
||
position: relative;
|
||
width: 54px;
|
||
height: 54px;
|
||
margin-right: 16px;
|
||
}
|
||
|
||
.avatar-img {
|
||
width: 54px;
|
||
height: 54px;
|
||
border-radius: 27px;
|
||
background-color: #E3E7ED;
|
||
}
|
||
|
||
.avatar-empty {
|
||
width: 54px;
|
||
height: 54px;
|
||
border-radius: 27px;
|
||
border: 1px dashed #C9CDD4;
|
||
background-color: #FFFFFF;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.avatar-add-icon {
|
||
font-size: 22px;
|
||
color: #667085;
|
||
line-height: 1;
|
||
}
|
||
|
||
.avatar-remove-badge {
|
||
position: absolute;
|
||
top: -2px;
|
||
right: -2px;
|
||
width: 16px;
|
||
height: 16px;
|
||
border-radius: 8px;
|
||
background-color: rgba(240, 68, 56, 0.9);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.avatar-remove-icon {
|
||
color: #FFFFFF;
|
||
font-size: 11px;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
}
|
||
|
||
.identity-info {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
}
|
||
|
||
.identity-name {
|
||
font-size: 18px;
|
||
font-weight: 600;
|
||
color: #101828;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.identity-company {
|
||
font-size: 13px;
|
||
color: #667085;
|
||
margin-top: 3px;
|
||
}
|
||
|
||
.identity-dept {
|
||
font-size: 12px;
|
||
color: #667085;
|
||
margin-top: 1px;
|
||
}
|
||
|
||
/* 2. Modern Inset Grouped Card */
|
||
.menu-group {
|
||
background-color: #FFFFFF;
|
||
border: 1px solid #E3E7ED;
|
||
border-radius: 16px;
|
||
padding: 0 16px;
|
||
margin-bottom: 14px;
|
||
}
|
||
|
||
.menu-row {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
min-height: 48px;
|
||
padding: 10px 0;
|
||
}
|
||
|
||
.menu-row:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.menu-row-switch {
|
||
min-height: 52px;
|
||
}
|
||
|
||
.menu-title {
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
color: #101828;
|
||
}
|
||
|
||
.menu-value {
|
||
font-size: 13px;
|
||
color: #667085;
|
||
}
|
||
|
||
.menu-arrow {
|
||
font-size: 16px;
|
||
color: #667085;
|
||
line-height: 1;
|
||
}
|
||
|
||
.menu-divider {
|
||
height: 1px;
|
||
background-color: #E3E7ED;
|
||
}
|
||
|
||
.switch-label-wrap {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
padding-right: 12px;
|
||
}
|
||
|
||
.menu-subtitle {
|
||
font-size: 12px;
|
||
color: #667085;
|
||
line-height: 1.4;
|
||
margin-top: 2px;
|
||
}
|
||
|
||
.switch-touch-area {
|
||
min-width: 44px;
|
||
min-height: 44px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.quota-tip-row {
|
||
padding-bottom: 12px;
|
||
}
|
||
|
||
.quota-tip-text {
|
||
font-size: 12px;
|
||
color: #F04438;
|
||
}
|
||
|
||
/* Language selector */
|
||
.language-header {
|
||
padding-top: 14px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.language-chip-list {
|
||
display: flex;
|
||
flex-direction: row;
|
||
flex-wrap: wrap;
|
||
gap: 8px;
|
||
padding-bottom: 14px;
|
||
}
|
||
|
||
.lang-pill {
|
||
min-height: 36px;
|
||
padding: 0 14px;
|
||
border-radius: 10px;
|
||
border: 1px solid #E3E7ED;
|
||
background-color: #F7F8FA;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.lang-pill-active {
|
||
border-color: #0B5CFF;
|
||
background-color: #0B5CFF;
|
||
}
|
||
|
||
.lang-pill-text {
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
color: #101828;
|
||
}
|
||
|
||
.lang-pill-text-active {
|
||
color: #FFFFFF;
|
||
}
|
||
|
||
/* Sign out button */
|
||
.signout-section {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-top: 12px;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.signout-btn {
|
||
min-height: 44px;
|
||
padding: 0 20px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.signout-text {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: #667085;
|
||
}
|
||
|
||
.signout-btn:active {
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.error-notice {
|
||
padding: 10px 14px;
|
||
background-color: #F7F8FA;
|
||
border: 1px solid #E3E7ED;
|
||
border-radius: 10px;
|
||
margin-bottom: 14px;
|
||
}
|
||
|
||
.error-notice-text {
|
||
font-size: 12px;
|
||
color: #667085;
|
||
}
|
||
|
||
.bottom-safe-space {
|
||
height: calc(24px + var(--window-bottom, 0px) + env(safe-area-inset-bottom, 0px));
|
||
}
|
||
</style>
|