1.优化充值跳转链接的问题
This commit is contained in:
@@ -46,6 +46,10 @@ AUTH_TOKEN_SECRET =
|
|||||||
# 示例:H5_WEBSOCKET_URL = wss://zihua-api.h55555game.top/ws/
|
# 示例:H5_WEBSOCKET_URL = wss://zihua-api.h55555game.top/ws/
|
||||||
H5_WEBSOCKET_URL = wss://zihua-api.h55555game.top/ws/
|
H5_WEBSOCKET_URL = wss://zihua-api.h55555game.top/ws/
|
||||||
|
|
||||||
|
# H5 前端游戏页地址(模拟充值完成后「返回游戏」在当前窗口跳转;无尾斜杠)
|
||||||
|
# 示例:H5_GAME_URL = http://127.0.0.1:5173
|
||||||
|
H5_GAME_URL = https://zihua-game.h55555game.top/
|
||||||
|
|
||||||
# 充值支付渠道:在代码注册表之外追加渠道(JSON 数组,每项含 code / name / name_en / sort)
|
# 充值支付渠道:在代码注册表之外追加渠道(JSON 数组,每项含 code / name / name_en / sort)
|
||||||
# 当前代码注册表仅内置 ddpay;一般无需再追加。示例:DEPOSIT_CHANNELS_REGISTRY_JSON =
|
# 当前代码注册表仅内置 ddpay;一般无需再追加。示例:DEPOSIT_CHANNELS_REGISTRY_JSON =
|
||||||
DEPOSIT_CHANNELS_REGISTRY_JSON =
|
DEPOSIT_CHANNELS_REGISTRY_JSON =
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ class Finance extends MobileBase
|
|||||||
$remaining = $expireAt > $now ? ($expireAt - $now) : 0;
|
$remaining = $expireAt > $now ? ($expireAt - $now) : 0;
|
||||||
$canPay = $statusCode === 0 && DepositOrderExpireService::isPendingPaymentValid($row) && $remaining > 0;
|
$canPay = $statusCode === 0 && DepositOrderExpireService::isPendingPaymentValid($row) && $remaining > 0;
|
||||||
|
|
||||||
return $this->mobileSuccess([
|
return $this->mobileSuccess($this->attachMockDepositReturnGameUrl([
|
||||||
'order_no' => $orderNo,
|
'order_no' => $orderNo,
|
||||||
'amount' => $this->amountNumber($amount),
|
'amount' => $this->amountNumber($amount),
|
||||||
'bonus_amount' => $this->amountNumber($bonus),
|
'bonus_amount' => $this->amountNumber($bonus),
|
||||||
@@ -475,7 +475,7 @@ class Finance extends MobileBase
|
|||||||
'reject_reason' => is_string($row['reject_reason'] ?? null) && trim($row['reject_reason']) !== ''
|
'reject_reason' => is_string($row['reject_reason'] ?? null) && trim($row['reject_reason']) !== ''
|
||||||
? trim($row['reject_reason'])
|
? trim($row['reject_reason'])
|
||||||
: null,
|
: null,
|
||||||
]);
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -563,13 +563,13 @@ class Finance extends MobileBase
|
|||||||
$status = is_numeric($row['status'] ?? null) ? intval($row['status']) : -1;
|
$status = is_numeric($row['status'] ?? null) ? intval($row['status']) : -1;
|
||||||
if ($status === 1) {
|
if ($status === 1) {
|
||||||
$order = DepositOrder::where('order_no', $orderNo)->find();
|
$order = DepositOrder::where('order_no', $orderNo)->find();
|
||||||
$payload = $this->buildDepositResponse($order, null);
|
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
|
||||||
$payload['review_required'] = false;
|
$payload['review_required'] = false;
|
||||||
return ['error' => null, 'payload' => $payload];
|
return ['error' => null, 'payload' => $payload];
|
||||||
}
|
}
|
||||||
if ($status === MockPay::DEPOSIT_STATUS_PENDING_REVIEW) {
|
if ($status === MockPay::DEPOSIT_STATUS_PENDING_REVIEW) {
|
||||||
$order = DepositOrder::where('order_no', $orderNo)->find();
|
$order = DepositOrder::where('order_no', $orderNo)->find();
|
||||||
$payload = $this->buildDepositResponse($order, null);
|
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
|
||||||
$payload['review_required'] = true;
|
$payload['review_required'] = true;
|
||||||
return ['error' => null, 'payload' => $payload];
|
return ['error' => null, 'payload' => $payload];
|
||||||
}
|
}
|
||||||
@@ -608,7 +608,7 @@ class Finance extends MobileBase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$order = DepositOrder::where('id', $orderId)->find();
|
$order = DepositOrder::where('id', $orderId)->find();
|
||||||
$payload = $this->buildDepositResponse($order, null);
|
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
|
||||||
$payload['review_required'] = true;
|
$payload['review_required'] = true;
|
||||||
$payload['mock_pay_success'] = true;
|
$payload['mock_pay_success'] = true;
|
||||||
$payload['mock_pay_message'] = 'Payment submitted. Pending admin review.';
|
$payload['mock_pay_message'] = 'Payment submitted. Pending admin review.';
|
||||||
@@ -616,6 +616,21 @@ class Finance extends MobileBase
|
|||||||
return ['error' => null, 'payload' => $payload];
|
return ['error' => null, 'payload' => $payload];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function attachMockDepositReturnGameUrl(array $payload): array
|
||||||
|
{
|
||||||
|
$returnGameUrl = MockPay::resolveGameReturnUrl();
|
||||||
|
if ($returnGameUrl !== '') {
|
||||||
|
$payload['return_game_url'] = $returnGameUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $payload;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \app\common\model\DepositOrder|object $order
|
* @param \app\common\model\DepositOrder|object $order
|
||||||
*/
|
*/
|
||||||
@@ -676,6 +691,8 @@ class Finance extends MobileBase
|
|||||||
$expireEsc = htmlspecialchars($expireText, ENT_QUOTES, 'UTF-8');
|
$expireEsc = htmlspecialchars($expireText, ENT_QUOTES, 'UTF-8');
|
||||||
$orderNoJs = json_encode($orderNo, JSON_UNESCAPED_UNICODE);
|
$orderNoJs = json_encode($orderNo, JSON_UNESCAPED_UNICODE);
|
||||||
$confirmUrlJs = json_encode($confirmUrl, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
$confirmUrlJs = json_encode($confirmUrl, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
$returnGameUrl = MockPay::resolveGameReturnUrl();
|
||||||
|
$returnGameUrlJs = json_encode($returnGameUrl, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
|
||||||
return '<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>'
|
return '<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>'
|
||||||
. '<title>模拟充值</title><style>'
|
. '<title>模拟充值</title><style>'
|
||||||
@@ -685,6 +702,7 @@ class Finance extends MobileBase
|
|||||||
. '.amt{font-size:28px;color:#1677ff;font-weight:700;margin:16px 0;}'
|
. '.amt{font-size:28px;color:#1677ff;font-weight:700;margin:16px 0;}'
|
||||||
. 'button{width:100%;padding:14px;font-size:16px;border:0;border-radius:8px;background:#1677ff;color:#fff;cursor:pointer;margin-top:12px;}'
|
. 'button{width:100%;padding:14px;font-size:16px;border:0;border-radius:8px;background:#1677ff;color:#fff;cursor:pointer;margin-top:12px;}'
|
||||||
. 'button:disabled{background:#ccc;}'
|
. 'button:disabled{background:#ccc;}'
|
||||||
|
. '.btn-back{display:none;background:#fff;color:#cf1322;border:1px solid #d9d9d9;}'
|
||||||
. '.hint{font-size:13px;color:#999;}'
|
. '.hint{font-size:13px;color:#999;}'
|
||||||
. '.ok{display:none;margin-top:16px;padding:12px;background:#f6ffed;border:1px solid #b7eb8f;border-radius:8px;color:#389e0d;line-height:1.6;}'
|
. '.ok{display:none;margin-top:16px;padding:12px;background:#f6ffed;border:1px solid #b7eb8f;border-radius:8px;color:#389e0d;line-height:1.6;}'
|
||||||
. '</style></head><body>'
|
. '</style></head><body>'
|
||||||
@@ -695,11 +713,14 @@ class Finance extends MobileBase
|
|||||||
. '<p class="hint">链接有效期至 ' . $expireEsc . '(约 3 分钟,过期后订单将自动失效)</p>'
|
. '<p class="hint">链接有效期至 ' . $expireEsc . '(约 3 分钟,过期后订单将自动失效)</p>'
|
||||||
. '<button type="button" id="btnPay">确认支付</button>'
|
. '<button type="button" id="btnPay">确认支付</button>'
|
||||||
. '<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br/>订单已提交,需管理员在后台审核通过后才会入账。</div>'
|
. '<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br/>订单已提交,需管理员在后台审核通过后才会入账。</div>'
|
||||||
. '<script>(function(){var confirmUrl=' . $confirmUrlJs . ',orderNo=' . $orderNoJs . ';'
|
. '<button type="button" class="btn-back" id="btnBackGame">返回游戏</button>'
|
||||||
|
. '<script>(function(){var confirmUrl=' . $confirmUrlJs . ',orderNo=' . $orderNoJs . ',returnGameUrl=' . $returnGameUrlJs . ';'
|
||||||
|
. 'function showBackGame(){if(!returnGameUrl){return;}var btn=document.getElementById("btnBackGame");btn.style.display="block";btn.onclick=function(){window.location.href=returnGameUrl;};}'
|
||||||
. 'document.getElementById("btnPay").onclick=function(){var btn=this;btn.disabled=true;btn.textContent="处理中...";'
|
. 'document.getElementById("btnPay").onclick=function(){var btn=this;btn.disabled=true;btn.textContent="处理中...";'
|
||||||
. 'fetch(confirmUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},'
|
. 'fetch(confirmUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},'
|
||||||
. 'body:"order_no="+encodeURIComponent(orderNo)}).then(function(r){return r.json();}).then(function(res){'
|
. 'body:"order_no="+encodeURIComponent(orderNo)}).then(function(r){return r.json();}).then(function(res){'
|
||||||
. 'if(res&&res.code===1){document.getElementById("okBox").style.display="block";btn.style.display="none";}'
|
. 'if(res&&res.code===1){document.getElementById("okBox").style.display="block";btn.style.display="none";'
|
||||||
|
. 'if(res.data&&res.data.return_game_url){returnGameUrl=res.data.return_game_url;}showBackGame();}'
|
||||||
. 'else{alert((res&&res.message)||"支付失败");btn.disabled=false;btn.textContent="确认支付";}})'
|
. 'else{alert((res&&res.message)||"支付失败");btn.disabled=false;btn.textContent="确认支付";}})'
|
||||||
. '.catch(function(){alert("网络错误,请重试");btn.disabled=false;btn.textContent="确认支付";});};})();</script>'
|
. '.catch(function(){alert("网络错误,请重试");btn.disabled=false;btn.textContent="确认支付";});};})();</script>'
|
||||||
. '</div></body></html>';
|
. '</div></body></html>';
|
||||||
|
|||||||
@@ -248,6 +248,14 @@ final class MockPay
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$returnGameUrl = self::resolveGameReturnUrl();
|
||||||
|
|
||||||
|
if ($returnGameUrl !== '') {
|
||||||
|
|
||||||
|
$query['return_game_url'] = $returnGameUrl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $htmlBase . '/mock-deposit.html?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
return $htmlBase . '/mock-deposit.html?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
||||||
@@ -332,6 +340,42 @@ final class MockPay
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* 模拟充值完成后「返回游戏」跳转地址(H5_GAME_URL)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static function resolveGameReturnUrl(): string
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
$raw = getenv('H5_GAME_URL');
|
||||||
|
|
||||||
|
if (is_string($raw) && trim($raw) !== '') {
|
||||||
|
|
||||||
|
return trim($raw);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$cfg = config('app.h5_game_url', '');
|
||||||
|
|
||||||
|
if (is_string($cfg) && trim($cfg) !== '') {
|
||||||
|
|
||||||
|
return trim($cfg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static function linkSecret(): string
|
private static function linkSecret(): string
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ return [
|
|||||||
*/
|
*/
|
||||||
'ddpay_public_base_url' => is_string(getenv('DDPAY_PUBLIC_BASE_URL')) ? trim(getenv('DDPAY_PUBLIC_BASE_URL')) : '',
|
'ddpay_public_base_url' => is_string(getenv('DDPAY_PUBLIC_BASE_URL')) ? trim(getenv('DDPAY_PUBLIC_BASE_URL')) : '',
|
||||||
|
|
||||||
|
/** H5 前端游戏页地址:模拟充值收银台「返回游戏」在当前窗口跳转至此(无尾斜杠) */
|
||||||
|
'h5_game_url' => is_string(getenv('H5_GAME_URL')) ? trim(getenv('H5_GAME_URL')) : '',
|
||||||
|
|
||||||
'ddpay_client_id' => is_string(getenv('DDPAY_CLIENT_ID')) ? trim(getenv('DDPAY_CLIENT_ID')) : '',
|
'ddpay_client_id' => is_string(getenv('DDPAY_CLIENT_ID')) ? trim(getenv('DDPAY_CLIENT_ID')) : '',
|
||||||
'ddpay_identifier' => is_string(getenv('DDPAY_IDENTIFIER')) ? trim(getenv('DDPAY_IDENTIFIER')) : '',
|
'ddpay_identifier' => is_string(getenv('DDPAY_IDENTIFIER')) ? trim(getenv('DDPAY_IDENTIFIER')) : '',
|
||||||
'ddpay_api_secret' => is_string(getenv('DDPAY_API_SECRET')) ? trim(getenv('DDPAY_API_SECRET')) : '',
|
'ddpay_api_secret' => is_string(getenv('DDPAY_API_SECRET')) ? trim(getenv('DDPAY_API_SECRET')) : '',
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
.countdown.expired { color: #cf1322; }
|
.countdown.expired { color: #cf1322; }
|
||||||
button { width: 100%; padding: 14px; font-size: 16px; border: 0; border-radius: 8px; background: #1677ff; color: #fff; cursor: pointer; margin-top: 12px; }
|
button { width: 100%; padding: 14px; font-size: 16px; border: 0; border-radius: 8px; background: #1677ff; color: #fff; cursor: pointer; margin-top: 12px; }
|
||||||
button:disabled { background: #ccc; cursor: not-allowed; }
|
button:disabled { background: #ccc; cursor: not-allowed; }
|
||||||
|
.btn-back { display: none; background: #fff; color: #cf1322; border: 1px solid #d9d9d9; }
|
||||||
.hint { font-size: 13px; color: #999; }
|
.hint { font-size: 13px; color: #999; }
|
||||||
.ok { display: none; margin-top: 16px; padding: 12px; background: #f6ffed; border: 1px solid #b7eb8f; border-radius: 8px; color: #389e0d; line-height: 1.6; }
|
.ok { display: none; margin-top: 16px; padding: 12px; background: #f6ffed; border: 1px solid #b7eb8f; border-radius: 8px; color: #389e0d; line-height: 1.6; }
|
||||||
.info { margin-top: 12px; padding: 12px; background: #e6f4ff; border: 1px solid #91caff; border-radius: 8px; color: #0958d9; font-size: 14px; line-height: 1.6; }
|
.info { margin-top: 12px; padding: 12px; background: #e6f4ff; border: 1px solid #91caff; border-radius: 8px; color: #0958d9; font-size: 14px; line-height: 1.6; }
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
<p class="hint" id="expireLine"></p>
|
<p class="hint" id="expireLine"></p>
|
||||||
<button type="button" id="btnPay">确认支付</button>
|
<button type="button" id="btnPay">确认支付</button>
|
||||||
<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br />订单已提交,需管理员在后台审核通过后才会入账。</div>
|
<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br />订单已提交,需管理员在后台审核通过后才会入账。</div>
|
||||||
|
<button type="button" class="btn-back" id="btnBackGame">返回游戏</button>
|
||||||
<div id="msg"></div>
|
<div id="msg"></div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
var apiBase = (params.get('api_base') || '').replace(/\/$/, '');
|
var apiBase = (params.get('api_base') || '').replace(/\/$/, '');
|
||||||
var expireAt = parseInt(params.get('expire_at') || '0', 10);
|
var expireAt = parseInt(params.get('expire_at') || '0', 10);
|
||||||
var sign = params.get('sign') || '';
|
var sign = params.get('sign') || '';
|
||||||
|
var returnGameUrl = params.get('return_game_url') || '';
|
||||||
if (!apiBase) {
|
if (!apiBase) {
|
||||||
apiBase = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
apiBase = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
||||||
}
|
}
|
||||||
@@ -49,8 +52,19 @@
|
|||||||
var countdownEl = document.getElementById('countdown');
|
var countdownEl = document.getElementById('countdown');
|
||||||
var expireLineEl = document.getElementById('expireLine');
|
var expireLineEl = document.getElementById('expireLine');
|
||||||
var btnPay = document.getElementById('btnPay');
|
var btnPay = document.getElementById('btnPay');
|
||||||
|
var btnBackGame = document.getElementById('btnBackGame');
|
||||||
var countdownTimer = null;
|
var countdownTimer = null;
|
||||||
|
|
||||||
|
function showBackGame(url) {
|
||||||
|
var target = (url || returnGameUrl || '').trim();
|
||||||
|
if (!target) return;
|
||||||
|
returnGameUrl = target;
|
||||||
|
btnBackGame.style.display = 'block';
|
||||||
|
btnBackGame.onclick = function () {
|
||||||
|
window.location.href = returnGameUrl;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function showErr(text) {
|
function showErr(text) {
|
||||||
document.getElementById('msg').innerHTML = '<div class="err">' + text + '</div>';
|
document.getElementById('msg').innerHTML = '<div class="err">' + text + '</div>';
|
||||||
}
|
}
|
||||||
@@ -110,12 +124,14 @@
|
|||||||
if (data.status === 'paid') {
|
if (data.status === 'paid') {
|
||||||
showInfo('该订单已入账。');
|
showInfo('该订单已入账。');
|
||||||
btnPay.style.display = 'none';
|
btnPay.style.display = 'none';
|
||||||
|
showBackGame(data.return_game_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.status === 'pending_review') {
|
if (data.status === 'pending_review') {
|
||||||
document.getElementById('okBox').style.display = 'block';
|
document.getElementById('okBox').style.display = 'block';
|
||||||
btnPay.style.display = 'none';
|
btnPay.style.display = 'none';
|
||||||
showInfo('您已提交支付,请等待管理员审核通过后到账。');
|
showInfo('您已提交支付,请等待管理员审核通过后到账。');
|
||||||
|
showBackGame(data.return_game_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.status === 'failed') {
|
if (data.status === 'failed') {
|
||||||
@@ -184,6 +200,11 @@
|
|||||||
if (countdownTimer) clearInterval(countdownTimer);
|
if (countdownTimer) clearInterval(countdownTimer);
|
||||||
countdownEl.textContent = '已提交,等待后台审核';
|
countdownEl.textContent = '已提交,等待后台审核';
|
||||||
countdownEl.className = 'countdown';
|
countdownEl.className = 'countdown';
|
||||||
|
if (res.data && res.data.return_game_url) {
|
||||||
|
showBackGame(res.data.return_game_url);
|
||||||
|
} else {
|
||||||
|
showBackGame('');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showErr((res && res.message) ? res.message : '提交失败');
|
showErr((res && res.message) ? res.message : '提交失败');
|
||||||
btnPay.disabled = false;
|
btnPay.disabled = false;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
.countdown.expired { color: #cf1322; }
|
.countdown.expired { color: #cf1322; }
|
||||||
button { width: 100%; padding: 14px; font-size: 16px; border: 0; border-radius: 8px; background: #1677ff; color: #fff; cursor: pointer; margin-top: 12px; }
|
button { width: 100%; padding: 14px; font-size: 16px; border: 0; border-radius: 8px; background: #1677ff; color: #fff; cursor: pointer; margin-top: 12px; }
|
||||||
button:disabled { background: #ccc; cursor: not-allowed; }
|
button:disabled { background: #ccc; cursor: not-allowed; }
|
||||||
|
.btn-back { display: none; background: #fff; color: #cf1322; border: 1px solid #d9d9d9; }
|
||||||
.hint { font-size: 13px; color: #999; }
|
.hint { font-size: 13px; color: #999; }
|
||||||
.ok { display: none; margin-top: 16px; padding: 12px; background: #f6ffed; border: 1px solid #b7eb8f; border-radius: 8px; color: #389e0d; line-height: 1.6; }
|
.ok { display: none; margin-top: 16px; padding: 12px; background: #f6ffed; border: 1px solid #b7eb8f; border-radius: 8px; color: #389e0d; line-height: 1.6; }
|
||||||
.info { margin-top: 12px; padding: 12px; background: #e6f4ff; border: 1px solid #91caff; border-radius: 8px; color: #0958d9; font-size: 14px; line-height: 1.6; }
|
.info { margin-top: 12px; padding: 12px; background: #e6f4ff; border: 1px solid #91caff; border-radius: 8px; color: #0958d9; font-size: 14px; line-height: 1.6; }
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
<p class="hint" id="expireLine"></p>
|
<p class="hint" id="expireLine"></p>
|
||||||
<button type="button" id="btnPay">确认支付</button>
|
<button type="button" id="btnPay">确认支付</button>
|
||||||
<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br />订单已提交,需管理员在后台审核通过后才会入账。</div>
|
<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br />订单已提交,需管理员在后台审核通过后才会入账。</div>
|
||||||
|
<button type="button" class="btn-back" id="btnBackGame">返回游戏</button>
|
||||||
<div id="msg"></div>
|
<div id="msg"></div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
var apiBase = (params.get('api_base') || '').replace(/\/$/, '');
|
var apiBase = (params.get('api_base') || '').replace(/\/$/, '');
|
||||||
var expireAt = parseInt(params.get('expire_at') || '0', 10);
|
var expireAt = parseInt(params.get('expire_at') || '0', 10);
|
||||||
var sign = params.get('sign') || '';
|
var sign = params.get('sign') || '';
|
||||||
|
var returnGameUrl = params.get('return_game_url') || '';
|
||||||
if (!apiBase) {
|
if (!apiBase) {
|
||||||
apiBase = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
apiBase = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
||||||
}
|
}
|
||||||
@@ -49,8 +52,19 @@
|
|||||||
var countdownEl = document.getElementById('countdown');
|
var countdownEl = document.getElementById('countdown');
|
||||||
var expireLineEl = document.getElementById('expireLine');
|
var expireLineEl = document.getElementById('expireLine');
|
||||||
var btnPay = document.getElementById('btnPay');
|
var btnPay = document.getElementById('btnPay');
|
||||||
|
var btnBackGame = document.getElementById('btnBackGame');
|
||||||
var countdownTimer = null;
|
var countdownTimer = null;
|
||||||
|
|
||||||
|
function showBackGame(url) {
|
||||||
|
var target = (url || returnGameUrl || '').trim();
|
||||||
|
if (!target) return;
|
||||||
|
returnGameUrl = target;
|
||||||
|
btnBackGame.style.display = 'block';
|
||||||
|
btnBackGame.onclick = function () {
|
||||||
|
window.location.href = returnGameUrl;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function showErr(text) {
|
function showErr(text) {
|
||||||
document.getElementById('msg').innerHTML = '<div class="err">' + text + '</div>';
|
document.getElementById('msg').innerHTML = '<div class="err">' + text + '</div>';
|
||||||
}
|
}
|
||||||
@@ -110,12 +124,14 @@
|
|||||||
if (data.status === 'paid') {
|
if (data.status === 'paid') {
|
||||||
showInfo('该订单已入账。');
|
showInfo('该订单已入账。');
|
||||||
btnPay.style.display = 'none';
|
btnPay.style.display = 'none';
|
||||||
|
showBackGame(data.return_game_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.status === 'pending_review') {
|
if (data.status === 'pending_review') {
|
||||||
document.getElementById('okBox').style.display = 'block';
|
document.getElementById('okBox').style.display = 'block';
|
||||||
btnPay.style.display = 'none';
|
btnPay.style.display = 'none';
|
||||||
showInfo('您已提交支付,请等待管理员审核通过后到账。');
|
showInfo('您已提交支付,请等待管理员审核通过后到账。');
|
||||||
|
showBackGame(data.return_game_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.status === 'failed') {
|
if (data.status === 'failed') {
|
||||||
@@ -184,6 +200,11 @@
|
|||||||
if (countdownTimer) clearInterval(countdownTimer);
|
if (countdownTimer) clearInterval(countdownTimer);
|
||||||
countdownEl.textContent = '已提交,等待后台审核';
|
countdownEl.textContent = '已提交,等待后台审核';
|
||||||
countdownEl.className = 'countdown';
|
countdownEl.className = 'countdown';
|
||||||
|
if (res.data && res.data.return_game_url) {
|
||||||
|
showBackGame(res.data.return_game_url);
|
||||||
|
} else {
|
||||||
|
showBackGame('');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showErr((res && res.message) ? res.message : '提交失败');
|
showErr((res && res.message) ? res.message : '提交失败');
|
||||||
btnPay.disabled = false;
|
btnPay.disabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user