style:添加中英文切换

master
黄伟杰 1 month ago
parent 0ea15894bd
commit 3f17d6317f

@ -1,14 +1,67 @@
<script>
import { initAllDict } from '@/utils/dict'
import { getToken } from '@/utils/auth'
import { initializeLocale, translateLiteral } from '@/locales'
let wrapped = false
function wrapUniTextApi() {
if (wrapped) return
wrapped = true
const rawShowToast = uni.showToast
const rawShowModal = uni.showModal
const rawShowLoading = uni.showLoading
const rawSetNavigationBarTitle = uni.setNavigationBarTitle
uni.showToast = (options = {}) => {
const next = { ...options }
if (typeof next.title === 'string') {
next.title = translateLiteral(next.title)
}
return rawShowToast(next)
}
uni.showLoading = (options = {}) => {
const next = { ...options }
if (typeof next.title === 'string') {
next.title = translateLiteral(next.title)
}
return rawShowLoading(next)
}
uni.showModal = (options = {}) => {
const next = { ...options }
if (typeof next.title === 'string') {
next.title = translateLiteral(next.title)
}
if (typeof next.content === 'string') {
next.content = translateLiteral(next.content)
}
if (typeof next.confirmText === 'string') {
next.confirmText = translateLiteral(next.confirmText)
}
if (typeof next.cancelText === 'string') {
next.cancelText = translateLiteral(next.cancelText)
}
return rawShowModal(next)
}
uni.setNavigationBarTitle = (options = {}) => {
const next = { ...options }
if (typeof next.title === 'string') {
next.title = translateLiteral(next.title)
}
return rawSetNavigationBarTitle(next)
}
}
export default {
onLaunch: function () {
initializeLocale()
wrapUniTextApi()
if (getToken()) {
initAllDict().catch(() => {})
}
},
onShow: function () {
initializeLocale()
wrapUniTextApi()
},
onHide: function () {
}

@ -6,18 +6,21 @@
<text class="back-icon"></text>
</view>
<view class="header-title-wrap">
<text class="header-title">{{ title }}</text>
<text class="header-title">{{ translatedTitle }}</text>
</view>
<view class="header-placeholder"></view>
</view>
</view>
<view v-if="showSubTitle && subTitle" class="header-subtitle-wrap">
<text class="header-desc">{{ subTitle }}</text>
<text class="header-desc">{{ translatedSubTitle }}</text>
</view>
</view>
</template>
<script setup>
import { computed } from 'vue'
import { translateLiteral } from '@/locales'
const props = defineProps({
title: {
type: String,
@ -35,6 +38,9 @@ const props = defineProps({
const emit = defineEmits(['back'])
const translatedTitle = computed(() => translateLiteral(props.title))
const translatedSubTitle = computed(() => translateLiteral(props.subTitle))
function handleBack() {
emit('back')
uni.navigateBack()

@ -0,0 +1,471 @@
import { createI18n } from 'vue-i18n'
const LOCALE_STORAGE_KEY = 'app_locale'
const LOCALE_CHANGE_EVENT = 'app-locale-changed'
const DEFAULT_LOCALE = 'zh-CN'
const messages = {
'zh-CN': {
common: {
submit: '提交',
close: '关闭',
exit: '退出',
notice: '通知',
moduleBuilding: '模块建设中~',
updateSuccess: '修改成功',
confirmLogout: '确定注销并退出系统吗',
languageSwitched: '语言已切换'
},
tab: {
home: '首页',
report: '报表',
work: '管理',
mine: '我的'
},
nav: {
home: '首页',
mine: '个人中心',
avatar: '修改头像',
info: '个人信息',
editInfo: '编辑资料',
pwd: '修改密码',
setting: '应用设置',
help: '常见问题',
about: '关于我们'
},
dashboard: {
welcome: '欢迎您使用',
subtitle: '必硕数字化智能中控平台',
functionNav: '功能导航',
productionOverview: '生产整体概况',
productionPlan: '生产计划',
collapseList: '收起列表',
viewMore: '查看更多 ',
productName: '产品名称',
pipeline: '生产线',
planNumber: '计划数量',
planStart: '计划开始',
planEnd: '计划结束',
back: '返回',
todoTitle: '待办任务',
noTodo: '暂无待办任务',
taskCode: '任务编号:{value}',
taskType: '任务类型:{value}',
taskTarget: '目标:{value}',
createTime: '创建时间:{value}',
all: '总数',
pending: '未开工',
running: '生产中',
finished: '完工',
mold: '模具',
equipment: '设备',
keypart: '关键件',
spare: '备件',
product: '产品物料',
statusScheduled: '已排产',
statusTrial: '试产',
statusMass: '量产',
statusPause: '暂停',
statusWaitStockIn: '待入库',
viewPlan: '查看计划: {code}'
},
functionCommon: {
search: '查询',
cancel: '取消',
save: '保存',
loading: '加载中...',
loadingMore: '正在加载更多...',
noMoreData: '没有更多数据了',
noIdView: '缺少ID无法查看详情',
noIdEdit: '缺少ID无法编辑',
noIdDelete: '缺少ID无法删除',
loadFailed: '加载失败',
deleteSuccess: '删除成功',
deleteFailed: '删除失败',
saveFailed: '保存失败',
createSuccess: '新增成功',
updateSuccess: '更新成功',
confirmDelete: '确认删除',
uploading: '上传中',
uploadImageFailed: '图片上传失败',
yes: '是',
no: '否'
},
mine: {
clickLogin: '点击登录',
username: '用户名:{name}',
profile: '个人信息',
feedback: '反馈中心',
service: '在线客服',
changePassword: '修改密码',
logout: '退出登录',
editProfile: '编辑资料',
faq: '常见问题',
about: '关于我们',
appSettings: '应用设置'
},
setting: {
language: '系统语言',
currentLanguage: '当前语言:{language}',
switchLanguage: '切换语言',
checkUpdate: '检查更新',
cleanCache: '清理缓存',
logout: '退出登录',
zhCN: '中文',
enUS: '英文'
},
about: {
appName: '必硕生管系统',
version: '版本信息',
email: '官方邮箱',
hotline: '服务热线',
website: '公司网站'
},
help: {
appUserQuestion: 'APP用户问题',
otherQuestion: '其他问题',
appFeatureQuestion: 'APP支持的功能业务有哪些',
appFeatureAnswer: '计划开工、生产报工、投料记录、生产记录',
reportQuestion: '生产报工如何报工?',
reportAnswer: '可以',
planQuestion: '计划管理如何进行?',
planAnswer: '计划管理',
materialQuestion: '投料记录如何进行?',
materialAnswer: '投料记录',
logoutQuestion: '如何退出登录?',
logoutAnswer: '请点击[我的] - [应用设置] - [退出登录]即可退出登录',
avatarQuestion: '如何修改用户头像?',
avatarAnswer: '请点击[我的] - [选择头像] - [点击提交]即可更换用户头像',
passwordQuestion: '如何修改登录密码?',
passwordAnswer: '请点击[我的] - [应用设置] - [修改密码]即可修改登录密码'
},
info: {
username: '用户名称',
nickname: '昵称',
gender: '性别',
male: '男',
female: '女',
phone: '手机号码',
email: '邮箱',
createdAt: '创建日期'
},
editInfo: {
nickname: '用户昵称',
nicknamePlaceholder: '请输入昵称',
phone: '手机号码',
phonePlaceholder: '请输入手机号码',
email: '邮箱',
emailPlaceholder: '请输入邮箱',
gender: '性别',
nicknameRequired: '用户昵称不能为空',
phoneRequired: '手机号码不能为空',
phoneInvalid: '请输入正确的手机号码',
emailRequired: '邮箱地址不能为空',
emailInvalid: '请输入正确的邮箱地址'
},
pwd: {
oldPassword: '旧密码',
newPassword: '新密码',
confirmPassword: '确认密码',
oldPasswordPlaceholder: '请输入旧密码',
newPasswordPlaceholder: '请输入新密码',
confirmPasswordPlaceholder: '请确认新密码',
oldPasswordRequired: '旧密码不能为空',
newPasswordRequired: '新密码不能为空',
passwordLength: '长度在 6 到 20 个字符',
confirmPasswordRequired: '确认密码不能为空',
passwordNotMatch: '两次输入的密码不一致'
},
avatar: {
chooseAvatar: '选择头像'
}
},
'en-US': {
common: {
submit: 'Submit',
close: 'Close',
exit: 'Exit',
notice: 'Notice',
moduleBuilding: 'This module is under construction',
updateSuccess: 'Updated successfully',
confirmLogout: 'Are you sure you want to log out?',
languageSwitched: 'Language switched'
},
tab: {
home: 'Home',
report: 'Reports',
work: 'Manage',
mine: 'Mine'
},
nav: {
home: 'Home',
mine: 'Profile',
avatar: 'Edit Avatar',
info: 'Profile',
editInfo: 'Edit Profile',
pwd: 'Change Password',
setting: 'App Settings',
help: 'FAQ',
about: 'About'
},
dashboard: {
welcome: 'Welcome to',
subtitle: 'Besure Digital Intelligent Control Platform',
functionNav: 'Function Navigation',
productionOverview: 'Production Overview',
productionPlan: 'Production Plans',
collapseList: 'Collapse',
viewMore: 'View More ',
productName: 'Product',
pipeline: 'Production Line',
planNumber: 'Planned Qty',
planStart: 'Start',
planEnd: 'End',
back: 'Back',
todoTitle: 'To-do Tasks',
noTodo: 'No pending tasks',
taskCode: 'Task Code: {value}',
taskType: 'Task Type: {value}',
taskTarget: 'Target: {value}',
createTime: 'Created At: {value}',
all: 'Total',
pending: 'Pending',
running: 'In Progress',
finished: 'Done',
mold: 'Mold',
equipment: 'Equipment',
keypart: 'Key Part',
spare: 'Spare Part',
product: 'Product Material',
statusScheduled: 'Scheduled',
statusTrial: 'Trial',
statusMass: 'Mass',
statusPause: 'Paused',
statusWaitStockIn: 'Waiting Stock-in',
viewPlan: 'View Plan: {code}'
},
functionCommon: {
search: 'Search',
cancel: 'Cancel',
save: 'Save',
loading: 'Loading...',
loadingMore: 'Loading more...',
noMoreData: 'No more data',
noIdView: 'Missing ID, cannot view details',
noIdEdit: 'Missing ID, cannot edit',
noIdDelete: 'Missing ID, cannot delete',
loadFailed: 'Load failed',
deleteSuccess: 'Deleted successfully',
deleteFailed: 'Delete failed',
saveFailed: 'Save failed',
createSuccess: 'Created successfully',
updateSuccess: 'Updated successfully',
confirmDelete: 'Confirm deletion',
uploading: 'Uploading',
uploadImageFailed: 'Image upload failed',
yes: 'Yes',
no: 'No'
},
mine: {
clickLogin: 'Tap to sign in',
username: 'Username: {name}',
profile: 'Profile',
feedback: 'Feedback',
service: 'Support',
changePassword: 'Change Password',
logout: 'Log Out',
editProfile: 'Edit Profile',
faq: 'FAQ',
about: 'About',
appSettings: 'Settings'
},
setting: {
language: 'System Language',
currentLanguage: 'Current: {language}',
switchLanguage: 'Switch Language',
checkUpdate: 'Check Updates',
cleanCache: 'Clear Cache',
logout: 'Log Out',
zhCN: 'Chinese',
enUS: 'English'
},
about: {
appName: 'Besure Production System',
version: 'Version',
email: 'Official Email',
hotline: 'Service Hotline',
website: 'Website'
},
help: {
appUserQuestion: 'App User Questions',
otherQuestion: 'Other Questions',
appFeatureQuestion: 'What business features are supported by the app?',
appFeatureAnswer: 'Plan start, production report, material feeding records, production records',
reportQuestion: 'How can I submit a production report?',
reportAnswer: 'You can submit it on the report page.',
planQuestion: 'How is plan management handled?',
planAnswer: 'Use the plan management module.',
materialQuestion: 'How to manage feeding records?',
materialAnswer: 'Use the feeding record module.',
logoutQuestion: 'How do I log out?',
logoutAnswer: 'Go to [Mine] - [App Settings] - [Log Out] to sign out.',
avatarQuestion: 'How do I change my avatar?',
avatarAnswer: 'Go to [Mine] - [Choose Avatar] - [Submit] to update your avatar.',
passwordQuestion: 'How do I change my login password?',
passwordAnswer: 'Go to [Mine] - [App Settings] - [Change Password] to update your password.'
},
info: {
username: 'Username',
nickname: 'Nickname',
gender: 'Gender',
male: 'Male',
female: 'Female',
phone: 'Mobile',
email: 'Email',
createdAt: 'Created At'
},
editInfo: {
nickname: 'Nickname',
nicknamePlaceholder: 'Enter nickname',
phone: 'Mobile',
phonePlaceholder: 'Enter mobile number',
email: 'Email',
emailPlaceholder: 'Enter email',
gender: 'Gender',
nicknameRequired: 'Nickname is required',
phoneRequired: 'Mobile number is required',
phoneInvalid: 'Please enter a valid mobile number',
emailRequired: 'Email is required',
emailInvalid: 'Please enter a valid email'
},
pwd: {
oldPassword: 'Current Password',
newPassword: 'New Password',
confirmPassword: 'Confirm Password',
oldPasswordPlaceholder: 'Enter current password',
newPasswordPlaceholder: 'Enter new password',
confirmPasswordPlaceholder: 'Confirm new password',
oldPasswordRequired: 'Current password is required',
newPasswordRequired: 'New password is required',
passwordLength: 'Length must be between 6 and 20 characters',
confirmPasswordRequired: 'Please confirm password',
passwordNotMatch: 'The two passwords do not match'
},
avatar: {
chooseAvatar: 'Choose Avatar'
}
}
}
function normalizeLocale(locale) {
if (locale === 'zh' || locale === 'zh_CN' || locale === 'zh-Hans') return 'zh-CN'
if (locale === 'en' || locale === 'en_US') return 'en-US'
return locale === 'en-US' ? 'en-US' : 'zh-CN'
}
function getSavedLocale() {
try {
const locale = uni.getStorageSync(LOCALE_STORAGE_KEY)
if (locale) {
return normalizeLocale(locale)
}
} catch (error) {
}
const systemLocale = typeof uni.getLocale === 'function' ? uni.getLocale() : DEFAULT_LOCALE
return normalizeLocale(systemLocale)
}
const i18n = createI18n({
legacy: false,
locale: getSavedLocale(),
fallbackLocale: DEFAULT_LOCALE,
globalInjection: true,
messages
})
const literalMap = {
'首页': 'nav.home',
'报表': 'tab.report',
'管理': 'tab.work',
'我的': 'tab.mine',
'返回': 'dashboard.back',
'查询': 'functionCommon.search',
'取消': 'functionCommon.cancel',
'保存': 'functionCommon.save',
'加载中...': 'functionCommon.loading',
'正在加载更多...': 'functionCommon.loadingMore',
'没有更多数据了': 'functionCommon.noMoreData',
'缺少ID无法查看详情': 'functionCommon.noIdView',
'缺少ID无法编辑': 'functionCommon.noIdEdit',
'缺少ID无法删除': 'functionCommon.noIdDelete',
'加载失败': 'functionCommon.loadFailed',
'删除成功': 'functionCommon.deleteSuccess',
'删除失败': 'functionCommon.deleteFailed',
'保存失败': 'functionCommon.saveFailed',
'新增成功': 'functionCommon.createSuccess',
'更新成功': 'functionCommon.updateSuccess',
'确认删除': 'functionCommon.confirmDelete',
'上传中': 'functionCommon.uploading',
'图片上传失败': 'functionCommon.uploadImageFailed',
'是': 'functionCommon.yes',
'否': 'functionCommon.no',
'暂无待办任务': 'dashboard.noTodo'
}
function applyTabBarLanguage() {
const labels = [
i18n.global.t('tab.home'),
i18n.global.t('tab.report'),
i18n.global.t('tab.work'),
i18n.global.t('tab.mine')
]
labels.forEach((text, index) => {
uni.setTabBarItem({
index,
text
})
})
}
export function getCurrentLocale() {
return i18n.global.locale.value
}
export function setLocale(locale) {
const nextLocale = normalizeLocale(locale)
i18n.global.locale.value = nextLocale
uni.setStorageSync(LOCALE_STORAGE_KEY, nextLocale)
if (typeof uni.setLocale === 'function') {
uni.setLocale(nextLocale)
}
applyTabBarLanguage()
uni.$emit(LOCALE_CHANGE_EVENT, nextLocale)
return nextLocale
}
export function translateLiteral(text) {
if (typeof text !== 'string') return text
const key = literalMap[text]
if (key) return i18n.global.t(key)
return text
}
export function initializeLocale() {
setLocale(getSavedLocale())
}
export function setNavigationTitle(key) {
uni.setNavigationBarTitle({
title: i18n.global.t(key)
})
}
export function onLocaleChange(callback) {
uni.$on(LOCALE_CHANGE_EVENT, callback)
}
export function offLocaleChange(callback) {
uni.$off(LOCALE_CHANGE_EVENT, callback)
}
export default i18n

@ -2,10 +2,12 @@ import App from './App.vue'
import plugins from './plugins'
import store from './store'
import uviewPlus from 'uview-plus'
import i18n from '@/locales'
import { createSSRApp } from 'vue'
import directive from './directive' // directive
import { translateLiteral } from '@/locales'
import { useDict } from '@/utils/dict'
import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
@ -15,6 +17,7 @@ import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, select
export function createApp() {
const app = createSSRApp(App)
app.use(store)
app.use(i18n)
app.use(uviewPlus)
app.use(plugins)
directive(app)
@ -27,6 +30,7 @@ export function createApp() {
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
app.config.globalProperties.$tl = translateLiteral
return {
app

@ -4,8 +4,8 @@
<view class="banner-section">
<view class="banner-bg">
<view class="banner-content">
<text class="banner-title">欢迎您使用</text>
<text class="banner-subtitle">必硕数字化智能中控平台</text>
<text class="banner-title">{{ t('dashboard.welcome') }}</text>
<text class="banner-subtitle">{{ t('dashboard.subtitle') }}</text>
</view>
<view class="banner-decoration">
<view class="deco-line"></view>
@ -24,32 +24,32 @@
<view class="content-section">
<view class="nav-section">
<view class="section-title">功能导航</view>
<view class="section-title">{{ t('dashboard.functionNav') }}</view>
<view class="nav-grid">
<view v-for="(item, index) in navList" :key="index" class="nav-item" @click="handleNavClick(item)">
<view class="nav-icon" :style="{ backgroundColor: item.bgColor }">
<text class="nav-icon-text">{{ item.icon }}</text>
</view>
<text class="nav-text">{{ item.name }}</text>
<text class="nav-text">{{ t(`dashboard.${item.key}`) }}</text>
</view>
</view>
</view>
<view class="stats-section">
<view class="section-title">生产整体概况</view>
<view class="section-title">{{ t('dashboard.productionOverview') }}</view>
<view class="stats-grid">
<view v-for="(stat, index) in statsData" :key="index" class="stat-card" :class="'stat-' + stat.type">
<text class="stat-value">{{ stat.value }}</text>
<text class="stat-label">{{ stat.label }}</text>
<text class="stat-label">{{ t(`dashboard.${stat.labelKey}`) }}</text>
</view>
</view>
</view>
<view class="plan-section">
<view class="section-header">
<text class="section-title">生产计划</text>
<text class="section-title">{{ t('dashboard.productionPlan') }}</text>
<text v-if="hasMorePlans || isShowAllPlans" class="section-more" @click="viewMorePlans">
{{ isShowAllPlans ? '收起列表' : '查看更多 ' }}
{{ isShowAllPlans ? t('dashboard.collapseList') : t('dashboard.viewMore') }}
</text>
</view>
<view class="plan-list">
@ -63,23 +63,23 @@
</view>
<view class="plan-body">
<view class="plan-row">
<text class="plan-label">产品名称</text>
<text class="plan-label">{{ t('dashboard.productName') }}</text>
<text class="plan-value">{{ plan.productName }}</text>
</view>
<view class="plan-row">
<text class="plan-label">生产线</text>
<text class="plan-label">{{ t('dashboard.pipeline') }}</text>
<text class="plan-value">{{ plan.feedingPipelineName }}</text>
</view>
<view class="plan-row">
<text class="plan-label">计划数量</text>
<text class="plan-label">{{ t('dashboard.planNumber') }}</text>
<text class="plan-value plan-num">{{ plan.planNumber }}</text>
</view>
<view class="plan-row">
<text class="plan-label">计划开始</text>
<text class="plan-label">{{ t('dashboard.planStart') }}</text>
<text class="plan-value">{{ plan.planStartTimeText }}</text>
</view>
<view class="plan-row">
<text class="plan-label">计划结束</text>
<text class="plan-label">{{ t('dashboard.planEnd') }}</text>
<text class="plan-value">{{ plan.planEndTimeText }}</text>
</view>
</view>
@ -98,23 +98,23 @@
<view class="todo-header">
<view class="todo-back" @click="closeTodoList">
<text class="back-icon"></text>
<text class="back-text">返回</text>
<text class="back-text">{{ t('dashboard.back') }}</text>
</view>
<text class="todo-title">待办任务</text>
<text class="todo-title">{{ t('dashboard.todoTitle') }}</text>
</view>
<scroll-view scroll-y class="todo-scroll">
<view v-if="todoList.length === 0" class="todo-empty">
<text class="empty-text">暂无待办任务</text>
<text class="empty-text">{{ t('dashboard.noTodo') }}</text>
</view>
<view v-else>
<view v-for="(item, index) in todoList" :key="index" class="todo-item">
<view class="todo-dot"></view>
<view class="todo-content">
<view class="todo-title" style="text-align: left;margin-right: 0;">{{ item.name }}</view>
<view class="todo-sub">任务编号{{ item.code }}</view>
<view class="todo-sub">任务类型{{ item.type }}</view>
<view class="todo-sub">目标{{ item.deviceName }}</view>
<view class="todo-sub">创建时间{{ formatDate(item.createTime) }}</view>
<view class="todo-sub">{{ t('dashboard.taskCode', { value: item.code }) }}</view>
<view class="todo-sub">{{ t('dashboard.taskType', { value: item.type }) }}</view>
<view class="todo-sub">{{ t('dashboard.taskTarget', { value: item.deviceName }) }}</view>
<view class="todo-sub">{{ t('dashboard.createTime', { value: formatDate(item.createTime) }) }}</view>
</view>
</view>
</view>
@ -125,8 +125,13 @@
</template>
<script setup>
import { onMounted, ref, reactive, computed } from 'vue';
import { onMounted, onUnmounted, ref, reactive, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import request from '@/utils/request'
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const { t } = useI18n()
const todoPopup = ref(null);
const todoCount = ref(0);
@ -143,18 +148,18 @@ const badgeText = computed(() => {
})
const navList = reactive([
{ name: '模具', icon: '🔧', bgColor: '#1a3a5c', path: '/pages_function/mold' },
{ name: '设备', icon: '⚙️', bgColor: '#2d5a87', path: '/pages_function/equipment' },
{ name: '关键件', icon: '🔩', bgColor: '#3d7ab5', path: '/pages_function/keypart' },
{ name: '备件', icon: '📦', bgColor: '#4a90c2', path: '/pages_function/spare' },
{ name: '产品物料', icon: '🧾', bgColor: '#5aa0d2', path: '/pages_function/product' }
{ key: 'mold', icon: '🔧', bgColor: '#1a3a5c', path: '/pages_function/mold' },
{ key: 'equipment', icon: '⚙️', bgColor: '#2d5a87', path: '/pages_function/equipment' },
{ key: 'keypart', icon: '🔩', bgColor: '#3d7ab5', path: '/pages_function/keypart' },
{ key: 'spare', icon: '📦', bgColor: '#4a90c2', path: '/pages_function/spare' },
{ key: 'product', icon: '🧾', bgColor: '#5aa0d2', path: '/pages_function/product' }
]);
const statsData = reactive([
{ label: '总数', type: 'total' },
{ label: '未开工', type: 'pending' },
{ label: '生产中', type: 'running' },
{ label: '完工', type: 'finished' }
{ labelKey: 'all', type: 'total' },
{ labelKey: 'pending', type: 'pending' },
{ labelKey: 'running', type: 'running' },
{ labelKey: 'finished', type: 'finished' }
]);
const planList = reactive([]);
@ -176,19 +181,19 @@ function closeTodoList() {
function handleNavClick(item) {
const navMap = {
'模具': '/pages_function/pages/mold/index',
'设备': '/pages_function/pages/equipment/index',
'备件': '/pages_function/pages/spare/index',
'关键件': '/pages_function/pages/keypart/index',
'产品物料': '/pages_function/pages/product/index'
mold: '/pages_function/pages/mold/index',
equipment: '/pages_function/pages/equipment/index',
spare: '/pages_function/pages/spare/index',
keypart: '/pages_function/pages/keypart/index',
product: '/pages_function/pages/product/index'
};
const url = navMap[item.name];
const url = navMap[item.key];
if (url) {
uni.navigateTo({ url });
} else {
uni.showToast({
title: `进入${item.name}模块`,
title: t('common.moduleBuilding'),
icon: 'none'
});
}
@ -196,7 +201,7 @@ function handleNavClick(item) {
function handlePlanClick(plan) {
uni.showToast({
title: `查看计划: ${plan.code}`,
title: t('dashboard.viewPlan', { code: plan.code }),
icon: 'none'
});
}
@ -232,11 +237,11 @@ function formatDate(ms) {
const getPlanStatusLabel = (value) => {
const v = value === '' || value === null || value === undefined ? undefined : String(value)
if (v == '1') return '已排产'
if (v == '6') return '试产'
if (v == '2') return '量产'
if (v == '3') return '暂停'
if (v == '4') return '待入库'
if (v == '1') return t('dashboard.statusScheduled')
if (v == '6') return t('dashboard.statusTrial')
if (v == '2') return t('dashboard.statusMass')
if (v == '3') return t('dashboard.statusPause')
if (v == '4') return t('dashboard.statusWaitStockIn')
return '-'
}
@ -304,6 +309,15 @@ async function loadDashboard() {
onMounted(() => {
loadDashboard()
})
const updatePageTitle = () => setNavigationTitle('nav.home')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>
<style lang="scss" scoped>

@ -1,6 +1,5 @@
<template>
<view class="mine-container" :style="{ height: `${windowHeight}px` }">
<!--顶部个人信息栏-->
<view class="header-section">
<view class="flex padding justify-between">
<view class="flex align-center">
@ -10,16 +9,16 @@
<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
</image>
<view v-if="!name" @click="handleToLogin" class="login-tip">
点击登录
{{ t('mine.clickLogin') }}
</view>
<view v-if="name" @click="handleToInfo" class="user-info">
<view class="u_title">
用户名{{ name }}
{{ t('mine.username', { name }) }}
</view>
</view>
</view>
<view @click="handleToInfo" class="flex align-center">
<text>个人信息</text>
<text>{{ t('mine.profile') }}</text>
<view class="iconfont icon-right"></view>
</view>
</view>
@ -29,19 +28,19 @@
<view class="mine-actions grid col-4 text-center">
<view class="action-item" @click="handleBuilding">
<view class="iconfont icon-friendfill text-green icon"></view>
<text class="text">反馈中心</text>
<text class="text">{{ t('mine.feedback') }}</text>
</view>
<view class="action-item" @click="handleBuilding">
<view class="iconfont icon-service text-blue icon"></view>
<text class="text">在线客服</text>
<text class="text">{{ t('mine.service') }}</text>
</view>
<view class="action-item" @click="handleToPwd">
<view class="iconfont icon-password text-mauve icon"></view>
<text class="text">修改密码</text>
<text class="text">{{ t('mine.changePassword') }}</text>
</view>
<view class="action-item" @click="handleLogout">
<view class="iconfont icon-logout text-red icon"></view>
<text class="text">退出登录</text>
<text class="text">{{ t('mine.logout') }}</text>
</view>
</view>
@ -49,25 +48,25 @@
<view class="list-cell list-cell-arrow" @click="handleToEditInfo">
<view class="menu-item-box">
<view class="iconfont icon-user menu-icon"></view>
<view>编辑资料</view>
<view>{{ t('mine.editProfile') }}</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleHelp">
<view class="menu-item-box">
<view class="iconfont icon-help menu-icon"></view>
<view>常见问题</view>
<view>{{ t('mine.faq') }}</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleAbout">
<view class="menu-item-box">
<view class="iconfont icon-aixin menu-icon"></view>
<view>关于我们</view>
<view>{{ t('mine.about') }}</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleToSetting">
<view class="menu-item-box">
<view class="iconfont icon-setting menu-icon"></view>
<view>应用设置</view>
<view>{{ t('mine.appSettings') }}</view>
</view>
</view>
</view>
@ -75,7 +74,7 @@
<view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog type="info" cancelText="关闭" confirmText="退出" title="通知" content="确定注销并退出系统吗"
<uni-popup-dialog type="info" :cancelText="t('common.close')" :confirmText="t('common.exit')" :title="t('common.notice')" :content="t('common.confirmLogout')"
@confirm="dialogConfirm" @close="dialogClose">
</uni-popup-dialog>
</uni-popup>
@ -84,12 +83,14 @@
</template>
<script setup>
import { ref } from "vue";
import config from '@/config.js'
import { onUnmounted, ref } from "vue";
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import useUserStore from '@/store/modules/user'
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const userStore = useUserStore()
const name = userStore.name;
const version = config.appInfo.version;
const { t } = useI18n()
const avatar = ref(userStore.avatar);
const windowHeight = ref(uni.getSystemInfoSync().windowHeight - 50);
@ -99,7 +100,11 @@ uni.$on('refresh', () => {
avatar.value = userStore.avatar;
})
console.log(avatar.value)
const updatePageTitle = () => setNavigationTitle('nav.mine')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
function handleToInfo() {
uni.navigateTo({
@ -130,7 +135,6 @@ function handleLogout() {
popup.value.open();
};
function dialogConfirm() {
//console.log('----------------------------')
userStore.logOut().then(() => {
uni.reLaunch({
url: '/pages/login'
@ -138,7 +142,6 @@ function dialogConfirm() {
})
};
function dialogClose() {
//console.log('')
};
function handleToPwd() {
uni.navigateTo({
@ -151,12 +154,6 @@ function handleHelp() {
});
}
function switchTab(index) {
const paths = ['/pages/index', '/pages/report', '/pages/work', '/pages/mine'];
if (index !== 3) {
uni.switchTab({ url: paths[index] });
}
};
function handleAbout() {
uni.navigateTo({
url: '/pages_mine/pages/about/index'
@ -164,13 +161,17 @@ function handleAbout() {
}
function handleBuilding() {
uni.showToast({
title: '模块建设中~',
title: t('common.moduleBuilding'),
mask: false,
icon: "none",
duration: 1000
});
}
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>
<style lang="scss">

@ -3,32 +3,32 @@
<view class="header-section text-center">
<image style="width: 150rpx;height: 150rpx;" src="/static/logo.png" mode="widthFix">
</image>
<uni-title type="h2" title="必硕生管系统"></uni-title>
<uni-title type="h2" :title="t('about.appName')"></uni-title>
</view>
<view class="content-section">
<view class="menu-list">
<view class="list-cell list-cell-arrow">
<view class="menu-item-box">
<view>版本信息</view>
<view>{{ t('about.version') }}</view>
<view class="text-right">v{{version}}</view>
</view>
</view>
<view class="list-cell list-cell-arrow">
<view class="menu-item-box">
<view>官方邮箱</view>
<view>{{ t('about.email') }}</view>
<view class="text-right">besure@xx.com</view>
</view>
</view>
<view class="list-cell list-cell-arrow">
<view class="menu-item-box">
<view>服务热线</view>
<view>{{ t('about.hotline') }}</view>
<view class="text-right">XXX_XXX_XXX</view>
</view>
</view>
<view class="list-cell list-cell-arrow">
<view class="menu-item-box">
<view>公司网站</view>
<view>{{ t('about.website') }}</view>
<view class="text-right">
<uni-link :href="url" :text="url" showUnderLine="false"></uni-link>
</view>
@ -44,10 +44,24 @@
</template>
<script setup>
import config from '@/config.js'
const url=config.appInfo.site_url;
const version=config.appInfo.version;
import { onUnmounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import config from '@/config.js'
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const { t } = useI18n()
const url = config.appInfo.site_url;
const version = config.appInfo.version;
const updatePageTitle = () => setNavigationTitle('nav.about')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>
<style lang="scss">

@ -40,8 +40,8 @@
</view>
</view>
<view class='cropper-config'>
<button type="primary reverse" @click="getImage" style='margin-top: 30rpx;'> 选择头像 </button>
<button type="warn" @click="getImageInfo" style='margin-top: 30rpx;'> 提交 </button>
<button type="primary reverse" @click="getImage" style='margin-top: 30rpx;'> {{ $t('avatar.chooseAvatar') }} </button>
<button type="warn" @click="getImageInfo" style='margin-top: 30rpx;'> {{ $t('common.submit') }} </button>
</view>
<canvas canvas-id="myCanvas"
:style="'position:absolute;border: 1px solid red; width:' + imageW + 'px;height:' + imageH + 'px;top:-9999px;left:-9999px;'"></canvas>
@ -114,9 +114,21 @@ export default {
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
uni.setNavigationBarTitle({
title: this.$t('nav.avatar')
})
uni.$on('app-locale-changed', this.handleLocaleChange)
this.loadImage()
},
onUnload() {
uni.$off('app-locale-changed', this.handleLocaleChange)
},
methods: {
handleLocaleChange() {
uni.setNavigationBarTitle({
title: this.$t('nav.avatar')
})
},
setData: function (obj) {
let that = this
Object.keys(obj).forEach(function (key) {
@ -273,7 +285,7 @@ export default {
// userStore.avatar = response.imgUrl
/*cloud*/
useUserStore().avatar = baseUrl + response.imgUrl
uni.showToast({ title: "修改成功", icon: 'success' })
uni.showToast({ title: this.$t('common.updateSuccess'), icon: 'success' })
uni.$emit('refresh');
uni.navigateBack();
})

@ -16,46 +16,60 @@
</template>
<script setup>
import { ref } from "vue";
const list =ref( [{
icon: 'iconfont icon-github',
title: 'APP用户问题',
childList: [{
title: 'APP支持的功能业务有哪些',
content: '计划开工、生产报工、投料记录、生产记录'
}, {
title: '生产报工如何报工?',
content: '可以'
}, {
title: '计划管理如何进行?',
content: '计划管理'
}, {
title: '投料记录如何进行?',
content: '投料记录'
}]
},
{
icon: 'iconfont icon-help',
title: '其他问题',
childList: [{
title: '如何退出登录?',
content: '请点击[我的] - [应用设置] - [退出登录]即可退出登录',
}, {
title: '如何修改用户头像?',
content: '请点击[我的] - [选择头像] - [点击提交]即可更换用户头像',
}, {
title: '如何修改登录密码?',
content: '请点击[我的] - [应用设置] - [修改密码]即可修改登录密码',
}]
}
])
function handleText(item) {
uni.navigateTo({
url: `/pages/common/textview/index?title=${item.title}&content=${item.content}`
});
}
import { computed, onUnmounted } from "vue";
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const { t } = useI18n()
const list = computed(() => [{
icon: 'iconfont icon-github',
title: t('help.appUserQuestion'),
childList: [{
title: t('help.appFeatureQuestion'),
content: t('help.appFeatureAnswer')
}, {
title: t('help.reportQuestion'),
content: t('help.reportAnswer')
}, {
title: t('help.planQuestion'),
content: t('help.planAnswer')
}, {
title: t('help.materialQuestion'),
content: t('help.materialAnswer')
}]
},
{
icon: 'iconfont icon-help',
title: t('help.otherQuestion'),
childList: [{
title: t('help.logoutQuestion'),
content: t('help.logoutAnswer'),
}, {
title: t('help.avatarQuestion'),
content: t('help.avatarAnswer'),
}, {
title: t('help.passwordQuestion'),
content: t('help.passwordAnswer'),
}]
}])
const updatePageTitle = () => setNavigationTitle('nav.help')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
function handleText(item) {
uni.navigateTo({
url: `/pages/common/textview/index?title=${item.title}&content=${item.content}`
});
}
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>
<style lang="scss" scoped>

@ -2,20 +2,20 @@
<view class="container">
<view class="example">
<uni-forms ref="form" :model="user" labelWidth="80px">
<uni-forms-item label="用户昵称" name="nickName">
<uni-easyinput v-model="user.nickname" placeholder="请输入昵称" />
<uni-forms-item :label="$t('editInfo.nickname')" name="nickName">
<uni-easyinput v-model="user.nickname" :placeholder="$t('editInfo.nicknamePlaceholder')" />
</uni-forms-item>
<uni-forms-item label="手机号码" name="phonenumber">
<uni-easyinput v-model="user.mobile" placeholder="请输入手机号码" />
<uni-forms-item :label="$t('editInfo.phone')" name="phonenumber">
<uni-easyinput v-model="user.mobile" :placeholder="$t('editInfo.phonePlaceholder')" />
</uni-forms-item>
<uni-forms-item label="邮箱" name="email">
<uni-easyinput v-model="user.email" placeholder="请输入邮箱" />
<uni-forms-item :label="$t('editInfo.email')" name="email">
<uni-easyinput v-model="user.email" :placeholder="$t('editInfo.emailPlaceholder')" />
</uni-forms-item>
<uni-forms-item label="性别" name="sex" required>
<uni-forms-item :label="$t('editInfo.gender')" name="sex" required>
<uni-data-checkbox v-model="user.sex" :localdata="sexs" />
</uni-forms-item>
</uni-forms>
<button type="primary" @click="submit"></button>
<button type="primary" @click="submit">{{ $t('common.submit') }}</button>
</view>
</view>
</template>
@ -33,48 +33,75 @@ export default {
email: "",
sex: ""
},
sexs: [{
text: '男',
sexs: [],
rules: {},
localeChangeHandler: null
}
},
onLoad() {
this.getUser()
this.refreshI18n()
this.localeChangeHandler = () => {
this.refreshI18n()
this.setPageTitle()
}
uni.$on('app-locale-changed', this.localeChangeHandler)
},
onShow() {
this.setPageTitle()
},
onUnload() {
if (this.localeChangeHandler) {
uni.$off('app-locale-changed', this.localeChangeHandler)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
setPageTitle() {
uni.setNavigationBarTitle({
title: this.$t('nav.editInfo')
})
},
refreshI18n() {
this.sexs = [{
text: this.$t('info.male'),
value: 1
}, {
text: '女',
text: this.$t('info.female'),
value: 2
}],
rules: {
}]
this.rules = {
nickname: {
rules: [{
required: true,
errorMessage: '用户昵称不能为空'
errorMessage: this.$t('editInfo.nicknameRequired')
}]
},
mobile: {
rules: [{
required: true,
errorMessage: '手机号码不能为空'
errorMessage: this.$t('editInfo.phoneRequired')
}, {
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
errorMessage: '请输入正确的手机号码'
errorMessage: this.$t('editInfo.phoneInvalid')
}]
},
email: {
rules: [{
required: true,
errorMessage: '邮箱地址不能为空'
errorMessage: this.$t('editInfo.emailRequired')
}, {
format: 'email',
errorMessage: '请输入正确的邮箱地址'
errorMessage: this.$t('editInfo.emailInvalid')
}]
}
}
}
},
onLoad() {
this.getUser()
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
if (this.$refs.form) {
this.$refs.form.setRules(this.rules)
}
},
getUser() {
getUserProfile().then(response => {
this.user = response.data
@ -84,7 +111,7 @@ export default {
this.$refs.form.validate().then(res => {
updateUserProfile(this.user).then(response => {
uni.showToast({
title: '修改成功',
title: this.$t('common.updateSuccess'),
mask: false,
duration: 1000
});

@ -1,15 +1,13 @@
<template>
<view class="container">
<uni-list>
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'contact' }" title="用户名称" :rightText="user.email" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'person-filled' }" title="昵称" :rightText="user.nickname" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'sex' }" title="性别"
:rightText="user.sex===2?'女' : '男'" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'phone-filled' }" title="手机号码" :rightText="user.mobile" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'email-filled' }" title="邮箱" :rightText="user.email" />
<!-- <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'auth-filled' }" title="岗位" :rightText="postGroup" />-->
<!-- <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'staff-filled' }" title="角色" :rightText="roleGroup" />-->
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'calendar-filled' }" title="创建日期"
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'contact' }" :title="t('info.username')" :rightText="user.email" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'person-filled' }" :title="t('info.nickname')" :rightText="user.nickname" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'sex' }" :title="t('info.gender')"
:rightText="user.sex===2?t('info.female') : t('info.male')" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'phone-filled' }" :title="t('info.phone')" :rightText="user.mobile" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'email-filled' }" :title="t('info.email')" :rightText="user.email" />
<uni-list-item showExtraIcon="true" :extraIcon="{ type: 'calendar-filled' }" :title="t('info.createdAt')"
:rightText="timestampToTime(user.createTime)" />
</uni-list>
@ -19,32 +17,31 @@
<script setup>
import { getUserProfile } from "@/api/system/user"
import { ref } from "vue";
import modal from "@/plugins/modal"
import { onUnmounted, ref } from "vue";
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import {timestampToTime} from "@/utils/dateUtil";
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const { t } = useI18n()
const user = ref({})
const roleGroup = ref("")
const postGroup = ref("")
const updatePageTitle = () => setNavigationTitle('nav.info')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
function getUser() {
getUserProfile().then(response => {
user.value = response.data
// roleGroup.value = user.value.roles
// postGroup.value = user.value.posts
})
}
getUser()
import { wxRegister } from "@/api/oauth"
import { getWxCode } from "@/utils/geek"
function register(){
// modal.loading('...')
// getWxCode().then(res=>{
// wxRegister('miniapp',res).then(res=>{
// modal.closeLoading()
// })
// })
}
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>

@ -1,16 +1,16 @@
<template>
<view class="pwd-retrieve-container">
<uni-forms ref="form" :value="user" labelWidth="80px">
<uni-forms-item required name="oldPassword" label="旧密码">
<uni-easyinput type="password" v-model="user.oldPassword" placeholder="请输入旧密码" />
<uni-forms-item required name="oldPassword" :label="$t('pwd.oldPassword')">
<uni-easyinput type="password" v-model="user.oldPassword" :placeholder="$t('pwd.oldPasswordPlaceholder')" />
</uni-forms-item>
<uni-forms-item required name="newPassword" label="新密码">
<uni-easyinput type="password" v-model="user.newPassword" placeholder="请输入新密码" />
<uni-forms-item required name="newPassword" :label="$t('pwd.newPassword')">
<uni-easyinput type="password" v-model="user.newPassword" :placeholder="$t('pwd.newPasswordPlaceholder')" />
</uni-forms-item>
<uni-forms-item required name="confirmPassword" label="确认密码">
<uni-easyinput type="password" v-model="user.confirmPassword" placeholder="请确认新密码" />
<uni-forms-item required name="confirmPassword" :label="$t('pwd.confirmPassword')">
<uni-easyinput type="password" v-model="user.confirmPassword" :placeholder="$t('pwd.confirmPasswordPlaceholder')" />
</uni-forms-item>
<button type="primary" @click="submit"></button>
<button type="primary" @click="submit">{{ $t('common.submit') }}</button>
</uni-forms>
</view>
</template>
@ -26,47 +26,75 @@
newPassword: undefined,
confirmPassword: undefined
},
rules: {
rules: {},
localeChangeHandler: null
}
},
onLoad() {
this.refreshI18n()
this.localeChangeHandler = () => {
this.refreshI18n()
this.setPageTitle()
}
uni.$on('app-locale-changed', this.localeChangeHandler)
},
onShow() {
this.setPageTitle()
},
onUnload() {
if (this.localeChangeHandler) {
uni.$off('app-locale-changed', this.localeChangeHandler)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
setPageTitle() {
uni.setNavigationBarTitle({
title: this.$t('nav.pwd')
})
},
refreshI18n() {
this.rules = {
oldPassword: {
rules: [{
required: true,
errorMessage: '旧密码不能为空'
errorMessage: this.$t('pwd.oldPasswordRequired')
}]
},
newPassword: {
rules: [{
required: true,
errorMessage: '新密码不能为空',
},
{
minLength: 6,
maxLength: 20,
errorMessage: '长度在 6 到 20 个字符'
}
required: true,
errorMessage: this.$t('pwd.newPasswordRequired'),
},
{
minLength: 6,
maxLength: 20,
errorMessage: this.$t('pwd.passwordLength')
}
]
},
confirmPassword: {
rules: [{
required: true,
errorMessage: '确认密码不能为空'
}, {
validateFunction: (rule, value, data) => data.newPassword === value,
errorMessage: '两次输入的密码不一致'
}
required: true,
errorMessage: this.$t('pwd.confirmPasswordRequired')
}, {
validateFunction: (rule, value, data) => data.newPassword === value,
errorMessage: this.$t('pwd.passwordNotMatch')
}
]
}
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
if (this.$refs.form) {
this.$refs.form.setRules(this.rules)
}
},
submit() {
this.$refs.form.validate().then(res => {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
uni.showToast({
title: '修改成功',
title: this.$t('common.updateSuccess'),
mask: false,
duration: 1000
});

@ -1,36 +1,43 @@
<template>
<view class="setting-container" :style="{ height: `${windowHeight}px` }">
<view class="menu-list">
<view class="list-cell list-cell-arrow" @click="handleLanguageChange">
<view class="menu-item-box">
<view class="iconfont icon-global menu-icon"></view>
<view>{{ t('setting.language') }}</view>
</view>
<view class="text-grey">{{ t('setting.currentLanguage', { language: currentLanguageLabel }) }}</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleToPwd">
<view class="menu-item-box">
<view class="iconfont icon-password menu-icon"></view>
<view>修改密码</view>
<view>{{ t('mine.changePassword') }}</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
<view class="menu-item-box">
<view class="iconfont icon-refresh menu-icon"></view>
<view>检查更新</view>
<view>{{ t('setting.checkUpdate') }}</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
<view class="menu-item-box">
<view class="iconfont icon-clean menu-icon"></view>
<view>清理缓存</view>
<view>{{ t('setting.cleanCache') }}</view>
</view>
</view>
</view>
<view class="cu-list menu">
<view class="cu-item item-box">
<view class="content text-center" @click="handleLogout">
<text class="text-black">退出登录</text>
<text class="text-black">{{ t('setting.logout') }}</text>
</view>
</view>
</view>
</view>
<view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog type="info" cancelText="关闭" confirmText="退出" title="通知" content="确定注销并退出系统吗"
<uni-popup-dialog type="info" :cancelText="t('common.close')" :confirmText="t('common.exit')" :title="t('common.notice')" :content="t('common.confirmLogout')"
@confirm="dialogConfirm" @close="dialogClose">
</uni-popup-dialog>
</uni-popup>
@ -38,12 +45,30 @@
</template>
<script setup>
import { ref } from "vue";
import { computed, onUnmounted, ref } from "vue";
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import useUserStore from '@/store/modules/user'
import { getCurrentLocale, setLocale, onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
const userStore = useUserStore()
const { t } = useI18n()
const windowHeight = ref(uni.getSystemInfoSync().windowHeight);
const popup = ref(null);
const currentLocale = ref(getCurrentLocale())
const currentLanguageLabel = computed(() => currentLocale.value === 'en-US' ? t('setting.enUS') : t('setting.zhCN'))
const updatePageTitle = () => setNavigationTitle('nav.setting')
onShow(() => {
updatePageTitle()
})
const updateLocale = (locale) => {
currentLocale.value = locale
updatePageTitle()
}
onLocaleChange(updateLocale)
function handleToPwd() {
uni.navigateTo({
@ -53,7 +78,7 @@ function handleToPwd() {
function handleToUpgrade() {
uni.showToast({
title: '模块建设中~',
title: t('common.moduleBuilding'),
mask: false,
icon: "none",
duration: 1000
@ -62,17 +87,31 @@ function handleToUpgrade() {
function handleCleanTmp() {
uni.showToast({
title: '模块建设中~',
title: t('common.moduleBuilding'),
mask: false,
icon: "none",
duration: 1000
});
};
function handleLanguageChange() {
uni.showActionSheet({
itemList: [t('setting.zhCN'), t('setting.enUS')],
success: ({ tapIndex }) => {
const nextLocale = tapIndex === 1 ? 'en-US' : 'zh-CN'
setLocale(nextLocale)
currentLocale.value = nextLocale
uni.showToast({
title: t('common.languageSwitched'),
icon: 'none',
duration: 1000
})
}
})
}
function handleLogout() {
popup.value.open();
};
function dialogConfirm() {
//console.log('----------------------------')
userStore.logOut().then(() => {
uni.reLaunch({
url: '/pages/login'
@ -80,8 +119,11 @@ function dialogConfirm() {
})
};
function dialogClose() {
//console.log('')
};
onUnmounted(() => {
offLocaleChange(updateLocale)
})
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save