loading

Loading

首页 TronLink钱包

使用PHP+CSS+JS+HTML5+JSON构建TronLink风格钱包(无MySQL)

字数: (12063)
阅读: (6)
0

使用PHP+CSS+JS+HTML5+JSON构建TronLink风格钱包(无MySQL)

本文将介绍如何使用纯前端技术构建一个TronLink风格的数字钱包界面,不依赖MySQL数据库,完全基于PHP、CSS、JavaScript、HTML5和JSON实现。

项目概述

这个钱包应用将实现以下功能:
1.钱包创建/导入
2.余额显示
3.交易记录
4.发送TRX功能(模拟)
5.响应式设计适配各种设备

目录结构

/tronlink-wallet/
├──index.php主入口文件
├──assets/
│├──css/
││└──style.css样式文件
│├──js/
││└──app.js主JavaScript文件
│└──img/图片资源
├──data/JSON数据存储
│└──wallets.json钱包数据存储
└──api/PHPAPI端点
├──create.php创建钱包
├──send.php发送交易
└──balance.php获取余额

实现代码

1.index.php(主页面)

<?php
//检查是否有已保存的钱包
$hasWallet=false;
if(file_exists('data/wallets.json')){
$wallets=json_decode(file_get_contents('data/wallets.json'),true);
$hasWallet=!empty($wallets);
}
?>
<!DOCTYPEhtml>
<htmllang="zh-CN">
<head>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width,initial-scale=1.0">
<title>TronLink风格钱包-轻量级TRX钱包</title>
<metaname="description"content="一个轻量级的TronLink风格钱包,无需数据库,使用PHP和JavaScript构建">
<metaname="keywords"content="TronLink,TRX钱包,波场钱包,数字货币钱包">
<linkrel="stylesheet"href="assets/css/style.css">
<linkrel="icon"href="assets/img/favicon.ico"type="image/x-icon">
</head>
<body>
<divclass="app-container">
<headerclass="app-header">
<divclass="logo">
<imgsrc="assets/img/logo.png"alt="TronLinkWallet">
<h1>TronLinkLite</h1>
</div>
<divclass="network-indicator">
<spanclass="dot"></span>
<span>Mainnet</span>
</div>
</header>

<mainclass="app-main">
<?phpif(!$hasWallet):?>
<divclass="welcome-screen"id="welcomeScreen">
<h2>欢迎使用TronLinkLite</h2>
<p>一个轻量级的TRX钱包解决方案</p>
<divclass="action-buttons">
<buttonid="createWalletBtn"class="btn-primary">创建新钱包</button>
<buttonid="importWalletBtn"class="btn-secondary">导入钱包</button>
</div>
<divclass="disclaimer">
<p>请妥善保管您的私钥,我们不会存储您的任何敏感信息。</p>
</div>
</div>

<divclass="create-wallet-form"id="createWalletForm"style="display:none;">
<h3>创建新钱包</h3>
<divclass="form-group">
<labelfor="walletPassword">设置密码</label>
<inputtype="password"id="walletPassword"placeholder="至少8位字符">
</div>
<divclass="form-group">
<labelfor="confirmPassword">确认密码</label>
<inputtype="password"id="confirmPassword"placeholder="再次输入密码">
</div>
<buttonid="generateWalletBtn"class="btn-primary">生成钱包</button>
<buttonid="backToWelcomeBtn"class="btn-secondary">返回</button>
</div>

<divclass="import-wallet-form"id="importWalletForm"style="display:none;">
<h3>导入钱包</h3>
<divclass="form-group">
<labelfor="privateKey">私钥</label>
<textareaid="privateKey"placeholder="输入您的TRX钱包私钥"></textarea>
</div>
<divclass="form-group">
<labelfor="importPassword">设置密码</label>
<inputtype="password"id="importPassword"placeholder="至少8位字符">
</div>
<buttonid="importWalletSubmitBtn"class="btn-primary">导入钱包</button>
<buttonid="backToWelcomeBtn2"class="btn-secondary">返回</button>
</div>
<?phpelse:?>
<divclass="wallet-dashboard"id="walletDashboard">
<divclass="wallet-overview">
<divclass="wallet-address">
<spanclass="label">钱包地址:</span>
<spanid="walletAddressDisplay"><?phpechosubstr($wallets[0]['address'],0,6).'...'.substr($wallets[0]['address'],-4);?></span>
<buttonid="copyAddressBtn"class="btn-icon">
<imgsrc="assets/img/copy-icon.png"alt="复制">
</button>
</div>
<divclass="wallet-balance">
<spanclass="label">余额:</span>
<spanid="walletBalance">0TRX</span>
</div>
</div>

