省建筑工程招标投标协会何传波理事长一行莅临广电项管调研指导
广电项管2022年度工作暨表彰大会圆满召开
安徽省招标采购协会会长殷君伯一行到广电项管莅临指导工作
- 招标公告
- 澄清/变更公告
- 流标公告
- 中标候选人公示
- 中标公告
(function (win) {
// 低版本框架cssboot.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 : '';
// 从cookie中读取主题名、皮肤名
var theme = getCookie('_theme_') || defaultTheme,
// 从cookie中根据主题名获取皮肤名,如果未定义则默认`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;
// 统一的cookie配置
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} 写入的cookie
*/
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(''));
};
/**
* 根据当前主题和皮肤 输出页面个性化皮肤资源
* @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;
// 当前主题下含有的皮肤
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);