Dread 4 years ago
parent
commit
eb6035b572
  1. 8
      pages/menu/sendToken/enPassword/index.vue
  2. 2
      pages/menu/sendToken/transfer/index.vue
  3. 4
      pages/menu/token/btc/index.css
  4. 3
      pages/register/index.vue
  5. 70
      utils/TokenUtil.js
  6. 72
      utils/TronUtil.js
  7. 2
      utils/locales/en.js
  8. 2
      utils/locales/zh-F.js
  9. 2
      utils/locales/zh.js

8
pages/menu/sendToken/enPassword/index.vue

@ -55,7 +55,7 @@
if (!err) { if (!err) {
uni.showToast({ uni.showToast({
title: 'Transfer succeeded', title: this.$t('index').Transfersucceeded,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -69,7 +69,7 @@
console.log(err, 'cuowu') console.log(err, 'cuowu')
uni.showToast({ uni.showToast({
title: 'Transfer failed, please confirm the information is correct', title: this.$t('index').Transferfailedconfirm,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -80,7 +80,7 @@
.then((res) => { .then((res) => {
uni.showToast({ uni.showToast({
title: 'Transfer succeeded', title: this.$t('index').Transfersucceeded,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })
@ -94,7 +94,7 @@
console.log(err, 'cuowu') console.log(err, 'cuowu')
uni.showToast({ uni.showToast({
title: 'Transfer failed, please confirm the information is correct', title: this.$t('index').Transferfailedconfirm,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}) })

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

@ -488,7 +488,7 @@
that.showFinger = false; that.showFinger = false;
uni.showToast({ uni.showToast({
title: this.$t('index').addresserror, title: this.$t('index').failedInitiate,
icon: 'none', icon: 'none',
duration: 1500 duration: 1500

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

@ -205,7 +205,7 @@
.main .money_con2 { .main .money_con2 {
margin-top: 32rpx; margin-top: 32rpx;
background-image: linear-gradient(to right, #FF820C, #FFB606); background-image: linear-gradient(to right, #FF820C, #FFB606);
height: 320rpx; height: 354rpx;
padding: 40rpx 36rpx; padding: 40rpx 36rpx;
position: relative; position: relative;
border-radius: 24rpx; border-radius: 24rpx;
@ -214,7 +214,7 @@
.main .money_con3 { .main .money_con3 {
margin-top: 32rpx; margin-top: 32rpx;
background-image: linear-gradient(to right, #B6162A, #F96D7D); background-image: linear-gradient(to right, #B6162A, #F96D7D);
height: 320rpx; height: 354rpx;
padding: 40rpx 36rpx; padding: 40rpx 36rpx;
position: relative; position: relative;
border-radius: 24rpx; border-radius: 24rpx;

3
pages/register/index.vue

@ -153,9 +153,8 @@
return; return;
} }
var word = this.$Token.creatingWallets();
// , // ,
var word2 = word.mnemonic var word2 = this.$Token.generateMnemonic();
uni.setStorage({ uni.setStorage({
key: 'word', key: 'word',
data: word2, data: word2,

70
utils/TokenUtil.js

@ -106,76 +106,6 @@ let token = {
'address': address 'address': address
}; };
}, },
initialWallet: function(mnemonic, password) {
let btc = this.generateBtc(mnemonic);
btc.mnemonic = mnemonic;
btc.password = password;
btc.balance = 0;
btc.coinList = [{
name: "BTC",
name2: "BTC",
xname: 'Bitcoin',
balance: 0,
icon: require('@/static/tongyonh/bye.png')
}];
let eth = this.generateEth(mnemonic);
eth.password = password;
eth.balance = 0;
eth.mnemonic = mnemonic;
eth.coinList = [{
name: "ETH",
name2: "ETH",
xname: 'Ethereum',
balance: 0,
icon: require('@/static/tongyonh/Frame3299.png')
},
{
name: "USDT",
name2: "ERC20-USDT",
xname: 'Tether USD',
balance: 0,
contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
icon: require('@/static/tongyonh/img500.png')
}
];
console.log(eth.coinList, 4444)
console.log(eth, 2224)
let tron = this.generateTron(mnemonic);
tron.password = password;
tron.balance = 0;
tron.mnemonic = mnemonic;
tron.coinList = [{
name: "TRX",
name2: "TRX",
xname: 'TRON',
balance: 0,
icon: require('@/static/tongyonh/tron1.png')
},
{
name: "USDT",
name2: "TRC20-USDT",
xname: 'Tether USD',
balance: 0,
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
icon: require('@/static/tongyonh/tether_usd.png')
},
];
let wallrtInfo = {
"BTC": [
btc
],
"ETH": [
eth
],
"TRON": [
tron
]
}
return wallrtInfo;
},
validateBtc: function(address) { validateBtc: function(address) {
let valid = WAValidator.validate(address, 'BTC'); let valid = WAValidator.validate(address, 'BTC');
console.log(valid, 'BTC') console.log(valid, 'BTC')

72
utils/TronUtil.js

@ -21,7 +21,7 @@ let tron = {
console.log(eventServer) console.log(eventServer)
console.log(address) console.log(address)
let balance = await tronWeb.trx.getBalance(address); let balance = await tronWeb.trx.getBalance(address);
console.log('查询trx余额',balance); console.log('查询trx余额', balance);
console.log(Number(tronWeb.fromSun(balance).toString())); console.log(Number(tronWeb.fromSun(balance).toString()));
return Number(tronWeb.fromSun(balance).toString()); return Number(tronWeb.fromSun(balance).toString());
}, },
@ -39,7 +39,7 @@ let tron = {
return balance / Math.pow(10, 6); return balance / Math.pow(10, 6);
}, },
// 发起TRC/USDT交易 // 发起TRC/USDT交易
sendRawTransaction: async function(transaction, privateKey){ sendRawTransaction: async function(transaction, privateKey) {
let signedTx = await tronWeb.trx.sign(transaction.transaction, privateKey) let signedTx = await tronWeb.trx.sign(transaction.transaction, privateKey)
await tronWeb.trx.sendRawTransaction(signedTx); await tronWeb.trx.sendRawTransaction(signedTx);
@ -61,18 +61,20 @@ let tron = {
} }
return null; return null;
}, },
transaction:async function(transaction, privateKey, contract){ transaction: async function(transaction, privateKey, contract) {
if(contract){ if (contract&&contract!='_') {
return await this.sendRawTransaction(transaction, privateKey); return await this.sendRawTransaction(transaction, privateKey);
}else{ } else {
return await this.sendTransaction(transaction, privateKey); return await this.sendTransaction(transaction, privateKey);
} }
}, },
getTransaction:async function(fromAddress, toAddress, amount, remark, contract){ getTransaction: async function(fromAddress, toAddress, amount, remark, contract) {
if(contract){ if (contract&&contract!='_') {
console.log(contract,'进来')
return await this.prepareRawTransaction(fromAddress, toAddress, amount, remark, contract); return await this.prepareRawTransaction(fromAddress, toAddress, amount, remark, contract);
}else{ } else {
return await this.prepareTransaction(fromAddress, toAddress, amount); console.log(contract,'进来12')
return await this.prepareTransaction(fromAddress, toAddress, amount,remark);
} }
}, },
prepareRawTransaction: async function(fromAddress, toAddress, amount, remark, contract) { prepareRawTransaction: async function(fromAddress, toAddress, amount, remark, contract) {
@ -87,63 +89,19 @@ let tron = {
const transaction = await tronWeb.transactionBuilder.triggerSmartContract(contract, const transaction = await tronWeb.transactionBuilder.triggerSmartContract(contract,
"transfer(address,uint256)", {}, "transfer(address,uint256)", {},
parameter, tronWeb.address.toHex(fromAddress)) parameter, tronWeb.address.toHex(fromAddress))
console.log(remark,'备注') console.log(transaction.transaction, '备注')
await tronWeb.transactionBuilder.addUpdateData(transaction.transaction, remark, 'utf8');
console.log(transaction.transaction, '备注')
return transaction; return transaction;
}, },
// 发起TRX交易 // 发起TRX交易
prepareTransaction: async function(fromAddress, toAddress, amount) { prepareTransaction: async function(fromAddress, toAddress, amount, remark) {
console.log(amount) console.log(amount)
const transaction = await tronWeb.transactionBuilder.sendTrx(toAddress, amount * Math.pow(10, 6), const transaction = await tronWeb.transactionBuilder.sendTrx(toAddress, amount * Math.pow(10, 6),
fromAddress); fromAddress);
return transaction; return transaction;
},
getContract:function(address,list,success){
uni.request({
url: 'https://apiasia.tronscan.io:5566/api/account/tokens?limit=100&address=' + address, //请求接口
header: {
'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));
}else{
console.log(Number(res.data.data[i].balance)/Math.pow(10, res.data.data[i].tokenDecimal))
var coin={
name: res.data.data[i].tokenAbbr,
xname: res.data.data[i].tokenName,
balance: (Number(res.data.data[i].balance)/ Math.pow(10, res.data.data[i].tokenDecimal)),
icon: res.data.data[i].tokenLogo,
}
if(res.data.data[i].tokenType==='trc20'){
coin.contractAddress=res.data.data[i].tokenId
}else{
coin.contractAddress=res.data.data[i].owner_address
}
newList.push(coin)
} }
}
console.log(list,12313)
success(newList);
// coinList: [{
// name: "ETH",
// xname: 'Ethereum',
// balance: 0,
// icon: require('@/static/tongyonh/Frame3299.png')
// },
}
});
},
} }
export default tron export default tron

2
utils/locales/en.js

@ -221,7 +221,7 @@ export default {
Transfersucceeded: 'Transfer succeeded', Transfersucceeded: 'Transfer succeeded',
Transferfailedconfirm: 'Transfer failed, please confirm the information is correct', Transferfailedconfirm: 'Transfer failed, please confirm the information is correct',
yourcredit: 'Sorry, your credit is running low', yourcredit: 'Sorry, your credit is running low',
addresserror: 'address error', failedInitiate: 'Failed to initiate',
offchain: 'Please enter a note (off-chain)', offchain: 'Please enter a note (off-chain)',
TermsofServiceTxt:'This "Service Agreement" ("Agreement" or "Service Agreement") contains the terms and conditions governing your access and use of the websites and services (defined below) provided by us, and is between us and you or the entity you represent protocol. Please read this "Service Agreement" carefully before using this website or service. By using this website, or by clicking a button or check box to accept or agree to the terms of service of this "Service Agreement" (if this option is available), or fill in a service order, or, if earlier, use or otherwise access the service ("Effective Date"), you (1) accept and agree to this "Service Agreement" and any additional terms, rules and participation conditions that we publish from time to time, and (2) agree to the collection as described in our "Privacy Policy" , Use, disclosure, and other information processing activities. If you do not agree to this Service Agreement, you may not access or use the service.', TermsofServiceTxt:'This "Service Agreement" ("Agreement" or "Service Agreement") contains the terms and conditions governing your access and use of the websites and services (defined below) provided by us, and is between us and you or the entity you represent protocol. Please read this "Service Agreement" carefully before using this website or service. By using this website, or by clicking a button or check box to accept or agree to the terms of service of this "Service Agreement" (if this option is available), or fill in a service order, or, if earlier, use or otherwise access the service ("Effective Date"), you (1) accept and agree to this "Service Agreement" and any additional terms, rules and participation conditions that we publish from time to time, and (2) agree to the collection as described in our "Privacy Policy" , Use, disclosure, and other information processing activities. If you do not agree to this Service Agreement, you may not access or use the service.',
updateTitle:'Version upgrade prompt', updateTitle:'Version upgrade prompt',

2
utils/locales/zh-F.js

@ -219,7 +219,7 @@ export default {
Transfersucceeded: '餘額不足', Transfersucceeded: '餘額不足',
Transferfailedconfirm: '轉賬失敗,請確認信息是否正確', Transferfailedconfirm: '轉賬失敗,請確認信息是否正確',
yourcredit: '餘額不足', yourcredit: '餘額不足',
addresserror: '地址錯誤', failedInitiate: '發起失敗',
offchain: '請輸入注釋(鏈外)', offchain: '請輸入注釋(鏈外)',
TermsofServiceTxt:'本《服務協議》(“協議”或“服務協議”)包含管理您訪問和使用我們提供的網站和服務(定義如下)的條款和條件,並且是我們與您或您所代表的實體之間的協議。在使用本網站或服務之前,請仔細閱讀本《服務協議》。通過使用本網站,或單擊按鈕或複選框以接收或同意本《服務協議》的服務條款(如有該選項),或者填寫服務訂單,或者,如果更早,使用或以其他方式訪問服務(“生效日期”),您(1)接收並同意本《服務協議》以及我們不時發布的任何附加條款、規則和參與條件,以及(2)同意如我們的《隱私政策》中所述的收集、使用、披露和其他處理信息的活動。如果您不同意本《服務協議》,則您不得訪問或使用服務。', TermsofServiceTxt:'本《服務協議》(“協議”或“服務協議”)包含管理您訪問和使用我們提供的網站和服務(定義如下)的條款和條件,並且是我們與您或您所代表的實體之間的協議。在使用本網站或服務之前,請仔細閱讀本《服務協議》。通過使用本網站,或單擊按鈕或複選框以接收或同意本《服務協議》的服務條款(如有該選項),或者填寫服務訂單,或者,如果更早,使用或以其他方式訪問服務(“生效日期”),您(1)接收並同意本《服務協議》以及我們不時發布的任何附加條款、規則和參與條件,以及(2)同意如我們的《隱私政策》中所述的收集、使用、披露和其他處理信息的活動。如果您不同意本《服務協議》,則您不得訪問或使用服務。',
updateTitle:'版本升級提示', updateTitle:'版本升級提示',

2
utils/locales/zh.js

@ -217,7 +217,7 @@ export default {
Transfersucceeded: '转账成功', Transfersucceeded: '转账成功',
Transferfailedconfirm: '转账失败,请确认信息是否正确', Transferfailedconfirm: '转账失败,请确认信息是否正确',
yourcredit: '余额不足', yourcredit: '余额不足',
addresserror: '地址错误', failedInitiate: '发起失败',
offchain: '请输入注释(链外)', offchain: '请输入注释(链外)',
TermsofServiceTxt:'本《服务协议》(“协议”或“服务协议”)包含管理您访问和使用我们提供的网站和服务(定义如下)的条款和条件,并且是我们与您或您所代表的实体之间的协议。在使用本网站或服务之前,请仔细阅读本《服务协议》。通过使用本网站,或单击按钮或复选框以接收或同意本《服务协议》的服务条款(如有该选项),或者填写服务订单,或者,如果更早,使用或以其他方式访问服务(“生效日期”),您(1)接收并同意本《服务协议》以及我们不时发布的任何附加条款、规则和参与条件,以及(2)同意如我们的《隐私政策》中所述的收集、使用、披露和其他处理信息的活动。如果您不同意本《服务协议》,则您不得访问或使用服务。', TermsofServiceTxt:'本《服务协议》(“协议”或“服务协议”)包含管理您访问和使用我们提供的网站和服务(定义如下)的条款和条件,并且是我们与您或您所代表的实体之间的协议。在使用本网站或服务之前,请仔细阅读本《服务协议》。通过使用本网站,或单击按钮或复选框以接收或同意本《服务协议》的服务条款(如有该选项),或者填写服务订单,或者,如果更早,使用或以其他方式访问服务(“生效日期”),您(1)接收并同意本《服务协议》以及我们不时发布的任何附加条款、规则和参与条件,以及(2)同意如我们的《隐私政策》中所述的收集、使用、披露和其他处理信息的活动。如果您不同意本《服务协议》,则您不得访问或使用服务。',
updateTitle:'版本升级提示', updateTitle:'版本升级提示',

Loading…
Cancel
Save