<divclass="wallet-actions">
<buttonid="sendTrxBtn"class="btn-action">
<imgsrc="assets/img/send-icon.png"alt="发送">
<span>发送</span>
</button>
<buttonid="receiveTrxBtn"class="btn-action">
<imgsrc="assets/img/receive-icon.png"alt="接收">
<span>接收</span>
</button>
<buttonid="historyBtn"class="btn-action">
<imgsrc="assets/img/history-icon.png"alt="历史">
<span>历史</span>
</button>
</div>

<divclass="transaction-form"id="sendTrxForm"style="display:none;">
<h3>发送TRX</h3>
<divclass="form-group">
<labelfor="recipientAddress">接收地址</label>
<inputtype="text"id="recipientAddress"placeholder="输入TRX地址">
</div>
<divclass="form-group">
<labelfor="sendAmount">数量(TRX)</label>
<inputtype="number"id="sendAmount"placeholder="0.00">
</div>
<divclass="form-group">
<labelfor="sendPassword">密码</label>
<inputtype="password"id="sendPassword"placeholder="输入钱包密码">
</div>
<divclass="form-actions">
<buttonid="confirmSendBtn"class="btn-primary">确认发送</button>
<buttonid="cancelSendBtn"class="btn-secondary">取消</button>
</div>
</div>

<divclass="receive-qr"id="receiveQr"style="display:none;">
<h3>接收TRX</h3>
<divclass="qr-code-placeholder"id="qrCode"></div>
<divclass="wallet-address-full">
<?phpecho$wallets[0]['address'];?>
</div>
<buttonid="copyFullAddressBtn"class="btn-primary">复制地址</button>
<buttonid="closeReceiveBtn"class="btn-secondary">关闭</button>
</div>

<divclass="transaction-history"id="transactionHistory"style="display:none;">
<h3>交易记录</h3>
<divclass="history-list"id="historyList">
<!--交易记录将通过JS动态加载-->
</div>
<buttonid="closeHistoryBtn"class="btn-secondary">返回</button>
</div>
</div>
<?phpendif;?>
</main>

<footerclass="app-footer">
<p>TronLinkLite&copy;<?phpechodate('Y');?>-轻量级TRX钱包</p>
<pclass="disclaimer">免责声明:这是一个演示项目,不应用于存储真实资产</p>
</footer>
</div>

<divclass="modal"id="successModal"style="display:none;">
<divclass="modal-content">
<spanclass="close-modal">&times;</span>
<divclass="modal-iconsuccess">
<imgsrc="assets/img/success-icon.png"alt="成功">
</div>
<h3id="modalTitle">操作成功</h3>
<pid="modalMessage">您的操作已成功完成</p>
<buttonid="modalConfirmBtn"class="btn-primary">确定</button>
</div>
</div>

<divclass="modal"id="errorModal"style="display:none;">
<divclass="modal-content">
<spanclass="close-modal">&times;</span>
<divclass="modal-iconerror">
<imgsrc="assets/img/error-icon.png"alt="错误">
</div>
<h3id="errorModalTitle">发生错误</h3>
<pid="errorModalMessage">操作未能完成</p>
<buttonid="errorModalConfirmBtn"class="btn-primary">确定</button>
</div>
</div>

<scriptsrc="assets/js/app.js"></script>
<scriptsrc="https://cdn.jsdelivr.net/npm/[email protected]/build/qrcode.min.js"></script>
</body>
</html>

2.style.css(样式文件)


