This commit is contained in:
279
common/common.js
279
common/common.js
@@ -106,279 +106,20 @@ $(function () {
|
||||
$(".no-login").attr("style", "display:block");
|
||||
}
|
||||
};
|
||||
// 获取通用配置信息(先用系统 /console/v1/common,若有插件则再用插件数据覆盖部分字段)
|
||||
const getCommentInfo = () => {
|
||||
$.ajax({
|
||||
url: "/console/v1/common",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (res) {
|
||||
if (!res || res.status !== 200 || !res.data) {
|
||||
return;
|
||||
}
|
||||
var baseData = res.data || {};
|
||||
|
||||
// 再尝试从主题配置插件读取额外配置,用于覆盖旧数据
|
||||
$.ajax({
|
||||
url: "/console/v1/theme/config",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (pluginRes) {
|
||||
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
|
||||
var cfg = pluginRes.data || {};
|
||||
|
||||
// SEO:如配置了插件 SEO,则覆盖页面标题与 meta
|
||||
if (cfg.seo) {
|
||||
if (cfg.seo.title) {
|
||||
document.title = cfg.seo.title;
|
||||
}
|
||||
if (cfg.seo.keywords) {
|
||||
var $kw = $('meta[name="keywords"]');
|
||||
if ($kw.length) {
|
||||
$kw.attr("content", cfg.seo.keywords);
|
||||
}
|
||||
}
|
||||
if (cfg.seo.description) {
|
||||
var $desc = $('meta[name="description"]');
|
||||
if ($desc.length) {
|
||||
$desc.attr("content", cfg.seo.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 覆盖基础字段:企业信息 & ICP 等
|
||||
baseData.enterprise_name =
|
||||
cfg.enterprise_name || baseData.enterprise_name;
|
||||
baseData.enterprise_telephone =
|
||||
cfg.enterprise_telephone || baseData.enterprise_telephone;
|
||||
baseData.enterprise_mailbox =
|
||||
cfg.enterprise_mailbox || baseData.enterprise_mailbox;
|
||||
baseData.enterprise_qrcode =
|
||||
cfg.enterprise_qrcode || baseData.enterprise_qrcode;
|
||||
baseData.official_website_logo =
|
||||
cfg.official_website_logo || baseData.official_website_logo;
|
||||
baseData.online_customer_service_link =
|
||||
cfg.online_customer_service_link ||
|
||||
baseData.online_customer_service_link;
|
||||
baseData.icp_info = cfg.icp_info || baseData.icp_info;
|
||||
baseData.icp_info_link =
|
||||
cfg.icp_info_link || baseData.icp_info_link;
|
||||
baseData.public_security_network_preparation =
|
||||
cfg.public_security_network_preparation ||
|
||||
baseData.public_security_network_preparation;
|
||||
baseData.public_security_network_preparation_link =
|
||||
cfg.public_security_network_preparation_link ||
|
||||
baseData.public_security_network_preparation_link;
|
||||
baseData.telecom_appreciation =
|
||||
cfg.telecom_appreciation || baseData.telecom_appreciation;
|
||||
baseData.copyright_info =
|
||||
cfg.copyright_info || baseData.copyright_info;
|
||||
baseData.cloud_product_link =
|
||||
cfg.cloud_product_link || baseData.cloud_product_link;
|
||||
baseData.dcim_product_link =
|
||||
cfg.dcim_product_link || baseData.dcim_product_link;
|
||||
baseData.terms_service_url =
|
||||
cfg.terms_service_url || baseData.terms_service_url;
|
||||
baseData.terms_privacy_url =
|
||||
cfg.terms_privacy_url || baseData.terms_privacy_url;
|
||||
|
||||
// 数组字段:优先使用插件配置
|
||||
if (cfg.friendly_link) {
|
||||
baseData.friendly_link = cfg.friendly_link;
|
||||
}
|
||||
if (cfg.honor) {
|
||||
baseData.honor = cfg.honor;
|
||||
}
|
||||
if (cfg.partner) {
|
||||
baseData.partner = cfg.partner;
|
||||
}
|
||||
if (cfg.feedback_type) {
|
||||
baseData.feedback_type = cfg.feedback_type;
|
||||
}
|
||||
if (cfg.header_nav) {
|
||||
baseData.header_nav = cfg.header_nav;
|
||||
}
|
||||
if (cfg.footer_nav) {
|
||||
baseData.footer_nav = cfg.footer_nav;
|
||||
}
|
||||
if (cfg.side_floating_window) {
|
||||
baseData.side_floating_window = cfg.side_floating_window;
|
||||
}
|
||||
}
|
||||
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setCommData();
|
||||
},
|
||||
error: function () {
|
||||
// 插件不可用则直接使用系统默认配置
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setCommData();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
// 根据插件配置重绘顶部导航(header_nav)
|
||||
const renderHeaderNav = (commentObj) => {
|
||||
var navData = commentObj && commentObj.header_nav;
|
||||
if (!Array.isArray(navData) || navData.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新 Logo 点击链接
|
||||
var home = navData[0] || {};
|
||||
if (home.file_address) {
|
||||
$(".nav-icon a").attr("href", home.file_address);
|
||||
}
|
||||
|
||||
var $menu = $(".nav-menu");
|
||||
var $navContSection = $(".nav-cont .section-content");
|
||||
if (!$menu.length || !$navContSection.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 顶部一级导航
|
||||
$menu.empty();
|
||||
for (var i = 1; i < navData.length; i++) {
|
||||
var item = navData[i] || {};
|
||||
var name = item.name || "";
|
||||
var file = item.file_address || "";
|
||||
var blank = Number(item.blank) === 1;
|
||||
|
||||
if (!name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file) {
|
||||
var $a = $("<a></a>")
|
||||
.attr("href", file)
|
||||
.attr("target", blank ? "_blank" : "_self");
|
||||
$a.append($("<div></div>").addClass("nav-item").text(name));
|
||||
$menu.append($a);
|
||||
} else {
|
||||
$menu.append($("<div></div>").addClass("nav-item").text(name));
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉菜单
|
||||
$navContSection.empty();
|
||||
for (var j = 1; j < navData.length; j++) {
|
||||
var parent = navData[j] || {};
|
||||
var children = Array.isArray(parent.children) ? parent.children : [];
|
||||
if (!children.length) {
|
||||
$navContSection.append(
|
||||
$("<div></div>").addClass("nav-cont-menu nav-cont-empty")
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
var $menuWrap = $("<div></div>").addClass(
|
||||
"nav-cont-menu animated slideInDown"
|
||||
);
|
||||
var $content = $("<div></div>").addClass("nav-content");
|
||||
children.forEach(function (child) {
|
||||
if (!child) return;
|
||||
var cname = child.name || "";
|
||||
var curl = child.file_address || "";
|
||||
var cblank = Number(child.blank) === 1;
|
||||
var cicon = child.icon || "";
|
||||
var cdesc = child.description || "";
|
||||
|
||||
if (!cname && !curl) return;
|
||||
|
||||
var $link = $("<a></a>");
|
||||
if (curl) {
|
||||
$link.attr("href", curl).attr("target", cblank ? "_blank" : "_self");
|
||||
} else {
|
||||
$link.attr("href", "javascript:;");
|
||||
}
|
||||
|
||||
var $box = $("<div></div>").addClass("nav-item-box");
|
||||
if (cicon) {
|
||||
$box.append($("<img>").attr("src", cicon).attr("alt", ""));
|
||||
}
|
||||
var $titleWrap = $("<div></div>").addClass("item-box-title");
|
||||
$titleWrap.append($("<div></div>").addClass("title").text(cname));
|
||||
$titleWrap.append($("<div></div>").addClass("desc").text(cdesc));
|
||||
$box.append($titleWrap);
|
||||
|
||||
$link.append($box);
|
||||
$content.append($link);
|
||||
});
|
||||
|
||||
$menuWrap.append($content);
|
||||
$navContSection.append($menuWrap);
|
||||
}
|
||||
|
||||
// 重绑 hover 事件,避免新节点没有事件
|
||||
$(".nav-menu .nav-item").off("mouseenter mouseleave");
|
||||
$(".nav-cont").off("mouseenter mouseleave");
|
||||
initHeader();
|
||||
};
|
||||
|
||||
// 设置通用信息函数
|
||||
// 设置通用信息相关的点击跳转(云服务器/物理机 CTA 等),来源于 SSR 注入的 window.__themeCommon
|
||||
const setCommData = () => {
|
||||
const commentObj = JSON.parse(sessionStorage.commentData);
|
||||
$("#enterprise_name").text(commentObj.enterprise_name);
|
||||
$(".com-contact-tel").text(commentObj.enterprise_telephone);
|
||||
$("#enterprise_telephone").text(
|
||||
`联系电话:${commentObj.enterprise_telephone}`
|
||||
);
|
||||
$("#enterprise_mailbox").text(`联系邮箱:${commentObj.enterprise_mailbox}`);
|
||||
$("#enterprise_qrcode").attr("src", commentObj.enterprise_qrcode);
|
||||
$("#logo").attr("src", commentObj.official_website_logo);
|
||||
if (commentObj.friendly_link.length > 0) {
|
||||
$("#index #footerLink").attr("style", "display: block;");
|
||||
// 先清空,再填充,避免重复叠加
|
||||
$("#footerLink a").remove();
|
||||
commentObj.friendly_link.forEach((item) => {
|
||||
$("#footerLink").append(
|
||||
`<a href=${item.url} target="_blank" rel="nofollow">${item.name}</a>`
|
||||
);
|
||||
});
|
||||
} else {
|
||||
$("#footerLink").attr("style", "display: none;");
|
||||
}
|
||||
|
||||
// 统一覆盖底部备案信息和版权
|
||||
$("#footerRecord").html(`
|
||||
<div class='left-info'>
|
||||
<a href='${commentObj.icp_info_link}' target="_blank" rel="nofollow">${commentObj.icp_info}</a>
|
||||
<a href='${commentObj.public_security_network_preparation_link}' target="_blank" rel="nofollow">${commentObj.public_security_network_preparation}</a>
|
||||
<span>${commentObj.telecom_appreciation}</span>
|
||||
</div>
|
||||
<span>${commentObj.copyright_info}</span>
|
||||
`);
|
||||
$("#terms_service_url").click(function () {
|
||||
location.href = commentObj.terms_service_url;
|
||||
});
|
||||
$("#terms_privacy_url").click(function () {
|
||||
location.href = commentObj.terms_privacy_url;
|
||||
});
|
||||
|
||||
|
||||
const commentObj = window.__themeCommon || {};
|
||||
$(".buy-cloud").click(function () {
|
||||
location.href = commentObj.cloud_product_link;
|
||||
if (commentObj.cloud_product_link) {
|
||||
location.href = commentObj.cloud_product_link;
|
||||
}
|
||||
});
|
||||
$(".buy-dcim-btn").click(function () {
|
||||
location.href = commentObj.dcim_product_link;
|
||||
if (commentObj.dcim_product_link) {
|
||||
location.href = commentObj.dcim_product_link;
|
||||
}
|
||||
});
|
||||
|
||||
// 顶部导航改用插件 header_nav
|
||||
renderHeaderNav(commentObj);
|
||||
};
|
||||
$(".line-server-btn").click(function () {
|
||||
const commentObj = sessionStorage.commentData
|
||||
? JSON.parse(sessionStorage.commentData)
|
||||
: null;
|
||||
if (commentObj && commentObj.online_customer_service_link) {
|
||||
window.open(commentObj.online_customer_service_link);
|
||||
}
|
||||
});
|
||||
// 跳转函数
|
||||
const goOtherPage = (url) => {
|
||||
sessionStorage.redirectUrl = location.href;
|
||||
@@ -482,8 +223,8 @@ $(function () {
|
||||
});
|
||||
}
|
||||
function initFooter() {
|
||||
// 始终从后端获取最新通用配置,避免缓存导致配置不生效
|
||||
getCommentInfo();
|
||||
// 主题配置已在服务端渲染阶段注入到 window.__themeCommon,这里只做少量点击事件绑定
|
||||
setCommData();
|
||||
}
|
||||
// 首页渲染
|
||||
// $("#header").load("/web/BlackFruit-web/public/header.html", function () {
|
||||
|
||||
108
header.html
108
header.html
@@ -1,11 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" theme-color="default" theme-mode id="addons_js" addons_js='{:json_encode($addons)}'>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{$title}</title>
|
||||
<meta name="keywords" content="{$keywords}" />
|
||||
<meta name="description" content="{$description}" />
|
||||
<head>
|
||||
{php}
|
||||
// 在渲染阶段从主题配置插件读取配置,并覆盖 $data 与 SEO 变量,实现 SSR
|
||||
if (class_exists('\\addon\\theme_configurator\\model\\ThemeConfigModel')) {
|
||||
$cfgModel = new \addon\theme_configurator\model\ThemeConfigModel();
|
||||
$themeCfg = $cfgModel->getConfig();
|
||||
|
||||
if (is_array($themeCfg)) {
|
||||
$site = isset($themeCfg['site_config']) && is_array($themeCfg['site_config'])
|
||||
? $themeCfg['site_config']
|
||||
: [];
|
||||
|
||||
if (!isset($data) || !is_array($data)) {
|
||||
$data = [];
|
||||
}
|
||||
|
||||
// 覆盖 / 补充首页相关结构数据
|
||||
if (isset($themeCfg['banner'])) {
|
||||
$data['banner'] = $themeCfg['banner'];
|
||||
}
|
||||
if (isset($themeCfg['honor'])) {
|
||||
$data['honor'] = $themeCfg['honor'];
|
||||
}
|
||||
if (isset($themeCfg['partner'])) {
|
||||
$data['partner'] = $themeCfg['partner'];
|
||||
}
|
||||
if (isset($themeCfg['friendly_link'])) {
|
||||
$data['friendly_link'] = $themeCfg['friendly_link'];
|
||||
}
|
||||
if (isset($themeCfg['header_nav'])) {
|
||||
$data['header_nav'] = $themeCfg['header_nav'];
|
||||
}
|
||||
if (isset($themeCfg['footer_nav'])) {
|
||||
$data['footer_nav'] = $themeCfg['footer_nav'];
|
||||
}
|
||||
if (isset($themeCfg['side'])) {
|
||||
$data['side_floating_window'] = $themeCfg['side'];
|
||||
}
|
||||
|
||||
// 站点基础信息,供 header/footer 与其他模板直接使用
|
||||
$data['enterprise_name'] = $site['enterprise_name'] ?? ($data['enterprise_name'] ?? '');
|
||||
$data['enterprise_telephone'] = $site['enterprise_telephone'] ?? ($data['enterprise_telephone'] ?? '');
|
||||
$data['enterprise_mailbox'] = $site['enterprise_mailbox'] ?? ($data['enterprise_mailbox'] ?? '');
|
||||
$data['enterprise_qrcode'] = $site['enterprise_qrcode'] ?? ($data['enterprise_qrcode'] ?? '');
|
||||
$data['official_website_logo']= $site['official_website_logo']?? ($data['official_website_logo']?? '');
|
||||
$data['online_customer_service_link'] =
|
||||
$site['online_customer_service_link'] ?? ($data['online_customer_service_link'] ?? '');
|
||||
$data['icp_info'] = $site['icp_info'] ?? ($data['icp_info'] ?? '');
|
||||
$data['icp_info_link'] = $site['icp_info_link'] ?? ($data['icp_info_link'] ?? '');
|
||||
$data['public_security_network_preparation'] =
|
||||
$site['public_security_network_preparation'] ??
|
||||
($data['public_security_network_preparation'] ?? '');
|
||||
$data['public_security_network_preparation_link'] =
|
||||
$site['public_security_network_preparation_link'] ??
|
||||
($data['public_security_network_preparation_link'] ?? '');
|
||||
$data['telecom_appreciation'] = $site['telecom_appreciation'] ?? ($data['telecom_appreciation'] ?? '');
|
||||
$data['copyright_info'] = $site['copyright_info'] ?? ($data['copyright_info'] ?? '');
|
||||
$data['terms_service_url'] = $site['terms_service_url'] ?? ($data['terms_service_url'] ?? '');
|
||||
$data['terms_privacy_url'] = $site['terms_privacy_url'] ?? ($data['terms_privacy_url'] ?? '');
|
||||
$data['cloud_product_link'] = $site['cloud_product_link'] ?? ($data['cloud_product_link'] ?? '');
|
||||
$data['dcim_product_link'] = $site['dcim_product_link'] ?? ($data['dcim_product_link'] ?? '');
|
||||
|
||||
// SEO:如插件配置了 SEO,则覆盖控制器传入的标题/关键词/描述
|
||||
if (!empty($themeCfg['seo']['title'])) {
|
||||
$title = $themeCfg['seo']['title'];
|
||||
}
|
||||
if (!empty($themeCfg['seo']['keywords'])) {
|
||||
$keywords = $themeCfg['seo']['keywords'];
|
||||
}
|
||||
if (!empty($themeCfg['seo']['description'])) {
|
||||
$description = $themeCfg['seo']['description'];
|
||||
}
|
||||
}
|
||||
}
|
||||
{/php}
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<title>{$title}</title>
|
||||
<meta name="keywords" content="{$keywords}" />
|
||||
<meta name="description" content="{$description}" />
|
||||
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -33,13 +108,22 @@
|
||||
|
||||
<link rel="alternate" hreflang="zh-Hans" href="{$url}">
|
||||
<link rel="canonical" href="{$url}">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
|
||||
"@id": "{$url}",
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
|
||||
"@id": "{$url}",
|
||||
"title": "{$title}",
|
||||
"description": "{$description}",
|
||||
"pubDate": "{$pub_date}",
|
||||
"upDate": "{$up_date}"
|
||||
}
|
||||
</script>
|
||||
"upDate": "{$up_date}"
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// 将后端注入的配置映射到前端变量,供旧脚本兼容使用,避免再次通过接口请求主题配置
|
||||
window.__themeCommon = {:json_encode(isset($data) ? $data : [])};
|
||||
try {
|
||||
if (!sessionStorage.commentData) {
|
||||
sessionStorage.commentData = JSON.stringify(window.__themeCommon || {});
|
||||
}
|
||||
} catch (e) {}
|
||||
</script>
|
||||
|
||||
39
index.html
39
index.html
@@ -24,6 +24,44 @@
|
||||
<div class="banner-cont">
|
||||
<div class="banner-text">
|
||||
<div class="section-content">
|
||||
{if isset($data.banner) && !empty($data.banner)}
|
||||
{php}$__firstBanner = $data['banner'][0];{/php}
|
||||
<div class="banner-copy">
|
||||
<div id="bannerTags" class="banner-tags">
|
||||
{if !empty($__firstBanner.tags)}
|
||||
{php}
|
||||
$__tags = preg_split('/[,,]/', $__firstBanner['tags']);
|
||||
{/php}
|
||||
{foreach $__tags as $__t}
|
||||
{php}$__t_trim = trim($__t);{/php}
|
||||
{if $__t_trim != ''}
|
||||
<span class="banner-tag-pill">{$__t_trim}</span>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
<h1 id="bannerTitle">{$__firstBanner.title|default=''}</h1>
|
||||
<p class="banner-desc" id="bannerDesc">{$__firstBanner.description|default=''}</p>
|
||||
{if !empty($__firstBanner.button_text)}
|
||||
<a
|
||||
class="btn btn2 btn-normal"
|
||||
href="{$__firstBanner.button_link|default=$__firstBanner.url|default='javascript:;'}"
|
||||
id="bannerButton"
|
||||
{if !empty($__firstBanner.button_blank)}target="_blank"{else}target="_self"{/if}
|
||||
>
|
||||
{$__firstBanner.button_text}
|
||||
</a>
|
||||
{else /}
|
||||
<a
|
||||
class="btn btn2 btn-normal"
|
||||
href="javascript:;"
|
||||
id="bannerButton"
|
||||
style="display: none;"
|
||||
></a>
|
||||
{/if}
|
||||
</div>
|
||||
{else /}
|
||||
<!-- 兼容未提供 banner 配置时的占位结构,仍由前端 JS 填充 -->
|
||||
<div class="banner-copy">
|
||||
<div id="bannerTags" class="banner-tags"></div>
|
||||
<h1 id="bannerTitle"></h1>
|
||||
@@ -35,6 +73,7 @@
|
||||
style="display: none;"
|
||||
></a>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- 3D 地球容器(Three.js 渲染输出挂载到这里),与下方卡片区域共用 section-content 对齐 -->
|
||||
<div id="bannerGlobe" class="banner-globe"></div>
|
||||
</div>
|
||||
|
||||
74
js/about.js
74
js/about.js
@@ -20,54 +20,12 @@ $(function () {
|
||||
viewer.show();
|
||||
});
|
||||
|
||||
// 获取通用配置信息(关于页:用插件覆盖 honor/partner)
|
||||
function getCommentInfo() {
|
||||
$.ajax({
|
||||
url: "/console/v1/common",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (res) {
|
||||
if (!res || res.status !== 200 || !res.data) {
|
||||
return;
|
||||
}
|
||||
var baseData = res.data || {};
|
||||
|
||||
$.ajax({
|
||||
url: "/console/v1/theme/config",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (pluginRes) {
|
||||
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
|
||||
var cfg = pluginRes.data || {};
|
||||
if (cfg.honor) {
|
||||
baseData.honor = cfg.honor;
|
||||
}
|
||||
if (cfg.partner) {
|
||||
baseData.partner = cfg.partner;
|
||||
}
|
||||
}
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
error: function () {
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
// 获取首页数据
|
||||
getCommentInfo();
|
||||
|
||||
// 设置首页函数
|
||||
function setIndexData() {
|
||||
const commentObj = JSON.parse(sessionStorage.commentData);
|
||||
if (commentObj.honor.length > 0) {
|
||||
const commentObj = window.__themeCommon
|
||||
? window.__themeCommon
|
||||
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
|
||||
if (Array.isArray(commentObj.honor) && commentObj.honor.length > 0) {
|
||||
commentObj.honor.forEach((item) => {
|
||||
$("#honor-box").append(`
|
||||
<div class="box-item">
|
||||
@@ -77,14 +35,18 @@ $(function () {
|
||||
`);
|
||||
});
|
||||
}
|
||||
commentObj.partner.forEach((item) => {
|
||||
$("#partner-box").append(`
|
||||
<div class="box-item">
|
||||
<img src="${item.img}" alt="">
|
||||
<h4 class="mt-30">${item.name}</h4>
|
||||
<p class="mt-20">${item.description}</p>
|
||||
</div>
|
||||
`);
|
||||
});
|
||||
}
|
||||
if (Array.isArray(commentObj.partner)) {
|
||||
commentObj.partner.forEach((item) => {
|
||||
$("#partner-box").append(`
|
||||
<div class="box-item">
|
||||
<img src="${item.img}" alt="">
|
||||
<h4 class="mt-30">${item.name}</h4>
|
||||
<p class="mt-20">${item.description}</p>
|
||||
</div>
|
||||
`);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 直接使用服务端注入的数据渲染关于页
|
||||
setIndexData();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
$(function () {
|
||||
const setIndexData = () => {
|
||||
const commentObj = JSON.parse(sessionStorage.commentData);
|
||||
commentObj.feedback_type.forEach((item, index) => {
|
||||
const setIndexData = () => {
|
||||
const commentObj = window.__themeCommon
|
||||
? window.__themeCommon
|
||||
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
|
||||
const types = Array.isArray(commentObj.feedback_type)
|
||||
? commentObj.feedback_type
|
||||
: [];
|
||||
types.forEach((item, index) => {
|
||||
$("#radioBox").append(`
|
||||
<div class="radio">
|
||||
<input type="radio" name="radioId" id="ptionsRadios${index}" value=${item.id} />
|
||||
@@ -65,43 +70,6 @@ $(function () {
|
||||
input.attr("style", "border: 1px solid #E6EAED;");
|
||||
return true;
|
||||
}
|
||||
// 获取通用配置信息(反馈页:用插件覆盖 feedback_type)
|
||||
function getCommentInfo() {
|
||||
$.ajax({
|
||||
url: "/console/v1/common",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (res) {
|
||||
if (!res || res.status !== 200 || !res.data) {
|
||||
return;
|
||||
}
|
||||
var baseData = res.data || {};
|
||||
|
||||
$.ajax({
|
||||
url: "/console/v1/theme/config",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (pluginRes) {
|
||||
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
|
||||
var cfg = pluginRes.data || {};
|
||||
if (cfg.feedback_type) {
|
||||
baseData.feedback_type = cfg.feedback_type;
|
||||
}
|
||||
}
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
error: function () {
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
getCommentInfo();
|
||||
// 反馈页直接使用服务端注入的反馈类型渲染单选项
|
||||
setIndexData();
|
||||
});
|
||||
|
||||
64
js/index.js
64
js/index.js
@@ -106,13 +106,15 @@ $(function () {
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
// 设置首页函数
|
||||
// 设置首页函数:直接使用服务端注入的 window.__themeCommon(SSR 数据),避免再次请求配置
|
||||
function setIndexData() {
|
||||
const commentObj = JSON.parse(sessionStorage.commentData);
|
||||
const commentObj = window.__themeCommon
|
||||
? window.__themeCommon
|
||||
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
|
||||
bannerData = commentObj.banner || [];
|
||||
// 仅轮播文案
|
||||
startBannerTextLoop();
|
||||
if (commentObj.honor.length > 0) {
|
||||
if (Array.isArray(commentObj.honor) && commentObj.honor.length > 0) {
|
||||
commentObj.honor.forEach((item) => {
|
||||
$("#certBox").append(`<div class="cert-item">
|
||||
<img src=${item.img} alt="">
|
||||
@@ -120,7 +122,7 @@ $(function () {
|
||||
</div>`);
|
||||
});
|
||||
}
|
||||
if (commentObj.partner.length > 0 && commentObj.partner.length <= 3) {
|
||||
if (Array.isArray(commentObj.partner) && commentObj.partner.length > 0 && commentObj.partner.length <= 3) {
|
||||
commentObj.partner.forEach((item) => {
|
||||
$("#practiceBox").append(`<div class="practice-box">
|
||||
<img src="${item.img}" alt="">
|
||||
@@ -128,7 +130,7 @@ $(function () {
|
||||
<p class="tr font-grey mt-20 font12">${item.name}</p>
|
||||
</div>`);
|
||||
});
|
||||
} else if (commentObj.partner.length > 3) {
|
||||
} else if (Array.isArray(commentObj.partner) && commentObj.partner.length > 3) {
|
||||
const arr1 = commentObj.partner.slice(0, 3);
|
||||
const arr2 = commentObj.partner.slice(3);
|
||||
arr1.forEach((item) => {
|
||||
@@ -146,56 +148,8 @@ $(function () {
|
||||
});
|
||||
}
|
||||
}
|
||||
// 获取通用配置信息(首页:先用 /console/v1/common,再用插件配置覆盖后渲染荣誉/合作伙伴)
|
||||
function getCommentInfo() {
|
||||
$.ajax({
|
||||
url: "/console/v1/common",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (res) {
|
||||
if (!res || res.status !== 200 || !res.data) {
|
||||
return;
|
||||
}
|
||||
var baseData = res.data || {};
|
||||
|
||||
$.ajax({
|
||||
url: "/console/v1/theme/config",
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: "Bearer" + " " + localStorage.jwt,
|
||||
},
|
||||
success: function (pluginRes) {
|
||||
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
|
||||
var cfg = pluginRes.data || {};
|
||||
// 仅覆盖首页会用到的字段:honor/partner/banner/friendly_link 等
|
||||
if (cfg.honor) {
|
||||
baseData.honor = cfg.honor;
|
||||
}
|
||||
if (cfg.partner) {
|
||||
baseData.partner = cfg.partner;
|
||||
}
|
||||
if (cfg.banner) {
|
||||
baseData.banner = cfg.banner;
|
||||
}
|
||||
if (cfg.friendly_link) {
|
||||
baseData.friendly_link = cfg.friendly_link;
|
||||
}
|
||||
}
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
error: function () {
|
||||
sessionStorage.commentData = JSON.stringify(baseData);
|
||||
setIndexData();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
// 获取首页数据
|
||||
getCommentInfo();
|
||||
// 首页直接使用服务端注入的数据渲染(SSR),不再请求 /console/v1/common 或 /console/v1/theme/config
|
||||
setIndexData();
|
||||
var viewer = new Viewer(document.getElementById("viewer"), {
|
||||
button: true,
|
||||
inline: false,
|
||||
|
||||
@@ -76,15 +76,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-nav-box">
|
||||
<div class="footer-nav-head">其他</div>
|
||||
<div class="footer-nav-cont">
|
||||
<div class="footer-nav-item"><a class="link-hover" id="terms_service_url" href="javascript:;">用户协议</a></div>
|
||||
<div class="footer-nav-item"><a class="link-hover" id="terms_privacy_url" href="javascript:;">隐私政策</a></div>
|
||||
<div class="footer-nav-item"><a class="link-hover" href="/agreement.htm?id=26">Cookies政策</a></div>
|
||||
<div class="footer-nav-item"><a class="link-hover" href="/agreement.htm?id=27">法律声明</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-nav-box">
|
||||
<div class="footer-nav-head">其他</div>
|
||||
<div class="footer-nav-cont">
|
||||
<div class="footer-nav-item">
|
||||
<a class="link-hover" id="terms_service_url" href="{$data.terms_service_url|default='/agreement/service.html'}">用户协议</a>
|
||||
</div>
|
||||
<div class="footer-nav-item">
|
||||
<a class="link-hover" id="terms_privacy_url" href="{$data.terms_privacy_url|default='/agreement/privacy.html'}">隐私政策</a>
|
||||
</div>
|
||||
<div class="footer-nav-item"><a class="link-hover" href="/agreement.htm?id=26">Cookies政策</a></div>
|
||||
<div class="footer-nav-item"><a class="link-hover" href="/agreement.htm?id=27">法律声明</a></div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -92,29 +96,48 @@
|
||||
<div class="footer-nav-box">
|
||||
<div class="footer-nav-head">联系我们</div>
|
||||
<div class="footer-nav-cont">
|
||||
<div class="footer-nav-item" id="enterprise_name"></div>
|
||||
<div class="footer-nav-item mt-20" id="enterprise_telephone"></div>
|
||||
<div class="footer-nav-item" id="enterprise_mailbox"></div>
|
||||
<div class="footer-nav-item" id="enterprise_name">{$data.enterprise_name|default=''}</div>
|
||||
<div class="footer-nav-item mt-20" id="enterprise_telephone">
|
||||
{if !empty($data.enterprise_telephone)}联系电话:{$data.enterprise_telephone}{/if}
|
||||
</div>
|
||||
<div class="footer-nav-item" id="enterprise_mailbox">
|
||||
{if !empty($data.enterprise_mailbox)}联系邮箱:{$data.enterprise_mailbox}{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="qr-code">
|
||||
<img src="{$data.enterprise_qrcode|default=''}" alt="" id="enterprise_qrcode">
|
||||
</div>
|
||||
<div class="qr-code"><img src="" alt="" id="enterprise_qrcode"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if ( isset($data.friendly_link) ) }
|
||||
<div class="footer-link">
|
||||
<span>友情链接:</span>
|
||||
{foreach $data.friendly_link as $key=>$value}
|
||||
<a href={$value.url} target="_blank" rel="nofollow">{$value.name}</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
{else /}
|
||||
<div class="footer-link" id="footerLink">
|
||||
<span>友情链接:</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if ( isset($data.friendly_link) && !empty($data.friendly_link) ) }
|
||||
<div class="footer-link">
|
||||
<span>友情链接:</span>
|
||||
{foreach $data.friendly_link as $key=>$value}
|
||||
<a href={$value.url} target="_blank" rel="nofollow">{$value.name}</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
{else /}
|
||||
<div class="footer-link" id="footerLink">
|
||||
<span>友情链接:</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="footer-record" id="footerRecord">
|
||||
<!-- 备案信息与版权由前端 common.js 的 setCommData 使用接口数据统一渲染 -->
|
||||
<div class="left-info">
|
||||
{if !empty($data.icp_info)}
|
||||
<a href="{$data.icp_info_link|default=''}" target="_blank" rel="nofollow">{$data.icp_info}</a>
|
||||
{/if}
|
||||
{if !empty($data.public_security_network_preparation)}
|
||||
<a href="{$data.public_security_network_preparation_link|default=''}" target="_blank" rel="nofollow">
|
||||
{$data.public_security_network_preparation}
|
||||
</a>
|
||||
{/if}
|
||||
{if !empty($data.telecom_appreciation)}
|
||||
<span>{$data.telecom_appreciation}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<span>{$data.copyright_info|default=''}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
<div class="nav-shadow">
|
||||
<div class="section-content nav-header">
|
||||
<div class="section-content nav-header">
|
||||
<div class="nav-left">
|
||||
{php}
|
||||
// 顶部导航与 Logo 走服务端渲染,兼容未配置时的默认值
|
||||
$__homeNav = isset($data['header_nav'][0])
|
||||
? $data['header_nav'][0]
|
||||
: ['file_address' => 'index.html', 'blank' => false];
|
||||
{/php}
|
||||
<div class="nav-icon">
|
||||
<a href="index.html">
|
||||
<img src="" alt="" id="logo">
|
||||
<a href="{$__homeNav.file_address|default='index.html'}" {if !empty($__homeNav.blank)}target="_blank"{/if}>
|
||||
<img src="{$data.official_website_logo|default='/web/BlackFruit-web/assets/img/index/logo.png'}" alt="" id="logo">
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-menu">
|
||||
<!-- 顶部导航内容由前端 common.js 的 renderHeaderNav 使用插件 header_nav 重绘 -->
|
||||
{if isset($data.header_nav) && !empty($data.header_nav)}
|
||||
{foreach $data.header_nav as $k=>$item}
|
||||
{if $k > 0}
|
||||
{if !empty($item.file_address)}
|
||||
<a href="{$item.file_address}" {if !empty($item.blank)}target="_blank"{/if}>
|
||||
<div class="nav-item">{$item.name}</div>
|
||||
</a>
|
||||
{else /}
|
||||
<div class="nav-item">{$item.name}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-right">
|
||||
@@ -42,9 +60,36 @@
|
||||
|
||||
<div class="nav-cont">
|
||||
<div class="section-content">
|
||||
<!-- 下拉导航内容由前端 common.js 的 renderHeaderNav 使用插件 header_nav 重绘 -->
|
||||
</div>
|
||||
</div>
|
||||
{if isset($data.header_nav) && !empty($data.header_nav)}
|
||||
{foreach $data.header_nav as $k=>$item}
|
||||
{if $k > 0}
|
||||
{if isset($item.children) && !empty($item.children)}
|
||||
<div class="nav-cont-menu animated slideInDown">
|
||||
<div class="nav-content">
|
||||
{foreach $item.children as $child}
|
||||
<a href="{if !empty($child.file_address)}{$child.file_address}{else/}javascript:;{/if}"
|
||||
{if !empty($child.blank)}target="_blank"{/if}>
|
||||
<div class="nav-item-box">
|
||||
{if !empty($child.icon)}
|
||||
<img src="{$child.icon}" alt="">
|
||||
{/if}
|
||||
<div class="item-box-title">
|
||||
<div class="title">{$child.name}</div>
|
||||
<div class="desc">{$child.description}</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
{else /}
|
||||
<div class="nav-cont-menu nav-cont-empty"></div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -68,24 +113,24 @@
|
||||
{/foreach}
|
||||
{else /}
|
||||
<div class="tools-item">
|
||||
<img src="/web/BlackFruit-web/assets/img/index/phone.png" alt="">
|
||||
<div class="tools-box">
|
||||
<div class="tools-box-s">
|
||||
<h5>电话咨询</h5>
|
||||
<p>7*24h不间断服务</p>
|
||||
<p class="com-contact-tel"></p>
|
||||
</div>
|
||||
</div>
|
||||
<img src="/web/BlackFruit-web/assets/img/index/phone.png" alt="">
|
||||
<div class="tools-box">
|
||||
<div class="tools-box-s">
|
||||
<h5>电话咨询</h5>
|
||||
<p>7*24h不间断服务</p>
|
||||
<p class="com-contact-tel">{$data.enterprise_telephone|default=''}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tools-item">
|
||||
<img src="/web/BlackFruit-web/assets/img/index/listen.png" alt="">
|
||||
<div class="tools-box">
|
||||
<div class="tools-box-s">
|
||||
<h5>在线客服</h5>
|
||||
<p>工作日 09:00-18:00</p>
|
||||
<a href="javascript:;" class="line-server-btn">
|
||||
<div class="button">立即查询</div>
|
||||
</a>
|
||||
<img src="/web/BlackFruit-web/assets/img/index/listen.png" alt="">
|
||||
<div class="tools-box">
|
||||
<div class="tools-box-s">
|
||||
<h5>在线客服</h5>
|
||||
<p>工作日 09:00-18:00</p>
|
||||
<a href="{$data.online_customer_service_link|default='javascript:;'}" class="line-server-btn" target="_blank">
|
||||
<div class="button">立即查询</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user