This commit is contained in:
hxhxhx 2025-04-23 14:56:14 +08:00
parent a433467868
commit eefd82d20b
2 changed files with 325 additions and 55 deletions

View File

@ -0,0 +1,234 @@
<template>
<view class="money_detail">
<web-view :webview-styles="webviewStyles" style="visibility: hidden; height: 1px; width: 100%;" src="/static/web3/transfer-web.html" @message="handleWebViewMessage"
:fullscreen="false" :update-title="false"></web-view>
<scroll-view scroll-y="true" class="" style="height: 100%;padding-top: 20rpx;box-sizing: border-box;">
<view v-if="swiperList.length == 0" style="text-align: center; width: 50%;margin: 20rpx auto;color: #fff;">
<view>暫無數據</view>
</view>
<view class="each_content" v-for="(item, index) in swiperList" :key="item.id">
<view class="each_content_left">
<view class="header_money">
<view class="text-green" v-if="item.to == userMoneyAdress">
<text class=" "></text>
<text class="">{{ "+ " + (item.value / 1e18).toFixed(6) + " USDT" }}</text>
</view>
<view class="text-red" v-else>
<text class=" "></text>
<text class="">{{ "- " + (item.value / 1e18).toFixed(6) + " USDT" }}</text>
</view>
</view>
<view class="content_adress">
<view class="text-gray">
收款地址:{{ adressOptions(item.to) }}
</view>
<view class="margin-top-lg">
<image @click="fuzhi(item.to)" src="/static/fizhi.png" style="width: 35rpx;height: 35rpx;">
</image>
</view>
</view>
<view class="content_adress">
<view class="text-gray">
付款地址:{{ adressOptions(item.from) }}
</view>
<view class="margin-top-lg">
<image @click="fuzhi(item.from)" src="/static/fizhi.png"
style="width: 35rpx;height: 35rpx;"></image>
</view>
</view>
</view>
<view class="each_content_right">
<view class="timeBtn">
{{ timeOptions(item.timeStamp * 1000) }}</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
import { _coinlist, _userInfos } from "@/request/api.js"
export default {
data() {
return {
webviewStyles: {
progress: false,
width: "0px",
height: "0px"
},
webviewInstance: null,
userinfo: {},
swiperList: [],
userMoneyAdress: ""
}
},
onReady() {
//
const currentWebview = this.$scope.$getAppWebview();
// web-view
this.webviewInstance = currentWebview.children()[0];
},
onShow() {
this.getUserInfos();
},
methods: {
handleWebViewMessage(event) {
let _that = this;
let obj = event.detail.data;
if (obj.length > 0) {
if (obj[0].status == "success") {
obj[0].transactions.map(item => {
let a = Number(item.value);
if (a > 0) {
_that.swiperList.push(item)
}
})
console.log(_that.swiperList,'ssssaaa')
}
}
},
adressOptions(data) {
let start = data.substring(0, 10);
let end = data.substring(data.length - 4);
let middle = "…";
let finalString = start + middle + end;
return finalString
},
async getUserInfos() {
let res = await _userInfos();
if (res.code === 1) {
this.userinfo = res.data.userinfo;
this.userMoneyAdress = res.data.userinfo.wallet.address;
this.userMoneyAdress = this.userMoneyAdress.toLowerCase();
this.getCoinlist();
}
},
getCoinlist() {
if (this.webviewInstance) {
this.webviewInstance.evalJS(`
getTransactions(${JSON.stringify(this.userinfo.wallet.address)});
`);
}
// uni.request({
// url:'https://nfta.ikiry.com/transactions?address=' + _that.userinfo.wallet.address,
// success(res) {
// let arrayM = res.data;
// arrayM.map(item=>{
// let a = Number(item.value);
// if(a > 0){
// _that.swiperList.push(item)
// }
// })
// },
// fail(err) {
// console.log(err,'err');
// }
// })
},
timeOptions(timestamp) {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
},
fuzhi(e) {
uni.setClipboardData({
data: e,
success: function () {
uni.showToast({
title: '複製成功'
})
}
})
}
}
}
</script>
<style lang="scss" scoped>
.money_detail {
width: 100vw;
height: 100vh;
background: linear-gradient(to bottom, #000033, #51599b);
padding: 20rpx;
box-sizing: border-box;
.each_content {
height: 180rpx;
background-color: #4c5188;
border-radius: 20rpx;
display: flex;
padding: 20rpx;
box-sizing: border-box;
margin-bottom: 30rpx;
color: #fff;
.header_money {
height: calc(100% / 3);
display: flex;
align-items: center;
.text-green {
color: #3eb93b;
font-weight: 700;
}
.text-red {
color: #e54d42;
font-weight: 700;
}
}
.footer_shouy {
width: 60%;
text-align: center;
color: #0081ff;
border: 1px solid skyblue;
border-radius: 30rpx;
font-weight: 700;
font-size: 30rpx;
line-height: 50rpx;
}
.content_adress {
display: flex;
align-items: center;
height: calc(100% / 3);
.text-gray {
width: calc(92% - 35rpx);
font-size: 25rpx;
}
}
.each_content_left {
width: 60%;
height: 100%;
}
.each_content_right {
width: 40%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
.timeBtn {
background: linear-gradient(to right, #8f8f8f, #3e3e3e);
font-size: 25rpx;
border-radius: 40rpx;
color: #fff;
height: 75rpx;
width: 90%;
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
</style>

View File

@ -1,8 +1,9 @@
<template> <template>
<view class="money_detail"> <view class="money_detail">
<web-view :webview-styles="webviewStyles" style="visibility: hidden; height: 1px; width: 100%;" src="/static/web3/transfer-web.html" @message="handleWebViewMessage" <picker :value="selectType" :range="selectData" @change="selectTypeChange" style="height: 60rpx;line-height: 60rpx;">
:fullscreen="false" :update-title="false"></web-view> <view style="color: #fff;">目前選擇{{ selectData[selectType] }}</view>
<scroll-view scroll-y="true" class="" style="height: 100%;padding-top: 20rpx;box-sizing: border-box;"> </picker>
<scroll-view scroll-y="true" class="" style="height: calc(100% - 60rpx);" @scrolltolower="loadMore">
<view v-if="swiperList.length == 0" style="text-align: center; width: 50%;margin: 20rpx auto;color: #fff;"> <view v-if="swiperList.length == 0" style="text-align: center; width: 50%;margin: 20rpx auto;color: #fff;">
<view>暫無數據</view> <view>暫無數據</view>
</view> </view>
@ -11,11 +12,12 @@
<view class="header_money"> <view class="header_money">
<view class="text-green" v-if="item.to == userMoneyAdress"> <view class="text-green" v-if="item.to == userMoneyAdress">
<text class=" "></text> <text class=" "></text>
<text class="">{{ "+ " + (item.value / 1e18).toFixed(6) + " USDT" }}</text> <text class="">{{ "+ " + (item.value / 10 ** 18).toFixed(8) + " " + selectData[selectType] }}</text>
</view> </view>
<view class="text-red" v-else> <view class="text-red" v-else>
<text class=" "></text> <text class=" "></text>
<text class="">{{ "- " + (item.value / 1e18).toFixed(6) + " USDT" }}</text> <text v-if="item.value == 0 && item.functionName">{{ "- " + (Number(item.gasUsed) / Number(item.gasPrice)).toFixed(8) + " " + selectData[selectType] }}</text>
<text v-else>{{ "- " + (item.value / 10 ** 18).toFixed(8) + " " + selectData[selectType] }}</text>
</view> </view>
</view> </view>
<view class="content_adress"> <view class="content_adress">
@ -51,42 +53,22 @@ import { _coinlist, _userInfos } from "@/request/api.js"
export default { export default {
data() { data() {
return { return {
webviewStyles: { selectData:['USDT','BNB','ETH','BTC'],
progress: false, selectType: '0',
width: "0px", contractaddress:"0x55d398326f99059fF775485246999027B3197955",
height: "0px"
},
webviewInstance: null,
userinfo: {}, userinfo: {},
swiperList: [], swiperList: [],
userMoneyAdress: "" userMoneyAdress: "",
page: 1,
offset: 10,
isLoading: false,
hasMore: true
} }
}, },
onReady() { mounted() {
//
const currentWebview = this.$scope.$getAppWebview();
// web-view
this.webviewInstance = currentWebview.children()[0];
},
onShow() {
this.getUserInfos(); this.getUserInfos();
}, },
methods: { methods: {
handleWebViewMessage(event) {
let _that = this;
let obj = event.detail.data;
if (obj.length > 0) {
if (obj[0].status == "success") {
obj[0].transactions.map(item => {
let a = Number(item.value);
if (a > 0) {
_that.swiperList.push(item)
}
})
console.log(_that.swiperList,'ssssaaa')
}
}
},
adressOptions(data) { adressOptions(data) {
let start = data.substring(0, 10); let start = data.substring(0, 10);
let end = data.substring(data.length - 4); let end = data.substring(data.length - 4);
@ -103,27 +85,81 @@ export default {
this.getCoinlist(); this.getCoinlist();
} }
}, },
getCoinlist() { selectTypeChange(selObj){
if (this.webviewInstance) { this.selectType = selObj.detail.value;
this.webviewInstance.evalJS(` switch(this.selectData[this.selectType]){
getTransactions(${JSON.stringify(this.userinfo.wallet.address)}); case 'USDT':
`); this.contractaddress = '0x55d398326f99059fF775485246999027B3197955';
break;
case 'BNB':
this.contractaddress = '';
break;
case 'ETH':
this.contractaddress = '0x2170ed0880ac9a755fd29b2688956bd959f933f8';
break;
case 'BTC':
this.contractaddress = '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c';
break;
}
this.swiperList = [];
this.getCoinlist();
},
getCoinlist() {
if (this.isLoading || !this.hasMore) return;
this.isLoading = true;
uni.showLoading({
mask:true,
title: "載入中..."
})
let _that = this;
let params = {
module: 'account',
apikey: '1UQ3PHID4UJUDTVD4EJK35PZB8XDKS7K9T',
sort: 'desc',
address: _that.userMoneyAdress,
page: _that.page,
offset: _that.offset,
};
if (_that.contractaddress && _that.contractaddress != '') {
params.action = 'tokentx';
params.contractaddress = _that.contractaddress;
} else {
params.action = 'txlist';
}
uni.request({
url:'https://api.bscscan.com/api',
data: params,
success(res) {
if(res.data.status == 1){
const newData = res.data.result;
if (newData.length < _that.offset) {
_that.hasMore = false;
}
if (_that.page === 1) {
_that.swiperList = newData;
} else {
_that.swiperList = [..._that.swiperList, ...newData];
}
}
},
fail(err) {
console.log(err,'err');
uni.showToast({
title: '加载失败',
icon: 'none'
});
},
complete() {
_that.isLoading = false;
uni.hideLoading();
}
})
},
loadMore() {
if (this.hasMore && !this.isLoading) {
this.page += 1;
this.getCoinlist();
} }
// uni.request({
// url:'https://nfta.ikiry.com/transactions?address=' + _that.userinfo.wallet.address,
// success(res) {
// let arrayM = res.data;
// arrayM.map(item=>{
// let a = Number(item.value);
// if(a > 0){
// _that.swiperList.push(item)
// }
// })
// },
// fail(err) {
// console.log(err,'err');
// }
// })
}, },
timeOptions(timestamp) { timeOptions(timestamp) {
const date = new Date(timestamp); const date = new Date(timestamp);
@ -153,7 +189,7 @@ export default {
.money_detail { .money_detail {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: linear-gradient(to bottom, #000033, #51599b); background: #000033;
padding: 20rpx; padding: 20rpx;
box-sizing: border-box; box-sizing: border-box;