/基础样式/
:root{
--primary-color:2e86de;
--secondary-color:54a0ff;
--success-color:26de81;
--danger-color:fc5c65;
--warning-color:f39c12;
--dark-color:2c3e50;
--light-color:ecf0f1;
--gray-color:95a5a6;
--white-color:ffffff;
--black-color:000000;
}

{
margin:0;
padding:0;
box-sizing:border-box;
font-family:'Arial',sans-serif;
}

body{
background-color:f5f6fa;
color:var(--dark-color);
line-height:1.6;
}

.app-container{
max-width:450px;
margin:0auto;
background-color:var(--white-color);
min-height:100vh;
box-shadow:0020pxrgba(0,0,0,0.1);
position:relative;
overflow-x:hidden;
}

/头部样式/
.app-header{
background-color:var(--primary-color);
color:var(--white-color);
padding:15px20px;
display:flex;
justify-content:space-between;
align-items:center;
}

.logo{
display:flex;
align-items:center;
}

.logoimg{
width:30px;
height:30px;
margin-right:10px;
}

.logoh1{
font-size:18px;
font-weight:600;
}

.network-indicator{
display:flex;
align-items:center;
font-size:14px;
}

.network-indicator.dot{
width:8px;
height:8px;
background-color:var(--success-color);
border-radius:50%;
margin-right:5px;
}

/主内容区/
.app-main{
padding:20px;
}

/欢迎屏幕/
.welcome-screen{
text-align:center;
padding:40px20px;
}

.welcome-screenh2{
font-size:24px;
margin-bottom:10px;
color:var(--primary-color);
}

.welcome-screenp{
color:var(--gray-color);
margin-bottom:30px;
}

.action-buttons{
display:flex;
flex-direction:column;
gap:15px;
margin-bottom:30px;
}

.btn-primary{
background-color:var(--primary-color);
color:var(--white-color);
border:none;
padding:12px20px;
border-radius:5px;
font-size:16px;
font-weight:600;
cursor:pointer;
transition:background-color0.3s;
}

.btn-primary:hover{
background-color:var(--secondary-color);
}

.btn-secondary{
background-color:var(--white-color);
color:var(--primary-color);
border:1pxsolidvar(--primary-color);
padding:12px20px;
border-radius:5px;
font-size:16px;
font-weight:600;
cursor:pointer;
transition:all0.3s;
}

.btn-secondary:hover{
background-color:f0f8ff;
}

.disclaimer{
font-size:12px;
color:var(--gray-color);
margin-top:30px;
}

/表单样式/
.create-wallet-form,
.import-wallet-form,
.transaction-form,
.receive-qr,
.transaction-history{
animation:fadeIn0.3sease-in-out;
}

@keyframesfadeIn{
from{opacity:0;transform:translateY(10px);}
to{opacity:1;transform:translateY(0);}
}

.form-group{
margin-bottom:20px;
}

.form-grouplabel{
display:block;
margin-bottom:8px;
font-weight:600;
color:var(--dark-color);
}

.form-groupinput,
.form-grouptextarea{
width:100%;
padding:12px15px;
border:1pxsolidddd;
border-radius:5px;
font-size:16px;
transition:border-color0.3s;
}

.form-groupinput:focus,
.form-grouptextarea:focus{
border-color:var(--primary-color);
outline:none;
}

.form-grouptextarea{
min-height:100px;
resize:vertical;
}

.form-actions{
display:flex;
gap:15px;
margin-top:20px;
}

/钱包仪表盘/
.wallet-dashboard{
display:flex;
flex-direction:column;
gap:20px;
}

.wallet-overview{
background-color:f8f9fa;
padding:20px;
border-radius:10px;
box-shadow:02px10pxrgba(0,0,0,0.05);
}

.wallet-address,
.wallet-balance{
display:flex;
align-items:center;
margin-bottom:15px;
}

.wallet-address.label,
.wallet-balance.label{
font-weight:600;
margin-right:10px;
}

.wallet-actions{
display:grid;
grid-template-columns:repeat(3,1fr);
gap:15px;
margin-bottom:20px;
}

