refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
+99
-99
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* AKSRT CMS Download
|
||||
* Jio CMS Download
|
||||
*
|
||||
* 功能:
|
||||
* - 监听购买入口(data-aksrt-pay-content / data-action="aksrt-need-purchase")
|
||||
* - 监听购买入口(data-jio-pay-content / data-action="jio-need-purchase")
|
||||
* - 内容购买收银台、扫码支付与错误提示弹窗
|
||||
* - 下载已改为直连:按钮为源地址锚点,不再经过本站中转请求
|
||||
*
|
||||
@@ -10,20 +10,20 @@
|
||||
* 付费收银台沿用参考实现的 colorful header 结构。
|
||||
*
|
||||
* 依赖:
|
||||
* - window.aksrtData.{ ajaxUrl, nonce, siteUrl }
|
||||
* - window.jioData.{ ajaxUrl, nonce, siteUrl }
|
||||
* - 主题已加载 fetch (现代浏览器)
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (!window.aksrtData) return;
|
||||
const REST_BASE = window.aksrtData.siteUrl ? window.aksrtData.siteUrl.replace(/\/$/, '') + '/wp-json/aksrt/v1' : '/wp-json/aksrt/v1';
|
||||
if (!window.jioData) return;
|
||||
const REST_BASE = window.jioData.siteUrl ? window.jioData.siteUrl.replace(/\/$/, '') + '/wp-json/jio/v1' : '/wp-json/jio/v1';
|
||||
const PAY_CONTENT_PATH = '/pay/content/';
|
||||
|
||||
// 自定义货币名称(后台「积分配置 → 自定义货币名称」)由服务端注入。
|
||||
// 余额不足提示在客户端拼装,必须跟随它。
|
||||
function currencyName() {
|
||||
return (window.aksrtData && window.aksrtData.currencyName) || '积分';
|
||||
return (window.jioData && window.jioData.currencyName) || '积分';
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
@@ -72,21 +72,21 @@
|
||||
|
||||
// ===== Modal helper =====
|
||||
function buildModal() {
|
||||
let modal = document.getElementById('aksrt-dl-modal');
|
||||
let modal = document.getElementById('jio-dl-modal');
|
||||
if (modal) return modal;
|
||||
modal = document.createElement('div');
|
||||
modal.id = 'aksrt-dl-modal';
|
||||
modal.className = 'aksrt-dl-modal';
|
||||
modal.id = 'jio-dl-modal';
|
||||
modal.className = 'jio-dl-modal';
|
||||
modal.setAttribute('role', 'dialog');
|
||||
modal.setAttribute('aria-modal', 'true');
|
||||
modal.setAttribute('aria-hidden', 'true');
|
||||
modal.setAttribute('aria-labelledby', 'aksrt-dl-modal-title');
|
||||
modal.setAttribute('aria-labelledby', 'jio-dl-modal-title');
|
||||
modal.innerHTML =
|
||||
'<div class="aksrt-dl-modal__backdrop" data-close></div>' +
|
||||
'<div class="aksrt-dl-modal__dialog modal-mini">' +
|
||||
' <div class="aksrt-dl-modal__panel modal-content" role="document" tabindex="-1">' +
|
||||
' <button type="button" class="aksrt-dl-modal__close" aria-label="关闭" data-close>×</button>' +
|
||||
' <div class="aksrt-dl-modal__body" data-body></div>' +
|
||||
'<div class="jio-dl-modal__backdrop" data-close></div>' +
|
||||
'<div class="jio-dl-modal__dialog modal-mini">' +
|
||||
' <div class="jio-dl-modal__panel modal-content" role="document" tabindex="-1">' +
|
||||
' <button type="button" class="jio-dl-modal__close" aria-label="关闭" data-close>×</button>' +
|
||||
' <div class="jio-dl-modal__body" data-body></div>' +
|
||||
' </div>' +
|
||||
'</div>';
|
||||
document.body.appendChild(modal);
|
||||
@@ -113,11 +113,11 @@
|
||||
const body = modal.querySelector('[data-body]');
|
||||
modal.classList.toggle('is-cashier', variant === 'cashier');
|
||||
body.innerHTML = html;
|
||||
const title = body.querySelector('.aksrt-dl-modal__title, .aksrt-cashier__title');
|
||||
if (title) title.id = 'aksrt-dl-modal-title';
|
||||
const title = body.querySelector('.jio-dl-modal__title, .jio-cashier__title');
|
||||
if (title) title.id = 'jio-dl-modal-title';
|
||||
modal.classList.add('is-open');
|
||||
modal.setAttribute('aria-hidden', 'false');
|
||||
document.body.classList.add('aksrt-dl-modal-open');
|
||||
document.body.classList.add('jio-dl-modal-open');
|
||||
|
||||
// 进入后将焦点放在第一个可聚焦元素,否则放 panel
|
||||
setTimeout(function () {
|
||||
@@ -125,17 +125,17 @@
|
||||
if (focusables.length) {
|
||||
focusables[0].focus();
|
||||
} else {
|
||||
modal.querySelector('.aksrt-dl-modal__panel').focus();
|
||||
modal.querySelector('.jio-dl-modal__panel').focus();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function close() {
|
||||
const modal = document.getElementById('aksrt-dl-modal');
|
||||
const modal = document.getElementById('jio-dl-modal');
|
||||
if (!modal) return;
|
||||
modal.classList.remove('is-open');
|
||||
modal.setAttribute('aria-hidden', 'true');
|
||||
document.body.classList.remove('aksrt-dl-modal-open');
|
||||
document.body.classList.remove('jio-dl-modal-open');
|
||||
// 焦点回到触发按钮
|
||||
if (lastFocusedElement && typeof lastFocusedElement.focus === 'function') {
|
||||
try { lastFocusedElement.focus(); } catch (_) { /* ignore */ }
|
||||
@@ -159,7 +159,7 @@
|
||||
function dlActionButton(action) {
|
||||
if (!action) return '';
|
||||
const tag = action.kind === 'link' ? 'a' : 'button';
|
||||
const cls = 'aksrt-dl-modal__btn' + (action.cls ? ' ' + action.cls : '');
|
||||
const cls = 'jio-dl-modal__btn' + (action.cls ? ' ' + action.cls : '');
|
||||
const attrs = [
|
||||
'class="' + cls + '"',
|
||||
action.url ? 'href="' + escapeAttr(action.url) + '"' : '',
|
||||
@@ -174,18 +174,18 @@
|
||||
function dlView(viewKey, options) {
|
||||
const meta = DL_VIEWS[viewKey] || DL_VIEWS.error;
|
||||
options = options || {};
|
||||
let html = '<div class="aksrt-dl-view">';
|
||||
html += '<div class="aksrt-dl-modal__hero">';
|
||||
html += '<div class="aksrt-dl-modal__hero-icon"><i class="fa fas ' + meta.icon + '" aria-hidden="true"></i></div>';
|
||||
html += '<h3 class="aksrt-dl-modal__title">' + (options.title || meta.title) + '</h3>';
|
||||
let html = '<div class="jio-dl-view">';
|
||||
html += '<div class="jio-dl-modal__hero">';
|
||||
html += '<div class="jio-dl-modal__hero-icon"><i class="fa fas ' + meta.icon + '" aria-hidden="true"></i></div>';
|
||||
html += '<h3 class="jio-dl-modal__title">' + (options.title || meta.title) + '</h3>';
|
||||
if (options.subtitle) {
|
||||
html += '<p class="aksrt-dl-modal__subtitle">' + escapeHtml(options.subtitle) + '</p>';
|
||||
html += '<p class="jio-dl-modal__subtitle">' + escapeHtml(options.subtitle) + '</p>';
|
||||
}
|
||||
html += '</div>';
|
||||
html += '<div class="aksrt-dl-modal__content">';
|
||||
html += '<div class="jio-dl-modal__content">';
|
||||
html += options.body || '';
|
||||
if (options.actions && options.actions.length) {
|
||||
html += '<div class="aksrt-dl-modal__actions">' +
|
||||
html += '<div class="jio-dl-modal__actions">' +
|
||||
options.actions.map(dlActionButton).join('') +
|
||||
'</div>';
|
||||
}
|
||||
@@ -204,35 +204,35 @@
|
||||
data = data || {};
|
||||
msg = msg || '';
|
||||
|
||||
if (code === 'aksrt_need_login') {
|
||||
if (code === 'jio_need_login') {
|
||||
viewKey = 'login';
|
||||
msg = data.login_url ? '登录后即可继续下载,访客不可使用此资源。' : (msg || '无下载权限。');
|
||||
if (data.login_url) action = { kind: 'link', url: data.login_url, label: '前往登录', icon: 'fa-sign-in-alt' };
|
||||
} else if (code === 'aksrt_need_purchase') {
|
||||
} else if (code === 'jio_need_purchase') {
|
||||
viewKey = 'purchase';
|
||||
msg = msg || '请先完成购买后再下载该资源。';
|
||||
if (data.post_id) {
|
||||
action = { kind: 'button', label: '去购买', icon: 'fa-shopping-cart', attrs: 'type="button" data-aksrt-open-cashier="' + escapeAttr(data.post_id) + '"' };
|
||||
action = { kind: 'button', label: '去购买', icon: 'fa-shopping-cart', attrs: 'type="button" data-jio-open-cashier="' + escapeAttr(data.post_id) + '"' };
|
||||
}
|
||||
} else if (code === 'aksrt_need_vip') {
|
||||
} else if (code === 'jio_need_vip') {
|
||||
viewKey = 'vip';
|
||||
msg = msg || '该资源仅限会员购买/下载。';
|
||||
subtitle = '开通会员即可解锁本资源';
|
||||
if (data.vip_url) action = { kind: 'link', url: data.vip_url, label: '开通会员', icon: 'fa-gem' };
|
||||
} else if (code === 'aksrt_points_insufficient' || code === 'aksrt_balance_insufficient') {
|
||||
} else if (code === 'jio_points_insufficient' || code === 'jio_balance_insufficient') {
|
||||
viewKey = 'credits';
|
||||
const balance = typeof data.balance === 'number' ? data.balance : 0;
|
||||
const cost = typeof data.cost === 'number' ? data.cost : 0;
|
||||
unit = currencyName();
|
||||
msg = '当前余额 ' + balance + ' ' + unit + ',需要 ' + cost + ' ' + unit + '。可通过签到、阅读、邀请好友等方式获取' + unit + '。';
|
||||
if (data.credits_url) action = { kind: 'link', url: data.credits_url, label: '我的' + unit, icon: 'fa-coins' };
|
||||
} else if (code === 'aksrt_download_limit') {
|
||||
} else if (code === 'jio_download_limit') {
|
||||
viewKey = 'quota';
|
||||
msg = msg || '您今日下载免费资源个数已超限,请明日再下载。';
|
||||
if (data.allow_limit_over && data.post_id) {
|
||||
action = { kind: 'button', label: '立即购买', icon: 'fa-shopping-cart', attrs: 'type="button" data-aksrt-open-cashier="' + escapeAttr(data.post_id) + '" data-price-type="download_limit_over"' };
|
||||
action = { kind: 'button', label: '立即购买', icon: 'fa-shopping-cart', attrs: 'type="button" data-jio-open-cashier="' + escapeAttr(data.post_id) + '" data-price-type="download_limit_over"' };
|
||||
}
|
||||
} else if (code === 'aksrt_captcha_failed') {
|
||||
} else if (code === 'jio_captcha_failed') {
|
||||
viewKey = 'captcha';
|
||||
msg = msg || '人机验证失败,请重试。';
|
||||
} else if (!action && data.login_url) {
|
||||
@@ -243,16 +243,16 @@
|
||||
dlView(viewKey, {
|
||||
title: viewKey === 'credits' && unit ? unit + '不足' : undefined,
|
||||
subtitle: subtitle,
|
||||
body: msg ? '<p class="aksrt-dl-modal__msg">' + escapeHtml(msg) + '</p>' : '',
|
||||
body: msg ? '<p class="jio-dl-modal__msg">' + escapeHtml(msg) + '</p>' : '',
|
||||
actions: action ? [action] : [],
|
||||
}),
|
||||
returnFocusEl
|
||||
);
|
||||
|
||||
const openCashierBtn = document.querySelector('[data-aksrt-open-cashier]');
|
||||
const openCashierBtn = document.querySelector('[data-jio-open-cashier]');
|
||||
if (openCashierBtn) {
|
||||
openCashierBtn.addEventListener('click', function () {
|
||||
const pid = parseInt(openCashierBtn.getAttribute('data-aksrt-open-cashier'), 10) || 0;
|
||||
const pid = parseInt(openCashierBtn.getAttribute('data-jio-open-cashier'), 10) || 0;
|
||||
const pt = openCashierBtn.getAttribute('data-price-type') || '';
|
||||
close();
|
||||
if (pid) openCashier(pid, returnFocusEl, pt);
|
||||
@@ -265,11 +265,11 @@
|
||||
|
||||
function cashierHeader() {
|
||||
return '<div class="modal-colorful-header colorful-bg jb-blue">' +
|
||||
'<button type="button" class="close aksrt-cashier__close" aria-label="关闭" data-close>×</button>' +
|
||||
'<button type="button" class="close jio-cashier__close" aria-label="关闭" data-close>×</button>' +
|
||||
'<div class="colorful-make"></div>' +
|
||||
'<div class="text-center">' +
|
||||
' <div class="em2x"><i class="fa fas fa-cart-plus" aria-hidden="true"></i></div>' +
|
||||
' <div class="aksrt-cashier__title mt10 em12 padding-w10">确认购买</div>' +
|
||||
' <div class="jio-cashier__title mt10 em12 padding-w10">确认购买</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
@@ -313,7 +313,7 @@
|
||||
function restHeaders(idempotencyKey) {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-WP-Nonce': window.aksrtData.restNonce || '',
|
||||
'X-WP-Nonce': window.jioData.restNonce || '',
|
||||
};
|
||||
if (idempotencyKey) headers['Idempotency-Key'] = idempotencyKey;
|
||||
return headers;
|
||||
@@ -343,7 +343,7 @@
|
||||
priceType = priceType || '';
|
||||
couponCode = couponCode || '';
|
||||
openCashierContent(
|
||||
'<p class="aksrt-cashier__loading muted-2-color">加载中…</p>',
|
||||
'<p class="jio-cashier__loading muted-2-color">加载中…</p>',
|
||||
returnFocusEl
|
||||
);
|
||||
|
||||
@@ -352,15 +352,15 @@
|
||||
if (!r.ok || (r.json && r.json.code)) {
|
||||
const code = r.json && r.json.code ? r.json.code : '';
|
||||
const data = (r.json && r.json.data) || {};
|
||||
if (code === 'aksrt_need_login' || r.status === 401) {
|
||||
renderError(r.json.message || '', data, returnFocusEl, 'aksrt_need_login');
|
||||
if (code === 'jio_need_login' || r.status === 401) {
|
||||
renderError(r.json.message || '', data, returnFocusEl, 'jio_need_login');
|
||||
return;
|
||||
}
|
||||
if (code === 'aksrt_need_vip') {
|
||||
renderError(r.json.message || '', data, returnFocusEl, 'aksrt_need_vip');
|
||||
if (code === 'jio_need_vip') {
|
||||
renderError(r.json.message || '', data, returnFocusEl, 'jio_need_vip');
|
||||
return;
|
||||
}
|
||||
if (code === 'aksrt_already_paid') {
|
||||
if (code === 'jio_already_paid') {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
@@ -396,12 +396,12 @@
|
||||
};
|
||||
const logo = logoNames[methodId];
|
||||
if (!logo) return '';
|
||||
const themeUrl = String(window.aksrtData.themeUrl || '').replace(/\/$/, '');
|
||||
const themeUrl = String(window.jioData.themeUrl || '').replace(/\/$/, '');
|
||||
return '<img src="' + escapeAttr(themeUrl + '/assets/img/' + logo) + '" alt="">';
|
||||
}
|
||||
|
||||
function cashierPriceRow(label, value, className) {
|
||||
return '<div class="flex jsb ab aksrt-cashier__price-row">' +
|
||||
return '<div class="flex jsb ab jio-cashier__price-row">' +
|
||||
'<span class="muted-2-color">' + label + '</span>' +
|
||||
'<div class="' + (className || '') + '">' + value + '</div>' +
|
||||
'</div>';
|
||||
@@ -410,11 +410,11 @@
|
||||
function renderCashier(preview, returnFocusEl) {
|
||||
if (!preview) return;
|
||||
if (preview.need_login && !preview.allow_guest) {
|
||||
renderError('', { login_url: preview.login_url }, returnFocusEl, 'aksrt_need_login');
|
||||
renderError('', { login_url: preview.login_url }, returnFocusEl, 'jio_need_login');
|
||||
return;
|
||||
}
|
||||
if (preview.need_vip) {
|
||||
renderError('', { vip_url: preview.vip_url }, returnFocusEl, 'aksrt_need_vip');
|
||||
renderError('', { vip_url: preview.vip_url }, returnFocusEl, 'jio_need_vip');
|
||||
return;
|
||||
}
|
||||
if (preview.has_paid_access) {
|
||||
@@ -452,17 +452,17 @@
|
||||
if (!isPoints && Number(preview.original) > Number(preview.base)) {
|
||||
regularPrice = '<span class="original-price">' + formatAssetLabel(preview, preview.original) + '</span>' + regularPrice;
|
||||
}
|
||||
priceRows += cashierPriceRow('价格', regularPrice, 'aksrt-cashier__regular-price');
|
||||
priceRows += cashierPriceRow('价格', regularPrice, 'jio-cashier__regular-price');
|
||||
}
|
||||
if (preview.list_amount !== preview.base) {
|
||||
priceRows += cashierPriceRow(
|
||||
'会员价<span class="aksrt-cashier__vip-mark">VIP' + escapeHtml(preview.vip_level || '') + '</span>',
|
||||
'会员价<span class="jio-cashier__vip-mark">VIP' + escapeHtml(preview.vip_level || '') + '</span>',
|
||||
'<span class="em14">' + listLabel + '</span>',
|
||||
'c-red'
|
||||
);
|
||||
} else if (preview.amount !== preview.base && !preview.rebate_discount && !preview.coupon_discount) {
|
||||
priceRows += cashierPriceRow(
|
||||
'会员价<span class="aksrt-cashier__vip-mark">VIP' + escapeHtml(preview.vip_level || '') + '</span>',
|
||||
'会员价<span class="jio-cashier__vip-mark">VIP' + escapeHtml(preview.vip_level || '') + '</span>',
|
||||
'<span class="em14">' + amountLabel + '</span>',
|
||||
'c-red'
|
||||
);
|
||||
@@ -497,10 +497,10 @@
|
||||
const unit = currencyName();
|
||||
body += '<div class="mb10 muted-box padding-h10">' +
|
||||
'<div class="flex jsb ac"><span class="muted-2-color">' +
|
||||
'<i class="fa fas fa-database aksrt-cashier__asset-icon" aria-hidden="true"></i>我的' + unit +
|
||||
'<i class="fa fas fa-database jio-cashier__asset-icon" aria-hidden="true"></i>我的' + unit +
|
||||
'</span><div class="c-green"><span class="em14">' + balance + '</span></div></div></div>';
|
||||
if (!preview.balance_enough) {
|
||||
body += '<div class="badg c-red btn-block mb20 aksrt-cashier__warn">抱歉,您的' + unit + '不足,暂时无法支付</div>';
|
||||
body += '<div class="badg c-red btn-block mb20 jio-cashier__warn">抱歉,您的' + unit + '不足,暂时无法支付</div>';
|
||||
body += '<div class="modal-buts but-average">';
|
||||
if (preview.credits_url) {
|
||||
body += '<a class="but padding-lg" href="' + escapeAttr(preview.credits_url) + '">我的' + unit + '</a>';
|
||||
@@ -509,23 +509,23 @@
|
||||
openCashierContent(body, returnFocusEl);
|
||||
return;
|
||||
}
|
||||
body += '<button type="button" class="mt6 but jb-red initiate-pay btn-block radius" data-aksrt-pay-submit data-mode="points" data-price-type="' + escapeAttr(priceType) + '">' +
|
||||
body += '<button type="button" class="mt6 but jb-red initiate-pay btn-block radius" data-jio-pay-submit data-mode="points" data-price-type="' + escapeAttr(priceType) + '">' +
|
||||
'立即支付<span class="pay-price-text ml10">' + amountLabel + '</span></button>';
|
||||
} else {
|
||||
if (couponAllowed) {
|
||||
body += '<div class="mb10 coupon-input-box">';
|
||||
body += '<div class="muted-2-color em09 mb6">使用优惠码</div>';
|
||||
body += '<div class="relative">';
|
||||
body += '<input type="text" class="form-control coupon-input" name="aksrt_coupon_code" value="' + couponCodeVal + '" placeholder="请输入优惠码" autocomplete="off">';
|
||||
body += '<span class="abs-right"><button type="button" class="but c-blue coupon-submit" data-aksrt-check-coupon>检查优惠码</button></span>';
|
||||
body += '<input type="text" class="form-control coupon-input" name="jio_coupon_code" value="' + couponCodeVal + '" placeholder="请输入优惠码" autocomplete="off">';
|
||||
body += '<span class="abs-right"><button type="button" class="but c-blue coupon-submit" data-jio-check-coupon>检查优惠码</button></span>';
|
||||
body += '</div>';
|
||||
if (preview.coupon_desc) {
|
||||
body += '<div class="muted-3-color px12 mt6 aksrt-cashier__coupon-desc">' + escapeHtml(preview.coupon_desc) + '</div>';
|
||||
body += '<div class="muted-3-color px12 mt6 jio-cashier__coupon-desc">' + escapeHtml(preview.coupon_desc) + '</div>';
|
||||
}
|
||||
if (preview.coupon_error) {
|
||||
body += '<div class="aksrt-cashier__warn">' + escapeHtml(preview.coupon_error) + '</div>';
|
||||
body += '<div class="jio-cashier__warn">' + escapeHtml(preview.coupon_error) + '</div>';
|
||||
} else if (preview.coupon_discount > 0) {
|
||||
body += '<div class="aksrt-cashier__coupon-ok">优惠码可用</div>';
|
||||
body += '<div class="jio-cashier__coupon-ok">优惠码可用</div>';
|
||||
}
|
||||
body += '</div>';
|
||||
}
|
||||
@@ -539,47 +539,47 @@
|
||||
const id = escapeAttr(rawId);
|
||||
const name = escapeHtml((m && m.name) || rawId);
|
||||
methodHtml += '<div class="flex jc hh payment-method-radio hollow-radio flex-auto pointer' + (idx === 0 ? ' active' : '') + '"' +
|
||||
' role="radio" aria-checked="' + (idx === 0 ? 'true' : 'false') + '" tabindex="0" data-aksrt-payment-method="' + id + '">' +
|
||||
' role="radio" aria-checked="' + (idx === 0 ? 'true' : 'false') + '" tabindex="0" data-jio-payment-method="' + id + '">' +
|
||||
paymentMethodLogo(rawId) + '<div>' + name + '</div></div>';
|
||||
});
|
||||
if (methods.length > 1) {
|
||||
body += '<div class="muted-2-color em09 mb6">请选择支付方式</div>' +
|
||||
'<div class="flex mb10 aksrt-cashier__methods" role="radiogroup">' + methodHtml + '</div>';
|
||||
'<div class="flex mb10 jio-cashier__methods" role="radiogroup">' + methodHtml + '</div>';
|
||||
}
|
||||
if (methods.length) {
|
||||
body += '<input type="hidden" name="aksrt_pay_method" value="' + escapeAttr(methods[0].id || '') + '">';
|
||||
body += '<input type="hidden" name="jio_pay_method" value="' + escapeAttr(methods[0].id || '') + '">';
|
||||
}
|
||||
if (hasBalanceMethod) {
|
||||
const balanceSelected = methods[0] && methods[0].id === 'balance';
|
||||
body += '<div class="mb10 muted-box padding-h10 aksrt-cashier__balance" data-aksrt-balance-box' + (balanceSelected ? '' : ' hidden') + '>' +
|
||||
body += '<div class="mb10 muted-box padding-h10 jio-cashier__balance" data-jio-balance-box' + (balanceSelected ? '' : ' hidden') + '>' +
|
||||
'<div class="flex jsb ac"><span class="muted-2-color">' +
|
||||
'<i class="fa fas fa-wallet aksrt-cashier__asset-icon" aria-hidden="true"></i>我的余额' +
|
||||
'<i class="fa fas fa-wallet jio-cashier__asset-icon" aria-hidden="true"></i>我的余额' +
|
||||
'</span><div class="c-blue-2"><span class="em14">' + escapeHtml(walletBal) + '</span></div></div>';
|
||||
if (preview.balance_enough === false) {
|
||||
if (preview.credits_url) {
|
||||
body += '<a class="but c-red block mt6 aksrt-cashier__recharge" href="' + escapeAttr(preview.credits_url) + '">' +
|
||||
body += '<a class="but c-red block mt6 jio-cashier__recharge" href="' + escapeAttr(preview.credits_url) + '">' +
|
||||
'抱歉!余额不足,请先充值 <i class="ml6 fa fas fa-angle-right em12" aria-hidden="true"></i></a>';
|
||||
} else {
|
||||
body += '<div class="c-red mt6 aksrt-cashier__recharge">抱歉!余额不足,请先充值</div>';
|
||||
body += '<div class="c-red mt6 jio-cashier__recharge">抱歉!余额不足,请先充值</div>';
|
||||
}
|
||||
}
|
||||
body += '</div>';
|
||||
}
|
||||
if (methods.length) {
|
||||
body += '<button type="button" class="mt6 but jb-red initiate-pay btn-block radius" data-aksrt-pay-submit data-mode="cash" data-price-type="' + escapeAttr(priceType) + '">' +
|
||||
body += '<button type="button" class="mt6 but jb-red initiate-pay btn-block radius" data-jio-pay-submit data-mode="cash" data-price-type="' + escapeAttr(priceType) + '">' +
|
||||
'立即支付<span class="pay-price-text ml10">' + amountLabel + '</span></button>';
|
||||
} else {
|
||||
body += '<div class="badg c-red btn-block aksrt-cashier__warn">暂无可用支付方式,请联系站长配置收款接口</div>';
|
||||
body += '<div class="badg c-red btn-block jio-cashier__warn">暂无可用支付方式,请联系站长配置收款接口</div>';
|
||||
}
|
||||
}
|
||||
|
||||
openCashierContent(body, returnFocusEl);
|
||||
const modal = document.getElementById('aksrt-dl-modal');
|
||||
const modal = document.getElementById('jio-dl-modal');
|
||||
|
||||
const checkBtn = modal && modal.querySelector('[data-aksrt-check-coupon]');
|
||||
const checkBtn = modal && modal.querySelector('[data-jio-check-coupon]');
|
||||
if (checkBtn) {
|
||||
checkBtn.addEventListener('click', function () {
|
||||
const input = modal.querySelector('input[name="aksrt_coupon_code"]');
|
||||
const input = modal.querySelector('input[name="jio_coupon_code"]');
|
||||
const code = input ? String(input.value || '').trim() : '';
|
||||
if (!code) {
|
||||
if (input) input.focus();
|
||||
@@ -610,11 +610,11 @@
|
||||
}
|
||||
|
||||
if (modal) {
|
||||
const methodCards = modal.querySelectorAll('[data-aksrt-payment-method]');
|
||||
const methodInput = modal.querySelector('input[name="aksrt_pay_method"]');
|
||||
const balanceBox = modal.querySelector('[data-aksrt-balance-box]');
|
||||
const methodCards = modal.querySelectorAll('[data-jio-payment-method]');
|
||||
const methodInput = modal.querySelector('input[name="jio_pay_method"]');
|
||||
const balanceBox = modal.querySelector('[data-jio-balance-box]');
|
||||
const selectMethod = function (card) {
|
||||
const method = card.getAttribute('data-aksrt-payment-method') || '';
|
||||
const method = card.getAttribute('data-jio-payment-method') || '';
|
||||
methodCards.forEach(function (item) {
|
||||
const active = item === card;
|
||||
item.classList.toggle('active', active);
|
||||
@@ -634,14 +634,14 @@
|
||||
});
|
||||
}
|
||||
|
||||
const submitBtn = modal && modal.querySelector('[data-aksrt-pay-submit]');
|
||||
const submitBtn = modal && modal.querySelector('[data-jio-pay-submit]');
|
||||
if (submitBtn) {
|
||||
submitBtn.addEventListener('click', function () {
|
||||
const mode = submitBtn.getAttribute('data-mode') || (isPoints ? 'points' : 'cash');
|
||||
let paymentMethod = 'balance';
|
||||
const selected = modal.querySelector('input[name="aksrt_pay_method"]');
|
||||
const selected = modal.querySelector('input[name="jio_pay_method"]');
|
||||
if (selected) paymentMethod = selected.value;
|
||||
const input = modal.querySelector('input[name="aksrt_coupon_code"]');
|
||||
const input = modal.querySelector('input[name="jio_coupon_code"]');
|
||||
const code = input ? String(input.value || '').trim() : (preview.coupon_code || preview._coupon_code || '');
|
||||
submitPurchase(preview.post_id, mode, paymentMethod, submitBtn, returnFocusEl, code);
|
||||
});
|
||||
@@ -660,13 +660,13 @@
|
||||
if (pt) payload.price_type = pt;
|
||||
if (mode === 'cash' && couponCode) payload.coupon_code = couponCode;
|
||||
|
||||
if (!button.dataset.aksrtOperationKey) {
|
||||
button.dataset.aksrtOperationKey = window.AksrtRequest.createIdempotencyKey();
|
||||
if (!button.dataset.jioOperationKey) {
|
||||
button.dataset.jioOperationKey = window.JioRequest.createIdempotencyKey();
|
||||
}
|
||||
fetch(REST_BASE + PAY_CONTENT_PATH + postId, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: restHeaders(button.dataset.aksrtOperationKey),
|
||||
headers: restHeaders(button.dataset.jioOperationKey),
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
.then(function (resp) { return resp.json().then(function (j) { return { ok: resp.ok, status: resp.status, json: j }; }); })
|
||||
@@ -676,7 +676,7 @@
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
const code = r.json && r.json.code ? r.json.code : '';
|
||||
const data = (r.json && r.json.data) || {};
|
||||
if (code === 'aksrt_already_paid') {
|
||||
if (code === 'jio_already_paid') {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
@@ -684,14 +684,14 @@
|
||||
return;
|
||||
}
|
||||
const data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||
delete button.dataset.aksrtOperationKey;
|
||||
delete button.dataset.jioOperationKey;
|
||||
if (data && data.mode) {
|
||||
if (window.AksrtModalRuntime) window.AksrtModalRuntime.invalidate(['orders']);
|
||||
if (window.JioModalRuntime) window.JioModalRuntime.invalidate(['orders']);
|
||||
if (data.mode === 'qrcode') {
|
||||
renderScanPay(data, returnFocusEl);
|
||||
} else if (window.AksrtPayCashier) {
|
||||
} else if (window.JioPayCashier) {
|
||||
close();
|
||||
window.AksrtPayCashier.handle(data, {});
|
||||
window.JioPayCashier.handle(data, {});
|
||||
}
|
||||
if ((data.mode === 'qrcode' || data.mode === 'jsapi') && data.order_number) {
|
||||
pollOrderPaid(data.order_number, returnFocusEl);
|
||||
@@ -709,28 +709,28 @@
|
||||
|
||||
function renderScanPay(data, returnFocusEl) {
|
||||
data = data || {};
|
||||
const body = window.AksrtPayCashier
|
||||
? window.AksrtPayCashier.qrHtml(data)
|
||||
: '<p class="aksrt-dl-modal__msg">' + escapeHtml('收银台组件未加载,请刷新页面重试。') + '</p>';
|
||||
const body = window.JioPayCashier
|
||||
? window.JioPayCashier.qrHtml(data)
|
||||
: '<p class="jio-dl-modal__msg">' + escapeHtml('收银台组件未加载,请刷新页面重试。') + '</p>';
|
||||
open(
|
||||
dlView('pay', {
|
||||
subtitle: '支付完成后页面会自动刷新',
|
||||
body: body,
|
||||
actions: [{ kind: 'button', label: '我已支付', icon: 'fa-sync-alt', attrs: 'type="button" data-aksrt-reload' }],
|
||||
actions: [{ kind: 'button', label: '我已支付', icon: 'fa-sync-alt', attrs: 'type="button" data-jio-reload' }],
|
||||
}),
|
||||
returnFocusEl
|
||||
);
|
||||
const reloadBtn = document.querySelector('[data-aksrt-reload]');
|
||||
const reloadBtn = document.querySelector('[data-jio-reload]');
|
||||
if (reloadBtn) reloadBtn.addEventListener('click', function () { window.location.reload(); });
|
||||
}
|
||||
|
||||
// ===== 事件绑定 =====
|
||||
document.addEventListener('click', function (e) {
|
||||
const buyBtn = e.target.closest('[data-action="aksrt-need-purchase"], [data-aksrt-pay-content]');
|
||||
const buyBtn = e.target.closest('[data-action="jio-need-purchase"], [data-jio-pay-content]');
|
||||
if (buyBtn) {
|
||||
e.preventDefault();
|
||||
const postId = parseInt(
|
||||
buyBtn.getAttribute('data-aksrt-pay-content') ||
|
||||
buyBtn.getAttribute('data-jio-pay-content') ||
|
||||
buyBtn.getAttribute('data-post-id') ||
|
||||
(buyBtn.closest('[data-post-id]') && buyBtn.closest('[data-post-id]').getAttribute('data-post-id')) ||
|
||||
'0',
|
||||
@@ -743,7 +743,7 @@
|
||||
});
|
||||
|
||||
// Public cashier bridge (content pay).
|
||||
window.aksrtOpenCashier = function (postId, returnFocusEl, priceType, couponCode) {
|
||||
window.jioOpenCashier = function (postId, returnFocusEl, priceType, couponCode) {
|
||||
openCashier(postId, returnFocusEl || null, priceType || '', couponCode || '');
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user