20 changed files with 576 additions and 760 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,263 +0,0 @@ |
|||
import index from './index.js' |
|||
let DataUtil = { |
|||
transactionData: function(type, dataType, address, contract, pageNum, pageSize, success) { |
|||
console.log(type, dataType, address, contract, pageNum, pageSize, 1111) |
|||
switch (type) { |
|||
case 'BTC': |
|||
success([]); |
|||
break; |
|||
case 'ETH': |
|||
this.ethTransactionData(contract, dataType, address, pageNum, pageSize, success); |
|||
break; |
|||
case 'TRX': |
|||
this.trxTransactionData(contract, dataType, address, pageNum, pageSize, success); |
|||
|
|||
break; |
|||
} |
|||
}, |
|||
ethTransactionData: function(contract, dataType, address, pageNum, pageSize, success) { |
|||
let dataList = []; |
|||
if (!contract) { |
|||
uni.request({ |
|||
url: 'http://scan.weirui0755.com/eth/api/eth/address/normal/' + address + '/' + |
|||
pageNum + |
|||
'/' + pageSize, //请求接口
|
|||
header: { |
|||
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
|
|||
}, |
|||
success: (res) => { |
|||
console.log(res, 1234654) |
|||
if (res.data.code === 1) { |
|||
var data = res.data.data; |
|||
for (let i = 0; i < data.length; i++) { |
|||
|
|||
if (!data[i].toAlias) { |
|||
if ((data[i].from != address && dataType == 'send') || (data[i] |
|||
.to != address && dataType == 'receive')) { |
|||
continue; |
|||
} |
|||
var transactionData = { |
|||
value: data[i].value, |
|||
from: data[i].from, |
|||
to: data[i].to, |
|||
fee: data[i].fee, |
|||
txid: data[i].txid, |
|||
confirmations: data[i].confirmations, |
|||
block_no: data[i].block_no, |
|||
time: index.formatyymmddhhmmss33(data[i].time * 1000) |
|||
|
|||
} |
|||
if (data[i].from === address) { |
|||
let newaddress = data[i].to; |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length) |
|||
transactionData.address = newaddress; |
|||
transactionData.type = 'out'; |
|||
} else { |
|||
let newaddress = data[i].from; |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length) |
|||
transactionData.address = newaddress; |
|||
|
|||
transactionData.type = 'in'; |
|||
} |
|||
dataList.push(transactionData) |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
success(dataList) |
|||
|
|||
}, |
|||
error: (res) => { |
|||
success(dataList) |
|||
} |
|||
}); |
|||
} else { |
|||
uni.request({ |
|||
url: 'http://scan.weirui0755.com/eth/api/eth/address/tokentrans/' + address + '/' + |
|||
contract + '/' + pageNum + |
|||
'/' + pageSize, //请求接口
|
|||
header: { |
|||
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
|
|||
}, |
|||
success: (res) => { |
|||
console.log(res, 1234654) |
|||
if (res.data.code === 1) { |
|||
var data = res.data.data; |
|||
for (let i = 0; i < data.length; i++) { |
|||
|
|||
if (!data[i].toAlias) { |
|||
|
|||
if ((data[i].from != address && dataType == 'send') || (data[i] |
|||
.to != address && dataType == 'receive')) { |
|||
continue; |
|||
} |
|||
var transactionData = { |
|||
value: data[i].value / Math.pow(10, data[i].tokenDecimals), |
|||
from: data[i].from, |
|||
to: data[i].to, |
|||
txid: data[i].txid, |
|||
fee: data[i].fee, |
|||
confirmations: data[i].conformations, |
|||
block_no: data[i].block_no, |
|||
time: index.formatyymmddhhmmss33(data[i].time * 1000) |
|||
|
|||
} |
|||
if (data[i].from === address) { |
|||
let newaddress = data[i].to; |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length) |
|||
transactionData.address = newaddress; |
|||
transactionData.type = 'out'; |
|||
} else { |
|||
let newaddress = data[i].from; |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length) |
|||
transactionData.address = newaddress; |
|||
|
|||
transactionData.type = 'in'; |
|||
} |
|||
dataList.push(transactionData) |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
success(dataList) |
|||
|
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
, |
|||
trxTransactionData: function(contract, dataType, address, pageNum, pageSize, success) { |
|||
|
|||
let dataList = []; |
|||
let add = address |
|||
if (contract == null || contract == '') { |
|||
uni.request({ |
|||
url: 'http://scan.weirui0755.com/trx/api/trx/address/normal/' + address + '/' + |
|||
pageNum + |
|||
'/' + pageSize, //请求接口
|
|||
header: { |
|||
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
|
|||
}, |
|||
success: (res) => { |
|||
console.log(res.data.code) |
|||
if (res.data.code === 1) { |
|||
var data = res.data.data; |
|||
|
|||
for (let i = 0; i < data.length; i++) { |
|||
|
|||
if ((data[i].from != address && dataType == 'send') || (data[i] |
|||
.to != address && dataType == 'receive') || data[i].tType != |
|||
'Transfer') { |
|||
continue; |
|||
} |
|||
var transactionData = { |
|||
value: data[i].value, |
|||
from: data[i].from, |
|||
to: data[i].to, |
|||
fee: data[i].fee, |
|||
txid: data[i].txid, |
|||
confirmations: data[i].confirmations, |
|||
block_no: data[i].block_no, |
|||
time: index.formatyymmddhhmmss33(data[i].time * 1000) |
|||
|
|||
} |
|||
if (data[i].from === address) { |
|||
var newaddress = data[i].to |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring(newaddress.length-6, |
|||
newaddress.length); |
|||
transactionData.address = newaddress; |
|||
transactionData.type = 'out'; |
|||
} else { |
|||
var newaddress = data[i].from |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring(newaddress.length-6, |
|||
newaddress.length); |
|||
transactionData.address = newaddress; |
|||
|
|||
transactionData.type = 'in'; |
|||
} |
|||
console.log(transactionData.address, 123456) |
|||
dataList.push(transactionData) |
|||
} |
|||
|
|||
|
|||
} |
|||
success(dataList) |
|||
|
|||
} |
|||
}); |
|||
} else { |
|||
uni.request({ |
|||
url: 'http://scan.weirui0755.com/trx/api/trx/address/tokentrans/' + address + '/' + |
|||
contract + '/' + pageNum + |
|||
'/' + pageSize, //请求接口
|
|||
header: { |
|||
'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
|
|||
}, |
|||
success: (res) => { |
|||
console.log(res, 12346545555) |
|||
console.log(dataType, 5555555555) |
|||
if (res.data.code === 1) { |
|||
var data = res.data.data; |
|||
|
|||
for (let i = 0; i < data.length; i++) { |
|||
console.log(!data[i].toAlias, 5555555555,data[i].to == add) |
|||
|
|||
|
|||
if ((data[i].to == add && dataType == 'send') || (data[i] |
|||
.from == add && dataType == 'receive')) { |
|||
continue; |
|||
} |
|||
var transactionData = { |
|||
value: data[i].value / Math.pow(10, data[i].tokenDecimals), |
|||
from: data[i].from, |
|||
to: data[i].to, |
|||
txid: data[i].txid, |
|||
fee: data[i].fee, |
|||
confirmations: data[i].conformations, |
|||
block_no: data[i].block_no, |
|||
time: index.formatyymmddhhmmss33(data[i].time * 1000) |
|||
|
|||
} |
|||
if (data[i].from === address) { |
|||
var newaddress = data[i].to |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length); |
|||
transactionData.address = newaddress; |
|||
transactionData.type = 'out'; |
|||
} else { |
|||
var newaddress = data[i].from |
|||
newaddress = newaddress.substring(0, 6) + '...' + newaddress.substring( |
|||
newaddress.length-6, |
|||
newaddress.length); |
|||
transactionData.address = newaddress; |
|||
|
|||
transactionData.type = 'in'; |
|||
} |
|||
dataList.push(transactionData) |
|||
} |
|||
|
|||
|
|||
} |
|||
success(dataList) |
|||
|
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
} |
|||
export default DataUtil |
Loading…
Reference in new issue