5 changed files with 267 additions and 22 deletions
@ -0,0 +1,222 @@ |
|||||
|
import index from './index.js' |
||||
|
let DataUtil = { |
||||
|
transactionData: function(type, dataType, address, contract, pageNum, pageSize, success) { |
||||
|
|
||||
|
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) { |
||||
|
transactionData.address = data[i].to; |
||||
|
transactionData.type = 'out'; |
||||
|
} else { |
||||
|
transactionData.address = data[i].from; |
||||
|
transactionData.type = 'in'; |
||||
|
} |
||||
|
dataList.push(transactionData) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
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) { |
||||
|
transactionData.address = data[i].to; |
||||
|
transactionData.type = 'out'; |
||||
|
} else { |
||||
|
transactionData.address = data[i].from; |
||||
|
transactionData.type = 'in'; |
||||
|
} |
||||
|
dataList.push(transactionData) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
success(dataList) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
, |
||||
|
trxTransactionData: function(contract, dataType, address, pageNum, pageSize, success) { |
||||
|
let dataList = []; |
||||
|
if (!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, 1234654) |
||||
|
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')) { |
||||
|
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) { |
||||
|
transactionData.address = data[i].to; |
||||
|
transactionData.type = 'out'; |
||||
|
} else { |
||||
|
transactionData.address = data[i].from; |
||||
|
transactionData.type = 'in'; |
||||
|
} |
||||
|
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, 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) { |
||||
|
transactionData.address = data[i].to; |
||||
|
transactionData.type = 'out'; |
||||
|
} else { |
||||
|
transactionData.address = data[i].from; |
||||
|
transactionData.type = 'in'; |
||||
|
} |
||||
|
dataList.push(transactionData) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
success(dataList) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
export default DataUtil |
@ -0,0 +1,11 @@ |
|||||
|
let isTest = true; |
||||
|
|
||||
|
const constant = isTest ? { |
||||
|
btcDataUrl:'' |
||||
|
}:{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
export default { |
||||
|
constant |
||||
|
} |
Loading…
Reference in new issue