騫跨數(shù)欏圭2022騫村害宸ヤ綔鏆ㄨ〃褰板ぇ浼?xì)鍦嗘弧鍙紑
瀹夊窘鐪佹嫑鏍囬噰璐崗浼?xì)浼?xì)闀挎鍚涗集涓€琛屽埌騫跨數(shù)欏圭鑾呬復(fù)鎸囧宸ヤ綔
浜ゆ槗淇℃伅
Trading Information
- 鎷涙爣鍏憡
- 婢勬竻/鍙樻洿鍏憡
- 嫻佹爣鍏憡
- 涓爣鍊欓€変漢鍏ず
- 涓爣鍏憡
(function (win) {
// 浣庣増鏈鏋禼ssboot.js涓湭閰嶇疆THEME_CONFIG,鎵嬪姩閰嶇疆THEME_CONFIG
if (typeof THEME_CONFIG === 'undefined') {
win.THEME_CONFIG = {
customTheme: {
layout: 'simple',
skins: [
{
name: 'default',
cname: '縐戞妧钃?,
colorObj: {
primaryColor: '#3a6fca',
primaryBackgroundColor: '#ecf5fc'
}
},
{
name: 'chinared',
cname: '涓浗綰?,
colorObj: {
primaryColor: '#e53335',
primaryBackgroundColor: '#f7f3f3'
}
}
]
}
};
}
var defaultTheme = 'customTheme';
//鑾峰彇鍚庡彴閰嶇疆鐨勯粯璁ょ毊鑲?
var defaultcolor =
"default"
;
defaultcolor = (defaultcolor == 'chinared' || defaultcolor == 'default') ? defaultcolor : '';
// 浠巆ookie涓鍙栦富棰樺悕銆佺毊鑲ゅ悕
var theme = getCookie('_theme_') || defaultTheme,
// 浠巆ookie涓牴鎹富棰樺悕鑾峰彇鐨偆鍚嶏紝濡傛灉鏈畾涔夊垯榛樿`default`
skin = getCookie('_' + theme + '_skin_') || defaultcolor || 'default';
win.skin = skin;
function getCookie(sName) {
var aCookie = document.cookie.split('; ');
var lastMatch = null;
for (var i = 0; i < aCookie.length; i++) {
var aCrumb = aCookie[i].split('=');
if (sName == aCrumb[0]) {
lastMatch = aCrumb;
}
}
if (lastMatch) {
var v = lastMatch[1];
if (v === undefined) return v;
return decodeURI(v);
}
return null;
}
// 瀵硅薄鍚堝茍
function assign() {
var target = arguments[0];
var i = 1,
len = arguments.length,
key = '',
obj = null,
hasOwnProperty = Object.prototype.hasOwnProperty;
for (; i < len; i++) {
obj = arguments[i];
for (key in obj) {
if (hasOwnProperty.call(obj, key)) {
target[key] = obj[key];
}
}
}
return target;
}
// 綾誨瀷鍒ゆ柇
var class2type = {
'[object Boolean]': 'boolean',
'[object Number]': 'number',
'[object String]': 'string',
'[object Function]': 'function',
'[object Array]': 'array',
'[object Date]': 'date',
'[object RegExp]': 'regexp',
'[object Object]': 'object',
'[object Error]': 'error',
'[object Symbol]': 'symbol'
};
function getType(obj) {
if (obj == null) {
return obj + '';
}
var str = Object.prototype.toString.call(obj);
return typeof obj === 'object' || typeof obj === 'function' ? class2type[str] || 'object' : typeof obj;
}
// 涓€澶╃殑姣鏁扮洰
var DAY_MILLISECONDS = 1000 * 60 * 60 * 24;
// 緇熶竴鐨刢ookie閰嶇疆
var DEFAULT_COOKIE_OPTIONS = {
// 榪囨湡鏃墮棿 鍗曚綅澶?
// expires: 30,
// path: '/',
// domain: '',
// secure: false
};
// 璁劇疆cookie鐨勯粯璁ら厤緗?
var setCookieDefaultOption = function (opt) {
for (var k in opt) {
if (Object.prototype.hasOwnProperty.call(opt, k)) {
DEFAULT_COOKIE_OPTIONS[k] = opt[k];
}
}
};
/**
* 鍐欏叆cookie
*
* @param {string} key cookie 鍚嶇О
* @param {string} value cookie 鍊?
* @param {object | undefined} options 褰撳墠cookie鐨勯厤緗?{ expires,path,domain,secure }
* @returns {string} 鍐欏叆鐨刢ookie
*/
var writeCookie = function (key, value, options) {
if (!options || getType(options) != 'object') {
options = assign({}, DEFAULT_COOKIE_OPTIONS, options || {});
}
// 榪囨湡鏃墮棿
if (getType(options.expires) == 'number') {
var d = options.expires;
options.expires = new Date();
options.expires.setMilliseconds(options.expires.getMilliseconds() + d * DAY_MILLISECONDS);
}
return (document.cookie = [
encodeURIComponent(key),
'=',
value,
options.expires ? '; expires=' + options.expires.toUTCString() : '',
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
};
/**
* 鏍規(guī)嵁褰撳墠涓婚鍜岀毊鑲?杈撳嚭欏甸潰涓€у寲鐨偆璧勬簮
* @param {string} themeName
* @param {string} currSkin
*/
function outputCustomSkin(themeName, currSkin) {
// 欏甸潰css鏂囦歡鐩綍緇撴瀯
var skinPrePath = '/css/skins/';
var delayArr = [],
isCurr = false,
name = 'custom-page-style', // 鏍囪瘑鐢ㄤ簬鏇存柊skin
skin;
// 褰撳墠涓婚?shù)笅鍚湁鐨勭毊鑲?
var skins = THEME_CONFIG[themeName] ? THEME_CONFIG[themeName].skins : [{ name: 'default' }];
if (cssRes && cssRes.length) {
for (var i = 0, l = skins.length; i < l; i++) {
skin = skins[i];
isCurr = skin.name === currSkin ? true : false;
for (var j = 0, cssLen = cssRes.length; j < cssLen; j++) {
linkStr =
'';
if (isCurr) {
output(linkStr);
} else {
delayArr.push(linkStr);
}
}
}
}
if (delayArr.length) {
setTimeout(function () {
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', delayArr.join(''));
}, 600);
}
function output(str) {
document.writeln(str);
}
}
// 杈撳嚭欏甸潰璧勬簮
outputCustomSkin(theme, skin);
/**
* 鏇存柊鐨偆
* @param {string} skin 鐨偆鍚嶇О
*/
function updateCustomSkin(skin) {
$('[name="custom-page-style"]')
.prop('disabled', true)
.filter('[data-name="' + skin + '"]')
.prop('disabled', false);
// 鏇存柊cookie
writeCookie('_' + theme + '_skin_', skin);
// location.reload();
setTimeout(function () {
if (document.createEvent) {
var event = document.createEvent('HTMLEvents');
event.initEvent('resize', true, true);
window.dispatchEvent(event);
} else if (document.createEventObject) {
window.fireEvent('onresize');
}
}, 30);
}
win.updateCustomSkin = updateCustomSkin;
// 鏇存柊鐨偆
function handleUpdateCustomSkins(event) {
if (!event.data) return;
try {
var data = JSON.parse(event.data);
if (data.type == 'skinChange' && data.skin) {
updateCustomSkin(data.skin);
if (Util.skinSwitcher) {
Util.skinSwitcher.postToChild(data.skin);
} else {
var iframes = document.getElementsByTagName('iframe');
try {
$.each(iframes, function (i, ifr) {
setTimeout(function () {
ifr.contentWindow.postMessage(
JSON.stringify({
type: 'skinChange',
skin: data.skin
}),
'*'
);
});
});
} catch (error) {
console.error(error);
iframes = null;
}
iframes = null;
}
}
} catch (error) {
console.error(error);
}
}
// 鐩戝惉鐖墮〉闈?鎹㈣偆
if (win.addEventListener) {
win.addEventListener('message', handleUpdateCustomSkins);
} else if (win.attachEvent) {
win.attachEvent('onmessage', handleUpdateCustomSkins);
}
})(this);