Explorar o código

我的页面国际化

xiaohaizhao hai 1 ano
pai
achega
3bfaf13020
Modificáronse 2 ficheiros con 19 adicións e 15 borrados
  1. 11 9
      pages/tabbar/mine/index.js
  2. 8 6
      pages/tabbar/mine/index.wxml

+ 11 - 9
pages/tabbar/mine/index.js

@@ -1,4 +1,5 @@
-const _Http = getApp().globalData.http;
+const _Http = getApp().globalData.http,
+    getMapText = getApp().globalData.Language.getMapText;
 let downCount = null;
 Page({
 
@@ -12,6 +13,7 @@ Page({
     },
     onLoad(options) {
         this.queryUserMsg();
+        getApp().globalData.Language.getLanguagePackage(this)
         let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
         let pathList = [{
             name: "修改登录密码",
@@ -66,15 +68,15 @@ Page({
     outLogin() {
         clearTimeout(downCount);
         wx.showLoading({
-            title: '正在退出...',
+            title: (getMapText('加载中') || '正在退出') + '...',
         })
         downCount = setTimeout(() => {
             _Http.logout().then(res => {
                 wx.showToast({
-                    title: '退出成功'
+                    title: getMapText('退出成功') || '退出成功'
                 });
                 let loginMsg = wx.getStorageSync("loginMsg"),
-                languagecode = wx.getStorageSync("languagecode");
+                    languagecode = wx.getStorageSync("languagecode");
 
                 wx.clearStorageSync();
                 wx.setStorageSync('loginMsg', loginMsg)
@@ -106,8 +108,8 @@ Page({
         if (this.data.userMsg.iswechatbinding) {
             let that = this;
             wx.showModal({
-                title: "提示",
-                content: "是否解除绑定",
+                title: getMapText('提示') || "提示",
+                content: getMapText('是否解除绑定') || "是否解除绑定",
                 success: (res) => {
                     if (res.confirm) that.handleBDWechat(0);
                 }
@@ -119,7 +121,7 @@ Page({
     handleBDWechat(isbinging) {
         let that = this;
         wx.getUserProfile({
-            desc: '用于完善用户资料',
+            desc: getMapText('用于完善用户资料') || '用于完善用户资料',
             success: ({
                 userInfo
             }) => {
@@ -142,7 +144,7 @@ Page({
                             });
                             setTimeout(() => {
                                 wx.showToast({
-                                    title: isbinging == 0 ? '解除成功' : '绑定成功',
+                                    title: isbinging == 0 ? (getMapText('解绑成功') || '解除成功') : (getMapText('绑定成功') || '绑定成功'),
                                     icon: "none"
                                 })
                             }, 100);
@@ -153,7 +155,7 @@ Page({
             },
             fail: () => {
                 wx.showToast({
-                    title: '操作失败,未获得授权',
+                    title: getMapText('未获取授权') || '操作失败,未获得授权',
                     icon: "none"
                 })
             }

+ 8 - 6
pages/tabbar/mine/index.wxml

@@ -27,7 +27,7 @@
         <view class="con">
             <view class="label">
                 <text class="iconfont {{item.icon}}" style="color: {{item.color}};" />
-                {{item.name}}
+                {{language[item.name]||item.name}}
             </view>
             <view class="item-right">
                 <van-icon size='30rpx' name="arrow" />
@@ -38,13 +38,13 @@
         <view class="con">
             <view class="label">
                 <text class="iconfont icon-a-wodebangdingweixin" style="color: var(--success);" />
-                绑定微信
-                <view wx:if="{{userMsg.iswechatbinding}}" class="bd-wechat">已绑定</view>
+                {{language['绑定微信']||'绑定微信'}}
+                <view wx:if="{{userMsg.iswechatbinding}}" class="bd-wechat">{{language['已绑定']||'已绑定'}}</view>
             </view>
             <view class="item-right">
                 <image class="user-img" wx:if="{{userMsg.iswechatbinding}}" src="{{userMsg.wechatuserinfo.avatarUrl}}" />
                 <view class="tips right-false" wx:else>
-                    未绑定
+                    {{language['未绑定']||'未绑定'}}
                 </view>
                 <van-icon size='30rpx' name="arrow" />
             </view>
@@ -54,7 +54,7 @@
         <view class="con">
             <view class="label">
                 <text class="iconfont icon-a-wodebangdingweixin" style="color: var(--success);" />
-                消息通知设置
+                {{language['消息通知设置']||'消息通知设置'}}
             </view>
             <view class="item-right">
                 <van-icon size='30rpx' name="arrow" />
@@ -63,6 +63,8 @@
     </navigator>
 </My_card>
 <view style="width: 100vw;text-align: center;margin-top: 200rpx;">
-    <van-button custom-class='out-login' color="#CCC" bindtap="outLogin" plain>退出登录</van-button>
+    <van-button custom-class='out-login' color="#CCC" bindtap="outLogin" plain>
+        {{language['退出登录']||'退出登录'}}
+    </van-button>
 </view>
 <view style="height: 140rpx;" />