From 3d67dc928d884aea206a4817d8af40213e8040b9 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Wed, 29 Oct 2025 15:48:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=9B=BD=E9=99=85=E5=8C=96=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 34 +- README.md | 300 ---- components/LocationListSheet.vue | 35 +- components/MapComponent.vue | 30 +- components/OrderItemCard.vue | 35 +- config/url.js | 4 +- locale/en-US.js | 608 ++++++++ locale/index.js | 8 + locale/zh-CN.js | 608 ++++++++ main.js | 152 +- package-lock.json | 1764 ---------------------- package.json | 27 +- pages.json | 92 +- pages/deposit/index.vue | 44 +- pages/device/detail.vue | 104 +- pages/expressReturn/addExpressReturn.vue | 57 +- pages/expressReturn/detail.vue | 65 +- pages/expressReturn/index.vue | 53 +- pages/feedback/index.vue | 92 +- pages/help/index.vue | 10 +- pages/index/index.vue | 94 +- pages/join/index.vue | 8 +- pages/legal/agreement.vue | 17 +- pages/legal/privacy.vue | 18 +- pages/login/index.vue | 72 +- pages/my/index.vue | 50 +- pages/order/detail.vue | 111 +- pages/order/index.vue | 74 +- pages/order/payment.vue | 53 +- pages/order/return-success.vue | 77 +- pages/order/success.vue | 45 +- pages/position/detail.vue | 40 +- pages/return/index.vue | 121 +- pages/search/index.vue | 49 +- pages/serve/bagCheck/index.vue | 14 +- pages/setting/index.vue | 116 +- pages/user/index.vue | 42 +- pages/userProfile/index.vue | 46 +- pages/waiting/index.vue | 16 +- pnpm-lock.yaml | 219 +++ utils/i18n.js | 33 + 41 files changed, 2636 insertions(+), 2801 deletions(-) delete mode 100644 README.md create mode 100644 locale/en-US.js create mode 100644 locale/index.js create mode 100644 locale/zh-CN.js delete mode 100644 package-lock.json create mode 100644 utils/i18n.js diff --git a/App.vue b/App.vue index bcff131..6e3a3fc 100644 --- a/App.vue +++ b/App.vue @@ -8,11 +8,39 @@ export default { onLaunch: function() { console.log('App Launch') - + // 注意:语言初始化已移至 main.js,确保每次 reLaunch 都能正确加载新语言 }, onShow: async function() { - // 手动登录模式:不再自动登录 - // 如需保留可开关逻辑,可在此读取配置决定是否执行 autoLogin + console.log('========================================') + console.log('=== App onShow 被调用 ===') + console.log('时间戳:', new Date().toLocaleTimeString()) + + // 检查并更新语言(uni.reLaunch 会触发 onShow) + try { + const savedLang = uni.getStorageSync('language') + console.log('App onShow - 缓存中的语言:', savedLang) + + // 获取当前 i18n 实例并检查语言 + if (this.$i18n) { + const currentLocale = this.$i18n.locale + console.log('App onShow - 当前 i18n locale:', currentLocale) + + if (savedLang && savedLang !== currentLocale) { + console.log('=== App onShow 检测到语言变化 ===') + console.log('旧语言:', currentLocale) + console.log('新语言:', savedLang) + + // 强制更新语言 + this.$i18n.locale = savedLang + console.log('App onShow - 语言已更新为:', this.$i18n.locale) + console.log('App onShow - 测试翻译:', this.$t('common.loading')) + } + } + } catch (e) { + console.error('App onShow - 语言检查失败:', e) + } + + console.log('========================================') }, onHide: function() { console.log('App Hide') diff --git a/README.md b/README.md deleted file mode 100644 index 506f3cf..0000000 --- a/README.md +++ /dev/null @@ -1,300 +0,0 @@ -# Uni-Fans API 接口文档 - -本文档详细说明了 Uni-Fans 应用中使用的所有接口,包括参数说明和使用示例。 - -## 目录 - -1. [订单查询接口](#1-订单查询接口) -2. [设备信息查询接口](#2-设备信息查询接口) -3. [订单套餐更新接口](#3-订单套餐更新接口) -4. [用户余额更新接口](#4-用户余额更新接口) -5. [微信支付订单创建接口](#5-微信支付订单创建接口) -6. [设备租借指令接口](#6-设备租借指令接口) - -## 1. 订单查询接口 - -### 描述 -根据订单ID查询订单详细信息。 - -### 接口信息 -- **方法名**: `queryById` -- **请求方式**: GET -- **URL**: `/app/order/query/{orderId}` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| orderId | String | 是 | 订单ID | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": { - "orderId": "订单ID", - "orderNo": "订单编号", - "deviceNo": "设备编号", - "createTime": "创建时间", - "phone": "联系电话", - "depositAmount": "押金金额", - "packageTime": "套餐时间(分钟)", - "packagePrice": "套餐价格" - } -} -``` - -### 使用示例 - -```javascript -const orderInfo = await queryById('12345'); -if (orderInfo.code === 200) { - // 处理订单信息 - console.log(orderInfo.data); -} -``` - -## 2. 设备信息查询接口 - -### 描述 -根据设备编号查询设备详细信息。 - -### 接口信息 -- **方法名**: `getDeviceInfo` -- **请求方式**: GET -- **URL**: `/app/device/info/{deviceNo}` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| deviceNo | String | 是 | 设备编号 | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": { - "device": { - "deviceNo": "设备编号", - "deviceName": "设备名称", - "deviceStatus": "设备状态", - "depositAmount": "押金金额", - "feeType": "收费类型(hour/times)", - "feeConfig": "费用配置JSON字符串" - } - } -} -``` - -### 使用示例 - -```javascript -const deviceInfo = await getDeviceInfo('D001'); -if (deviceInfo.code === 200) { - // 处理设备信息 - console.log(deviceInfo.data.device); -} -``` - -## 3. 订单套餐更新接口 - -### 描述 -更新订单的套餐信息。 - -### 接口信息 -- **方法名**: `updateOrderPackage` -- **请求方式**: POST -- **URL**: `/app/order/update-package` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| orderId | String | 是 | 订单ID | -| packageTime | Number | 是 | 套餐时间(分钟) | -| packagePrice | Number | 是 | 套餐价格 | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": null -} -``` - -### 使用示例 - -```javascript -const result = await updateOrderPackage({ - orderId: '12345', - packageTime: 360, // 6小时(分钟) - packagePrice: 30 // 30元 -}); -if (result.code === 200) { - console.log('套餐更新成功'); -} -``` - -## 4. 用户余额更新接口 - -### 描述 -支付成功后更新用户余额信息。 - -### 接口信息 -- **方法名**: `updateUserBalance` -- **请求方式**: POST -- **URL**: `/app/user/update-balance` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| orderId | String | 是 | 订单ID | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": { - "userId": "用户ID", - "balance": "更新后余额" - } -} -``` - -### 使用示例 - -```javascript -const result = await updateUserBalance('12345'); -if (result.code === 200) { - console.log('用户余额更新成功'); -} -``` - -## 5. 微信支付订单创建接口 - -### 描述 -创建微信支付订单。 - -### 接口信息 -- **请求方式**: GET -- **URL**: `/app/wx-payment/create/{orderNo}` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| orderNo | String | 是 | 订单编号 | - -### 请求头 - -| 参数名 | 必须 | 描述 | -| ----- | ---- | ---- | -| Authorization | 是 | Bearer 认证令牌 | -| Clientid | 是 | 客户端ID | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": { - "appId": "微信应用ID", - "timeStamp": "时间戳", - "nonceStr": "随机字符串", - "package": "预支付交易会话标识", - "signType": "签名类型", - "paySign": "签名" - } -} -``` - -### 使用示例 - -```javascript -const res = await uni.request({ - url: `${URL}/app/wx-payment/create/${orderNo}`, - method: 'GET', - header: { - 'Authorization': "Bearer " + uni.getStorageSync('token'), - 'Clientid': uni.getStorageSync('client_id') - } -}); - -if (res.statusCode === 200 && res.data.code === 200) { - const payParams = res.data.data; - await uni.requestPayment({ - ...payParams, - success: () => { - console.log('支付成功'); - }, - fail: (err) => { - console.error('支付失败:', err); - } - }); -} -``` - -## 6. 设备租借指令接口 - -### 描述 -发送设备租借指令。 - -### 接口信息 -- **请求方式**: POST -- **URL**: `/app/device/sendRentCommand` - -### 请求参数 - -| 参数名 | 类型 | 必须 | 描述 | -| ----- | ---- | ---- | ---- | -| orderId | String | 是 | 订单ID | - -### 请求头 - -| 参数名 | 必须 | 描述 | -| ----- | ---- | ---- | -| Content-Type | 是 | application/x-www-form-urlencoded | -| Authorization | 是 | Bearer 认证令牌 | -| Clientid | 是 | 客户端ID | - -### 响应参数 - -```json -{ - "code": 200, - "msg": "操作成功", - "data": null -} -``` - -### 使用示例 - -```javascript -const res = await uni.request({ - url: `${URL}/app/device/sendRentCommand`, - method: 'POST', - data: { - orderId: '12345' - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded', - 'Authorization': "Bearer " + uni.getStorageSync('token'), - 'Clientid': uni.getStorageSync('client_id') - } -}); - -if (res.statusCode === 200 && res.data.code === 200) { - console.log('租借指令发送成功'); -} -``` \ No newline at end of file diff --git a/components/LocationListSheet.vue b/components/LocationListSheet.vue index 8160253..02d08e3 100644 --- a/components/LocationListSheet.vue +++ b/components/LocationListSheet.vue @@ -14,23 +14,23 @@ @click="$emit('select', item)"> {{ item.name }} - - 可租借 - 可归还 - - 营业时间:{{ item.workTime }} - - - - {{ item.distance }} - 导航 + + {{ $t('location.rent') }} + {{ $t('location.return') }} + + {{ $t('location.businessHours') }}{{ item.workTime }} + + + + {{ item.distance }} + {{ $t('location.navigate') }} - - - 附近暂无设备 - + + + {{ $t('home.noNearbyDevice') }} + @@ -39,12 +39,17 @@ \ No newline at end of file diff --git a/pages/user/index.vue b/pages/user/index.vue index 5771b06..4e5e069 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -6,40 +6,40 @@ - {{ userInfo.nickName || '未登录' }} - {{ userInfo.phone || '未绑定手机号' }} + {{ userInfo.nickName || $t('user.notLoggedIn') }} + {{ userInfo.phone || $t('user.phoneNotBound') }} - 余额 + {{ $t('userProfile.balance') }} ¥{{ userInfo.balanceAmount || '0.00' }} - 可用于租借设备 + {{ $t('user.balanceDesc') }} - + 📋 - 我的订单 + {{ $t('user.myOrders') }} > - + 💬 - 意见反馈 + {{ $t('user.feedback') }} > - + ℹ️ - 关于我们 + {{ $t('help.title') }} > - 退出登录 + {{ $t('user.logout') }} @@ -55,6 +55,12 @@ export default { isLogin: false } }, + onLoad() { + // 设置页面标题 + uni.setNavigationBarTitle({ + title: this.$t('user.personalCenter') + }) + }, onShow() { this.loadUserInfo() }, @@ -90,16 +96,22 @@ export default { }, handleLogout() { uni.showModal({ - title: '提示', - content: '确定要退出登录吗?', + title: this.$t('common.tips'), + content: this.$t('user.confirmLogout'), success: (res) => { if (res.confirm) { uni.removeStorageSync('token') uni.removeStorageSync('userInfo') this.isLogin = false - uni.redirectTo({ - url: '/pages/login/index' + uni.showToast({ + title: this.$t('user.logoutSuccess'), + icon: 'success' }) + setTimeout(() => { + uni.redirectTo({ + url: '/pages/login/index' + }) + }, 500) } } }) diff --git a/pages/userProfile/index.vue b/pages/userProfile/index.vue index 2a77444..57af9bc 100644 --- a/pages/userProfile/index.vue +++ b/pages/userProfile/index.vue @@ -9,15 +9,15 @@ - 点击头像更换 - + {{ $t('userProfile.clickToChange') }} + - 昵称 + {{ $t('userProfile.nickname') }} - {{ userInfo.nickName || '未设置' }} + {{ userInfo.nickName || $t('userProfile.notSet') }} @@ -27,25 +27,25 @@ - - + + - 手机号 + {{ $t('userProfile.phone') }} - {{ userInfo.phone ? maskPhone(userInfo.phone) : '未绑定' }} + {{ userInfo.phone ? maskPhone(userInfo.phone) : $t('userProfile.notBound') }} - 余额 + {{ $t('userProfile.balance') }} ¥{{ userInfo.balanceAmount || '0.00' }} @@ -57,6 +57,9 @@