Signed-off-by: 吴文峰 <kevin@lmve.net>
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
@@ -1,4 +0,0 @@
|
||||
node_modules/
|
||||
unpackage/
|
||||
.hbuilderx/
|
||||
.DS_Store
|
||||
@@ -1,168 +0,0 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
|
||||
// 初始化全局 API 地址
|
||||
const apiUrl = uni.getStorageSync('apiUrl')
|
||||
if (!getApp().globalData) {
|
||||
getApp().globalData = {}
|
||||
}
|
||||
|
||||
// H5 端使用相对路径走代理,其他端使用完整 URL
|
||||
// #ifdef H5
|
||||
getApp().globalData.BASE_URL = '/api/'
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
getApp().globalData.BASE_URL = apiUrl
|
||||
// #endif
|
||||
|
||||
// 暂时禁用自动跳转登录
|
||||
// this.checkLoginStatus()
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
},
|
||||
methods: {
|
||||
checkLoginStatus() {
|
||||
const sessionCookie = uni.getStorageSync('sessionCookie')
|
||||
if (!sessionCookie) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 全局样式 */
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
/* 移除默认按钮样式 */
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Flex 布局类 */
|
||||
.flex { display: flex; }
|
||||
.flex-col { flex-direction: column; }
|
||||
.flex-1 { flex: 1; }
|
||||
.items-center { align-items: center; }
|
||||
.justify-center { justify-content: center; }
|
||||
.justify-between { justify-content: space-between; }
|
||||
.items-end { align-items: flex-end; }
|
||||
|
||||
/* Grid */
|
||||
.grid { display: flex; flex-wrap: wrap; }
|
||||
.grid-cols-4 > view, .grid-cols-4 > .grid-item { width: 25%; }
|
||||
|
||||
/* Gap */
|
||||
.gap-3 { gap: 0.75rem; }
|
||||
.gap-4 { gap: 1rem; }
|
||||
|
||||
/* Spacing */
|
||||
.mx-4 { margin-left: 1rem; margin-right: 1rem; }
|
||||
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
|
||||
.mt-2 { margin-top: 0.5rem; }
|
||||
.mt-4 { margin-top: 1rem; }
|
||||
.mb-3 { margin-bottom: 0.75rem; }
|
||||
.mb-4 { margin-bottom: 1rem; }
|
||||
.mb-6 { margin-bottom: 1.5rem; }
|
||||
.mb-8 { margin-bottom: 2rem; }
|
||||
.ml-2 { margin-left: 0.5rem; }
|
||||
.ml-4 { margin-left: 1rem; }
|
||||
.mr-4 { margin-right: 1rem; }
|
||||
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
|
||||
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
|
||||
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
|
||||
.px-4 { padding-left: 1rem; padding-right: 1rem; }
|
||||
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
|
||||
.p-4 { padding: 1rem; }
|
||||
.p-6 { padding: 1.5rem; }
|
||||
.pb-8 { padding-bottom: 2rem; }
|
||||
|
||||
/* 文字 */
|
||||
.text-sm { font-size: 0.875rem; }
|
||||
.text-base { font-size: 1rem; }
|
||||
.text-lg { font-size: 1.125rem; }
|
||||
.text-xl { font-size: 1.25rem; }
|
||||
.text-2xl { font-size: 1.5rem; }
|
||||
.text-3xl { font-size: 1.875rem; }
|
||||
.text-4xl { font-size: 2.25rem; }
|
||||
.font-medium { font-weight: 500; }
|
||||
.font-semibold { font-weight: 600; }
|
||||
.font-bold { font-weight: 700; }
|
||||
.text-center { text-align: center; }
|
||||
.tracking-wider { letter-spacing: 0.05em; }
|
||||
|
||||
/* 圆角 */
|
||||
.rounded-xl { border-radius: 0.75rem; }
|
||||
.rounded-2xl { border-radius: 1rem; }
|
||||
.rounded-3xl { border-radius: 1.5rem; }
|
||||
.rounded-full { border-radius: 9999px; }
|
||||
|
||||
/* 阴影 */
|
||||
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
|
||||
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
|
||||
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
|
||||
|
||||
/* 背景 */
|
||||
.bg-white { background-color: #ffffff; }
|
||||
.bg-gray-100 { background-color: #f3f4f6; }
|
||||
.bg-gradient-to-br { background: linear-gradient(to bottom right, var(--tw-gradient-stops)); }
|
||||
.bg-gradient-to-r { background: linear-gradient(to right, var(--tw-gradient-stops)); }
|
||||
|
||||
/* 渐变颜色 - 需要在元素上直接指定 */
|
||||
.from-purple-500 { --tw-gradient-from: #8b5cf6; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(139, 92, 246, 0)); }
|
||||
.to-purple-700 { --tw-gradient-to: #7c3aed; }
|
||||
.to-purple-800 { --tw-gradient-stops: var(--tw-gradient-from), #6b21a8; }
|
||||
|
||||
/* 文字颜色 */
|
||||
.text-white { color: #ffffff; }
|
||||
.text-white\/60 { color: rgba(255, 255, 255, 0.6); }
|
||||
.text-white\/80 { color: rgba(255, 255, 255, 0.8); }
|
||||
.text-white\/40 { color: rgba(255, 255, 255, 0.4); }
|
||||
.text-gray-100 { color: #f3f4f6; }
|
||||
.text-gray-800 { color: #1f2937; }
|
||||
.text-gray-600 { color: #4b5563; }
|
||||
.text-gray-500 { color: #6b7280; }
|
||||
.text-gray-400 { color: #9ca3af; }
|
||||
|
||||
/* 宽度高度 */
|
||||
.w-full { width: 100%; }
|
||||
.w-20 { width: 5rem; }
|
||||
.h-10 { height: 2.5rem; }
|
||||
.h-11 { height: 2.75rem; }
|
||||
.h-12 { height: 3rem; }
|
||||
.h-20 { height: 5rem; }
|
||||
.min-h-screen { min-height: 100vh; }
|
||||
|
||||
/* 边框 */
|
||||
.border-b { border-bottom-width: 1px; border-bottom-style: solid; }
|
||||
.border-gray-100 { border-color: #f3f4f6; }
|
||||
.border-2 { border-width: 2px; border-style: solid; }
|
||||
|
||||
/* Overflow */
|
||||
.overflow-hidden { overflow: hidden; }
|
||||
|
||||
/* 位置 */
|
||||
.relative { position: relative; }
|
||||
.absolute { position: absolute; }
|
||||
.right-3 { right: 0.75rem; }
|
||||
.bottom-2\.5 { bottom: 0.625rem; }
|
||||
|
||||
/* 其他 */
|
||||
.cursor-pointer { cursor: pointer; }
|
||||
.border { border-width: 1px; border-style: solid; }
|
||||
</style>
|
||||
@@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<script>
|
||||
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||
CSS.supports('top: constant(a)'))
|
||||
document.write(
|
||||
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||
</script>
|
||||
<title></title>
|
||||
<!--preload-links-->
|
||||
<!--app-context-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"><!--app-html--></div>
|
||||
<script type="module" src="/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,126 +0,0 @@
|
||||
export default {
|
||||
// tabBar
|
||||
tabBar: {
|
||||
home: 'Home',
|
||||
user: 'Profile',
|
||||
settings: 'Settings',
|
||||
},
|
||||
// 首页
|
||||
index: {
|
||||
welcome: 'Welcome to OPS',
|
||||
subtitle: 'Operations Management System',
|
||||
quickActions: 'Quick Actions',
|
||||
allOrders: 'All Orders',
|
||||
addOrder: 'New Order',
|
||||
schedule: 'Schedule',
|
||||
language: 'Language',
|
||||
logout: 'Logout',
|
||||
logoutConfirm: 'Confirm Logout',
|
||||
logoutMessage: 'Are you sure you want to logout?',
|
||||
pending: 'Pending',
|
||||
ordered: 'Ordered',
|
||||
arrived: 'Arrived',
|
||||
received: 'Received',
|
||||
pleaseLogin: 'Please login first',
|
||||
login: 'Login',
|
||||
},
|
||||
// 登录页
|
||||
login: {
|
||||
title: 'Login',
|
||||
username: 'Username',
|
||||
password: 'Password',
|
||||
rememberMe: 'Remember me',
|
||||
loginBtn: 'Login',
|
||||
logging: 'Logging in...',
|
||||
registerLink: "Don't have an account?",
|
||||
forgotLink: 'Forgot password?',
|
||||
usernamePlaceholder: 'Enter username',
|
||||
passwordPlaceholder: 'Enter password',
|
||||
// 错误提示
|
||||
usernameRequired: 'Please enter username',
|
||||
passwordRequired: 'Please enter password',
|
||||
loginSuccess: 'Login successful',
|
||||
loginFailed: 'Login failed, please check username and password',
|
||||
networkError: 'Network error, please try again later',
|
||||
usernameNotFound: 'Username not found',
|
||||
passwordIncorrect: 'Username or password incorrect',
|
||||
paramError: 'Parameter error',
|
||||
requestFailed: 'Request failed',
|
||||
},
|
||||
// 注册页
|
||||
register: {
|
||||
title: 'Register',
|
||||
username: 'Username',
|
||||
email: 'Email',
|
||||
password: 'Password',
|
||||
confirmPassword: 'Confirm Password',
|
||||
registerBtn: 'Register',
|
||||
registering: 'Registering...',
|
||||
loginLink: 'Already have an account?',
|
||||
usernamePlaceholder: 'Enter username',
|
||||
emailPlaceholder: 'Enter email',
|
||||
passwordPlaceholder: 'Enter password',
|
||||
confirmPlaceholder: 'Confirm password',
|
||||
showPassword: 'Show password',
|
||||
hidePassword: 'Hide password',
|
||||
// 验证提示
|
||||
usernameRequired: 'Please enter username',
|
||||
emailRequired: 'Please enter email',
|
||||
emailInvalid: 'Invalid email format',
|
||||
passwordRequired: 'Please enter password',
|
||||
passwordLength: 'Password must be at least 6 characters',
|
||||
confirmRequired: 'Please confirm password',
|
||||
passwordMismatch: 'Passwords do not match',
|
||||
// 结果提示
|
||||
usernameExists: 'Username already exists',
|
||||
emailUsed: 'Email already in use',
|
||||
paramError: 'Parameter error',
|
||||
requestFailed: 'Request failed',
|
||||
registerSuccess: 'Registration successful',
|
||||
registerFailed: 'Registration failed, please try again later',
|
||||
},
|
||||
// API 配置页
|
||||
apiConfig: {
|
||||
title: 'Settings',
|
||||
apiUrl: 'API Server URL',
|
||||
apiUrlPlaceholder: 'Enter API address',
|
||||
format: 'Format',
|
||||
current: 'Current',
|
||||
notSet: 'Not set',
|
||||
save: 'Save',
|
||||
saveSuccess: 'Saved successfully',
|
||||
pleaseInput: 'Please enter API address',
|
||||
testConnection: 'Test Connection',
|
||||
testBtn: 'Test Connection',
|
||||
testing: 'Testing...',
|
||||
connectionSuccess: 'Connection successful',
|
||||
connectionFailed: 'Connection failed',
|
||||
language: 'Language',
|
||||
zh: '中文',
|
||||
en: 'English',
|
||||
},
|
||||
// 通用
|
||||
common: {
|
||||
loading: 'Loading...',
|
||||
error: 'Request failed',
|
||||
retry: 'Retry',
|
||||
confirm: 'Confirm',
|
||||
cancel: 'Cancel',
|
||||
success: 'Operation successful',
|
||||
failed: 'Operation failed',
|
||||
back: 'Back',
|
||||
networkError: 'Network request failed, please check your connection',
|
||||
},
|
||||
// 用户页
|
||||
user: {
|
||||
profile: 'Profile',
|
||||
username: 'Username',
|
||||
firstName: 'Name',
|
||||
birthday: 'Birthday',
|
||||
gender: 'Gender',
|
||||
region: 'Region',
|
||||
male: 'Male',
|
||||
female: 'Female',
|
||||
unknown: 'Unknown',
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import { createI18n, useI18n as _useI18n } from 'vue-i18n'
|
||||
import zh from './zh.js'
|
||||
import en from './en.js'
|
||||
|
||||
// 兼容 uni-app 的 useI18n 导出
|
||||
export const useI18n = _useI18n
|
||||
|
||||
// 获取本地语言设置,默认中文
|
||||
function getLocale() {
|
||||
// 从本地存储读取
|
||||
const stored = uni.getStorageSync('locale')
|
||||
if (stored) return stored
|
||||
|
||||
// 获取系统语言
|
||||
const sysInfo = uni.getSystemInfoSync()
|
||||
const sysLang = sysInfo.language || 'zh-CN'
|
||||
// 简单判断:是否以 zh 开头
|
||||
return sysLang.toLowerCase().startsWith('zh') ? 'zh' : 'en'
|
||||
}
|
||||
|
||||
// 创建 i18n 实例
|
||||
export const i18n = createI18n({
|
||||
legacy: false, // uni-app 必须用 composition API 模式
|
||||
locale: getLocale(),
|
||||
fallbackLocale: 'zh',
|
||||
messages: {
|
||||
zh,
|
||||
en
|
||||
}
|
||||
})
|
||||
|
||||
// 切换语言
|
||||
export function setLocale(locale) {
|
||||
if (i18n.global.locale && typeof i18n.global.locale.value !== 'undefined') {
|
||||
i18n.global.locale.value = locale
|
||||
} else {
|
||||
i18n.global.locale = locale
|
||||
}
|
||||
uni.setStorageSync('locale', locale)
|
||||
// 触发页面更新
|
||||
uni.$emit('localeChanged', locale)
|
||||
}
|
||||
|
||||
// 获取当前语言
|
||||
export function getCurrentLocale() {
|
||||
if (i18n.global.locale && typeof i18n.global.locale.value !== 'undefined') {
|
||||
return i18n.global.locale.value
|
||||
}
|
||||
return i18n.global.locale
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
export default {
|
||||
// tabBar
|
||||
tabBar: {
|
||||
home: '首页',
|
||||
user: '我的',
|
||||
settings: '设置',
|
||||
},
|
||||
// 首页
|
||||
index: {
|
||||
welcome: '欢迎使用 OPS',
|
||||
subtitle: '运营管理系统',
|
||||
quickActions: '快捷操作',
|
||||
allOrders: '全部订单',
|
||||
addOrder: '新建订单',
|
||||
schedule: '日程管理',
|
||||
language: '语言',
|
||||
logout: '退出登录',
|
||||
logoutConfirm: '确认退出',
|
||||
logoutMessage: '确定要退出登录吗?',
|
||||
pending: '待处理',
|
||||
ordered: '已下单',
|
||||
arrived: '已到达',
|
||||
received: '已收件',
|
||||
pleaseLogin: '请先登录',
|
||||
login: '登 录',
|
||||
},
|
||||
// 登录页
|
||||
login: {
|
||||
title: '登录',
|
||||
username: '用户名',
|
||||
password: '密码',
|
||||
rememberMe: '记住登录状态',
|
||||
loginBtn: '登 录',
|
||||
logging: '登录中...',
|
||||
registerLink: '没有账号?立即注册',
|
||||
forgotLink: '忘记密码?',
|
||||
usernamePlaceholder: '请输入用户名',
|
||||
passwordPlaceholder: '请输入密码',
|
||||
// 错误提示
|
||||
usernameRequired: '请输入用户名',
|
||||
passwordRequired: '请输入密码',
|
||||
loginSuccess: '登录成功',
|
||||
loginFailed: '登录失败,请检查用户名和密码',
|
||||
networkError: '网络错误,请稍后重试',
|
||||
usernameNotFound: '用户名不存在',
|
||||
passwordIncorrect: '用户名或密码错误',
|
||||
paramError: '参数错误',
|
||||
requestFailed: '请求失败',
|
||||
},
|
||||
// 注册页
|
||||
register: {
|
||||
title: '注册',
|
||||
username: '用户名',
|
||||
email: '邮箱',
|
||||
password: '密码',
|
||||
confirmPassword: '确认密码',
|
||||
registerBtn: '注 册',
|
||||
registering: '注册中...',
|
||||
loginLink: '已有账号?立即登录',
|
||||
usernamePlaceholder: '请输入用户名',
|
||||
emailPlaceholder: '请输入邮箱',
|
||||
passwordPlaceholder: '请输入密码',
|
||||
confirmPlaceholder: '请再次输入密码',
|
||||
showPassword: '显示密码',
|
||||
hidePassword: '隐藏密码',
|
||||
// 验证提示
|
||||
usernameRequired: '请输入用户名',
|
||||
emailRequired: '请输入邮箱',
|
||||
emailInvalid: '邮箱格式不正确',
|
||||
passwordRequired: '请输入密码',
|
||||
passwordLength: '密码至少6位',
|
||||
confirmRequired: '请确认密码',
|
||||
passwordMismatch: '两次密码输入不一致',
|
||||
// 结果提示
|
||||
usernameExists: '用户名已存在',
|
||||
emailUsed: '邮箱已被使用',
|
||||
paramError: '参数错误',
|
||||
requestFailed: '请求失败',
|
||||
registerSuccess: '注册成功',
|
||||
registerFailed: '注册失败,请稍后重试',
|
||||
},
|
||||
// API 配置页
|
||||
apiConfig: {
|
||||
title: '设置',
|
||||
apiUrl: 'API 服务器地址',
|
||||
apiUrlPlaceholder: '请输入 API 地址',
|
||||
format: '格式',
|
||||
current: '当前',
|
||||
notSet: '未设置',
|
||||
save: '保存配置',
|
||||
saveSuccess: '保存成功',
|
||||
pleaseInput: '请输入 API 地址',
|
||||
testConnection: '测试连接',
|
||||
testBtn: '测试连接',
|
||||
testing: '测试中...',
|
||||
connectionSuccess: '连接成功',
|
||||
connectionFailed: '连接失败',
|
||||
language: '语言设置',
|
||||
zh: '中文',
|
||||
en: 'English',
|
||||
},
|
||||
// 通用
|
||||
common: {
|
||||
loading: '加载中...',
|
||||
error: '请求失败',
|
||||
retry: '重试',
|
||||
confirm: '确定',
|
||||
cancel: '取消',
|
||||
success: '操作成功',
|
||||
failed: '操作失败',
|
||||
back: '返回',
|
||||
networkError: '网络请求失败,请检查网络',
|
||||
},
|
||||
// 用户页
|
||||
user: {
|
||||
profile: '个人资料',
|
||||
username: '用户名',
|
||||
firstName: '姓名',
|
||||
birthday: '生日',
|
||||
gender: '性别',
|
||||
region: '地区',
|
||||
male: '男',
|
||||
female: '女',
|
||||
unknown: '未知',
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import App from './App'
|
||||
import { i18n } from './locales/index.js'
|
||||
|
||||
// 默认 API 地址
|
||||
const DEFAULT_API_URL = 'http://192.168.13.105/api/'
|
||||
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import './uni.promisify.adaptor'
|
||||
Vue.config.productionTip = false
|
||||
|
||||
// 从本地存储读取用户配置的 API 地址
|
||||
Vue.prototype.$BASE_URL = uni.getStorageSync('apiUrl') || DEFAULT_API_URL
|
||||
Vue.prototype.$i18n = i18n
|
||||
|
||||
const app = new Vue({
|
||||
...App,
|
||||
i18n
|
||||
})
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
// #ifdef VUE3
|
||||
import { createSSRApp } from 'vue'
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
app.use(i18n)
|
||||
// 从本地存储读取用户配置的 API 地址
|
||||
app.config.globalProperties.$BASE_URL = uni.getStorageSync('apiUrl') || DEFAULT_API_URL
|
||||
app.config.globalProperties.BASE_URL = uni.getStorageSync('apiUrl') || DEFAULT_API_URL
|
||||
return {
|
||||
app
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
@@ -1,134 +0,0 @@
|
||||
{
|
||||
"name" : "Operations",
|
||||
"appid" : "",
|
||||
"description" : "Operations(运营)的缩写,一个前后端分离的工作流/运营管理系统。",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* H5特有相关 */
|
||||
"h5": {
|
||||
"devServer": {
|
||||
"https": false,
|
||||
"port": 5173,
|
||||
"proxy": {
|
||||
"/api": {
|
||||
"target": "http://192.168.13.105",
|
||||
"changeOrigin": true,
|
||||
"secure": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"router": {
|
||||
"mode": "hash"
|
||||
}
|
||||
},
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
"usingComponents" : true,
|
||||
"nvueStyleCompiler" : "uni-app",
|
||||
"compilerVersion" : 3,
|
||||
"splashscreen" : {
|
||||
"alwaysShowBeforeRender" : true,
|
||||
"waiting" : true,
|
||||
"autoclose" : true,
|
||||
"delay" : 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules" : {
|
||||
"Barcode" : {},
|
||||
"Camera" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
"android" : {
|
||||
"permissions" : [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
]
|
||||
},
|
||||
/* ios打包配置 */
|
||||
"ios" : {},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {},
|
||||
"icons" : {
|
||||
"android" : {
|
||||
"hdpi" : "unpackage/res/icons/72x72.png",
|
||||
"xhdpi" : "unpackage/res/icons/96x96.png",
|
||||
"xxhdpi" : "unpackage/res/icons/144x144.png",
|
||||
"xxxhdpi" : "unpackage/res/icons/192x192.png"
|
||||
},
|
||||
"ios" : {
|
||||
"appstore" : "unpackage/res/icons/1024x1024.png",
|
||||
"ipad" : {
|
||||
"app" : "unpackage/res/icons/76x76.png",
|
||||
"app@2x" : "unpackage/res/icons/152x152.png",
|
||||
"notification" : "unpackage/res/icons/20x20.png",
|
||||
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||
"proapp@2x" : "unpackage/res/icons/167x167.png",
|
||||
"settings" : "unpackage/res/icons/29x29.png",
|
||||
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||
"spotlight" : "unpackage/res/icons/40x40.png",
|
||||
"spotlight@2x" : "unpackage/res/icons/80x80.png"
|
||||
},
|
||||
"iphone" : {
|
||||
"app@2x" : "unpackage/res/icons/120x120.png",
|
||||
"app@3x" : "unpackage/res/icons/180x180.png",
|
||||
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||
"notification@3x" : "unpackage/res/icons/60x60.png",
|
||||
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||
"settings@3x" : "unpackage/res/icons/87x87.png",
|
||||
"spotlight@2x" : "unpackage/res/icons/80x80.png",
|
||||
"spotlight@3x" : "unpackage/res/icons/120x120.png"
|
||||
}
|
||||
}
|
||||
},
|
||||
"splashscreen" : {
|
||||
"androidStyle" : "default",
|
||||
"android" : {
|
||||
"hdpi" : "static/logo.png",
|
||||
"xhdpi" : "static/logo.png",
|
||||
"xxhdpi" : "static/logo.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
},
|
||||
"vueVersion" : "3",
|
||||
"locale" : "auto"
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "ops-uniapp",
|
||||
"version": "1.0.0",
|
||||
"description": "OPS Mobile App",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "uni -p h5",
|
||||
"build": "uni build -p h5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dcloudio/uni-app": "3.0.0-4010520250107001",
|
||||
"vue-i18n": "^9.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@dcloudio/types": "^3.4.8",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-4010520250107001",
|
||||
"@dcloudio/uni-h5": "3.0.0-4010520250107001",
|
||||
"@dcloudio/vite-plugin-uni": "3.0.0-4010520250107001",
|
||||
"vite": "^5.4.0"
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
{
|
||||
"easycom": {
|
||||
"autoscan": true,
|
||||
"custom": {
|
||||
"^custom-(.*)": "@/components/custom-$1/custom-$1.vue"
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/user",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/settings/apiConfig",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/register/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "OPS",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
"selectedColor": "#667eea",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/user/user",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/settings.png",
|
||||
"selectedIconPath": "static/tabbar/settings-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/settings/apiConfig",
|
||||
"text": "设置",
|
||||
"iconPath": "static/tabbar/settings.png",
|
||||
"selectedIconPath": "static/tabbar/settings-active.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
<template>
|
||||
<view class="min-h-screen" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<!-- 未登录状态 -->
|
||||
<view v-if="!isLoggedIn" class="flex flex-col items-center justify-center px-6" style="min-height: 80vh">
|
||||
<text class="text-6xl mb-6">🔐</text>
|
||||
<text class="block text-xl font-semibold text-center mb-8" style="color: #1f2937">{{ t('index.pleaseLogin') }}</text>
|
||||
<button
|
||||
class="w-full max-w-xs h-12 rounded-full flex items-center justify-center font-semibold text-base"
|
||||
:style="{ background: 'linear-gradient(to right, #667eea, #764ba2)', color: '#fff' }"
|
||||
@click="goToLogin"
|
||||
>
|
||||
{{ t('index.login') }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 已登录状态 -->
|
||||
<template v-else>
|
||||
<!-- 顶部标题 -->
|
||||
<view class="header mx-4 mt-4 rounded-3xl p-8 mb-6" :style="{ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' }">
|
||||
<text class="block text-3xl font-bold text-white">{{ t('index.welcome') }}</text>
|
||||
<text class="block text-base text-white/80 mt-2">{{ t('index.subtitle') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单统计卡片 -->
|
||||
<view class="grid grid-cols-4 gap-3 mx-4 mb-6">
|
||||
<view class="stat-card rounded-2xl p-4 text-center shadow-sm" @click="goToOrders('pending')">
|
||||
<text class="block text-3xl font-bold" style="color: #667eea">{{ stats.pending }}</text>
|
||||
<text class="block text-sm mt-2" style="color: #6b7280">{{ t('index.pending') }}</text>
|
||||
</view>
|
||||
<view class="stat-card rounded-2xl p-4 text-center shadow-sm" @click="goToOrders('ordered')">
|
||||
<text class="block text-3xl font-bold" style="color: #667eea">{{ stats.ordered }}</text>
|
||||
<text class="block text-sm mt-2" style="color: #6b7280">{{ t('index.ordered') }}</text>
|
||||
</view>
|
||||
<view class="stat-card rounded-2xl p-4 text-center shadow-sm" @click="goToOrders('arrived')">
|
||||
<text class="block text-3xl font-bold" style="color: #667eea">{{ stats.arrived }}</text>
|
||||
<text class="block text-sm mt-2" style="color: #6b7280">{{ t('index.arrived') }}</text>
|
||||
</view>
|
||||
<view class="stat-card rounded-2xl p-4 text-center shadow-sm" @click="goToOrders('received')">
|
||||
<text class="block text-3xl font-bold" style="color: #667eea">{{ stats.received }}</text>
|
||||
<text class="block text-sm mt-2" style="color: #6b7280">{{ t('index.received') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 快捷操作 -->
|
||||
<view class="mx-4 mb-6">
|
||||
<text class="block text-xl font-semibold mb-4" style="color: #1f2937">{{ t('index.quickActions') }}</text>
|
||||
<view class="bg-white rounded-2xl overflow-hidden shadow-sm">
|
||||
<view class="action-item flex items-center p-6 border-b border-gray-100" @click="goToOrders('all')">
|
||||
<text class="text-2xl mr-4">📋</text>
|
||||
<text class="flex-1 text-base" style="color: #1f2937">{{ t('index.allOrders') }}</text>
|
||||
<text class="text-base" style="color: #d1d5db">→</text>
|
||||
</view>
|
||||
<view class="action-item flex items-center p-6 border-b border-gray-100" @click="goToAddOrder">
|
||||
<text class="text-2xl mr-4">➕</text>
|
||||
<text class="flex-1 text-base" style="color: #1f2937">{{ t('index.addOrder') }}</text>
|
||||
<text class="text-base" style="color: #d1d5db">→</text>
|
||||
</view>
|
||||
<view class="action-item flex items-center p-6" @click="goToSchedule">
|
||||
<text class="text-2xl mr-4">📅</text>
|
||||
<text class="flex-1 text-base" style="color: #1f2937">{{ t('index.schedule') }}</text>
|
||||
<text class="text-base" style="color: #d1d5db">→</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 语言切换入口 -->
|
||||
<view class="mx-4 mb-6">
|
||||
<view class="bg-white rounded-2xl p-6 flex items-center shadow-sm" @click="switchLang">
|
||||
<text class="text-2xl mr-4">🌐</text>
|
||||
<view class="flex-1">
|
||||
<text class="block text-base" style="color: #1f2937">{{ t('index.language') }}</text>
|
||||
<text class="block text-sm mt-1" style="color: #6b7280">{{ locale === 'zh' ? '中文' : 'English' }}</text>
|
||||
</view>
|
||||
<text class="text-base" style="color: #d1d5db">→</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<view class="mx-4 pb-8">
|
||||
<button class="w-full h-11 rounded-full text-center text-lg"
|
||||
style="background: #fff; color: #e53935" @click="handleLogout">
|
||||
{{ t('index.logout') }}
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { setLocale, getCurrentLocale } from '../../locales/index.js'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const statusBarHeight = ref(20)
|
||||
const isLoggedIn = ref(false)
|
||||
|
||||
// API 请求封装,解决路径拼接问题
|
||||
const request = (path, method = 'GET', data = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 确保 BASE_URL 不以 / 结尾
|
||||
const baseUrl = (getApp().globalData.BASE_URL || '').replace(/\/$/, '')
|
||||
// 确保 path 以 / 开头
|
||||
const fullPath = path.startsWith('/') ? path : '/' + path
|
||||
|
||||
uni.request({
|
||||
url: baseUrl + fullPath,
|
||||
method,
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': uni.getStorageSync('sessionCookie') || ''
|
||||
},
|
||||
success: (res) => resolve(res),
|
||||
fail: (err) => reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const stats = reactive({
|
||||
pending: 0,
|
||||
ordered: 0,
|
||||
arrived: 0,
|
||||
received: 0
|
||||
})
|
||||
|
||||
const fetchStats = () => {
|
||||
request('/purchase/getordercount', 'POST').then((res) => {
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
stats.pending = res.data.data.pending || 0
|
||||
stats.ordered = res.data.data.ordered || 0
|
||||
stats.arrived = res.data.data.arrived || 0
|
||||
stats.received = res.data.data.received || 0
|
||||
}
|
||||
}).catch(console.error)
|
||||
}
|
||||
|
||||
const goToLogin = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
|
||||
const goToOrders = (status) => {
|
||||
const url = status === 'all' ? '/pages/order/list' : `/pages/order/list?status=${status}`
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
const goToAddOrder = () => {
|
||||
uni.navigateTo({ url: '/pages/order/add' })
|
||||
}
|
||||
|
||||
const goToSchedule = () => {
|
||||
uni.navigateTo({ url: '/pages/schedule/schedule' })
|
||||
}
|
||||
|
||||
const switchLang = () => {
|
||||
const newLang = locale.value === 'zh' ? 'en' : 'zh'
|
||||
setLocale(newLang)
|
||||
locale.value = newLang
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
uni.showModal({
|
||||
title: t('index.logoutConfirm'),
|
||||
content: t('index.logoutMessage'),
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.removeStorageSync('sessionCookie')
|
||||
uni.removeStorageSync('userInfo')
|
||||
isLoggedIn.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 20
|
||||
|
||||
locale.value = getCurrentLocale()
|
||||
|
||||
// 检查登录状态
|
||||
const sessionCookie = uni.getStorageSync('sessionCookie')
|
||||
isLoggedIn.value = !!sessionCookie
|
||||
|
||||
// 已登录才获取数据
|
||||
if (isLoggedIn.value) {
|
||||
fetchStats()
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('localeChanged')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.min-h-screen {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.flex-col { flex-direction: column; }
|
||||
.items-center { align-items: center; }
|
||||
.justify-center { justify-content: center; }
|
||||
</style>
|
||||
@@ -1,227 +0,0 @@
|
||||
<template>
|
||||
<view class="min-h-screen bg-gradient-to-br from-purple-500 to-purple-800 px-6" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<!-- 语言切换 -->
|
||||
<view class="flex justify-center items-center py-4">
|
||||
<text
|
||||
class="text-sm px-2"
|
||||
:class="locale === 'zh' ? 'text-white font-semibold' : 'text-white/60'"
|
||||
@click="switchLang('zh')"
|
||||
>中文</text>
|
||||
<text class="text-white/40 mx-1">|</text>
|
||||
<text
|
||||
class="text-sm px-2"
|
||||
:class="locale === 'en' ? 'text-white font-semibold' : 'text-white/60'"
|
||||
@click="switchLang('en')"
|
||||
>EN</text>
|
||||
</view>
|
||||
|
||||
<!-- Logo 区域 -->
|
||||
<view class="flex flex-col items-center mb-16">
|
||||
<image class="w-20 h-20 rounded-2xl bg-white shadow-lg" src="/static/logo.png" mode="aspectFit"></image>
|
||||
<text class="text-4xl font-bold text-white mt-4 tracking-wider">OPS</text>
|
||||
<text class="text-sm text-white/80 mt-2">{{ t('login.title') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<view class="bg-white rounded-3xl p-8 shadow-xl">
|
||||
<view class="mb-6">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('login.username') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
type="text"
|
||||
v-model="form.username"
|
||||
:placeholder="t('login.usernamePlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
@confirm="handleLogin"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-6 relative">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('login.password') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base pr-10"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
v-model="form.password"
|
||||
:placeholder="t('login.passwordPlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
@confirm="handleLogin"
|
||||
/>
|
||||
<view class="absolute right-3 bottom-2.5 text-xl" @click="showPassword = !showPassword">
|
||||
<text>{{ showPassword ? '👁️' : '👁️🗨️' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mb-8 flex items-center">
|
||||
<checkbox-group @change="onRememberChange">
|
||||
<label class="flex items-center text-sm" style="color: #6b7280">
|
||||
<checkbox value="1" :checked="form.remember" color="#667eea" />
|
||||
<text class="ml-2">{{ t('login.rememberMe') }}</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="w-full h-12 rounded-full flex items-center justify-center font-semibold text-lg"
|
||||
:style="{ background: 'linear-gradient(to right, #667eea, #764ba2)', color: '#fff' }"
|
||||
:loading="loading"
|
||||
:disabled="loading"
|
||||
@click="handleLogin"
|
||||
>
|
||||
{{ loading ? t('login.logging') : t('login.loginBtn') }}
|
||||
</button>
|
||||
|
||||
<view class="mt-4 p-4 rounded-xl text-center" style="background: #fef2f2" v-if="errorMsg">
|
||||
<text class="text-sm" style="color: #ef4444">{{ errorMsg }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部信息 -->
|
||||
<view class="flex justify-center items-end pb-8 mt-8">
|
||||
<text class="text-sm text-white/80">{{ t('login.registerLink') }}</text>
|
||||
<navigator url="/pages/register/register" class="text-sm text-white font-semibold ml-1">{{ t('register.title') }}</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { setLocale, getCurrentLocale } from '../../locales/index.js'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const statusBarHeight = ref(20)
|
||||
const form = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
remember: false
|
||||
})
|
||||
|
||||
const showPassword = ref(false)
|
||||
const loading = ref(false)
|
||||
const errorMsg = ref('')
|
||||
|
||||
const switchLang = (lang) => {
|
||||
setLocale(lang)
|
||||
locale.value = lang
|
||||
}
|
||||
|
||||
const onRememberChange = (e) => {
|
||||
form.remember = e.detail.value.length > 0
|
||||
}
|
||||
|
||||
const validate = () => {
|
||||
if (!form.username.trim()) {
|
||||
errorMsg.value = t('login.usernameRequired')
|
||||
return false
|
||||
}
|
||||
if (!form.password) {
|
||||
errorMsg.value = t('login.passwordRequired')
|
||||
return false
|
||||
}
|
||||
errorMsg.value = ''
|
||||
return true
|
||||
}
|
||||
|
||||
const handleLogin = () => {
|
||||
if (!validate()) return
|
||||
|
||||
loading.value = true
|
||||
errorMsg.value = ''
|
||||
|
||||
uni.request({
|
||||
url: getApp().globalData.BASE_URL + '/users/login',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userCookieValue: '',
|
||||
data: {
|
||||
username: form.username,
|
||||
password: form.password,
|
||||
remember: form.remember
|
||||
}
|
||||
},
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.err_code === 0 && res.data.return && res.data.return.cookie) {
|
||||
const cookieData = res.data.return.cookie
|
||||
// 存储 cookie Value 作为 session 标识
|
||||
uni.setStorageSync('sessionCookie', cookieData.Value)
|
||||
uni.setStorageSync('cookieExpires', cookieData.ExpiresAt)
|
||||
uni.setStorageSync('userInfo', {
|
||||
userId: cookieData.ID,
|
||||
username: form.username
|
||||
})
|
||||
|
||||
if (form.remember) {
|
||||
uni.setStorageSync('savedUsername', form.username)
|
||||
uni.setStorageSync('savedRemember', true)
|
||||
} else {
|
||||
uni.removeStorageSync('savedUsername')
|
||||
uni.removeStorageSync('savedRemember')
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: t('login.loginSuccess'),
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
// 根据 err_code 显示错误信息
|
||||
const errCode = res.data.err_code
|
||||
const msgMap = {
|
||||
'-41': t('login.usernameNotFound'),
|
||||
'-42': t('login.passwordIncorrect'),
|
||||
'-3': t('login.paramError'),
|
||||
'-2': t('login.requestFailed')
|
||||
}
|
||||
errorMsg.value = msgMap[errCode] || res.data.err_msg || t('login.loginFailed')
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
errorMsg.value = t('login.networkError')
|
||||
console.error('Login error:', err)
|
||||
},
|
||||
complete: () => {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 20
|
||||
|
||||
locale.value = getCurrentLocale()
|
||||
|
||||
const savedUsername = uni.getStorageSync('savedUsername')
|
||||
const savedRemember = uni.getStorageSync('savedRemember')
|
||||
if (savedUsername && savedRemember) {
|
||||
form.username = savedUsername
|
||||
form.remember = true
|
||||
}
|
||||
|
||||
uni.$on('localeChanged', (lang) => {
|
||||
locale.value = lang
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('localeChanged')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.placeholder-gray {
|
||||
color: #9ca3af;
|
||||
}
|
||||
</style>
|
||||
@@ -1,226 +0,0 @@
|
||||
<template>
|
||||
<view class="min-h-screen bg-gradient-to-br from-purple-500 to-purple-800 px-6" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<!-- 语言切换 -->
|
||||
<view class="flex justify-center items-center py-4">
|
||||
<text
|
||||
class="text-sm px-2"
|
||||
:class="locale === 'zh' ? 'text-white font-semibold' : 'text-white/60'"
|
||||
@click="switchLang('zh')"
|
||||
>中文</text>
|
||||
<text class="text-white/40 mx-1">|</text>
|
||||
<text
|
||||
class="text-sm px-2"
|
||||
:class="locale === 'en' ? 'text-white font-semibold' : 'text-white/60'"
|
||||
@click="switchLang('en')"
|
||||
>EN</text>
|
||||
</view>
|
||||
|
||||
<!-- 返回按钮 -->
|
||||
<view class="mb-8 py-3" @click="goBack">
|
||||
<text class="text-lg text-white">← {{ t('common.back') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 注册表单 -->
|
||||
<view class="bg-white rounded-3xl p-8 shadow-xl">
|
||||
<text class="block text-3xl font-bold text-center mb-8" style="color: #1f2937">{{ t('register.title') }}</text>
|
||||
|
||||
<view class="mb-5">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('register.username') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
type="text"
|
||||
v-model="form.username"
|
||||
:placeholder="t('register.usernamePlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-5">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('register.email') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
type="email"
|
||||
v-model="form.email"
|
||||
:placeholder="t('register.emailPlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-5">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('register.password') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
v-model="form.password"
|
||||
:placeholder="t('register.passwordPlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-5">
|
||||
<text class="block text-sm font-medium mb-3" style="color: #1f2937">{{ t('register.confirmPassword') }}</text>
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
v-model="form.confirmPassword"
|
||||
:placeholder="t('register.confirmPlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-6" @click="showPassword = !showPassword">
|
||||
<text class="text-sm" style="color: #6b7280">{{ showPassword ? '👁️ ' : '👁️🗨️ ' }}{{ showPassword ? t('register.showPassword') : t('register.hidePassword') }}</text>
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="w-full h-12 rounded-full flex items-center justify-center font-semibold text-lg"
|
||||
:style="{ background: 'linear-gradient(to right, #667eea, #764ba2)', color: '#fff' }"
|
||||
:loading="loading"
|
||||
:disabled="loading"
|
||||
@click="handleRegister"
|
||||
>
|
||||
{{ loading ? t('register.registering') : t('register.registerBtn') }}
|
||||
</button>
|
||||
|
||||
<view class="mt-4 p-4 rounded-xl text-center" style="background: #fef2f2" v-if="errorMsg">
|
||||
<text class="text-sm" style="color: #ef4444">{{ errorMsg }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { setLocale, getCurrentLocale } from '../../locales/index.js'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const statusBarHeight = ref(20)
|
||||
const form = reactive({
|
||||
username: '',
|
||||
email: '',
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
const showPassword = ref(false)
|
||||
const loading = ref(false)
|
||||
const errorMsg = ref('')
|
||||
|
||||
const switchLang = (lang) => {
|
||||
setLocale(lang)
|
||||
locale.value = lang
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
const validate = () => {
|
||||
if (!form.username.trim()) {
|
||||
errorMsg.value = t('register.usernameRequired')
|
||||
return false
|
||||
}
|
||||
if (!form.email.trim()) {
|
||||
errorMsg.value = t('register.emailRequired')
|
||||
return false
|
||||
}
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
if (!emailRegex.test(form.email)) {
|
||||
errorMsg.value = t('register.emailInvalid')
|
||||
return false
|
||||
}
|
||||
if (!form.password) {
|
||||
errorMsg.value = t('register.passwordRequired')
|
||||
return false
|
||||
}
|
||||
if (form.password.length < 6) {
|
||||
errorMsg.value = t('register.passwordLength')
|
||||
return false
|
||||
}
|
||||
if (form.password !== form.confirmPassword) {
|
||||
errorMsg.value = t('register.passwordMismatch')
|
||||
return false
|
||||
}
|
||||
errorMsg.value = ''
|
||||
return true
|
||||
}
|
||||
|
||||
const handleRegister = () => {
|
||||
if (!validate()) return
|
||||
|
||||
loading.value = true
|
||||
errorMsg.value = ''
|
||||
|
||||
uni.request({
|
||||
url: getApp().globalData.BASE_URL + '/users/register',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userCookieValue: '',
|
||||
data: {
|
||||
username: form.username,
|
||||
useremail: form.email,
|
||||
userpass: form.password
|
||||
}
|
||||
},
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.err_code === 0) {
|
||||
uni.showToast({
|
||||
title: t('register.registerSuccess'),
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 根据 err_code 显示错误信息
|
||||
const errCode = res.data.err_code
|
||||
const msgMap = {
|
||||
'-4': t('register.usernameExists'),
|
||||
'-43': t('register.emailInvalid'),
|
||||
'-3': t('register.paramError'),
|
||||
'-2': t('register.requestFailed')
|
||||
}
|
||||
errorMsg.value = msgMap[errCode] || res.data.err_msg || t('register.registerFailed')
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
errorMsg.value = t('common.networkError')
|
||||
console.error('Register error:', err)
|
||||
},
|
||||
complete: () => {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 20
|
||||
|
||||
locale.value = getCurrentLocale()
|
||||
|
||||
uni.$on('localeChanged', (lang) => {
|
||||
locale.value = lang
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('localeChanged')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.placeholder-gray {
|
||||
color: #9ca3af;
|
||||
}
|
||||
</style>
|
||||
@@ -1,200 +0,0 @@
|
||||
<template>
|
||||
<view class="min-h-screen" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<!-- 页面标题 -->
|
||||
<view class="mx-4 mt-4 mb-6">
|
||||
<text class="block text-2xl font-bold" style="color: #1f2937">{{ t('apiConfig.title') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- #ifndef H5 -->
|
||||
<!-- API 地址配置 - 非H5端显示 -->
|
||||
<view class="mx-4 mb-4 bg-white rounded-2xl p-6 shadow-sm">
|
||||
<text class="block text-base font-semibold mb-4" style="color: #1f2937">{{ t('apiConfig.apiUrl') }}</text>
|
||||
|
||||
<view class="mb-4">
|
||||
<input
|
||||
class="w-full h-11 rounded-xl px-4 text-base"
|
||||
style="background: #f3f4f6; color: #1f2937"
|
||||
type="text"
|
||||
v-model="apiUrl"
|
||||
:placeholder="t('apiConfig.apiUrlPlaceholder')"
|
||||
placeholder-class="placeholder-gray"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="mb-3">
|
||||
<text class="block text-sm" style="color: #9ca3af">{{ t('apiConfig.format') }}: http://192.168.1.100/api/</text>
|
||||
</view>
|
||||
|
||||
<view class="mb-4">
|
||||
<text class="block text-sm" style="color: #9ca3af">{{ t('apiConfig.current') }}: {{ currentApiUrl }}</text>
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="w-full h-11 rounded-full flex items-center justify-center font-semibold text-base"
|
||||
:style="{ background: 'linear-gradient(to right, #667eea, #764ba2)', color: '#fff' }"
|
||||
:loading="saving"
|
||||
@click="saveApiUrl"
|
||||
>
|
||||
{{ t('apiConfig.save') }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<!-- #endif -->
|
||||
<view class="mx-4 mb-4 bg-white rounded-2xl p-6 shadow-sm">
|
||||
<text class="block text-base font-semibold mb-4" style="color: #1f2937">{{ t('apiConfig.testConnection') }}</text>
|
||||
|
||||
<button
|
||||
class="w-full h-10 rounded-full flex items-center justify-center text-base"
|
||||
:style="{ background: testResult === true ? '#dcfce7' : testResult === false ? '#fef2f2' : '#f3f4f6', color: testResult === true ? '#22c55e' : testResult === false ? '#ef4444' : '#1f2937' }"
|
||||
:loading="testing"
|
||||
:disabled="!apiUrl"
|
||||
@click="testConnection"
|
||||
>
|
||||
{{ testing ? t('apiConfig.testing') : t('apiConfig.testBtn') }}
|
||||
</button>
|
||||
|
||||
<view class="mt-4 text-center" v-if="testResult !== null">
|
||||
<text class="text-base font-medium" :style="{ color: testResult ? '#22c55e' : '#ef4444' }">
|
||||
{{ testResult ? t('apiConfig.connectionSuccess') : t('apiConfig.connectionFailed') }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 语言切换 -->
|
||||
<view class="mx-4 mb-8 bg-white rounded-2xl p-6 shadow-sm">
|
||||
<text class="block text-base font-semibold mb-4" style="color: #1f2937">{{ t('apiConfig.language') }}</text>
|
||||
|
||||
<view class="flex gap-4">
|
||||
<view
|
||||
class="flex-1 h-11 rounded-xl flex items-center justify-center border-2"
|
||||
:style="currentLang === 'zh' ? { borderColor: '#667eea', backgroundColor: '#f0f5ff' } : { borderColor: 'transparent', backgroundColor: '#f3f4f6' }"
|
||||
@click="switchLang('zh')"
|
||||
>
|
||||
<text class="text-base" :style="{ color: currentLang === 'zh' ? '#667eea' : '#1f2937' }">🇨🇳 中文</text>
|
||||
</view>
|
||||
<view
|
||||
class="flex-1 h-11 rounded-xl flex items-center justify-center border-2"
|
||||
:style="currentLang === 'en' ? { borderColor: '#667eea', backgroundColor: '#f0f5ff' } : { borderColor: 'transparent', backgroundColor: '#f3f4f6' }"
|
||||
@click="switchLang('en')"
|
||||
>
|
||||
<text class="text-base" :style="{ color: currentLang === 'en' ? '#667eea' : '#1f2937' }">🇺🇸 English</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const statusBarHeight = ref(20)
|
||||
const apiUrl = ref('')
|
||||
const saving = ref(false)
|
||||
const testing = ref(false)
|
||||
const testResult = ref(null)
|
||||
const currentLang = ref('zh')
|
||||
|
||||
const currentApiUrl = computed(() => {
|
||||
return getApp().globalData.BASE_URL || t('apiConfig.notSet')
|
||||
})
|
||||
|
||||
const switchLang = (lang) => {
|
||||
locale.value = lang
|
||||
currentLang.value = lang
|
||||
uni.setStorageSync('locale', lang)
|
||||
uni.$emit('localeChanged', lang)
|
||||
}
|
||||
|
||||
const saveApiUrl = () => {
|
||||
if (!apiUrl.value) {
|
||||
uni.showToast({
|
||||
title: t('apiConfig.pleaseInput'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let url = apiUrl.value.trim()
|
||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||
url = 'http://' + url
|
||||
}
|
||||
if (!url.endsWith('/')) {
|
||||
url = url + '/'
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
|
||||
// 保存原始 URL 到本地存储
|
||||
uni.setStorageSync('apiUrl', url)
|
||||
|
||||
// H5 端使用相对路径走代理,其他端使用完整 URL
|
||||
// #ifdef H5
|
||||
getApp().globalData.BASE_URL = '/api/'
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
getApp().globalData.BASE_URL = url
|
||||
// #endif
|
||||
|
||||
setTimeout(() => {
|
||||
saving.value = false
|
||||
uni.showToast({
|
||||
title: t('apiConfig.saveSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
const testConnection = () => {
|
||||
testing.value = true
|
||||
testResult.value = null
|
||||
|
||||
uni.request({
|
||||
url: getApp().globalData.BASE_URL,
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
success: (res) => {
|
||||
if (res.data && res.data.err_code === 0) {
|
||||
testResult.value = true
|
||||
} else {
|
||||
testResult.value = false
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
testResult.value = false
|
||||
},
|
||||
complete: () => {
|
||||
testing.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 20
|
||||
|
||||
const savedApiUrl = uni.getStorageSync('apiUrl')
|
||||
if (savedApiUrl) {
|
||||
apiUrl.value = savedApiUrl
|
||||
} else {
|
||||
apiUrl.value = getApp().globalData.BASE_URL || ''
|
||||
}
|
||||
|
||||
currentLang.value = locale.value || 'zh'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.min-h-screen {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.placeholder-gray {
|
||||
color: #9ca3af;
|
||||
}
|
||||
</style>
|
||||
@@ -1,319 +0,0 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 未登录状态 -->
|
||||
<view v-if="!isLoggedIn" class="login-prompt">
|
||||
<view class="prompt-icon">👤</view>
|
||||
<text class="prompt-text">{{ t('index.pleaseLogin') }}</text>
|
||||
<button class="login-btn" @click="goLogin">{{ t('index.login') }}</button>
|
||||
</view>
|
||||
|
||||
<!-- 已登录状态 -->
|
||||
<view v-else class="user-info">
|
||||
<!-- 用户卡片 -->
|
||||
<view class="user-card">
|
||||
<view class="avatar-box">
|
||||
<view class="avatar-placeholder">👤</view>
|
||||
</view>
|
||||
<view class="user-details">
|
||||
<text class="username">{{ userInfo.username || userInfo.Name || 'User' }}</text>
|
||||
<text class="email">{{ userInfo.email || userInfo.Email || '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view v-if="loading" class="loading-box">
|
||||
<text>{{ t('common.loading') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 用户详细信息 -->
|
||||
<view v-else-if="userDetail" class="detail-section">
|
||||
<view class="section-title">{{ t('user.profile') }}</view>
|
||||
<view class="info-list">
|
||||
<view class="info-item">
|
||||
<text class="info-label">{{ t('user.username') }}</text>
|
||||
<text class="info-value">{{ userDetail.userInfo.Username || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">{{ t('user.firstName') }}</text>
|
||||
<text class="info-value">{{ userDetail.userInfo.FirstName || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">{{ t('user.birthday') }}</text>
|
||||
<text class="info-value">{{ userDetail.userInfo.Birthdate || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">{{ t('user.gender') }}</text>
|
||||
<text class="info-value">{{ genderText }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">{{ t('user.region') }}</text>
|
||||
<text class="info-value">{{ userDetail.userInfo.Region || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<view class="action-section">
|
||||
<button class="action-btn logout" @click="handleLogout">
|
||||
{{ t('index.logout') }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const isLoggedIn = ref(false)
|
||||
const loading = ref(false)
|
||||
const userInfo = ref({})
|
||||
const userDetail = ref(null)
|
||||
|
||||
// 性别显示文本
|
||||
const genderText = computed(() => {
|
||||
if (!userDetail.value?.userInfo?.Gender) return '-'
|
||||
const map = { M: t('user.male'), F: t('user.female'), U: t('user.unknown') }
|
||||
return map[userDetail.value.userInfo.Gender] || '-'
|
||||
})
|
||||
|
||||
// 检查登录状态
|
||||
const checkLogin = () => {
|
||||
const cookie = uni.getStorageSync('sessionCookie')
|
||||
const info = uni.getStorageSync('userInfo')
|
||||
isLoggedIn.value = !!cookie && !!info
|
||||
if (info) userInfo.value = info
|
||||
}
|
||||
|
||||
// 获取用户详细信息
|
||||
const fetchUserDetail = () => {
|
||||
if (!isLoggedIn.value) return
|
||||
|
||||
loading.value = true
|
||||
const cookie = uni.getStorageSync('sessionCookie')
|
||||
|
||||
uni.request({
|
||||
url: getApp().globalData.BASE_URL + '/users/getinfo',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userCookieValue: cookie,
|
||||
data: {}
|
||||
},
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.err_code === 0 && res.data.return) {
|
||||
userDetail.value = res.data.return
|
||||
// 更新本地存储的用户信息
|
||||
const newInfo = {
|
||||
userId: res.data.return.user?.ID,
|
||||
username: res.data.return.user?.Name,
|
||||
email: res.data.return.user?.Email,
|
||||
...res.data.return.userInfo
|
||||
}
|
||||
uni.setStorageSync('userInfo', newInfo)
|
||||
userInfo.value = newInfo
|
||||
} else if (res.data.err_code === -44) {
|
||||
// Cookie 过期,清除登录状态
|
||||
handleLogout()
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('Get user info error:', err)
|
||||
},
|
||||
complete: () => {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到登录页
|
||||
const goLogin = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
const handleLogout = () => {
|
||||
uni.showModal({
|
||||
title: t('index.logoutConfirm'),
|
||||
content: t('index.logoutMessage'),
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.removeStorageSync('sessionCookie')
|
||||
uni.removeStorageSync('cookieExpires')
|
||||
uni.removeStorageSync('userInfo')
|
||||
isLoggedIn.value = false
|
||||
userInfo.value = {}
|
||||
userDetail.value = null
|
||||
uni.showToast({
|
||||
title: t('index.logout'),
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 页面显示时刷新数据
|
||||
onShow(() => {
|
||||
checkLogin()
|
||||
if (isLoggedIn.value) {
|
||||
fetchUserDetail()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.login-prompt {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: 200rpx;
|
||||
}
|
||||
|
||||
.prompt-icon {
|
||||
font-size: 120rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.prompt-text {
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 300rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #fff;
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.user-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.avatar-box {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 60rpx;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.avatar-placeholder {
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.user-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.username {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.email {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.loading-box {
|
||||
text-align: center;
|
||||
padding: 60rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.info-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.action-section {
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.action-btn.logout {
|
||||
background: #fff;
|
||||
color: #ff4d4f;
|
||||
border: 2rpx solid #ff4d4f;
|
||||
}
|
||||
</style>
|
||||
|
Before Width: | Height: | Size: 355 B |
|
Before Width: | Height: | Size: 344 B |
|
Before Width: | Height: | Size: 413 B |
|
Before Width: | Height: | Size: 403 B |
@@ -1,5 +0,0 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="20" cy="20" r="20" fill="#F0F0F0"/>
|
||||
<circle cx="20" cy="15" r="6" fill="#999"/>
|
||||
<path d="M8 36C8 28.268 13.372 22 20 22C26.628 22 32 28.268 32 36" stroke="#999" stroke-width="4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 323 B |
@@ -1,13 +0,0 @@
|
||||
uni.addInterceptor({
|
||||
returnValue (res) {
|
||||
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
|
||||
return res;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
res.then((res) => {
|
||||
if (!res) return resolve(res)
|
||||
return res[0] ? reject(res[0]) : resolve(res[1])
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [uni()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://192.168.13.105',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||