Browse Source

完善

master
vee 4 years ago
parent
commit
a44b319db3
  1. 32
      pages/menu/sendToken/transfer/index.vue
  2. 150
      pages/menu/setting/currency/index.vue
  3. 457
      pages/menu/setting/index.vue
  4. 191
      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

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

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

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

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

457
pages/menu/setting/index.vue

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

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

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

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

@ -15,7 +15,10 @@
<view class="">
{{coin.balance}} {{coin.name}}
</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>
<image src="../../../../static/tongyonh/ethereum.png" mode="aspectFit" class="img1"
v-if="coin.type=='ETH'&&!coin.contractAddress"></image>
@ -114,6 +117,7 @@
// address
trxs: [],
coin: {},
currency:'USD',
isNoData:false,
showInfo: false,
list: [{
@ -231,6 +235,10 @@
onLoad() {
this.coin = uni.getStorageSync('coin');
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>
</view>
<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 class="textcon2" v-if="showMoney2">
***
@ -63,7 +63,8 @@
{{item.balance}}
</view>
<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 class="text2" v-if="!item.balancePrice">
$ 0.00
@ -91,6 +92,7 @@
return {
eth: '',
trc: 'Hello',
currency:'USD',
walletInfo: {},
userObj: {},
userObj2: {},
@ -104,14 +106,16 @@
this.isStop = true
},
onLoad() {
let currency=uni.getStorageSync('currency');
if(currency){
this.currency=currency;
}
//
this.$walletUtil.updateBalance();
this.userObj = uni.getStorageSync('wallet');
let that = this;
this.$walletUtil.updateBalance(function() {
that.userObj = uni.getStorageSync('wallet');
that.userObj2 = uni.getStorageSync('wallet');
});
},
computed: {
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 = {
getBalance: function(address,success) {
getBalance:async function(address,success) {
let balance=0;
try{
uni.request({
let res= await uni.request({
url: 'http://scan.weirui0755.com/btc/api/address/balancetrend/btc/' + address, //请求接口
header: {
'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){
//TODO handle the exception
}
success(balance);
return balance;
}
}
export default BtcUtil

20
utils/EthUtil.js

@ -48,14 +48,12 @@ let eth = {
'params': [address, "latest"]
};
let res =await uni.request({
url: 'http://47.245.25.82:8545', //仅为示例,并非真实接口地址。
url: systemConfiguration.constant.ethNode, //仅为示例,并非真实接口地址。
method: 'POST',
data: data,
dataType: 'json'});
try {
let balance = Number(web3.utils.hexToNumberString(res[1].data.result)) / Math.pow(10, 18)
console.log(balance,45465465)
return balance
} catch (e) {
return 0;
@ -70,7 +68,7 @@ let eth = {
return s + num;
},
// 获取bms,bmdt,usdt/erc余额
getTokenBalance: function(address, contract,success) {
getTokenBalance:async function(address, contract,success) {
web3 = new Web3();
const data = {
'jsonrpc': '2.0',
@ -83,19 +81,15 @@ let eth = {
};
uni.request({
let res =await uni.request({
url: 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', //仅为示例,并非真实接口地址。
method: 'POST',
data: data,
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)
}
dataType: 'json'
});
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 TronUtil from './TronUtil.js'
import EthUtil from './EthUtil.js'
import api from './api.js'
let fullWallet = {
"BTC": [{
@ -65,8 +66,9 @@ let WalletUtil = {
walletInfo.BTC[0].mnemonic = mnemonic;
walletInfo.BTC[0].privateKey = btc.privateKey;
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].address.length)
walletInfo.BTC[0].ellipsisAddress = walletInfo.BTC[0].address.substring(0, 6) + '...' + walletInfo.BTC[
0].address.substring(25,
walletInfo.BTC[0].address.length)
let eth = TokenUtil.generateEth(mnemonic)
walletInfo.ETH[0].password = password;
walletInfo.ETH[0].mnemonic = mnemonic;
@ -205,9 +207,87 @@ let WalletUtil = {
}
},
updateBalance: function(success) {
updateBalance: async function(success) {
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');
for (var k = 0, length = walletInfo[wallet.type].length; k < length; k++) {
if (walletInfo[wallet.type][k].address === wallet.address) {
@ -216,88 +296,8 @@ let WalletUtil = {
}
}
uni.setStorageSync('walletInfo', walletInfo);
let that = this
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;
}
})
})
return wallet;
},
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) {
@ -440,8 +440,8 @@ let WalletUtil = {
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
plus.nativeUI.alert(
'The number of fingerprint identification failures exceeds the limit. Please use other methods for authentication'
);
break;
);
break;
case e.CANCEL:
plus.nativeUI.toast('Recognition has been cancelled');
break;

1
utils/api.js

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

1
utils/locales/en.js

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

1
utils/locales/zh-F.js

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

1
utils/locales/zh.js

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

Loading…
Cancel
Save