浏览代码

请求语言包切换完成

sys 3 年之前
父节点
当前提交
81b93241f1
共有 4 个文件被更改,包括 21 次插入18 次删除
  1. 3 8
      api/ajax.js
  2. 6 1
      locale/en.json
  3. 6 1
      locale/zh-Hans.json
  4. 6 8
      pages/index/index.vue

+ 3 - 8
api/ajax.js

@@ -1,21 +1,16 @@
 import tools from "@/common/js/tools";
-import store from '@/store/index'
-
-
 /**
  * post请求封装
  */
 export const request = (url, method, data, show = false) => {
   let token=uni.getStorageSync('token')
-  // data.token = token;
-  // data.m_id = uni.getStorageSync('m_id')
   if (show) {
     tools.showLoading();
   }
-  console.log(data)
   if (data === undefined) {
     data = {};
   }
+  data.language = uni.getLocale();
   return new Promise((resolve, reject) => {
     // 封装主体:网络请求
     console.log(url)
@@ -47,11 +42,11 @@ export const request = (url, method, data, show = false) => {
             url: '/pages/login/index'
           });
         } else{
-          tools.error('网络错误!!')
+          tools.error('error!!')
         }
       },
       fail: (err) => {
-        tools.error('网络错误!!')
+        tools.error('error!!')
         // 返回错误消息
         reject(err)
         tools.hideLoading();

+ 6 - 1
locale/en.json

@@ -13,5 +13,10 @@
   "index.index.all": "all",
   "index.index.transaction": "trading record",
   "index.index.team": "team",
-  "index.index.code": "code"
+  "index.index.code": "code",
+  "index.index.invest.execute": "transactions being executed",
+  "index.index.invest.mix": "No less than TRX5",
+  "index.index.invest.no_usdt": "Insufficient USDT",
+  "index.index.invest.send_no": "fail",
+  "index.index.invest.send_ok": "succeed"
 }

+ 6 - 1
locale/zh-Hans.json

@@ -13,5 +13,10 @@
 	"index.index.all": "更多",
 	"index.index.transaction": "交易记录",
 	"index.index.team": "我的团队",
-	"index.index.code": "推荐码"
+	"index.index.code": "推荐码",
+	"index.index.invest.execute": "有正在执行的交易",
+	"index.index.invest.mix": "不低于TRX5",
+	"index.index.invest.no_usdt": "USDT数量不足",
+	"index.index.invest.send_no": "失败",
+	"index.index.invest.send_ok": "成功"
 }

+ 6 - 8
pages/index/index.vue

@@ -69,7 +69,7 @@
               </view>
             </view>
             <view class="from-but">
-              <button>{{$t('index.index.affirm')}}</button>
+              <button @click="setInvest">{{$t('index.index.affirm')}}</button>
             </view>
           </view>
 
@@ -154,17 +154,17 @@ export default {
       },
       async setInvest() {
         if (this.investData.sendNum > 0) {
-          tools.error('有正在执行的交易')
+          tools.error(this.$t('index.index.invest.execute'))
           return;
         }
         let trxNum = await bitkeepTron.getBalance('');
         if (trxNum < 5) {
-          tools.error('不低于TRX5')
+          tools.error(this.$t('index.index.invest.mix'))
           return
         }
         let usdtNum = await bitkeepTron.getTokenBalance('', 0);
         if (usdtNum < this.investData.invest_money && !tools.isDevelopment()) {
-          tools.error('USDT数量不足')
+          tools.error(this.$t('index.index.invest.no_usdt'))
           return
         }
         if (this.isAjax) {
@@ -172,8 +172,6 @@ export default {
         }
         this.isAjax = true
         let transactionData = bitkeepTron.getContractData(this.investData.sysAddress, this.investData.invest_money,0)
-        console.log('transactionData:')
-        console.log(transactionData)
         bitkeepTron.sendTransaction(transactionData).then((res) => {
           if (res) {
             setInvest({'txid':res,'id':this.investData.id}).then((res)=>{
@@ -189,11 +187,11 @@ export default {
             })
           } else {
             this.isAjax = false
-            tools.error('交易失败')
+            tools.error(this.$t('index.index.invest.send_no'))
           }
         }).catch((e) => {
           this.isAjax = false
-          tools.error('交易失败')
+          tools.error(this.$t('index.index.invest.send_no'))
         })
       },
       setShowLang(){