Browse Source

完善

master
vee 4 years ago
parent
commit
a44b319db3
  1. 30
      pages/menu/sendToken/transfer/index.vue
  2. 134
      pages/menu/setting/currency/index.vue
  3. 429
      pages/menu/setting/index.vue
  4. 173
      pages/menu/setting/lang/index.vue
  5. 10
      pages/menu/token/btc/index.vue
  6. 20
      pages/menu/wallet/index.vue
  7. 8
      unpackage/dist/dev/app-plus/app-service.js
  8. 27
      utils/BtcUtil.js
  9. 20
      utils/EthUtil.js
  10. 174
      utils/WalletUtil.js
  11. 1
      utils/api.js
  12. 1
      utils/locales/en.js
  13. 1
      utils/locales/zh-F.js
  14. 1
      utils/locales/zh.js

30
pages/menu/sendToken/transfer/index.vue

@ -49,7 +49,7 @@
<text> </text> <text> </text>
<view class="inputc flex"> <view class="inputc flex">
<view class="textt"> <view class="textt">
USD {{currency}}
</view> </view>
<input type="text" :value="(price*transInfoPass.amount).toFixed(2)" disabled="disabled" <input type="text" :value="(price*transInfoPass.amount).toFixed(2)" disabled="disabled"
placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="0.0000000" placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="0.0000000"
@ -250,6 +250,7 @@
fee: 0, fee: 0,
show: false, show: false,
show2: false, show2: false,
currency:'USD',
showFinger: false, showFinger: false,
showBottom: false, showBottom: false,
fingerSuccess: false, fingerSuccess: false,
@ -434,8 +435,7 @@
}) })
return return
} }
this.showBottom = true;
this.show = true;
let that = this let that = this
if (this.coin.type === 'ETH') { if (this.coin.type === 'ETH') {
this.$EthUtil.getGas().then((res) => { this.$EthUtil.getGas().then((res) => {
@ -458,12 +458,14 @@
console.log(size.toString().length, "size") console.log(size.toString().length, "size")
that.transInfoPass.fee = Number(size) * (size.toString().length + 1) * 1000 / Math.pow(10, that.transInfoPass.fee = Number(size) * (size.toString().length + 1) * 1000 / Math.pow(10,
6) 6)
that.showBottom = true;
that.show = true;
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
that.showFinger = false; that.showFinger = false;
that.showBottom = true;
uni.showToast({ uni.showToast({
title: 'address error', title: that.i18n.ReceivingaddressError + 'error',
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -626,9 +628,7 @@
this.coin = uni.getStorageSync('coin') this.coin = uni.getStorageSync('coin')
if (this.coin.balancePrice) {
this.price = (this.coin.balancePrice / this.coin.balance).toFixed(2)
}
// //
this.transInfoPass.fromAddress = this.coin.address; this.transInfoPass.fromAddress = this.coin.address;
this.transInfoPass.privateKey = this.coin.privateKey; this.transInfoPass.privateKey = this.coin.privateKey;
@ -639,7 +639,19 @@
if (uni.getStorageSync('fingerPass')) { if (uni.getStorageSync('fingerPass')) {
this.passShow = uni.getStorageSync('fingerPass') this.passShow = uni.getStorageSync('fingerPass')
} }
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}
if(this.currency==='USD'){
if (this.coin.balancePrice) {
this.price = (this.coin.balancePrice / this.coin.balance).toFixed(2)
}
}else{
if (this.coin.balanceCnyPrice) {
this.price = (this.coin.balanceCnyPrice / this.coin.balance).toFixed(2)
}
}
} }
}; };

134
pages/menu/setting/currency/index.vue

@ -8,27 +8,23 @@
<u-radio-group v-model="value" @change="radioGroupChange"> <u-radio-group v-model="currency" @change="radioGroupChange">
<view class="item flex" v-for="(item, index) in list" :key="index" @click="handove('en')"> <view class="item flex" v-for="(item, index) in list" :key="index" @click="handove('en')">
<view class="text1"> <view class="text1">
{{item.lang}} {{item.lang}}
</view> </view>
<u-radio <u-radio @change="radioChange" :name="item.name" :disabled="item.disabled"
@change="radioChange" active-color="#5B53FF">
:name="item.name"
:disabled="item.disabled"
active-color="#5B53FF"
>
</u-radio> </u-radio>
</view> </view>
</u-radio-group> </u-radio-group>
<view class="select_btn"> <view class="select_btn" @click="confirmCurrency">
Select Select
</view> </view>
</view>
</view> </view>
</view>
</view> </view>
</template> </template>
@ -38,69 +34,75 @@
export default { export default {
data() { data() {
return { return {
checked: false, checked: false,
list: [ currency:'USD',
{ list: [{
lang:'USD', lang: 'USD',
disabled: false, disabled: false,
name:"b" name: "USD"
}, },
{ {
lang:'JPY', lang: 'CNY',
disabled: false, disabled: false,
name:"a" name: "CNY"
}, },
{
lang:'EUR', ],
disabled: false, // u-radio-groupv-modelradioname
name:"c"
},
],
// u-radio-groupv-modelradioname
value: '',
}; };
}, },
onLoad(){
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}else{
uni.setStorageSync('currency',this.currency)
}
},
methods: { methods: {
handove(item){ confirmCurrency(){
// if(item){ uni.setStorageSync('currency',this.currency)
uni.reLaunch({
url: '/pages/menu/setting/index'
})
},
handove(item) {
// if(item){
// } // }
this.$i18n.locale = item; this.$i18n.locale = item;
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.storage.setItem('locale', item); plus.storage.setItem('locale', item);
// #endif // #endif
// #ifdef H5 // #ifdef H5
localStorage.setItem('locale', item); localStorage.setItem('locale', item);
// #endif // #endif
}, },
radioChange(e) { radioChange(e) {
// console.log(e); // console.log(e);
}, },
// radioradio-group // radioradio-group
radioGroupChange(e) { radioGroupChange(e) {
// console.log(e); console.log(this.currency)
}, },
change(status) { change(status) {
// console.log(status); // console.log(status);
}, },
}, },
computed: { computed: {
i18n() { i18n() {
return this.$t('index') return this.$t('index')
} }
}, },
}; };
</script> </script>
<style scoped> <style scoped>
page { page {
background: #FAFAFA; background: #FAFAFA;
} }
</style> </style>
<style> <style>
@import './index.css'; @import './index.css';
</style> </style>

429
pages/menu/setting/index.vue

@ -7,66 +7,68 @@
<view class="main"> <view class="main">
<view class="main_con"> <view class="main_con">
<view class="item flex"> <view class="item flex">
<view class="text1"> <view class="text1">
{{i18n.fingerPass}} {{i18n.fingerPass}}
</view> </view>
<u-switch v-model="checked" active-color="#5B53FF" @change="fingerPass()"></u-switch> <u-switch v-model="checked" active-color="#5B53FF" @change="fingerPass()"></u-switch>
</view> </view>
<view class="item flex" @click="goLang()"> <view class="item flex" @click="goLang()">
<view class="text1"> <view class="text1">
{{i18n.lans}} {{i18n.lans}}
</view> </view>
<view class=""> <view class="">
<text class="text2">{{value}}</text> <text class="text2">{{value}}</text>
<image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1"></image> <image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1">
</view> </image>
</view> </view>
<view class="item flex" @click="goCurr()"> </view>
<view class="text1"> <view class="item flex" @click="goCurr()">
<view class="text1">
{{i18n.curr}} {{i18n.curr}}
</view> </view>
<view class=""> <view class="">
<text class="text2">USD</text> <text class="text2">{{currency}}</text>
<image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1"></image> <image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1">
</view> </image>
</view> </view>
<view class="item flex"> </view>
<view class="text1"> <view class="item flex">
{{i18n.nodes}} <view class="text1">
</view> {{i18n.nodes}}
</view>
<image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1"></image>
</view>
</view>
</view> <image src="../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="img1"></image>
<u-mask z-index="10" :show="show"></u-mask>
<view class="hou_jia" v-if="showFinger">
<view class="Log">
{{i18n.Login}}
</view>
<image src="../../../static/tongyonh/zww.png" mode="aspectFit" class="zzw"></image>
<view class="Log" @click="cancel">
{{i18n.Cancel}}
</view> </view>
</view> </view>
<view class="hou_jia hou_jia_w" v-if="hou_jia_w">
<view class="fontt">
{{i18n.closevalidation}}
</view> </view>
<view class="ccon"> <u-mask z-index="10" :show="show"></u-mask>
<view class="cancle" @click="cancel_hou">
<view class="hou_jia" v-if="showFinger">
<view class="Log">
{{i18n.Login}}
</view>
<image src="../../../static/tongyonh/zww.png" mode="aspectFit" class="zzw"></image>
<view class="Log" @click="cancel">
{{i18n.Cancel}} {{i18n.Cancel}}
</view>
</view> </view>
<view class="" @click="confirm_hou"> <view class="hou_jia hou_jia_w" v-if="hou_jia_w">
{{i18n.Confirm}} <view class="fontt">
{{i18n.closevalidation}}
</view>
<view class="ccon">
<view class="cancle" @click="cancel_hou">
{{i18n.Cancel}}
</view>
<view class="" @click="confirm_hou">
{{i18n.Confirm}}
</view> </view>
</view> </view>
</view> </view>
@ -79,224 +81,231 @@
export default { export default {
data() { data() {
return { return {
checked: false, checked: false,
show:false, show: false,
showFinger:false, showFinger: false,
fingerSuccess:false, fingerSuccess: false,
fingerFail:false, fingerFail: false,
hou_jia_w:false, hou_jia_w: false,
value:'English', currency: 'USD',
value: 'English',
}; };
}, },
methods: { methods: {
back(){ back() {
uni.reLaunch({ uni.reLaunch({
url:'/pages/menu/profile/index' url: '/pages/menu/profile/index'
}) })
}, },
// //
goLang(){ goLang() {
uni.navigateTo({ uni.navigateTo({
url:'./lang/index' url: './lang/index'
}) })
}, },
goCurr(){ goCurr() {
uni.navigateTo({ uni.navigateTo({
url:'./currency/index' url: './currency/index'
}) })
}, },
// //
cancel_hou(){ cancel_hou() {
this.hou_jia_w=false; this.hou_jia_w = false;
this.show=false; this.show = false;
this.checked=true; this.checked = true;
}, },
// //
confirm_hou(){ confirm_hou() {
this.checked=false this.checked = false
this.hou_jia_w=false; this.hou_jia_w = false;
this.show=false; this.show = false;
uni.setStorageSync('fingerPass',false) uni.setStorageSync('fingerPass', false)
}, },
// //
cancel(){ cancel() {
this.showFinger=false; this.showFinger = false;
this.checked=false; this.checked = false;
this.show=false; this.show = false;
this.printCancel(); this.printCancel();
}, },
// //
printCancel(){ printCancel() {
this.show=false; this.show = false;
plus.fingerprint.cancel(); plus.fingerprint.cancel();
this.showFinger=false this.showFinger = false
}, },
fingerPass(){ fingerPass() {
console.log(this.checked) console.log(this.checked)
// //
if(this.checked){ if (this.checked) {
console.log(111) console.log(111)
this.show=true; this.show = true;
this.showFinger=true; this.showFinger = true;
this.fingerprint(true); this.fingerprint(true);
} }
// false使 // false使
if(!this.checked){ if (!this.checked) {
this.hou_jia_w=true; this.hou_jia_w = true;
this.show=true this.show = true
} }
}, },
fingerprint: function() { fingerprint: function() {
// //
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (!plus.fingerprint.isSupport()) { if (!plus.fingerprint.isSupport()) {
uni.showToast({ uni.showToast({
title:this.$t('index').fingerprintidentification, title: this.$t('index').fingerprintidentification,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
// this.disabled = true; // this.disabled = true;
} else if (!plus.fingerprint.isKeyguardSecure()) { } else if (!plus.fingerprint.isKeyguardSecure()) {
uni.showToast({ uni.showToast({
title: this.$t('index').notequipped, title: this.$t('index').notequipped,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
} else if (!plus.fingerprint.isEnrolledFingerprints()) { } else if (!plus.fingerprint.isEnrolledFingerprints()) {
uni.showToast({ uni.showToast({
title: this.$t('index').oninthesetting, title: this.$t('index').oninthesetting,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
// this.disabled = true; // this.disabled = true;
} else { } else {
// this.result = ''; // this.result = '';
// // this.disabled = false; // // this.disabled = false;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// this.disabled = false; // this.disabled = false;
uni.showToast({ uni.showToast({
title: 'Please use it in wechat real machine. The simulator does not support it', title: 'Please use it in wechat real machine. The simulator does not support it',
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
// #endif // #endif
// #ifndef APP-PLUS || MP-WEIXIN // #ifndef APP-PLUS || MP-WEIXIN
uni.showToast({ uni.showToast({
title: 'Fingerprint identification is not supported on this platform', title: 'Fingerprint identification is not supported on this platform',
icon: 'none', icon: 'none',
duration: 1500, duration: 1500,
}) })
// #endif // #endif
// //
let that=this; let that = this;
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.fingerprint.authenticate(function() { plus.fingerprint.authenticate(function() {
plus.nativeUI.closeWaiting(); //Android plus.nativeUI.closeWaiting(); //Android
// //
// 使 // 使
uni.setStorageSync('fingerPass',true) uni.setStorageSync('fingerPass', true)
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
that.showFinger=false; that.showFinger = false;
that.fingerSuccess=true; that.fingerSuccess = true;
that.show=false; that.show = false;
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
}, function(e) { }, function(e) {
switch (e.code) { switch (e.code) {
case e.AUTHENTICATE_MISMATCH: case e.AUTHENTICATE_MISMATCH:
// plus.nativeUI.toast('Fingerprint matching failed, please re-enter'); // plus.nativeUI.toast('Fingerprint matching failed, please re-enter');
uni.setStorageSync('fingerPass',false) uni.setStorageSync('fingerPass', false)
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
that.showFinger=false; that.showFinger = false;
that.fingerFail=true; that.fingerFail = true;
that.checked=false that.checked = false
console.log(that.fingerFail,454545) console.log(that.fingerFail, 454545)
break; break;
case e.AUTHENTICATE_OVERLIMIT: case e.AUTHENTICATE_OVERLIMIT:
plus.nativeUI.closeWaiting(); //Android plus.nativeUI.closeWaiting(); //Android
// plus.nativeUI.alert('The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication'); // plus.nativeUI.alert('The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication');
uni.setStorageSync('fingerPass',false) uni.setStorageSync('fingerPass', false)
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
that.showFinger=false; that.showFinger = false;
that.fingerFail=true; that.fingerFail = true;
that.checked=false that.checked = false
console.log(that.fingerFail,454545) console.log(that.fingerFail, 454545)
break; break;
case e.CANCEL: case e.CANCEL:
plus.nativeUI.toast('Recognition has been cancelled'); plus.nativeUI.toast('Recognition has been cancelled');
uni.setStorageSync('fingerPass',false) uni.setStorageSync('fingerPass', false)
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
that.showFinger=false; that.showFinger = false;
that.checked=false that.checked = false
that.fingerFail=true; that.fingerFail = true;
console.log(that.fingerFail,454545) console.log(that.fingerFail, 454545)
break; break;
default: default:
plus.nativeUI.closeWaiting(); //Android plus.nativeUI.closeWaiting(); //Android
uni.setStorageSync('fingerPass',false) uni.setStorageSync('fingerPass', false)
console.log(that.showFinger,454545) console.log(that.showFinger, 454545)
that.showFinger=false; that.showFinger = false;
that.checked=false that.checked = false
that.fingerFail=true; that.fingerFail = true;
console.log(that.fingerFail,454545) console.log(that.fingerFail, 454545)
plus.nativeUI.alert('Fingerprint identification failed, please try again'); plus.nativeUI.alert('Fingerprint identification failed, please try again');
break; break;
}
});
// Android
if ('Android' == plus.os.name) {
this.show=true;
/* plus.nativeUI.showWaiting('...').onclose = function() {
plus.fingerprint.cancel();
} */
} }
// #endif });
// Android
if ('Android' == plus.os.name) {
this.show = true;
/* plus.nativeUI.showWaiting('...').onclose = function() {
plus.fingerprint.cancel();
} */
} }
// #endif // #endif
},
change(status) {
}, }
// #endif
},
change(status) {
},
}, },
onShow() { onShow() {
if(uni.getStorageSync('langTrue')){ if (uni.getStorageSync('langTrue')) {
this.value=uni.getStorageSync('langTrue') this.value = uni.getStorageSync('langTrue')
console.log(this.value,454545) console.log(this.value, 454545)
}else{ } else {
uni.setStorageSync('langTrue',this.value) uni.setStorageSync('langTrue', this.value)
}
let currency = uni.getStorageSync('currency');
if (currency) {
this.currency = currency;
console.log(this.currency)
} else {
uni.setStorageSync('currency', this.currency)
} }
}, },
onLoad() { onLoad() {
// //
if(uni.getStorageSync('fingerPass')){ if (uni.getStorageSync('fingerPass')) {
this.checked=uni.getStorageSync('fingerPass') this.checked = uni.getStorageSync('fingerPass')
} }
}, },
computed: { computed: {
i18n() { i18n() {
return this.$t('index') return this.$t('index')
}, },
} }
}; };
</script> </script>
<style scoped> <style scoped>
page { page {
background: #FAFAFA; background: #FAFAFA;
} }
</style> </style>
<style> <style>
@import './index.css'; @import './index.css';
</style> </style>

173
pages/menu/setting/lang/index.vue

@ -5,26 +5,22 @@
</navigation> </navigation>
<view class="main"> <view class="main">
<view class="main_con"> <view class="main_con">
<u-radio-group v-model="value" @change="radioGroupChange"> <u-radio-group v-model="value" @change="radioGroupChange">
<view class="item flex" v-for="(item, index) in list" :key="index" @click="nowLanguage(item,index)"> <view class="item flex" v-for="(item, index) in list" :key="index" @click="nowLanguage(item,index)">
<view class="text1"> <view class="text1">
{{item.lang}} {{item.lang}}
</view> </view>
<u-radio <u-radio @change="radioChange" :name="item.name" :disabled="item.disabled"
@change="radioChange" active-color="#5B53FF">
:name="item.name"
:disabled="item.disabled"
active-color="#5B53FF"
>
</u-radio> </u-radio>
</view> </view>
</u-radio-group> </u-radio-group>
<view class="select_btn" @click="confirmLanguage"> <view class="select_btn" @click="confirmLanguage">
{{ i18n.langSelect }} {{ i18n.langSelect }}
</view> </view>
</view>
</view> </view>
</view>
</view> </view>
@ -35,100 +31,97 @@
export default { export default {
data() { data() {
return { return {
language: this.$store.state.language == 'en' ? 'English' : '简体中文' , language: this.$store.state.language == 'en' ? 'English' : '简体中文',
checked: false, checked: false,
langInfo:{}, langInfo: {},
lang:'', lang: '',
list: [ list: [{
{ lang: this.$t('index').langfan,
lang:this.$t('index').langfan, disabled: false,
disabled: false, name: "b",
name:"b", },
}, {
{ lang: this.$t('index').langjian,
lang:this.$t('index').langjian, disabled: false,
disabled: false, name: "a",
name:"a", },
}, {
{ lang: this.$t('index').eng,
lang:this.$t('index').eng, disabled: false,
disabled: false, name: "c",
name:"c", },
},
], ],
// u-radio-groupv-modelradioname // u-radio-groupv-modelradioname
value: 'c', value: 'c',
}; };
}, },
methods: { methods: {
// //
// //
nowLanguage(e,i) { nowLanguage(e, i) {
console.log(e,22222) console.log(e, 22222)
this.value=e.name this.value = e.name
this.lang=e.lang this.lang = e.lang
this.langInfo=e; this.langInfo = e;
console.log(this.langInfo,22222) console.log(this.langInfo, 22222)
}, },
confirmLanguage(){ confirmLanguage() {
uni.setStorageSync('lang',this.value) uni.setStorageSync('lang', this.value)
console.log(this.langInfo,1212212) console.log(this.langInfo, 1212212)
if (this.langInfo.name == 'c') { if (this.langInfo.name == 'c') {
this._i18n.locale = 'en' this._i18n.locale = 'en'
this.$store.commit('setLanguage', 'en') this.$store.commit('setLanguage', 'en')
uni.setStorageSync('langTrue','English') uni.setStorageSync('langTrue', 'English')
uni.setStorageSync("language", 'en') uni.setStorageSync("language", 'en')
} else if (this.langInfo.name == 'a') { } else if (this.langInfo.name == 'a') {
this._i18n.locale = 'zh-CN' this._i18n.locale = 'zh-CN'
this.$store.commit('setLanguage', 'zh-CN') this.$store.commit('setLanguage', 'zh-CN')
uni.setStorageSync("language", 'zh-CN') uni.setStorageSync("language", 'zh-CN')
uni.setStorageSync('langTrue','简体中文') uni.setStorageSync('langTrue', '简体中文')
}else{ } else {
this._i18n.locale = 'zh-CNF' this._i18n.locale = 'zh-CNF'
this.$store.commit('setLanguage', 'zh-CNF') this.$store.commit('setLanguage', 'zh-CNF')
uni.setStorageSync("language", 'zh-CNF') uni.setStorageSync("language", 'zh-CNF')
uni.setStorageSync('langTrue','繁體中文') uni.setStorageSync('langTrue', '繁體中文')
} }
uni.reLaunch({ uni.reLaunch({
url:'/pages/menu/setting/index' url: '/pages/menu/setting/index'
}) })
}, },
radioChange(e) { radioChange(e) {
}, },
// radioradio-group // radioradio-group
radioGroupChange(e) { radioGroupChange(e) {
}, },
change(status) { change(status) {
}, },
}, },
computed: { computed: {
i18n() { i18n() {
return this.$t('index') return this.$t('index')
},
}, },
}, onLoad() {
onLoad() { if (uni.getStorageSync('lang')) {
if(uni.getStorageSync('lang')){ this.value = uni.getStorageSync('lang')
this.value=uni.getStorageSync('lang') } else {
}else{ uni.setStorageSync('lang', this.value)
uni.setStorageSync('lang',this.value) }
} }
}
}; };
</script> </script>
<style scoped> <style scoped>
page { page {
background: #FAFAFA; background: #FAFAFA;
} }
</style> </style>
<style> <style>
@import './index.css'; @import './index.css';
</style> </style>

10
pages/menu/token/btc/index.vue

@ -15,7 +15,10 @@
<view class=""> <view class="">
{{coin.balance}} {{coin.name}} {{coin.balance}} {{coin.name}}
</view> </view>
<text class="text2"> $ {{coin.balancePrice?coin.balancePrice:0}}</text> <text class="text2">
{{currency=='USD'?'$ '+(!coin.balancePrice?0.00:coin.balancePrice):'¥ '+(!coin.balanceCnyPrice?0.00:coin.balanceCnyPrice)}}
</text>
</text> </text>
<image src="../../../../static/tongyonh/ethereum.png" mode="aspectFit" class="img1" <image src="../../../../static/tongyonh/ethereum.png" mode="aspectFit" class="img1"
v-if="coin.type=='ETH'&&!coin.contractAddress"></image> v-if="coin.type=='ETH'&&!coin.contractAddress"></image>
@ -114,6 +117,7 @@
// address // address
trxs: [], trxs: [],
coin: {}, coin: {},
currency:'USD',
isNoData:false, isNoData:false,
showInfo: false, showInfo: false,
list: [{ list: [{
@ -231,6 +235,10 @@
onLoad() { onLoad() {
this.coin = uni.getStorageSync('coin'); this.coin = uni.getStorageSync('coin');
this.change(0); this.change(0);
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}
} }
}; };

20
pages/menu/wallet/index.vue

@ -26,7 +26,7 @@
v-if="showMoney2"></image> v-if="showMoney2"></image>
</view> </view>
<view class="textcon2" v-if="showMoney1"> <view class="textcon2" v-if="showMoney1">
$ {{!userObj.balancePrice?0.00:userObj.balancePrice}} {{currency=='USD'?'$ '+(!userObj.totalBalancePrice?0.00:userObj.totalBalancePrice):'¥ '+(!userObj.totalBalanceCnyPrice?0.00:userObj.totalBalanceCnyPrice)}}
</view> </view>
<view class="textcon2" v-if="showMoney2"> <view class="textcon2" v-if="showMoney2">
*** ***
@ -63,7 +63,8 @@
{{item.balance}} {{item.balance}}
</view> </view>
<view class="text2" v-if="item.balancePrice"> <view class="text2" v-if="item.balancePrice">
$ {{item.balancePrice}}
{{currency=='USD'?'$ '+(!item.balancePrice?0.00:item.balancePrice):'¥ '+(!item.balanceCnyPrice?0.00:item.balanceCnyPrice)}}
</view> </view>
<view class="text2" v-if="!item.balancePrice"> <view class="text2" v-if="!item.balancePrice">
$ 0.00 $ 0.00
@ -91,6 +92,7 @@
return { return {
eth: '', eth: '',
trc: 'Hello', trc: 'Hello',
currency:'USD',
walletInfo: {}, walletInfo: {},
userObj: {}, userObj: {},
userObj2: {}, userObj2: {},
@ -104,14 +106,16 @@
this.isStop = true this.isStop = true
}, },
onLoad() { onLoad() {
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}
// //
this.$walletUtil.updateBalance();
this.userObj = uni.getStorageSync('wallet'); this.userObj = uni.getStorageSync('wallet');
let that = this;
this.$walletUtil.updateBalance(function() {
that.userObj = uni.getStorageSync('wallet');
that.userObj2 = uni.getStorageSync('wallet');
});
}, },
computed: { computed: {
i18n() { i18n() {

8
unpackage/dist/dev/app-plus/app-service.js

File diff suppressed because one or more lines are too long

27
utils/BtcUtil.js

@ -1,29 +1,26 @@
let BtcUtil = { let BtcUtil = {
getBalance: function(address,success) { getBalance:async function(address,success) {
let balance=0; let balance=0;
try{ try{
uni.request({ let res= await uni.request({
url: 'http://scan.weirui0755.com/btc/api/address/balancetrend/btc/' + address, //请求接口 url: 'http://scan.weirui0755.com/btc/api/address/balancetrend/btc/' + address, //请求接口
header: { header: {
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息 'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
},
success: (res) => {
if (res.data.code === 1) {
if(res.data.data.length>0){
var data=res.data.data[0];
console.log(data,11111)
for(let b in data){
balance=data[b];
}
}
}
} }
}); });
if (res.data.code === 1) {
if(res.data.data.length>0){
var data=res.data.data[0];
console.log(data,11111)
for(let b in data){
balance=data[b];
}
}
}
}catch(e){ }catch(e){
//TODO handle the exception //TODO handle the exception
} }
success(balance); return balance;
} }
} }
export default BtcUtil export default BtcUtil

20
utils/EthUtil.js

@ -48,14 +48,12 @@ let eth = {
'params': [address, "latest"] 'params': [address, "latest"]
}; };
let res =await uni.request({ let res =await uni.request({
url: 'http://47.245.25.82:8545', //仅为示例,并非真实接口地址。 url: systemConfiguration.constant.ethNode, //仅为示例,并非真实接口地址。
method: 'POST', method: 'POST',
data: data, data: data,
dataType: 'json'}); dataType: 'json'});
try { try {
let balance = Number(web3.utils.hexToNumberString(res[1].data.result)) / Math.pow(10, 18) let balance = Number(web3.utils.hexToNumberString(res[1].data.result)) / Math.pow(10, 18)
console.log(balance,45465465)
return balance return balance
} catch (e) { } catch (e) {
return 0; return 0;
@ -70,7 +68,7 @@ let eth = {
return s + num; return s + num;
}, },
// 获取bms,bmdt,usdt/erc余额 // 获取bms,bmdt,usdt/erc余额
getTokenBalance: function(address, contract,success) { getTokenBalance:async function(address, contract,success) {
web3 = new Web3(); web3 = new Web3();
const data = { const data = {
'jsonrpc': '2.0', 'jsonrpc': '2.0',
@ -83,19 +81,15 @@ let eth = {
}; };
uni.request({ let res =await uni.request({
url: 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', //仅为示例,并非真实接口地址。 url: 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', //仅为示例,并非真实接口地址。
method: 'POST', method: 'POST',
data: data, data: data,
dataType: 'json', dataType: 'json'
success: (res) => {
console.log(res,45454)
let balance = Number(web3.utils.hexToNumberString(res['data']['result'])) / Math.pow(10, 18)
console.log(balance,45454)
success(balance)
}
}); });
let balance = Number(web3.utils.hexToNumberString(res['data']['result'])) / Math.pow(10, 18)
return balance;
}, },

174
utils/WalletUtil.js

@ -2,6 +2,7 @@ import TokenUtil from './TokenUtil.js'
import BtcUtil from './BtcUtil.js' import BtcUtil from './BtcUtil.js'
import TronUtil from './TronUtil.js' import TronUtil from './TronUtil.js'
import EthUtil from './EthUtil.js' import EthUtil from './EthUtil.js'
import api from './api.js'
let fullWallet = { let fullWallet = {
"BTC": [{ "BTC": [{
@ -65,8 +66,9 @@ let WalletUtil = {
walletInfo.BTC[0].mnemonic = mnemonic; walletInfo.BTC[0].mnemonic = mnemonic;
walletInfo.BTC[0].privateKey = btc.privateKey; walletInfo.BTC[0].privateKey = btc.privateKey;
walletInfo.BTC[0].address = btc.address; walletInfo.BTC[0].address = btc.address;
walletInfo.BTC[0].ellipsisAddress =walletInfo.BTC[0].address.substring(0, 6) + '...' + walletInfo.BTC[0].address.substring(25, walletInfo.BTC[0].ellipsisAddress = walletInfo.BTC[0].address.substring(0, 6) + '...' + walletInfo.BTC[
walletInfo.BTC[0].address.length) 0].address.substring(25,
walletInfo.BTC[0].address.length)
let eth = TokenUtil.generateEth(mnemonic) let eth = TokenUtil.generateEth(mnemonic)
walletInfo.ETH[0].password = password; walletInfo.ETH[0].password = password;
walletInfo.ETH[0].mnemonic = mnemonic; walletInfo.ETH[0].mnemonic = mnemonic;
@ -205,9 +207,87 @@ let WalletUtil = {
} }
}, },
updateBalance: function(success) { updateBalance: async function(success) {
const wallet = uni.getStorageSync('wallet'); const wallet = uni.getStorageSync('wallet');
console.log(wallet, '更新余额') let params = {
coinName: wallet.type
}
const mainCoinP = await api.getCoinRate(params);
params.coinName = 'USDT';
const usdtU = await api.getCoinRate(params);
wallet.totalBalancePrice = 0
wallet.totalBalanceCnyPrice=0
console.log(usdtU, 8888)
switch (wallet.type) {
case 'BTC':
console.log("进来BTC")
wallet.balance = await BtcUtil.getBalance(wallet.address)
break;
case 'ETH':
console.log("进来ETH")
wallet.balance = await EthUtil.getBalance(wallet.address);
for (let i = 1; i < wallet.coinList.length; i++) {
wallet.coinList[i].balance = EthUtil.getTokenBalance(wallet.address, wallet.coinList[
i].contractAddress);
}
wallet.totalBalancePrice = wallet.coinList[1].balancePrice
wallet.totalBalanceCnyPrice=wallet.coinList[1].balanceCnyPrice
wallet.coinList[1].balancePrice = (wallet
.coinList[1].balance * usdtU.data.priceInUsd).toFixed(2);
wallet.coinList[1].balanceCnyPrice = (wallet
.coinList[1].balance * usdtU.data.priceCny).toFixed(2);
break;
case 'TRX':
console.log("进来TRX")
wallet.balance = await TronUtil.getTronBalance(wallet.address);
params.address = wallet.address;
params.chainName = wallet.type;
const tronCoin = await api.getBalance(params);
var newList=[];
newList.push(wallet.coinList[0])
newList.push(wallet.coinList[1])
for (let i = 1; i < tronCoin.data.length; i++) {
if (tronCoin.data[i].tokenAbbr === 'USDT') {
newList[1].balance = (Number(tronCoin.data[i].balance) / Math.pow(10, tronCoin
.data[i].tokenDecimal));
newList[1].balanceCnyPrice = (newList[1].balance * usdtU.data.priceCny).toFixed(2);
newList[1].balancePrice = (newList[1].balance * usdtU.data.priceInUsd).toFixed(2);
wallet.totalBalancePrice = newList[1].balancePrice
wallet.totalBalanceCnyPrice=newList[1].balanceCnyPrice
} else {
console.log(Number(tronCoin.data[i].balance) / Math.pow(10, tronCoin.data[i]
.tokenDecimal))
var coin = {
name: tronCoin.data[i].tokenAbbr,
xname: tronCoin.data[i].tokenName,
balance: (Number(tronCoin.data[i].balance) / Math.pow(10, tronCoin.data[i]
.tokenDecimal)),
icon: tronCoin.data[i].tokenLogo,
}
if (tronCoin.data[i].tokenType === 'trc20') {
coin.contractAddress = tronCoin.data[i].tokenId
} else {
coin.contractAddress = tronCoin.data[i].owner_address
}
newList.push(coin)
}
}
wallet.coinList=newList;
break;
}
wallet.balancePrice = (wallet.balance * mainCoinP.data.priceInUsd).toFixed(2);
wallet.balanceCnyPrice = (wallet.balance * mainCoinP.data.priceCny).toFixed(2);
wallet.totalBalancePrice=Number(wallet.totalBalancePrice)+Number(wallet.balancePrice);
wallet.totalBalanceCnyPrice=Number(wallet.totalBalanceCnyPrice)+Number(wallet.balanceCnyPrice);
wallet.coinList[0].balance = wallet.balance
wallet.coinList[0].balancePrice = wallet.balancePrice
wallet.coinList[0].balanceCnyPrice = wallet.balanceCnyPrice
uni.setStorageSync('wallet',wallet);
const walletInfo = uni.getStorageSync('walletInfo'); const walletInfo = uni.getStorageSync('walletInfo');
for (var k = 0, length = walletInfo[wallet.type].length; k < length; k++) { for (var k = 0, length = walletInfo[wallet.type].length; k < length; k++) {
if (walletInfo[wallet.type][k].address === wallet.address) { if (walletInfo[wallet.type][k].address === wallet.address) {
@ -216,88 +296,8 @@ let WalletUtil = {
} }
} }
uni.setStorageSync('walletInfo', walletInfo); uni.setStorageSync('walletInfo', walletInfo);
let that = this return wallet;
this.getPrice(wallet.type, function(rr) {
that.getPrice('USDT', function(usdt) {
switch (wallet.type) {
case 'BTC':
console.log("进来BTC")
BtcUtil.getBalance(wallet.address, function(balance) {
wallet.balance = balance;
wallet.balancePrice = (balance * rr).toFixed(2);
wallet.coinList[0].balance = balance
wallet.coinList[0].balancePrice = wallet.balancePrice
uni.setStorageSync('wallet', wallet);
success()
})
break;
case 'ETH':
console.log("进来ETH")
EthUtil.getBalance(wallet.address, function(balance) {
wallet.balance = balance;
wallet.balancePrice = (balance * rr).toFixed(2);
wallet.coinList[0].balance = balance
wallet.coinList[0].balancePrice = wallet.balancePrice
for (let i = 1; i < wallet.coinList.length; i++) {
EthUtil.getTokenBalance(wallet.address, wallet.coinList[
i].contractAddress, function(b) {
wallet.coinList[i].balance = b;
wallet.coinList[1].balancePrice = (wallet
.coinList[1].balance * usdt)
.toFixed(2);
uni.setStorageSync('wallet', wallet);
success()
});
}
});
break;
case 'TRX':
console.log("进来TRX")
TronUtil.getTronBalance(wallet.address).then((res) => {
wallet.balance = res;
wallet.balancePrice = (res * rr).toFixed(2);
wallet.coinList[0].balance = res
wallet.coinList[0].balancePrice = wallet.balancePrice
TronUtil.getContract(wallet.address, wallet.coinList,
function(list) {
wallet.coinList = list;
wallet.coinList[1].balancePrice = (wallet
.coinList[1].balance * usdt).toFixed(2);
console.log(wallet.coinList)
uni.setStorageSync('wallet', wallet);
success()
})
})
break;
}
})
})
}, },
getPrice: function(type, success) {
uni.request({
url: 'https://apilist.tronscan.org/api/token/price?token=' + type.toLowerCase(), //请求接口
header: {
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
},
success: (res) => {
console.log(res.data.price_in_usd)
success(res.data.price_in_usd)
}
});
},
// 封装地址方法 // 封装地址方法
updateAddress: function(type, value, bigAddress, addressName) { updateAddress: function(type, value, bigAddress, addressName) {
@ -440,8 +440,8 @@ let WalletUtil = {
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框 plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
plus.nativeUI.alert( plus.nativeUI.alert(
'The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication' 'The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication'
); );
break; break;
case e.CANCEL: case e.CANCEL:
plus.nativeUI.toast('Recognition has been cancelled'); plus.nativeUI.toast('Recognition has been cancelled');
break; break;

1
utils/api.js

@ -12,6 +12,7 @@ const api = {
getCoinRate: (params) => Vue.prototype.$axios.get('/api/coinRate/getCoinRate?' + qs.stringify(params)), getCoinRate: (params) => Vue.prototype.$axios.get('/api/coinRate/getCoinRate?' + qs.stringify(params)),
getChainDataList: (params) => Vue.prototype.$axios.get('/api/chainData/getChainDataList?' + qs.stringify(params)), getChainDataList: (params) => Vue.prototype.$axios.get('/api/chainData/getChainDataList?' + qs.stringify(params)),
getCoinTickerList: (params) => Vue.prototype.$axios.get('/api/coinTicker/getCoinTickerList'), getCoinTickerList: (params) => Vue.prototype.$axios.get('/api/coinTicker/getCoinTickerList'),
getBalance: (params) => Vue.prototype.$axios.get('/api/balance/getBalance?' + qs.stringify(params))
//--------------------------------- free --------------------------------- //--------------------------------- free ---------------------------------
} }

1
utils/locales/en.js

@ -140,6 +140,7 @@ export default {
Receive:'Receive', Receive:'Receive',
// sendToken index // sendToken index
Receivingaddress:'Receiving address', Receivingaddress:'Receiving address',
ReceivingaddressError:'Receiving address error',
ScanQR:'Scan the QR code to transfer to the asset', ScanQR:'Scan the QR code to transfer to the asset',
Copyaddress:'Copy address', Copyaddress:'Copy address',
CopySuccessful:'Copy address Successful!', CopySuccessful:'Copy address Successful!',

1
utils/locales/zh-F.js

@ -140,6 +140,7 @@ export default {
Receive:'接收', Receive:'接收',
// sendToken index // sendToken index
Receivingaddress:'接收地址', Receivingaddress:'接收地址',
ReceivingaddressError:'接受地址錯誤',
ScanQR:'掃描二維碼以轉移到資產', ScanQR:'掃描二維碼以轉移到資產',
Copyaddress:'複製地址', Copyaddress:'複製地址',
CopySuccessful:'複製地址成功!', CopySuccessful:'複製地址成功!',

1
utils/locales/zh.js

@ -138,6 +138,7 @@ export default {
Receive:'接收', Receive:'接收',
// sendToken index // sendToken index
Receivingaddress:'接受地址', Receivingaddress:'接受地址',
ReceivingaddressError:'接受地址错误',
ScanQR:'扫描二维码以转移到资产', ScanQR:'扫描二维码以转移到资产',
Copyaddress:'复制地址', Copyaddress:'复制地址',
CopySuccessful:'复制地址成功!', CopySuccessful:'复制地址成功!',

Loading…
Cancel
Save