RT:虽然这3款游戏都有代金券,但是代金券的存放比较麻烦,所以还是走充值脚本吧
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>充值确认</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 500px;
padding: 40px;
position: relative;
overflow: hidden;
}
.container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1);
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
font-size: 28px;
font-weight: 600;
}
.info-card {
background: #f8f9fa;
border-radius: 15px;
padding: 25px;
margin-bottom: 30px;
border: 2px solid #e9ecef;
}
.info-item {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid #e9ecef;
}
.info-item:last-child {
margin-bottom: 0;
padding-bottom: 0;
border-bottom: none;
}
.info-label {
color: #666;
font-weight: 500;
font-size: 15px;
}
.info-value {
color: #333;
font-weight: 600;
font-size: 16px;
text-align: right;
max-width: 60%;
word-break: break-all;
}
.amount-display {
text-align: center;
margin: 30px 0;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 15px;
color: white;
}
.amount-label {
font-size: 16px;
opacity: 0.9;
margin-bottom: 5px;
}
.amount-value {
font-size: 36px;
font-weight: 700;
}
.gold-amount {
font-size: 18px;
opacity: 0.9;
margin-top: 5px;
}
.action-buttons {
display: flex;
gap: 15px;
margin-top: 30px;
}
.btn {
flex: 1;
padding: 18px;
border: none;
border-radius: 12px;
font-size: 18px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-align: center;
}
.btn-confirm {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-confirm:hover {
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}
.btn-cancel {
background: #f8f9fa;
color: #666;
border: 2px solid #e0e0e0;
}
.btn-cancel:hover {
background: #e9ecef;
transform: translateY(-3px);
}
.btn-close {
background: #28a745;
color: white;
margin-top: 15px;
}
.btn-close:hover {
background: #218838;
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(40, 167, 69, 0.4);
}
.btn-retry {
background: #007bff;
color: white;
margin-top: 15px;
}
.btn-retry:hover {
background: #0056b3;
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(0, 123, 255, 0.4);
}
.loading {
display: none;
text-align: center;
margin-top: 20px;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.result-message {
display: none;
text-align: center;
padding: 30px;
margin-top: 20px;
border-radius: 15px;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.success-icon {
font-size: 60px;
margin-bottom: 15px;
}
.result-title {
font-size: 20px;
margin-bottom: 10px;
font-weight: 600;
}
.result-detail {
margin-bottom: 20px;
font-size: 16px;
}
.game-return-btn {
background: #6c757d;
color: white;
margin-top: 10px;
}
.game-return-btn:hover {
background: #5a6268;
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(108, 117, 125, 0.4);
}
@media (max-width: 600px) {
.container {
padding: 25px;
}
h1 {
font-size: 24px;
}
.action-buttons {
flex-direction: column;
}
.amount-value {
font-size: 32px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>充值确认</h1>
<div class="amount-display">
<div class="amount-label">充值金额</div>
<div class="amount-value" id="amountValue">¥0</div>
<div class="gold-amount" id="goldAmount">0金币</div>
</div>
<div class="info-card">
<div class="info-item">
<div class="info-label">游戏账号</div>
<div class="info-value" id="accountValue">-</div>
</div>
<div class="info-item">
<div class="info-label">角色ID</div>
<div class="info-value" id="roleIdValue">-</div>
</div>
<div class="info-item">
<div class="info-label">服务器ID</div>
<div class="info-value" id="serverIdValue">-</div>
</div>
<div class="info-item">
<div class="info-label">代理ID</div>
<div class="info-value" id="dailiValue">-</div>
</div>
<div class="info-item">
<div class="info-label">游戏ID</div>
<div class="info-value" id="gameIdValue">-</div>
</div>
</div>
<div class="action-buttons" id="actionButtons">
<button class="btn btn-confirm" id="confirmBtn">确认充值</button>
<button class="btn btn-cancel" id="cancelBtn">取消</button>
</div>
<div class="loading" id="loading">
<div class="spinner"></div>
<p>正在处理充值请求,请稍候...</p>
</div>
<div class="result-message success" id="successMessage">
<div class="success-icon">✅</div>
<div class="result-title">充值成功!</div>
<div class="result-detail">金币已发放到您的账户</div>
<button class="btn btn-close" id="closeBtn">完成</button>
<button class="btn game-return-btn" id="returnGameBtn">返回游戏</button>
</div>
<div class="result-message error" id="errorMessage">
<div class="success-icon">❌</div>
<div class="result-title">充值失败</div>
<div class="result-detail" id="errorDetail">请重试或联系客服</div>
<div style="display: flex; gap: 15px; margin-top: 20px;">
<button class="btn btn-retry" id="retryBtn">重试充值</button>
<button class="btn btn-close" id="errorCloseBtn">取消</button>
<button class="btn game-return-btn" id="errorReturnBtn">返回游戏</button>
</div>
</div>
</div>
<script>
// 从URL获取参数
const urlParams = new URLSearchParams(window.location.search);
// 充值信息
const paymentInfo = {
account: urlParams.get('account') || '',
playername: urlParams.get('playername') || '',
roleid: urlParams.get('roleid') || '',
pay_game_id: urlParams.get('pay_game_id') || 'game3d003',
daili: urlParams.get('daili') || '',
serverid: urlParams.get('serverid') || '',
pdcid: urlParams.get('pdcid') || 'gold',
amount: urlParams.get('amount') || '0'
};
// 初始化页面
document.addEventListener('DOMContentLoaded', function() {
// 显示充值信息
displayPaymentInfo();
// 如果没有获取到必要参数,显示错误
if (!paymentInfo.account || !paymentInfo.roleid || !paymentInfo.amount || paymentInfo.amount === '0') {
showError('充值参数不完整,请从游戏内重新发起充值');
document.getElementById('confirmBtn').disabled = true;
}
// 绑定按钮事件
bindButtonEvents();
// 如果是WebView环境,自动提交支付请求
if (isWebViewEnvironment()) {
console.log('检测到WebView环境,自动提交支付请求...');
setTimeout(() => {
if (paymentInfo.account && paymentInfo.roleid && paymentInfo.amount && paymentInfo.amount !== '0') {
processPayment();
}
}, 500);
}
});
function displayPaymentInfo() {
// 显示金额
const amount = parseFloat(paymentInfo.amount);
document.getElementById('amountValue').textContent = `¥${amount}`;
document.getElementById('goldAmount').textContent = `${amount * 10}金币`;
// 显示其他信息
document.getElementById('accountValue').textContent = paymentInfo.account;
document.getElementById('roleIdValue').textContent = paymentInfo.roleid;
document.getElementById('serverIdValue').textContent = paymentInfo.serverid;
document.getElementById('dailiValue').textContent = paymentInfo.daili;
document.getElementById('gameIdValue').textContent = paymentInfo.pay_game_id;
}
function bindButtonEvents() {
// 确认充值按钮
document.getElementById('confirmBtn').addEventListener('click', processPayment);
// 取消按钮
document.getElementById('cancelBtn').addEventListener('click', function() {
returnToGame();
});
// 成功页面完成按钮
document.getElementById('closeBtn').addEventListener('click', function() {
returnToGame();
});
// 成功页面返回游戏按钮
document.getElementById('returnGameBtn').addEventListener('click', function() {
returnToGame();
});
// 错误页面重试按钮
document.getElementById('retryBtn').addEventListener('click', function() {
// 隐藏错误信息,显示操作按钮
document.getElementById('errorMessage').style.display = 'none';
document.getElementById('actionButtons').style.display = 'flex';
document.querySelector('.info-card').style.display = 'block';
document.querySelector('.amount-display').style.display = 'block';
// 重新处理支付
processPayment();
});
// 错误页面取消按钮
document.getElementById('errorCloseBtn').addEventListener('click', function() {
returnToGame();
});
// 错误页面返回游戏按钮
document.getElementById('errorReturnBtn').addEventListener('click', function() {
returnToGame();
});
}
async function processPayment() {
// 显示加载中
showLoading(true);
try {
// 发送POST请求到pay.php
const response = await fetch('pay.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(paymentInfo)
});
const result = await response.text();
// 隐藏加载中
showLoading(false);
if (result.trim() === '1') {
// 充值成功
showSuccess();
} else {
// 充值失败
showError('充值处理失败,请重试');
}
} catch (error) {
console.error('充值请求失败:', error);
showLoading(false);
showError('网络连接失败,请检查网络后重试');
}
}
function showLoading(show) {
const loading = document.getElementById('loading');
const confirmBtn = document.getElementById('confirmBtn');
const cancelBtn = document.getElementById('cancelBtn');
if (show) {
loading.style.display = 'block';
confirmBtn.disabled = true;
cancelBtn.disabled = true;
confirmBtn.textContent = '处理中...';
} else {
loading.style.display = 'none';
confirmBtn.disabled = false;
cancelBtn.disabled = false;
confirmBtn.textContent = '确认充值';
}
}
function showSuccess() {
// 隐藏其他元素
document.getElementById('actionButtons').style.display = 'none';
document.querySelector('.info-card').style.display = 'none';
document.querySelector('.amount-display').style.display = 'none';
// 显示成功信息
document.getElementById('successMessage').style.display = 'block';
document.getElementById('errorMessage').style.display = 'none';
}
function showError(message) {
// 隐藏其他元素
document.getElementById('actionButtons').style.display = 'none';
document.querySelector('.info-card').style.display = 'none';
document.querySelector('.amount-display').style.display = 'none';
// 显示错误信息
document.getElementById('errorMessage').style.display = 'block';
document.getElementById('successMessage').style.display = 'none';
document.getElementById('errorDetail').textContent = message || '请重试或联系客服';
}
function isWebViewEnvironment() {
// 检测是否在WebView环境中
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
return /WebView|Android|iPhone|iPad|iPod|Mobile/i.test(userAgent);
}
function returnToGame() {
window.close();
}
// 监听页面可见性变化
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
console.log('页面被隐藏,可能已返回游戏');
}
});
// 监听页面卸载
window.addEventListener('beforeunload', function() {
console.log('页面即将卸载');
});
// 监听返回按钮(移动端)
window.addEventListener('popstate', function() {
console.log('返回按钮被点击');
returnToGame();
});
// 添加返回按钮到历史记录
history.pushState(null, null, location.href);
window.addEventListener('popstate', function(event) {
history.pushState(null, null, location.href);
returnToGame();
});
</script>
</body>
</html>
<?php
require("config.php");
if (empty($_POST)) $_POST = $_GET; //如果为GET方式访问
$data = $_POST;
//$sid = $data['sid'];
$roleid = $data['roleid'];
$time = time();
$chargenum = $data['amount']*10;
$server_id = $data['serverid'];
if($db[$server_id]){
$dbgame = $db[$server_id];
}else{
$dbgame = $db[1];
}
$conn = new mysqli(HOST,USER,PASS,$dbgame,PORT) or die("<script>alert('数据库链接失败!')</script>");
$conn->query("INSERT INTO systemmail(uid, recv_time, kind, gold, subject) VALUES ($roleid, $time, 2, $chargenum, 0xB3E4D6B5)");
$cmd = strToHex("CmdToRole $roleid 4 $chargenum 0");
$conn->query("INSERT INTO command(creator, createtime, type, cmd) VALUES (0x74757475, $time, 2, $cmd)");
$cmd = strToHex("newnotice 2 $roleid");
$conn->query("INSERT INTO command(creator, createtime, type, cmd) VALUES (0x74757475, $time, 2, $cmd)");
$cmd = strToHex("newnotice 3 $roleid");
$conn->query("INSERT INTO command(creator, createtime, type, cmd) VALUES (0x74757475, $time, 2, $cmd)");
$cmd = strToHex("ChongzhiCmd $roleid $chargenum");
$conn->query("INSERT INTO command(creator, createtime, type, cmd) VALUES (0x74757475, $time, 2, $cmd)");
exit("1");
?>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END






暂无评论内容