From b65b9a995ce0e61e567f513845a813fa801d5d77 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Tue, 17 Jun 2025 23:45:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=A4=9A=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E5=9B=BD=E9=99=85=E5=8C=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 重构代码以支持i18n国际化 feat(locale): 添加多语言配置文件 feat(components): 国际化组件文本 feat(pages): 国际化页面文本 feat(store): 更新用户信息获取逻辑 docs: 添加国际化配置文档 --- .cursor/rules/index.mdc | 60 ++++ api/api.js | 3 + api/http.js | 5 +- components/active/active-item.vue | 10 +- components/base/tabbar.vue | 64 ++-- components/cart/CardList.vue | 42 ++- components/cart/signInQrcodePopup.vue | 2 +- components/travel/travelList.vue | 10 +- components/userShop/userShopCommission.vue | 130 -------- components/zhaomu/zhaomu-item.vue | 14 +- components/zhaomu/zlx-item.vue | 8 +- config.js | 3 + locale/en.json | 389 ++++++++++++++++++++++ locale/index.js | 76 +++++ locale/objectLangMap.js | 65 ++++ locale/zh-Hans.json | 389 ++++++++++++++++++++++ main.js | 2 + pages.json | 9 +- pages/index/cart.vue | 12 +- pages/index/center.vue | 63 ++-- pages/index/index.vue | 57 ++-- pages/index/order.vue | 131 -------- pages_login/fuwutiaokuan.vue | 2 +- pages_login/wxLogin.vue | 10 +- pages_login/wxUserInfo.vue | 30 +- pages_login/yinsixieyi.vue | 8 +- pages_my/activeList.vue | 16 +- pages_my/collection.vue | 414 ++++++++++++------------ pages_my/guanyuwomen.vue | 2 +- pages_my/qiandao-list.vue | 35 +- pages_my/travelList.vue | 12 +- pages_my/user-info.vue | 44 +-- pages_my/user-msg.vue | 80 +++-- pages_my/zlx-qiandao.vue | 6 +- pages_my/zlx-xieyi.vue | 2 +- pages_order/huodong-detail.vue | 54 ++-- pages_order/invoiceIssuance.vue | 28 +- pages_order/invoiceRecords.vue | 17 +- pages_order/lvyou-detail.vue | 44 +-- pages_order/orderDetails.vue | 76 +++-- pages_order/orderEvaluation.vue | 22 +- pages_order/payOrder.vue | 496 ++++++++++++++--------------- pages_zlx/zlx-form.vue | 59 ++-- store/store.js | 35 +- 44 files changed, 1926 insertions(+), 1110 deletions(-) create mode 100644 .cursor/rules/index.mdc delete mode 100644 components/userShop/userShopCommission.vue create mode 100644 locale/en.json create mode 100644 locale/index.js create mode 100644 locale/objectLangMap.js create mode 100644 locale/zh-Hans.json delete mode 100644 pages/index/order.vue diff --git a/.cursor/rules/index.mdc b/.cursor/rules/index.mdc new file mode 100644 index 0000000..99da546 --- /dev/null +++ b/.cursor/rules/index.mdc @@ -0,0 +1,60 @@ +--- +description: +globs: +alwaysApply: true +--- +## 当前项目是uniapp开发微信小程序 + +在你修改locale下的json文件需要根据文件路径进行国际化配置 + +例如: + +文件路径 +/components/active/active-item +/pages/index/index +/pages/index/center +/pages_login/wxLogin + +en.json +{ + "components" : { + "active" : { + "active_item" : { + ... + } + } + }, + "pages" : { + "index" : { + ... + }, + "center" : { + ... + }, + }, + "pages_login" : { + "wxLogin" : { + ... + }, + }, +} + + +并且在国际化替换内容的位置需要留有中文版的注释内容 + +国际化对象需要在objectLangMap.json中配置,将后端对象多个不同语言的字段进行关联,而不是国际化成中文 + +例如: +{ + //国际化活动 + "active" : { + "title" : { + "zh-Hans" : "title", + "en" : "enTitle", + }, + ... + } +} + +使用方式 +$ot(item, 'active', 'title') \ No newline at end of file diff --git a/api/api.js b/api/api.js index dcfd220..7c4ab0a 100644 --- a/api/api.js +++ b/api/api.js @@ -48,6 +48,9 @@ export function api(key, data, callback, loadingTitle) { if (req.auth) { if (!uni.getStorageSync('token')) { utils.toLogin() + store.state.userInfo = {} + store.state.token = "" + uni.removeStorageSync('token') console.error('需要登录') return Promise.reject('必须登录') } diff --git a/api/http.js b/api/http.js index 6c3da63..06a0e40 100644 --- a/api/http.js +++ b/api/http.js @@ -35,7 +35,10 @@ function http(uri, data, callback, method = 'GET', showLoading, title) { if(res.statusCode == 401 || res.data.message == '操作失败,token非法无效!' || res.data.message == '操作失败,用户不存在!'){ - store.commit('logout') + // store.commit('logout') + store.state.userInfo = {} + store.state.token = "" + uni.removeStorageSync('token') console.error('登录过期'); utils.toLogin() } diff --git a/components/active/active-item.vue b/components/active/active-item.vue index d56c134..b5dfdd9 100644 --- a/components/active/active-item.vue +++ b/components/active/active-item.vue @@ -5,18 +5,18 @@ v-for="(item, index) in cardListData" :key="index"> - + - {{item.title}} + {{$ot(item, 'active', 'title')}} {{ $dayjs(item.startTime).format('YYYY-MM-DD') }} - {{item.address}} + {{$ot(item, 'active', 'address')}} {{item.num || 0}}/{{item.sum || 0}} - 立即报名 - 已结束 + {{$t('components.active.activeItem.signUp')}} + {{$t('components.active.activeItem.ended')}} diff --git a/components/base/tabbar.vue b/components/base/tabbar.vue index 5880be7..97b6534 100644 --- a/components/base/tabbar.vue +++ b/components/base/tabbar.vue @@ -30,38 +30,42 @@ }, data() { return { - list : [ - { - "selectedIconPath": "/static/image/tabbar/home-a.png", - "iconPath": "/static/image/tabbar/home.png", - "pagePath": "/pages/index/index", - "title": "首页", - key : 'home', - }, - { - "selectedIconPath": "/static/image/tabbar/zhaomu-a.png", - "iconPath": "/static/image/tabbar/zhaomu.png", - "pagePath": "/pages/index/member", - "title": "招募", - key : 'member', - }, - { - "selectedIconPath": "/static/image/tabbar/order-a.png", - "iconPath": "/static/image/tabbar/order.png", - "pagePath": "/pages/index/cart", - "title": "订单", - key : 'cart', - }, - { - "selectedIconPath": "/static/image/tabbar/center-a.png", - "iconPath": "/static/image/tabbar/center.png", - "pagePath": "/pages/index/center", - "title": "我的", - key : 'center', - } - ] + list : [] }; }, + mounted() { + // 初始化国际化的 tabbar 数据 + this.list = [ + { + "selectedIconPath": "/static/image/tabbar/home-a.png", + "iconPath": "/static/image/tabbar/home.png", + "pagePath": "/pages/index/index", + "title": this.$t('components.base.tabbar.home'), // 首页 + key : 'home', + }, + { + "selectedIconPath": "/static/image/tabbar/zhaomu-a.png", + "iconPath": "/static/image/tabbar/zhaomu.png", + "pagePath": "/pages/index/member", + "title": this.$t('components.base.tabbar.member'), // 招募 + key : 'member', + }, + { + "selectedIconPath": "/static/image/tabbar/order-a.png", + "iconPath": "/static/image/tabbar/order.png", + "pagePath": "/pages/index/cart", + "title": this.$t('components.base.tabbar.cart'), // 订单 + key : 'cart', + }, + { + "selectedIconPath": "/static/image/tabbar/center-a.png", + "iconPath": "/static/image/tabbar/center.png", + "pagePath": "/pages/index/center", + "title": this.$t('components.base.tabbar.center'), // 我的 + key : 'center', + } + ] + }, methods : { toPath(item, index){ if(item.key == this.select){ diff --git a/components/cart/CardList.vue b/components/cart/CardList.vue index 56958c6..1b18824 100644 --- a/components/cart/CardList.vue +++ b/components/cart/CardList.vue @@ -2,21 +2,23 @@ - 下单时间:{{item.createTime}} + {{$t('components.cart.cardList.orderTime')}}:{{item.createTime}} {{ stateText[item.state] }} - + - {{item.title}} + {{ getTitle(item) }} + {{item.startTime}} - {{item.address}} + {{ getAddress(item) }} + - 总计¥{{item.payPrice}} + {{$t('components.cart.cardList.total')}}¥{{item.payPrice}} @@ -25,18 +27,18 @@ class="mini-btn" size="mini">立即支付 --> + class="mini-btn" size="mini">{{$t('components.cart.cardList.cancelActivity')}} + class="mini-btn" size="mini">{{$t('components.cart.cardList.signIn')}} + class="mini-btn" size="mini">{{$t('components.cart.cardList.evaluate')}} + class="mini-btn" size="mini">{{$t('components.cart.cardList.invoice')}} @@ -52,7 +54,7 @@ }, data() { return { - stateText : ['', '待参加', '已完成', '已取消'], + stateText : ['', this.$t('components.cart.cardList.states.pending'), this.$t('components.cart.cardList.states.completed'), this.$t('components.cart.cardList.states.cancelled')], }; }, components: { @@ -76,6 +78,26 @@ getImage(item){ return item.image && item.image.split(',')[0] }, + getTitle(item) { + // 根据订单类型决定使用哪种对象类型进行国际化 + if (item.type == 0) { + // 活动订单 + return this.$ot(item.activity, 'active', 'title') + } else { + // 旅行订单 + return this.$ot(item.travel, 'travel', 'title') + } + }, + getAddress(item) { + // 根据订单类型决定使用哪种对象类型进行国际化 + if (item.type == 0) { + // 活动订单 + return this.$ot(item.activity, 'active', 'address') + } else { + // 旅行订单 + return this.$ot(item.travel, 'travel', 'address') + } + }, } }; diff --git a/components/cart/signInQrcodePopup.vue b/components/cart/signInQrcodePopup.vue index f3c508f..de3bf0d 100644 --- a/components/cart/signInQrcodePopup.vue +++ b/components/cart/signInQrcodePopup.vue @@ -30,7 +30,7 @@ {{adminUserInfo.nickName}} - 主理人 + {{$t('components.cart.signInQrcodePopup.organizer')}} - + - {{item.title}} + {{$ot(item, 'travel', 'title')}} {{ $dayjs(item.startTime).format('YYYY-MM-DD') }} - {{item.address}} + {{$ot(item, 'travel', 'address')}} ¥{{item.price}} {{item.num || 0}}/{{item.sum || 0}} - 报名中 - 已结束 + {{$t('components.travel.travelList.enrolling')}} + {{$t('components.travel.travelList.ended')}} diff --git a/components/userShop/userShopCommission.vue b/components/userShop/userShopCommission.vue deleted file mode 100644 index be66e89..0000000 --- a/components/userShop/userShopCommission.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/zhaomu/zhaomu-item.vue b/components/zhaomu/zhaomu-item.vue index d1a9284..21345e1 100644 --- a/components/zhaomu/zhaomu-item.vue +++ b/components/zhaomu/zhaomu-item.vue @@ -7,13 +7,13 @@ - {{item.title}} + {{$ot(item, 'active', 'title')}} {{item.startTime}} - {{item.address}} + {{$ot(item, 'active', 'address')}} @@ -30,23 +30,23 @@ - 参与招募 + {{$t('components.zhaomu.zhaomuItem.joinRecruit')}} - 不通过 + {{$t('components.zhaomu.zhaomuItem.rejected')}} - {{ ['审核中', '已参加'][item.openState - 1] }} + {{ [$t('components.zhaomu.zhaomuItem.reviewing'), $t('components.zhaomu.zhaomuItem.joined')][item.openState - 1] }} - {{item == 1? '保证成行' : '已成行'}} + {{item == 1? $t('components.zhaomu.zhaomuItem.guaranteed') : $t('components.zhaomu.zhaomuItem.confirmed')}} @@ -95,7 +95,7 @@ this.$api('shopUserAuth',params,res=>{ this.$emit('getData') if(res.code == 200) { - this.$Toast('参与成功') + this.$Toast(this.$t('components.zhaomu.zhaomuItem.joinSuccess')) } }) } diff --git a/components/zhaomu/zlx-item.vue b/components/zhaomu/zlx-item.vue index 0272aad..53fbac3 100644 --- a/components/zhaomu/zlx-item.vue +++ b/components/zhaomu/zlx-item.vue @@ -2,18 +2,18 @@ - + - {{item.title}} + {{$ot(item, 'active', 'title')}} {{item.createTime}} - {{item.address}} + {{$ot(item, 'active', 'address')}} {{ item.doNum || 0 }}/{{ item.num || 0 }} 开始签到 + >{{$t('components.zhaomu.zlxItem.startSignIn')}} diff --git a/config.js b/config.js index 28ad995..905a727 100644 --- a/config.js +++ b/config.js @@ -12,6 +12,9 @@ const type = 'prod' // 环境配置 const config = { + local : { + baseUrl : 'http://127.0.0.1:8001/popularize-admin', + }, dev : { // baseUrl : 'http://test-lzx.natapp1.cc/popularize-admin', baseUrl : 'http://h5.xzaiyp.top/popularize-admin', diff --git a/locale/en.json b/locale/en.json new file mode 100644 index 0000000..c7f3d5e --- /dev/null +++ b/locale/en.json @@ -0,0 +1,389 @@ +{ + "pages": { + "index": { + "index": { + "uv_search_placeholder": "Search for relevant content", + "nav_title": "Home", + "moments_title": "Joy Moments", + "sign_in_activity": "Sign-in Activity", + "sign_in_desc": "Get rewards by signing in", + "view_now": "View Now", + "activity": "Activity", + "travel": "Travel", + "recent": "Recent", + "past": "Past", + "select_area": "Select Area", + "confirm": "Confirm" + }, + "cart": { + "title": "My Orders", + "tabs": { + "all": "All", + "pending": "Pending", + "completed": "Completed", + "cancelled": "Cancelled" + }, + "confirmCancel": "Cancel this order?" + }, + "center": { + "nav_title": "Profile", + "please_login": "Please click to login", + "my_activities": "My Activities", + "pending": "Pending", + "completed": "Completed", + "cancelled": "Cancelled", + "my_tools": "My Tools", + "invoice_records": "Invoice Records", + "my_favorites": "My Favorites", + "about_us": "About Us", + "user_agreement": "User Agreement", + "privacy_policy": "Privacy Policy", + "organizer_agreement": "Organizer Agreement", + "organizer_checkin": "Organizer Check-in", + "logout": "Logout" + } + } + }, + "pages_login": { + "wxLogin": { + "wechatLogin": "WeChat Authorization Login", + "cancelLogin": "Cancel Login", + "agreed": "Agreed to ", + "privacyPolicy": "Privacy Policy", + "userAgreement": "User Agreement", + "pleaseAgree": "Please check the privacy agreement" + }, + "wxUserInfo": { + "requestInfo": "Request your avatar and nickname", + "avatar": "Avatar", + "nickname": "Nickname", + "gender": "Gender", + "phone": "Phone", + "enterNickname": "Please enter nickname", + "selectGender": "Please select gender", + "enterPhone": "Please enter phone number", + "getPhone": "Get Phone Number", + "confirm": "Confirm", + "male": "Male", + "female": "Female", + "pleaseSelectAvatar": "Please select avatar", + "pleaseEnterNickname": "Please enter nickname", + "pleaseEnterPhone": "Please enter phone number", + "pleaseSelectGender": "Please select gender" + }, + "fuwutiaokuan": { + "title": "User Agreement" + }, + "yinsixieyi": { + "defaultTitle": "Privacy Policy", + "travelGuide": "Travel Guide", + "paymentGuide": "Payment Guide", + "organizerAgreement": "Organizer Agreement" + } + }, + "pages_my": { + "zlx_xieyi": { + "title": "Organizer Agreement" + }, + "zlx_qiandao": { + "title": "Organizer Check-in", + "activity": "Activity", + "travel": "Travel" + }, + "user_msg": { + "title": "Edit Profile", + "basic_info": "Basic Information", + "username": "Username", + "email": "Email", + "phone": "Phone", + "gender": "Gender", + "nationality": "Nationality", + "birthday": "Birthday", + "address": "Current Address", + "personal_status": "Personal Status", + "education": "Education", + "degree": "Degree", + "school": "School", + "work": "Work", + "industry": "Industry", + "about_me": "About Me", + "save": "Save", + "enter_username": "Please enter username", + "enter_email": "Please enter email", + "enter_phone": "Please enter phone number", + "select_gender": "Please select gender", + "enter_nationality": "Please enter nationality", + "enter_birthday": "Please enter birthday", + "enter_address": "Please enter current address", + "enter_status": "Please enter personal status", + "enter_industry": "Please enter industry", + "enter_about_me": "Please enter self introduction...", + "male": "Male", + "female": "Female", + "bachelor": "Bachelor", + "master": "Master", + "doctor": "Doctor", + "other": "Other", + "save_success": "Save successfully" + }, + "user_info": { + "title": "Profile", + "change_avatar": "Click to change avatar", + "nationality": "Nationality", + "degree": "Degree", + "industry": "Industry", + "phone": "Phone", + "gender": "Gender", + "tags": "Tags", + "about_me": "About Me", + "edit_info": "Edit Information", + "not_set": "Not Set", + "years_old": "years old" + }, + "travelList": { + "title": "Travel List", + "all": "All", + "enrolling": "Enrolling", + "ended": "Ended", + "time": "Time" + }, + "activeList": { + "title": "Activity List", + "all_area": "All Areas", + "enrolling": "Enrolling", + "ended": "Ended", + "time": "Time" + }, + "guanyuwomen": { + "title": "About Us" + }, + "qiandao_list": { + "title": "Check-in List", + "scan_checkin": "Scan to Check-in", + "early_bird": "Early Bird", + "single_ticket": "Single Ticket", + "premium_ticket": "Premium Ticket" + }, + "collection": { + "title": "My Favorites", + "tabs": { + "activity": "Activity", + "travel": "Travel" + }, + "confirm_cancel_collection": "Are you sure to cancel the collection?", + "sign_up_now": "Sign Up Now", + "ended": "Ended" + } + }, + "pages_order": { + "huodong_detail": { + "title": "Activity Details", + "start_time": "Start Time: ", + "activity_address": "Activity Address: ", + "navigation": "Navigation", + "organizer": "Organizer", + "add_wechat": "Add WeChat", + "activity_description": "Activity Description", + "precautions": "Precautions", + "registration_fee": "Registration Fee", + "collect": "Collect", + "collected": "Collected", + "forward": "Forward", + "sign_up_now": "Sign Up Now", + "ended": "Ended", + "select_activity_status": "Select Activity Status", + "confirm": "Confirm", + "early_bird": "Early Bird", + "single_ticket": "Single Ticket", + "premium_ticket": "Premium Ticket", + "complete_info_required": "Please complete the required information first" + }, + "invoice_issuance": { + "title": "Apply for Invoice", + "total": "Total", + "individual": "Individual", + "enterprise": "Enterprise", + "name": "Name", + "enterprise_name": "Enterprise Name", + "id_number": "ID Number", + "tax_number": "Tax Number", + "email": "Email", + "apply": "Apply", + "please_enter": "Please enter content" + }, + "invoice_records": { + "title": "Invoice Records", + "standard_ticket": "Standard Ticket", + "states": { + "invoicing": "Invoicing", + "invoiced": "Invoiced", + "failed": "Failed" + } + }, + "lvyou_detail": { + "title": "Travel Details", + "start_time": "Start Time: ", + "tour_guide": "Tour Guide", + "add_wechat": "Add WeChat", + "travel_description": "Travel Description", + "registration_fee": "Registration Fee", + "collect": "Collect", + "collected": "Collected", + "forward": "Forward", + "sign_up_now": "Sign Up Now", + "ended": "Ended", + "complete_info_required": "Please complete the required information first", + "tabs": { + "introduction": "Introduction", + "route": "Route", + "cost": "Cost", + "notice": "Notice", + "agent": "Agent" + } + }, + "order_details": { + "title": "Order Details", + "total": "Total", + "order_info": "Order Information", + "order_number": "Order Number", + "order_time": "Order Time", + "order_amount": "Order Amount", + "order_status": "Order Status", + "payment_notice": "Payment Notice", + "activity_notice": "Activity Notice", + "travel_notice": "Travel Notice", + "activity_checkin": "Activity Check-in", + "status": { + "unpaid": "Unpaid", + "pending": "Pending", + "completed": "Completed", + "cancelled": "Cancelled" + } + }, + "order_evaluation": { + "title": "Activity Evaluation", + "organizer_evaluation": "Organizer Evaluation", + "activity_evaluation": "Activity Evaluation", + "please_enter_content": "Please enter content", + "submit_comment": "Submit Comment", + "please_rate_first": "Please rate before submitting!" + }, + "pay_order": { + "title": "Payment Details", + "pending_payment": "Pending Payment", + "price": "Price", + "order_info": "Order Information", + "ticket_quantity": "Ticket Quantity", + "ticket_content": "Ticket Content", + "order_total": "Order Total", + "order_status": "Order Status", + "invitation_code": "Invitation Code", + "enter_invitation_code": "Please enter invitation code", + "payment_notice": "Payment Notice", + "pay_order": "Pay Order", + "payment_success": "Payment Successful", + "status": { + "unpaid": "Unpaid", + "pending": "Pending", + "completed": "Completed", + "cancelled": "Cancelled" + }, + "ticket_types": { + "early_bird": "Early Bird", + "single_ticket": "Single Ticket", + "premium_ticket": "Premium Ticket" + } + } + }, + "pages_zlx": { + "zlx_form": { + "title": "Organizer Certification", + "basic_info": "Basic Information", + "real_name": "Real Name", + "enter_real_name": "Please enter real name", + "contact_info": "Contact Information", + "enter_contact_info": "Please enter contact information", + "id_card": "ID Card Number", + "enter_id_card": "Please enter ID card number", + "resume_attachment": "Resume Attachment", + "upload_resume": "Upload Resume", + "wechat_qr_code": "WeChat QR Code", + "upload_image": "Upload Image", + "personal_photos_title": "Personal Photos (Including Full Body Shot)", + "agreement_title": "Read and Agree to Agreement", + "agreement_text": "I have read and agree to", + "agreement_link": "Organizer Agreement", + "save": "Save", + "approved": "Approved", + "copy": "Copy", + "copy_success": "Copy Successful", + "save_success": "Save Successful", + "submit_success": "Submit Successful", + "please_agree_agreement": "Please read and agree to the Organizer Agreement first", + "please_enter_name": "Please enter name", + "please_enter_contact": "Please enter contact information", + "please_enter_correct_contact": "Please enter correct contact information", + "please_enter_id_card": "Please enter ID card number", + "please_enter_correct_id_card": "Please enter correct ID card number" + } + }, + "common": { + "confirm_logout": "Confirm logout?", + "logging_in": "Logging in...", + "all": "All" + }, + "components": { + "base": { + "tabbar": { + "home": "Home", + "member": "Recruit", + "cart": "Orders", + "center": "Mine" + } + }, + "active": { + "activeItem": { + "signUp": "Sign Up Now", + "ended": "Ended" + } + }, + "travel": { + "travelList": { + "enrolling": "Enrolling", + "ended": "Ended" + } + }, + "cart": { + "cardList": { + "orderTime": "Order Time", + "total": "Total", + "cancelActivity": "Cancel Activity", + "signIn": "Sign In", + "evaluate": "Evaluate", + "invoice": "Invoice", + "states": { + "pending": "Pending", + "completed": "Completed", + "cancelled": "Cancelled" + } + }, + "signInQrcodePopup": { + "organizer": "Organizer" + } + }, + "zhaomu": { + "zlxItem": { + "startSignIn": "Start Sign In" + }, + "zhaomuItem": { + "joinRecruit": "Join Recruitment", + "rejected": "Rejected", + "reviewing": "Under Review", + "joined": "Joined", + "guaranteed": "Guaranteed", + "confirmed": "Confirmed", + "joinSuccess": "Successfully Joined" + } + } + } +} \ No newline at end of file diff --git a/locale/index.js b/locale/index.js new file mode 100644 index 0000000..66483a9 --- /dev/null +++ b/locale/index.js @@ -0,0 +1,76 @@ +import en from './en.json'//英语语言包 +import zhHans from './zh-Hans.json'//英语语言包 +import Vue from 'vue' +import VueI18n from 'vue-i18n' + +// 国际化字段映射 +import objectLangMap from './objectLangMap' +Vue.use(VueI18n) + + +// 获取系统语言 +const systemInfo = uni.getSystemInfoSync(); +const systemLang = 'en'; +// const systemLang = systemInfo.language || 'en'; + +console.log(systemInfo.language, systemLang); + +// 语言映射,将系统语言映射到我们支持的语言包 +const langMap = { + 'zh': 'zh-Hans', + 'zh_CN': 'zh-Hans', + 'zh-Hans': 'zh-Hans', + 'zh-Hant': 'zh-Hans', // 暂时都映射到简体中文 + 'zh-TW': 'zh-Hans', + 'zh-HK': 'zh-Hans', + 'en': 'en', + 'en-US': 'en', + 'en-GB': 'en' +}; + + +// 获取语言:优先缓存 -> 系统语言 -> 默认英语 +const lang = uni.getStorageSync('language') || langMap[systemLang] || 'en'; +// const lang = 'en'; +// VueI18n构造函数所需要的配置 +const i18nConfig = { + locale: lang,//当前语言 + // 所需要用的语言包 + messages:{ + en, + 'zh-Hans' : zhHans, + } +} + + + +//将对象国际化 +Vue.prototype.$ot = (obj, type, key) => { + // 如果对象不存在,返回空字符串 + if (!obj) return ''; + + // 获取当前语言 + const currentLang = i18n.locale; + + // 获取字段映射配置 + const typeConfig = objectLangMap[type]; + if (!typeConfig) return obj[key] || ''; + + const fieldConfig = typeConfig[key]; + if (!fieldConfig) return obj[key] || ''; + + // 获取当前语言对应的字段名 + const fieldName = fieldConfig[currentLang]; + if (!fieldName) return obj[key] || ''; + + // 返回对象中对应字段的值,如果不存在则返回默认字段的值 + return obj[fieldName] || obj[key] || ''; +} + + + + + + +const i18n = new VueI18n(i18nConfig) +export default i18n \ No newline at end of file diff --git a/locale/objectLangMap.js b/locale/objectLangMap.js new file mode 100644 index 0000000..7c1a553 --- /dev/null +++ b/locale/objectLangMap.js @@ -0,0 +1,65 @@ +/** + * 对象字段国际化映射配置 + * 用于 $ot 函数根据当前语言环境自动选择对应的字段名 + * + * 使用方式: $ot(对象, 对象类型, 字段名) + * 例如: $ot(activity, 'active', 'title') + * - 中文环境下会取 activity.title + * - 英文环境下会取 activity.enTitle + */ +export default { + // 活动对象字段映射 + "active" : { + "title" : { // 活动标题 + "zh-Hans" : "title", + "en" : "enTitle", + }, + "address" : { // 活动地址 + "zh-Hans" : "address", + "en" : "enAddress", + }, + "details" : { // 活动描述/详情 + "zh-Hans" : "details", + "en" : "enDetails", + }, + "precautions" : { // 活动注意事项 + "zh-Hans" : "precautions", + "en" : "enPrecautions", + }, + "orderDetails" : { // 订单详情中的活动须知 + "zh-Hans" : "orderDetails", + "en" : "orderDetails", + } + }, + // 旅行对象字段映射 + "travel" : { + "title" : { // 旅行标题 + "zh-Hans" : "title", + "en" : "enTitle", + }, + "address" : { // 旅行地址 + "zh-Hans" : "address", + "en" : "enAddress", + }, + "js" : { // 旅行介绍 + "zh-Hans" : "js", + "en" : "enJs", + }, + "lx" : { // 旅行路线 + "zh-Hans" : "lx", + "en" : "enLx", + }, + "fy" : { // 旅行费用 + "zh-Hans" : "fy", + "en" : "enFy", + }, + "xz" : { // 旅行须知 + "zh-Hans" : "xz", + "en" : "enXz", + }, + "dl" : { // 旅行代理 + "zh-Hans" : "dl", + "en" : "enDl", + } + } +} \ No newline at end of file diff --git a/locale/zh-Hans.json b/locale/zh-Hans.json new file mode 100644 index 0000000..46dc252 --- /dev/null +++ b/locale/zh-Hans.json @@ -0,0 +1,389 @@ +{ + "pages": { + "index": { + "index": { + "uv_search_placeholder": "搜索相关内容", + "nav_title": "首页", + "moments_title": "悦动时刻", + "sign_in_activity": "活动签到", + "sign_in_desc": "签到有好礼", + "view_now": "立即查看", + "activity": "活动", + "travel": "旅行", + "recent": "近期", + "past": "往期", + "select_area": "选择地区", + "confirm": "确定" + }, + "cart": { + "title": "我的订单", + "tabs": { + "all": "全部", + "pending": "待参加", + "completed": "已完成", + "cancelled": "已取消" + }, + "confirmCancel": "是否取消订单?" + }, + "center": { + "nav_title": "个人中心", + "please_login": "请点击登录", + "my_activities": "我的活动", + "pending": "待参加", + "completed": "已完成", + "cancelled": "已取消", + "my_tools": "我的工具", + "invoice_records": "开票记录", + "my_favorites": "我的收藏", + "about_us": "关于我们", + "user_agreement": "用户协议", + "privacy_policy": "隐私协议", + "organizer_agreement": "主理人协议", + "organizer_checkin": "主理人签到", + "logout": "退出登录" + } + } + }, + "pages_login": { + "wxLogin": { + "wechatLogin": "微信授权登录", + "cancelLogin": "取消登录", + "agreed": "已同意", + "privacyPolicy": "《隐私政策》", + "userAgreement": "《用户协议》", + "pleaseAgree": "请勾选隐私协议" + }, + "wxUserInfo": { + "requestInfo": "申请获取你的头像、昵称", + "avatar": "头像", + "nickname": "昵称", + "gender": "性别", + "phone": "手机号", + "enterNickname": "请输入昵称", + "selectGender": "请选择性别", + "enterPhone": "请输入手机号", + "getPhone": "获取电话号码", + "confirm": "确认", + "male": "男", + "female": "女", + "pleaseSelectAvatar": "请选择头像", + "pleaseEnterNickname": "请填写昵称", + "pleaseEnterPhone": "请填写手机号", + "pleaseSelectGender": "请选择性别" + }, + "fuwutiaokuan": { + "title": "用户协议" + }, + "yinsixieyi": { + "defaultTitle": "隐私协议", + "travelGuide": "旅行需知", + "paymentGuide": "支付需知", + "organizerAgreement": "主理人协议" + } + }, + "pages_my": { + "zlx_xieyi": { + "title": "主理人协议" + }, + "zlx_qiandao": { + "title": "主理人签到", + "activity": "活动", + "travel": "旅行" + }, + "user_msg": { + "title": "编辑资料", + "basic_info": "基础信息", + "username": "用户名称", + "email": "邮箱", + "phone": "手机号", + "gender": "性别", + "nationality": "国籍", + "birthday": "生日", + "address": "现居住址", + "personal_status": "个人状态", + "education": "教育", + "degree": "学历", + "school": "院校", + "work": "工作", + "industry": "行业", + "about_me": "关于我", + "save": "保存", + "enter_username": "请输入用户名称", + "enter_email": "请输入邮箱", + "enter_phone": "请输入手机号", + "select_gender": "请选择性别", + "enter_nationality": "请输入国籍", + "enter_birthday": "请输入生日", + "enter_address": "请输入现居住址", + "enter_status": "请输入个人状态", + "enter_industry": "请输入行业", + "enter_about_me": "请输入自我介绍...", + "male": "男", + "female": "女", + "bachelor": "本科", + "master": "硕士", + "doctor": "博士", + "other": "其他", + "save_success": "保存成功" + }, + "user_info": { + "title": "个人资料", + "change_avatar": "点击更换头像", + "nationality": "国籍", + "degree": "学历", + "industry": "行业", + "phone": "电话", + "gender": "性别", + "tags": "标签", + "about_me": "关于我", + "edit_info": "编辑信息", + "not_set": "未设置", + "years_old": "岁" + }, + "travelList": { + "title": "旅行列表", + "all": "全部", + "enrolling": "报名中", + "ended": "已结束", + "time": "时间" + }, + "activeList": { + "title": "活动列表", + "all_area": "全部地区", + "enrolling": "报名中", + "ended": "已结束", + "time": "时间" + }, + "guanyuwomen": { + "title": "关于我们" + }, + "qiandao_list": { + "title": "签到列表", + "scan_checkin": "扫码签到", + "early_bird": "早鸟票", + "single_ticket": "单人票", + "premium_ticket": "尊享票" + }, + "collection": { + "title": "我的收藏", + "tabs": { + "activity": "活动", + "travel": "旅行" + }, + "confirm_cancel_collection": "确认取消收藏吗?", + "sign_up_now": "立即报名", + "ended": "已结束" + } + }, + "pages_order": { + "huodong_detail": { + "title": "活动详情", + "start_time": "开始时间:", + "activity_address": "活动地址:", + "navigation": "导航", + "organizer": "主理人", + "add_wechat": "添加微信", + "activity_description": "活动描述", + "precautions": "注意事项", + "registration_fee": "报名费用", + "collect": "收藏", + "collected": "已收藏", + "forward": "转发", + "sign_up_now": "立即报名", + "ended": "已结束", + "select_activity_status": "选择活动状态", + "confirm": "确定", + "early_bird": "早鸟票", + "single_ticket": "单人票", + "premium_ticket": "尊享票", + "complete_info_required": "请您先完善必要信息" + }, + "invoice_issuance": { + "title": "申请开票", + "total": "总计", + "individual": "个人", + "enterprise": "企业", + "name": "姓名", + "enterprise_name": "企业名称", + "id_number": "身份证号", + "tax_number": "税号", + "email": "邮箱", + "apply": "申请", + "please_enter": "请输入内容" + }, + "invoice_records": { + "title": "开票记录", + "standard_ticket": "标准票", + "states": { + "invoicing": "开票中", + "invoiced": "已开票", + "failed": "开票失败" + } + }, + "lvyou_detail": { + "title": "旅行详情", + "start_time": "开始时间:", + "tour_guide": "领队", + "add_wechat": "添加微信", + "travel_description": "旅行描述", + "registration_fee": "报名费用", + "collect": "收藏", + "collected": "已收藏", + "forward": "转发", + "sign_up_now": "立即报名", + "ended": "已结束", + "complete_info_required": "请您先完善必要信息", + "tabs": { + "introduction": "介绍", + "route": "路线", + "cost": "费用", + "notice": "须知", + "agent": "代理" + } + }, + "order_details": { + "title": "订单详情", + "total": "总计", + "order_info": "订单信息", + "order_number": "订单编号", + "order_time": "下单时间", + "order_amount": "订单金额", + "order_status": "订单状态", + "payment_notice": "支付须知", + "activity_notice": "活动须知", + "travel_notice": "旅行须知", + "activity_checkin": "活动签到", + "status": { + "unpaid": "未付款", + "pending": "待参加", + "completed": "已完成", + "cancelled": "已取消" + } + }, + "order_evaluation": { + "title": "活动评价", + "organizer_evaluation": "主理人评价", + "activity_evaluation": "活动评价", + "please_enter_content": "请输入内容", + "submit_comment": "提交评论", + "please_rate_first": "请评分之后再提交!" + }, + "pay_order": { + "title": "支付详情", + "pending_payment": "待支付", + "price": "价格", + "order_info": "订单信息", + "ticket_quantity": "购票数量", + "ticket_content": "购票内容", + "order_total": "订单总金额", + "order_status": "订单状态", + "invitation_code": "邀请码", + "enter_invitation_code": "请输入邀请码", + "payment_notice": "支付须知", + "pay_order": "支付订单", + "payment_success": "支付成功", + "status": { + "unpaid": "未付款", + "pending": "待参加", + "completed": "已完成", + "cancelled": "已取消" + }, + "ticket_types": { + "early_bird": "早鸟票", + "single_ticket": "单人票", + "premium_ticket": "尊享票" + } + } + }, + "pages_zlx": { + "zlx_form": { + "title": "主理人认证", + "basic_info": "基础信息", + "real_name": "真实姓名", + "enter_real_name": "请输入真实姓名", + "contact_info": "联系方式", + "enter_contact_info": "请输入联系方式", + "id_card": "身份证号", + "enter_id_card": "请输入身份证号", + "resume_attachment": "简历附件", + "upload_resume": "上传简历", + "wechat_qr_code": "微信二维码", + "upload_image": "上传图片", + "personal_photos_title": "个人生活照片(含全身照)", + "agreement_title": "阅读并同意协议", + "agreement_text": "我已经阅读并同意", + "agreement_link": "《主理人协议》", + "save": "保存", + "approved": "已审核通过", + "copy": "复制", + "copy_success": "复制成功", + "save_success": "保存成功", + "submit_success": "提交成功", + "please_agree_agreement": "请先阅读并同意《主理人协议》", + "please_enter_name": "请输入姓名", + "please_enter_contact": "请输入联系方式", + "please_enter_correct_contact": "请输入正确的联系方式", + "please_enter_id_card": "请输入身份证号", + "please_enter_correct_id_card": "请输入正确的身份证号" + } + }, + "common": { + "confirm_logout": "确认退出登录吗", + "logging_in": "登录中...", + "all": "全部" + }, + "components": { + "base": { + "tabbar": { + "home": "首页", + "member": "招募", + "cart": "订单", + "center": "我的" + } + }, + "active": { + "activeItem": { + "signUp": "立即报名", + "ended": "已结束" + } + }, + "travel": { + "travelList": { + "enrolling": "报名中", + "ended": "已结束" + } + }, + "cart": { + "cardList": { + "orderTime": "下单时间", + "total": "总计", + "cancelActivity": "取消活动", + "signIn": "活动签到", + "evaluate": "评价活动", + "invoice": "开具发票", + "states": { + "pending": "待参加", + "completed": "已完成", + "cancelled": "已取消" + } + }, + "signInQrcodePopup": { + "organizer": "主理人" + } + }, + "zhaomu": { + "zlxItem": { + "startSignIn": "开始签到" + }, + "zhaomuItem": { + "joinRecruit": "参与招募", + "rejected": "不通过", + "reviewing": "审核中", + "joined": "已参加", + "guaranteed": "保证成行", + "confirmed": "已成行", + "joinSuccess": "参与成功" + } + } + } +} \ No newline at end of file diff --git a/main.js b/main.js index d74721b..2b8044a 100644 --- a/main.js +++ b/main.js @@ -10,6 +10,7 @@ Vue.config.productionTip = false App.mpType = 'app' import store from '@/store/store' +import i18n from '@/locale/index.js' import './config' import './utils/index.js' @@ -33,6 +34,7 @@ Vue.prototype.$Toast = function(title) { const app = new Vue({ ...App, store, + i18n, }) app.$mount() // #endif diff --git a/pages.json b/pages.json index 2867f13..29e6b57 100644 --- a/pages.json +++ b/pages.json @@ -7,13 +7,6 @@ "enablePullDownRefresh": true } }, - { - "path": "pages/index/order", - "style": { - "navigationBarTitleText": "", - "enablePullDownRefresh": true - } - }, { "path": "pages/index/center", "style": { @@ -220,7 +213,7 @@ }], "globalStyle": { "navigationBarTextStyle": "black", - "navigationBarTitleText": "酒店桌布", + "navigationBarTitleText": "", "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8", "navigationStyle": "custom" diff --git a/pages/index/cart.vue b/pages/index/cart.vue index 8d4382b..d9fd089 100644 --- a/pages/index/cart.vue +++ b/pages/index/cart.vue @@ -1,7 +1,7 @@