478 行
10 KiB
Plaintext
478 行
10 KiB
Plaintext
<template>
|
||
<view class="profile-page">
|
||
<scroll-view class="profile-scroll" :scroll-y="true">
|
||
<view class="profile-container">
|
||
<!-- Header section: title & subtitle -->
|
||
<view class="header-section">
|
||
<text class="page-title">{{ t('title') }}</text>
|
||
<text class="page-subtitle">{{ t('subtitle') }}</text>
|
||
</view>
|
||
|
||
<!-- Account profile section -->
|
||
<view class="section-card">
|
||
<text class="section-title">{{ t('accountSection') }}</text>
|
||
|
||
<view class="account-header">
|
||
<view class="avatar-container">
|
||
<image
|
||
v-if="state.account.avatar !== ''"
|
||
class="account-avatar"
|
||
:src="state.account.avatar"
|
||
mode="aspectFill"
|
||
@click="onAvatarClick"
|
||
/>
|
||
<view
|
||
v-else
|
||
class="account-avatar-placeholder"
|
||
@click="onAvatarChoose"
|
||
>
|
||
<text class="avatar-placeholder-plus">+</text>
|
||
</view>
|
||
<view
|
||
v-if="state.account.avatar !== ''"
|
||
class="avatar-del-badge"
|
||
@click="onAvatarDelete"
|
||
>
|
||
<text class="avatar-del-icon">×</text>
|
||
</view>
|
||
</view>
|
||
<view class="account-info">
|
||
<text class="account-name">{{ state.account.name }}</text>
|
||
<text class="account-meta">{{ state.account.company }}</text>
|
||
<text class="account-dept">{{ state.account.department }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- Notification settings section -->
|
||
<view class="section-card">
|
||
<text class="section-title">{{ t('notificationsSection') }}</text>
|
||
|
||
<!-- Radar push notification -->
|
||
<view class="setting-row">
|
||
<view class="setting-text-wrap">
|
||
<text class="setting-label">{{ t('radarPushTitle') }}</text>
|
||
<text class="setting-desc">{{ t('radarPushDesc') }}</text>
|
||
</view>
|
||
<view class="switch-touch-area">
|
||
<switch
|
||
:checked="state.notifications.radarPush"
|
||
color="#0B5CFF"
|
||
@change="onRadarPushChange"
|
||
/>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="row-divider"></view>
|
||
|
||
<!-- Lead notice notification -->
|
||
<view class="setting-row">
|
||
<view class="setting-text-wrap">
|
||
<text class="setting-label">{{ t('leadNoticeTitle') }}</text>
|
||
<text class="setting-desc">{{ t('leadNoticeDesc') }}</text>
|
||
</view>
|
||
<view class="switch-touch-area">
|
||
<switch
|
||
:checked="state.notifications.leadNotice"
|
||
color="#0B5CFF"
|
||
@change="onLeadNoticeChange"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- Preferred language section -->
|
||
<view class="section-card">
|
||
<text class="section-title">{{ t('languageSection') }}</text>
|
||
<text class="setting-desc language-desc">{{ t('languageLabel') }}</text>
|
||
|
||
<view class="language-options">
|
||
<view
|
||
v-for="item in languageList"
|
||
:key="item.code"
|
||
class="language-chip"
|
||
:class="{ 'language-chip-active': item.code === state.locale }"
|
||
@click="onSelectLocale(item.code)"
|
||
>
|
||
<text
|
||
class="language-chip-text"
|
||
:class="{ 'language-chip-text-active': item.code === state.locale }"
|
||
>
|
||
{{ item.label }}
|
||
</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- Error feedback banner -->
|
||
<view v-if="state.errorMessage !== ''" class="error-banner">
|
||
<text class="error-banner-text">{{ state.errorMessage }}</text>
|
||
</view>
|
||
|
||
<view class="bottom-spacer"></view>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<!-- Bottom single primary CTA bar -->
|
||
<view class="bottom-cta-bar">
|
||
<button
|
||
class="primary-cta-btn"
|
||
:disabled="state.saving"
|
||
@click="onSaveSettings"
|
||
>
|
||
<text class="primary-cta-btn-text">{{ t('save') }}</text>
|
||
</button>
|
||
</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';
|
||
|
||
type LangOption = {
|
||
code: OmniLocale;
|
||
label: string;
|
||
};
|
||
|
||
const state = reactive<ProfileState>(loadProfileSettings());
|
||
|
||
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];
|
||
}
|
||
},
|
||
});
|
||
}
|
||
|
||
function onAvatarDelete(): void {
|
||
removeAccountAvatar(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);
|
||
}
|
||
|
||
function onSaveSettings(): void {
|
||
state.saving = true;
|
||
const ok = saveProfileSettings(state);
|
||
state.saving = false;
|
||
if (ok) {
|
||
uni.showToast({
|
||
title: resolveProfileText('saved'),
|
||
icon: 'none',
|
||
});
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
const loaded = loadProfileSettings();
|
||
state.account = loaded.account;
|
||
state.notifications = loaded.notifications;
|
||
state.locale = loaded.locale;
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.profile-page {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
background-color: #F7F8FA;
|
||
}
|
||
|
||
.profile-scroll {
|
||
flex: 1;
|
||
}
|
||
|
||
.profile-container {
|
||
padding: 24px 16px 16px 16px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.header-section {
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.page-title {
|
||
font-size: 24px;
|
||
font-weight: 700;
|
||
color: #101828;
|
||
line-height: 1.25;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.page-subtitle {
|
||
font-size: 14px;
|
||
color: #667085;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.section-card {
|
||
background-color: #FFFFFF;
|
||
border: 1px solid #E3E7ED;
|
||
border-radius: 16px;
|
||
padding: 16px;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.section-title {
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
color: #101828;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.account-header {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
}
|
||
|
||
.avatar-container {
|
||
position: relative;
|
||
width: 56px;
|
||
height: 56px;
|
||
margin-right: 16px;
|
||
}
|
||
|
||
.account-avatar {
|
||
width: 56px;
|
||
height: 56px;
|
||
border-radius: 28px;
|
||
background-color: #E3E7ED;
|
||
}
|
||
|
||
.account-avatar-placeholder {
|
||
width: 56px;
|
||
height: 56px;
|
||
border-radius: 28px;
|
||
border: 1px dashed #C9CDD4;
|
||
background-color: #F7F8FA;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.avatar-placeholder-plus {
|
||
font-size: 24px;
|
||
color: #667085;
|
||
line-height: 1;
|
||
}
|
||
|
||
.avatar-del-badge {
|
||
position: absolute;
|
||
top: 0px;
|
||
right: 0px;
|
||
width: 18px;
|
||
height: 18px;
|
||
border-radius: 9px;
|
||
background-color: rgba(240, 68, 56, 0.9);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.avatar-del-icon {
|
||
color: #FFFFFF;
|
||
font-size: 13px;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
}
|
||
|
||
.account-info {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
}
|
||
|
||
.account-name {
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
color: #101828;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.account-meta {
|
||
font-size: 14px;
|
||
color: #667085;
|
||
margin-top: 4px;
|
||
}
|
||
|
||
.account-dept {
|
||
font-size: 12px;
|
||
color: #667085;
|
||
margin-top: 2px;
|
||
}
|
||
|
||
.setting-row {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
min-height: 48px;
|
||
padding-top: 8px;
|
||
padding-bottom: 8px;
|
||
}
|
||
|
||
.setting-text-wrap {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
padding-right: 16px;
|
||
}
|
||
|
||
.setting-label {
|
||
font-size: 15px;
|
||
font-weight: 500;
|
||
color: #101828;
|
||
}
|
||
|
||
.setting-desc {
|
||
font-size: 13px;
|
||
color: #667085;
|
||
line-height: 1.5;
|
||
margin-top: 2px;
|
||
}
|
||
|
||
.language-desc {
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.switch-touch-area {
|
||
min-width: 44px;
|
||
min-height: 44px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.row-divider {
|
||
height: 1px;
|
||
background-color: #E3E7ED;
|
||
margin-top: 8px;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.language-options {
|
||
display: flex;
|
||
flex-direction: row;
|
||
flex-wrap: wrap;
|
||
gap: 8px;
|
||
}
|
||
|
||
.language-chip {
|
||
min-height: 44px;
|
||
padding: 0 16px;
|
||
border-radius: 12px;
|
||
border: 1px solid #E3E7ED;
|
||
background-color: #F7F8FA;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.language-chip-active {
|
||
border-color: #0B5CFF;
|
||
background-color: #0B5CFF;
|
||
}
|
||
|
||
.language-chip-text {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: #101828;
|
||
}
|
||
|
||
.language-chip-text-active {
|
||
color: #FFFFFF;
|
||
}
|
||
|
||
.error-banner {
|
||
padding: 12px 16px;
|
||
background-color: #F7F8FA;
|
||
border: 1px solid #E3E7ED;
|
||
border-radius: 12px;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.error-banner-text {
|
||
font-size: 13px;
|
||
color: #667085;
|
||
}
|
||
|
||
.bottom-spacer {
|
||
height: 80px;
|
||
}
|
||
|
||
.bottom-cta-bar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
padding: 12px 16px 24px 16px;
|
||
background-color: #FFFFFF;
|
||
border-top: 1px solid #E3E7ED;
|
||
}
|
||
|
||
.primary-cta-btn {
|
||
height: 48px;
|
||
background-color: #0B5CFF;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 100%;
|
||
}
|
||
|
||
.primary-cta-btn-text {
|
||
color: #FFFFFF;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
}
|
||
</style>
|