Browse Source

修改

master
vee 4 years ago
parent
commit
722d4064f4
  1. 12
      pages.json
  2. 7
      pages/menu/collection/index.vue
  3. 384
      pages/menu/sendToken/transfer2/index.vue
  4. 2
      pages/menu/token/btc/index.css
  5. 7
      pages/menu/token/btc/index.vue
  6. 10
      pages/menu/token/btc/index2.vue
  7. 12
      pages/menu/wallet/index.css
  8. 192
      pages/menu/wallet/index.vue
  9. 8
      utils/TronUtil.js
  10. 2
      utils/WalletUtil.js

12
pages.json

@ -30,7 +30,8 @@
{
"path": "pages/menu/token/btc/index",
"style": {
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
@ -66,7 +67,8 @@
{
"path": "pages/menu/collection/index",
"style": {
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
@ -289,7 +291,8 @@
{
"path": "pages/menu/token/btc/index2",
"style": {
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
@ -300,7 +303,8 @@
{
"path": "pages/menu/wallet/index",
"style": {
"navigationStyle": "custom"
"navigationStyle": "custom",
"enablePullDownRefresh": true
}
},
{

7
pages/menu/collection/index.vue

@ -95,6 +95,13 @@
this.getCollection();
},
onPullDownRefresh() {
console.log('refresh');
this.getCollection();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
methods: {
showMsg(item,index){

384
pages/menu/sendToken/transfer2/index.vue

@ -8,91 +8,96 @@
@click="chooseImage()"></image>
</navigation>
<view class="main">
<view class="item">
<view class="title">
Collection address
</view>
<view class="inputcon">
<input type="text" value="" :placeholder="addValue" placeholder-style="color:#D0D0D2" class="input" v-model="toAddress"/>
<image src="../../../../static/tongyonh/lu.png" mode="aspectFit" class="img" @click="goAddress"></image>
</view>
</view>
<view class="item">
<view class="title flex">
<text>Amount of Money</text>
<text class="all" @click="toAll">ALL</text>
</view>
<view class="inputcon2">
<view class="input_con">
<input type="text" value="" placeholder="0" placeholder-style="color:#D0D0D2" class="input2" v-model="toValue"/>
<!-- <input type="text" value="" placeholder="Remark" placeholder-style="color:#D0D0D2" class="input1"/> -->
<view class="item">
<view class="title">
Collection address
</view>
<view class="inputcon">
<input type="text" value="" :placeholder="addValue" placeholder-style="color:#D0D0D2" class="input"
v-model="toAddress" />
<image src="../../../../static/tongyonh/lu.png" mode="aspectFit" class="img" @click="goAddress">
</image>
</view>
</view>
</view>
</view>
<!-- <view class="item minitem flex">
<view class="item">
<view class="title flex">
<text>Amount of Money</text>
<text class="all" @click="toAll">ALL</text>
</view>
<view class="inputcon2">
<view class="input_con">
<input type="text" value="" placeholder="0" placeholder-style="color:#D0D0D2" class="input2"
v-model="toValue" />
<!-- <input type="text" value="" placeholder="Remark" placeholder-style="color:#D0D0D2" class="input1"/> -->
</view>
</view>
</view>
<!-- <view class="item minitem flex">
<text>Miner's fee</text>
<view class="imgcon">
<image src="../../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="rimg"></image>
</view>
</view> -->
<view class="btn" @click="next">
Next step
</view>
</view>
<view class="bottom_con" v-if="show">
<view class="title_con">
Payment details
<view class="btn" @click="next">
Next step
</view>
</view>
<view class="money_con">
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img" @click="show=false"></image>
<view class="money">
<text class="tex1">{{toValue}}</text>
<text class="tex2">{{info.coinList[0].name2}}</text>
<view class="bottom_con" v-if="show">
<view class="title_con">
Payment details
</view>
<view class="info_con">
<view class="item">
<text class="text1">Payment information</text>
<text class="text2">{{info.coinList[0].name2}} transfer</text>
<view class="money_con">
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img" @click="show=false">
</image>
<view class="money">
<text class="tex1">{{toValue}}</text>
<text class="tex2">{{info.coinList[0].name2}}</text>
</view>
<view class="item">
<text class="text1">Collection address</text>
<text class="text2">{{toAddress}}</text>
</view>
<view class="item">
<text class="text1">Payment address</text>
<text class="text2">{{info.address}}</text>
<view class="info_con">
<view class="item">
<text class="text1">Payment information</text>
<text class="text2">{{info.coinList[0].name2}} transfer</text>
</view>
<view class="item">
<text class="text1">Collection address</text>
<text class="text2">{{toAddress}}</text>
</view>
<view class="item">
<text class="text1">Payment address</text>
<text class="text2">{{info.address}}</text>
</view>
</view>
</view>
<view class="btn" @click="toNext">
Next step
</view>
</view>
<view class="btn" @click="toNext">
Next step
</view>
</view>
<view class="bottom_con" v-if="show2">
<view class="title_con">
Password
</view>
<view class="money_con money_con2">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="img2" @click="back"></image>
<u-input placeholder="Wallet password" v-model="value" :type="type" :border="border" :password-icon="passwordIcon" @input="btnco()" />
</view>
<view class="btn2" :class="btntype?'btncolor':'btncolor2'" @click="confirm()">
Next step
<view class="bottom_con" v-if="show2">
<view class="title_con">
Password
</view>
<view class="money_con money_con2">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="img2" @click="back"></image>
<u-input placeholder="Wallet password" v-model="value" :type="type" :border="border"
:password-icon="passwordIcon" @input="btnco()" />
</view>
<view class="btn2" :class="btntype?'btncolor':'btncolor2'" @click="confirm()">
Next step
</view>
</view>
<u-mask :show="show" z-index="10"></u-mask>
<u-mask :show="show2" z-index="10"></u-mask>
</view>
<u-mask :show="show" z-index="10"></u-mask>
<u-mask :show="show2" z-index="10"></u-mask>
</view>
@ -103,135 +108,160 @@
export default {
data() {
return {
btntype:false,
addValue:'',
info:{},
toAddress:'',
toValue:null,
show:false,
show2:false,
value: '',
type: 'password',
passwordIcon: true,
border: true,
btntype: false,
addValue: '',
info: {},
toAddress: '',
toValue: null,
show: false,
show2: false,
value: '',
type: 'password',
passwordIcon: true,
border: true,
}
},
methods: {
toNext(){
this.show=false;
this.show2=true;
toNext() {
this.show = false;
this.show2 = true;
},
back(){
this.show2=false;
this.show=true
back() {
this.show2 = false;
this.show = true
},
btnco(){
if(this.value.length==0){
this.btntype=false;
return;
btnco() {
if (this.value.length == 0) {
this.btntype = false;
return;
}
this.btntype=true;
},
toAll(){
this.toValue=this.info.balance
this.btntype = true;
},
succ(a,b){
console.log(a,4545)
console.log(b,45646)
toAll() {
this.toValue = this.info.balance
},
next(){
if(this.toAddress==''){
uni.showToast({
title: 'Transfer receiving address cannot be blank',
icon: 'none',
duration: 1500
})
return
}
if(this.toValue==null){
uni.showToast({
title: 'Please enter the transfer amount',
icon: 'none',
duration: 1500
})
return
}
if(this.toValue<=0){
uni.showToast({
title: 'The transfer amount cannot be less than or equal to zero',
icon: 'none',
duration: 1500
})
return
}
this.show=true;
succ(a, b) {
console.log(a, 4545)
console.log(b, 45646)
},
confirm(){
if(this.value!=this.info.password){
uni.showToast({
title: 'Password error',
icon: 'none',
duration: 1500
})
next() {
if (this.toAddress == '') {
uni.showToast({
title: 'Transfer receiving address cannot be blank',
icon: 'none',
duration: 1500
})
return
}
if(this.info.coinList[0].xname=='Ethereum'){
this.$EthUtil.transaction(this.info.address,this.toAddress,this.toValue,this.info.privateKey).then((res) => {
console.log(res,'钱包')
this.show2=false;
uni.reLaunch({
url:'../transfer2/index'
}
if (this.toValue == null) {
uni.showToast({
title: 'Please enter the transfer amount',
icon: 'none',
duration: 1500
})
}).catch(err => {
console.log(err)
})
return
}
if(this.info.coinList[0].xname=='TRON'){
this.$TronUtil.sendTransaction(this.info.address,this.info.privateKey,this.toAddress,this.toValue,).then((res) => {
if (this.toValue <= 0) {
uni.showToast({
title: 'Successfully',
icon: 'success',
title: 'The transfer amount cannot be less than or equal to zero',
icon: 'none',
duration: 1500
})
this.show2=false;
uni.reLaunch({
url:'../transfer2/index'
return
}
this.show = true;
},
confirm() {
if (this.value != this.info.password) {
uni.showToast({
title: 'Password error',
icon: 'none',
duration: 1500
})
}).catch(err => {
uni.showToast({
title: err,
icon: 'none',
duration: 1500
})
})
return
}
if (this.info.coinList[0].xname == 'Ethereum') {
this.$EthUtil.transaction(this.info.address, this.toAddress, this.toValue, this.info.privateKey).then((
res) => {
console.log(res, '钱包')
this.show2 = false;
uni.reLaunch({
url: '../transfer2/index'
})
}).catch(err => {
console.log(err)
})
}
if (this.info.coinList[0].xname == 'TRON') {
if (!this.contractAddress) {
this.$TronUtil.sendTransaction(this.info.address, this.info.privateKey, this.toAddress, this.toValue, )
.then((res) => {
uni.showToast({
title: 'Successfully',
icon: 'success',
duration: 2000
})
this.show2 = false;
uni.reLaunch({
url: '/pages/menu/wallet/index'
})
}).catch(err => {
uni.showToast({
title: err,
icon: 'none',
duration: 2000
})
})
}else{
this.$TronUtil.sendRawTransaction(this.info.address, this.info.privateKey, this.toAddress, this.toValue,'',this.contractAddress )
.then((res) => {
uni.showToast({
title: 'Successfully',
icon: 'success',
duration: 2000
})
this.show2 = false;
uni.reLaunch({
url: '/pages/menu/wallet/index'
})
}).catch(err => {
console.log(err)
uni.showToast({
title: err,
icon: 'none',
duration: 2000
})
})
}
}
},
goAddress(){
goAddress() {
uni.navigateTo({
url:'../address/index'
url: '../address/index'
})
},
//
chooseImage() {
var _this = this
uni.chooseImage({
count: 1, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album', 'camera'], //
success: function(res) {
_this.imgShow = res.tempFilePaths[0]
}
});
// ass()
},
//
chooseImage() {
var _this = this
uni.chooseImage({
count: 1, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album', 'camera'], //
success: function(res) {
_this.imgShow = res.tempFilePaths[0]
}
});
// ass()
},
},
onLoad(option) {
const item = JSON.parse(option.item);
this.info=item;
this.addValue=this.info.coinList[0].xname+' Address'
this.contractAddress = option.contractAddress;
this.info = uni.getStorageSync('wallet');
this.addValue = this.info.coinList[0].xname + ' Address'
}
};
</script>

2
pages/menu/token/btc/index.css

@ -5,7 +5,7 @@
right: 30rpx;
}
.big_title{
font-size: 48rpx;
font-size: 36rpx;
}
.main .money_con{

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

@ -232,6 +232,13 @@
console.log(this.infoWallet,1111)
this.getWalletInfo()
},
onPullDownRefresh() {
console.log('refresh');
this.getWalletInfo();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
onReachBottom() {
this.pageSize += 5;
this.getWalletInfo()

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

@ -144,7 +144,7 @@
goSend() {
let itemm = JSON.stringify(this.infoWallet)
uni.navigateTo({
url: '/pages/menu/sendToken/transfer2/index?item=' + itemm
url: '/pages/menu/sendToken/transfer2/index?contractAddress=' + this.contractAddress
})
},
goReceive() {
@ -222,8 +222,16 @@
this.xname=this.infoWallet.coinList[index].xname
this.balance=this.infoWallet.coinList[index].balance
this.xbalance=this.infoWallet.coinList[index].balancePrice
this.contractAddress=this.infoWallet.coinList[index].contractAddress
this.getWalletInfo()
},
onPullDownRefresh() {
console.log('refresh');
this.getWalletInfo();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
onReachBottom() {
this.pageSize += 5;
this.getWalletInfo()

12
pages/menu/wallet/index.css

@ -12,7 +12,7 @@
right: 30rpx;
}
.big_title{
font-size: 48rpx;
font-size: 36rpx;
}
.main{
padding: 0 26rpx;
@ -64,7 +64,7 @@
margin-top:40rpx;
}
.textcon3{
color: #D6CAF7;
color: #FFFFFF;
font-size: 28rpx;
margin-top:40rpx;
}
@ -109,20 +109,20 @@
margin-right: 20rpx;
}
.bot_con .item .left .textcon .text1{
font-size: 36rpx;
font-size: 30rpx;
}
.bot_con .item .left .textcon .text2{
font-size: 28rpx;
font-size: 24rpx;
color: #B0BBD5;
}
.bot_con .item .rig{
text-align: right;
}
.bot_con .item .rig .text1{
font-size: 36rpx;
font-size: 32rpx;
}
.bot_con .item .rig .text2{
font-size: 28rpx;
font-size: 24rpx;
color: #B0BBD5;
}
.opc{

192
pages/menu/wallet/index.vue

@ -10,14 +10,20 @@
</text>
</navigation>
<view class="main">
<view :class="{'money_con': userObj.coinList[0].xname=='Ethereum', 'money_con2': userObj.coinList[0].xname=='Bitcoin', 'money_con3': userObj.coinList[0].xname=='TRON'}">
<image src="../../../static/tongyonh/ethereum.png" mode="aspectFit" class="imgicon" v-if="userObj.coinList[0].xname=='Ethereum'"></image>
<image src="../../../static/tongyonh/Frame28.png" mode="aspectFit" class="imgicon" v-if="userObj.coinList[0].xname=='Bitcoin'"></image>
<image src="../../../static/tongyonh/tronicon.png" mode="aspectFit" class="imgicon" v-if="userObj.coinList[0].xname=='TRON'"></image>
<view
:class="{'money_con': userObj.coinList[0].xname=='Ethereum', 'money_con2': userObj.coinList[0].xname=='Bitcoin', 'money_con3': userObj.coinList[0].xname=='TRON'}">
<image src="../../../static/tongyonh/ethereum.png" mode="aspectFit" class="imgicon"
v-if="userObj.coinList[0].xname=='Ethereum'"></image>
<image src="../../../static/tongyonh/Frame28.png" mode="aspectFit" class="imgicon"
v-if="userObj.coinList[0].xname=='Bitcoin'"></image>
<image src="../../../static/tongyonh/tronicon.png" mode="aspectFit" class="imgicon"
v-if="userObj.coinList[0].xname=='TRON'"></image>
<view class="textcon1 flex">
<text class="text">{{this.userObj.name}}</text>
<image src="../../../static/tongyonh/visibility_24px.png" mode="aspectFit" class="img1" @click="showMoney()" v-if="showMoney1"></image>
<image src="../../../static/tongyonh/eyeno.png" mode="aspectFit" class="img1" @click="showMoney22()" v-if="showMoney2"></image>
<image src="../../../static/tongyonh/visibility_24px.png" mode="aspectFit" class="img1"
@click="showMoney()" v-if="showMoney1"></image>
<image src="../../../static/tongyonh/eyeno.png" mode="aspectFit" class="img1" @click="showMoney22()"
v-if="showMoney2"></image>
</view>
<view class="textcon2" v-if="showMoney1">
$ {{!userObj.balancePrice?0.00:userObj.balancePrice}}
@ -35,35 +41,37 @@
<view class="title">
Assets
</view>
<image src="../../../static/tongyonh/IconGroup.png" mode="aspectFit" class="jiaimg" v-if="userObj.coinList[0].xname!='Bitcoin'&&userObj.coinList[0].xname!='TRON'" @click="goOther"></image>
<image src="../../../static/tongyonh/IconGroup.png" mode="aspectFit" class="jiaimg"
v-if="userObj.coinList[0].xname!='Bitcoin'&&userObj.coinList[0].xname!='TRON'" @click="goOther">
</image>
</view>
<view class="scroll">
<view class="item flexx" @click="goTrans(item,index)" v-for="item,index in this.userObj.coinList">
<view class="left flex">
<image :src="item.icon" mode="aspectFit" class="img1"></image>
<view class="textcon">
<view class="text1">
{{item.name}}
<view class="scroll">
<view class="item flexx" @click="goTrans(item,index)" v-for="item,index in this.userObj.coinList">
<view class="left flex">
<image :src="item.icon" mode="aspectFit" class="img1"></image>
<view class="textcon">
<view class="text1">
{{item.name}}
</view>
<view class="text2">
{{item.xname}}
</view>
</view>
<view class="text2">
{{item.xname}}
</view>
</view>
</view>
<view class="rig">
<view class="text1">
{{item.balance}}
</view>
<view class="text2" v-if="item.balancePrice">
$ {{item.balancePrice}}
</view>
<view class="text2" v-if="!item.balancePrice">
$ 0.00
<view class="rig">
<view class="text1">
{{item.balance}}
</view>
<view class="text2" v-if="item.balancePrice">
$ {{item.balancePrice}}
</view>
<view class="text2" v-if="!item.balancePrice">
$ 0.00
</view>
</view>
</view>
</view>
</view>
</view>
@ -83,81 +91,91 @@
return {
eth: '',
trc: 'Hello',
walletInfo:{},
userObj:{},
userObj2:{},
showMoney1:true,
showMoney2:false,
btcBalance:0,
walletInfo: {},
userObj: {},
userObj2: {},
showMoney1: true,
showMoney2: false,
btcBalance: 0,
}
},
onLoad() {
this.setStorage();
if(uni.getStorageSync('wallet')){
this.userObj=uni.getStorageSync('wallet');
this.userObj2=uni.getStorageSync('wallet');
this.$walletUtil.updateBalance();
if (uni.getStorageSync('wallet')) {
this.userObj = uni.getStorageSync('wallet');
this.userObj2 = uni.getStorageSync('wallet');
this.updateData();
this.userObj.address = this.userObj.address.substring(0, 6)+'...'+this.userObj.address.substring(25,this.userObj.address.length);
this.userObj.address = this.userObj.address.substring(0, 6) + '...' + this.userObj.address.substring(25,
this.userObj.address.length);
}
},
methods: {
updateData(){
let thar=this;
setTimeout(
function(){
thar.userObj=uni.getStorageSync('wallet');
thar.userObj2=uni.getStorageSync('wallet');
thar.userObj.address = thar.userObj.ellipsisAddress;
thar.updateData();
},200);
},
goOther(){
console.log(this.userObj2,8888)
let item = JSON.stringify(this.userObj2)
uni.navigateTo({
url:'otherCoin/index?type='+item
})
onPullDownRefresh() {
console.log('refresh');
this.$walletUtil.updateBalance();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
showMoney(){
this.showMoney1=false
this.showMoney2=true
methods: {
updateData() {
let thar = this;
setTimeout(
function() {
thar.userObj = uni.getStorageSync('wallet');
thar.userObj2 = uni.getStorageSync('wallet');
thar.userObj.address = thar.userObj.ellipsisAddress;
thar.updateData();
}, 200);
},
goOther() {
console.log(this.userObj2, 8888)
let item = JSON.stringify(this.userObj2)
uni.navigateTo({
url: 'otherCoin/index?type=' + item
})
},
showMoney22(){
this.showMoney1=true
this.showMoney2=false
showMoney() {
this.showMoney1 = false
this.showMoney2 = true
},
showMoney22() {
this.showMoney1 = true
this.showMoney2 = false
},
setStorage() {
this.walletInfo = uni.getStorageSync('walletInfo');
this.userObj=this.walletInfo.BTC[0]
this.userObj.address = this.userObj.address.substring(0, 6)+'...'+this.userObj.address.substring(25,this.userObj.address.length);
this.userObj = this.walletInfo.BTC[0]
this.userObj.address = this.userObj.address.substring(0, 6) + '...' + this.userObj.address.substring(25,
this.userObj.address.length);
console.log(this.walletInfo.BTC[0])
},
goTrans(itemm,index) {
console.log(index,444)
let item = JSON.stringify(this.userObj2)
console.log(item,454545)
if(index==0){
goTrans(itemm, index) {
console.log(index, 444)
let item = JSON.stringify(this.userObj2)
console.log(item, 454545)
if (index == 0) {
uni.navigateTo({
url:'/pages/menu/token/btc/index?item='+item
})
}else{
url: '/pages/menu/token/btc/index?item=' + item
})
} else {
//
uni.setStorageSync('otherCoin',index)
uni.setStorageSync('otherCoin', index)
uni.navigateTo({
url:'/pages/menu/token/btc/index2'
})
url: '/pages/menu/token/btc/index2'
})
}
},
},
//
chooseImage() {
var _this = this
@ -177,7 +195,7 @@
url: './cwallet/index'
})
}
}
}
};
</script>
<style scoped>

8
utils/TronUtil.js

@ -41,6 +41,7 @@ let tron = {
},
// 发起TRC/USDT交易
sendRawTransaction: async function(fromAddress, privateKey, toAddress, amount, remark, contract) {
console.log(fromAddress, privateKey, toAddress, amount, remark, contract)
const parameter = [{
type: 'address',
value: toAddress
@ -83,6 +84,9 @@ let tron = {
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
},
success: (res) => {
var newList=[];
newList.push(list[0])
newList.push(list[1])
for(let i=1;i<res.data.data.length;i++){
if(res.data.data[i].tokenAbbr==='USDT'){
list[1].balance=(Number(res.data.data[i].balance)/ Math.pow(10, res.data.data[i].tokenDecimal));
@ -101,14 +105,14 @@ let tron = {
}else{
coin.contractAddress=res.data.data[i].owner_address
}
list.push(coin)
newList.push(coin)
}
}
console.log(list,12313)
success(list);
success(newList);
// coinList: [{
// name: "ETH",
// xname: 'Ethereum',

2
utils/WalletUtil.js

@ -197,7 +197,7 @@ let WalletUtil = {
}
}
this.updateBalance();
//this.updateBalance();
},
updateBalance:function() {

Loading…
Cancel
Save