.btn-action{
background-color:var(--white-color);
border:1pxsolidddd;
border-radius:8px;
padding:15px10px;
display:flex;
flex-direction:column;
align-items:center;
cursor:pointer;
transition:all0.3s;
}

.btn-action:hover{
background-color:f0f8ff;
border-color:var(--primary-color);
}

.btn-actionimg{
width:24px;
height:24px;
margin-bottom:5px;
}

.btn-actionspan{
font-size:14px;
color:var(--dark-color);
}

.btn-icon{
background:none;
border:none;
cursor:pointer;
padding:5px;
margin-left:10px;
}

.btn-iconimg{
width:16px;
height:16px;
}

/接收QR码/
.receive-qr{
text-align:center;
padding:20px;
}

.qr-code-placeholder{
width:200px;
height:200px;
margin:0auto20px;
background-color:var(--light-color);
display:flex;
align-items:center;
justify-content:center;
border-radius:5px;
}

.wallet-address-full{
word-break:break-all;
font-family:monospace;
margin:20px0;
padding:10px;
background-color:f8f9fa;
border-radius:5px;
}

/交易历史/
.transaction-history{
padding:20px;
}

.history-list{
margin:20px0;
}

.history-item{
display:flex;
justify-content:space-between;
padding:15px0;
border-bottom:1pxsolideee;
}

.history-item:last-child{
border-bottom:none;
}

.history-type{
display:flex;
align-items:center;
}

.history-typeimg{
width:20px;
height:20px;
margin-right:10px;
}

.history-details{
text-align:right;
}

.history-amount{
font-weight:600;
}

.history-date{
font-size:12px;
color:var(--gray-color);
}

/模态框/
.modal{
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background-color:rgba(0,0,0,0.5);
display:flex;
align-items:center;
justify-content:center;
z-index:1000;
animation:fadeIn0.3sease-in-out;
}

.modal-content{
background-color:var(--white-color);
padding:30px;
border-radius:10px;
width:

转载请注明出处: TronLink官网下载-TRON-TRX-波场-波比-波币-波宝|官网-钱包-苹果APP|安卓-APP-下载

本文的链接地址: https://tianjinfa.org/post/3281


扫描二维码,在手机上阅读


    TronLink TronLink 官网 TronLink 下载 TronLink 钱包 波场 TRON TRX 波币 波比 波宝 波场钱包 苹果 APP 下载 安卓 APP 下载 数字货币钱包 区块链钱包 去中心化钱包 数字资产管理 加密货币存储 波场生态 TRC-20 代币 TRC-10 代币 波场 DApp 波场智能合约 钱包安全 私钥管理 钱包备份 钱包恢复 多账户管理 代币转账 波场超级代表 波场节点 波场跨链 波场 DeFi 波场 NFT 波场测试网 波场开发者 钱包教程 新手入门 钱包使用指南 波场交易手续费 波场价格 波场行情 波场生态合作 波场应用 波场质押 波场挖矿 波场冷钱包 硬件钱包连接 波场钱包对比 波场钱包更新 波场链上数据 TronLink 官网下载 TronLink 安卓 APP TronLink 苹果 APP TRON 区块链 TRX 下载 TRX 交易 波场官方 波场钱包下载 波比钱包 波币官网 波宝钱包 APP 波宝钱包下载 波场 TRC20 代币 波场 TRC10 代币 波场 TRC721 代币 波场 DApp 浏览器 波场去中心化应用 TronLink 钱包安全 TronLink 钱包教程 TronLink 私钥管理 TronLink 多账户管理 TronLink 交易手续费 波场超级代表投票 波场去中心化存储 波场跨链交易 波场 DeFi 应用 波场 NFT 市场 波场质押挖矿 波场钱包备份 波场钱包恢复 波场硬件钱包连接 波场开发者工具 波场节点搭建 波场钱包使用指南 波场代币转账 波场钱包创建 波场钱包导入 波场 DApp 推荐 波场 TRX 价格走势 波场生态发展 TronLink 钱包更新 波场链上数据查询 波场钱包安全防护 波场钱包对比评测 TronLink钱包下载