define(function (t) {
$.support.cors = true;
if (typeof _hmt == 'undefined') {
window._hmt = window._hmt || [];
}
window.common = {
requests: 1,
clktk_click:'',
curl_click:'',
// 动态dom模板
supplant: function (template, values, pattern) {
pattern = pattern || /\{([^\{\}]*)\}/g
return template.replace(pattern, function (a, b) {
var p = b.split('.'),
r = values
try {
for (var s in p) {
if (p.hasOwnProperty(s)) {
r = r[p[s]];
}
}
} catch (e) {
r = a
}
return (typeof r === 'string' || typeof r === 'number') ? r : a
})
},
// 获取用户设备的宽高
userClientWidth: function() {
if (window.innerHeight !== undefined) {
return {
"width": window.innerWidth,
"height": window.innerHeight
}
} else if (document.compatMode === "CSS1Compat") {
return {
"width": document.documentElement.clientWidth,
"height": document.documentElement.clientHeight
}
} else {
return {
"width": document.body.clientWidth,
"height": document.body.clientHeight
}
}
},
// 获取系统
getSystem: function () {
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
if (isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if (isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if (isLinux) return "Linux";
if (isWin) {
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if (isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if (isWinXP) return "WinXP";
var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
if (isWin2003) return "Win2003";
var isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
if (isWinVista) return "WinVista";
var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
if (isWin7) return "Win7";
var isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1;
if (isWin10) return "Win10";
}
return "other";
},
// 获取浏览器
getBrowser:function () {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
var isIE = userAgent.indexOf("compatible") > -1
&& userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isSafari = userAgent.indexOf("Safari") > -1
&& userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
var isChrome = userAgent.indexOf("Chrome") > -1
&& userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) {
return "IE7";
} else if (fIEVersion == 8) {
return "IE8";
} else if (fIEVersion == 9) {
return "IE9";
} else if (fIEVersion == 10) {
return "IE10";
} else if (fIEVersion == 11) {
return "IE11";
} else {
return "0";
}//IE版本过低
return "IE";
}
if (isOpera) {
return "Opera";
}
if (isEdge) {
return "Edge";
}
if (isFF) {
return "FF";
}
if (isSafari) {
return "Safari";
}
if (isChrome) {
return "Chrome";
}
},
// 懒加载图片
lazyImg: function() {
var images = $(".lazy");
// load images that have entered the viewport
$(images).each(function (index) {
if (common.isElementInViewport(this)) {
$(this).attr("src", $(this).attr("data-origina"));
$(this).removeAttr("data-origina").removeClass('lazy');
}
});
},
isElementInViewport: function(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= $(window).height() &&
rect.right <= $(window).width()
);
},
// 深拷贝
// deepCopy(obj) {
// var t = this;
// var result = Array.isArray(obj) ? [] : {};
// for (var key in obj) {
// if (obj.hasOwnProperty(key)) {
// if (typeof obj[key] === 'object' && obj[key]!==null) {
// result[key] = t.deepCopy(obj[key]);
// } else {
// result[key] = obj[key];
// }
// }
// }
// return result;
// },
//获取url参数
getUrlParmsAll: function (query) {
var str = query.split("?");//在逗号处断开
if (!str[1]) {
return [];
}
var pairs = str[1];
var pairs2 = pairs.split('&');
var arrall = [];
if (pairs2.length > 0) {
for (var i = 0; i < pairs2.length; i++) {
var p = pairs2[i].split('=');
var arr = [];
arr['name'] = p[0];
arr['value'] = p[1];
arrall.push(arr);
}
}
return arrall;
},
//百度广告加载
loadPjs: function (el, op, loc) {
var _script = document.createElement("script");
var _iframe = document.createElement("iframe");
_script.type = "text/javascript";
switch (op.ad_type) {
case 'baidu':
_script.setAttribute('smua', op.id_smua);
_script.setAttribute('src', op.src);
break;
case 'taobao':
_script.setAttribute('charset', 'gbk');
_script.id = 'tanx-s-mm_' + op.id_smua;
_script.setAttribute('async', true);
$(el).append('<a style="display:none!important" id="tanx-a-mm_' + op.id_smua + '"></a>');
break;
case 'game':
common.prepareFrame(el, config.url + '/public/werburg/html/' + op.ad_type + '/' + op.id_smua + '.html');
break;
case 'google':
common.prepareFrame(el, config.url + '/public/werburg/html/' + op.ad_type + '/' + op.aid + '.html');
break;
case 'original_bd':
common.prepareScript(el, op);
break;
case "zhike":
var locN = loc + 'close';
function closeClick(e) {
_hmt.push(['_trackEvent', 'detail', 'click', locN]);
$(this).parents('.zhike').hide();
e.stopPropagation();
}
if(op.screen.length == 0){
$(el).empty()
if(op.is_close) {
$(el).append('<div><a href="' + op.url + '" target="_blank"><img src="' + op.img + '"></a><img src="/public/images/incentive-close.png" class="zhike_close" onclick="_hmt.push([\'_trackEvent\', \'detail\', \'click\',\'' + locN + '\']);$(this).parents(\'.zhike\').hide();event.stopPropagation();event.cancelBubble = true;" style="position:absolute;right:0;top:0;cursor:pointer;width:18px;height:16px;"></div>')
} else {
$(el).append('<a href="' + op.url + '" target="_blank"><img src="' + op.img + '"></a>')
}
var start_time_zhike = new Date().getTime();
baidu_Report.str({
ad_id: "null",
position: el.attr('data-loc'),
time: start_time_zhike,
ad_type: "zhike",
behavior:"show"
})
$(el).on('click', function() {
var zhikePosition = $(this).data("loc");
var start_time_zhike = new Date().getTime();
baidu_Report.str({
ad_id: "null",
position: zhikePosition,
time: start_time_zhike,
ad_type: "zhike",
behavior:"click"
})
})
if(op.img) {
if($(el).hasClass('zhike02')) {
$(el).parent().height(267)
}
}
} else {
$.ajax({
url: "http://iplocation.7654.com/v1",
dataType: "json",
success: function(data) {
var zone = data.city;
var zoneFlag = true;
if(zone) {
if(op.screen) {
for(var i = 0; i < op.screen.length; i++) {
if(zone.indexOf(op.screen[i]) == 0) {
zoneFlag = false;
}
}
}
if(zoneFlag) {
$(el).empty()
if(op.is_close) {
$(el).append('<div><a href="' + op.url + '" target="_blank"><img src="' + op.img + '"></a><img class="zhike_close" src="/public/images/incentive-close.png" onclick="_hmt.push([\'_trackEvent\', \'detail\', \'click\',\'' + locN + '\']);$(this).parents(\'.zhike\').hide();event.stopPropagation();event.cancelBubble = true;" style="position:absolute;right:0;top:0;cursor:pointer;width:18px;height:16px;"></div>')
} else {
$(el).append('<a href="' + op.url + '" target="_blank"><img src="' + op.img + '"></a>')
}
var start_time_zhike = new Date().getTime();
baidu_Report.str({
ad_id: "null",
position: el.attr('data-loc'),
time: start_time_zhike,
ad_type: "zhike",
behavior:"show"
})
$(el).on('click', function() {
var zhikePosition = $(this).data("loc");
var start_time_zhike = new Date().getTime();
baidu_Report.str({
ad_id: "null",
position: zhikePosition,
time: start_time_zhike,
ad_type: "zhike",
behavior:"click"
})
})
if(op.img) {
if($(el).hasClass('zhike02')) {
$(el).parent().height(267)
}
}
}
}
},
error: function(err) {
return
}
})
}
break;
case 'sougou':
var _width = op.id_smua.split(",")[0];
var _height = op.id_smua.split(",")[1];
$(_iframe).css({
"width": _width,
"height": _height
})
var srcDoc = '<script>var sogou_ad_id=' + op.aid + ';var sogou_ad_width=' + _width + ';var sogou_ad_height=' + _height + ';</script><script type="text/javascript" src="' + op.src + '"></script>'
_iframe.setAttribute('srcdoc', srcDoc)
_iframe.setAttribute('marginwidth', 0)
_iframe.setAttribute('marginheight', 0)
_iframe.setAttribute('align', "center,center")
_iframe.setAttribute('frameborder', 0)
_iframe.setAttribute('scrolling', "no")
}
var ad_start_time = new Date().getTime();
if(op.ad_type != "zhike") {
baidu_Report.str({
// clicking_behavior: "click_" + ad_type + "",
ad_id: op.aid,
position: $(el).attr('id'),
time: ad_start_time,
ad_type: op.ad_type,
behavior:"show"
})
}
if (op && op.src && op.ad_type !== 'original_bd') {
_script.src = op.src;
el.attr("data-id", op.aid)//广告的id
el.attr("data-type", op.ad_type)//广告的类别
if (op.ad_type == "sougou") {
el[0].appendChild(_iframe)
} else {
el[0].appendChild(_script);
}
}
},
prepareScript: function(el,op) {
var _aid = op.aid;
if ($(el).attr("data_toc") == "suspend") {
var cc = $('<script type="text/javascript">var cpro_id = "' + op.aid + '";</script><script type="text/javascript" src="' + op.src + '"></script>')
$(el).append(cc)
} else {
el.attr("data-id", op.aid)//广告的id
el.attr("data-type", op.ad_type)//广告的类别
$.getScript("http://cpro.baidustatic.com/cpro/ui/c.js", function () {
// console.log("百度回调")
BAIDU_CLB_fillSlotAsync(op.aid, $(el).attr("id"));
})
}
},
prepareFrame: function(el, src) {
var ifrm = document.createElement("iframe");
ifrm.setAttribute("src", src);
ifrm.width = $(el).width();
ifrm.height = $(el).height();
ifrm.style.cssText = 'margin:0;padding:0;border:0;';
$(el)[0].appendChild(ifrm);
},
lodMedia: function(_obj, _loc, _param) {
var getTag3 = [], _objData = {};
if(_loc) {
_objData = _param[_loc];
if(typeof _objData != 'undefined') {
var nowTime = $.cookie("deepTimes")
var nowAd = nowTime % (_objData.length)
if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1) {
getTag3.push(_objData.aid);
common.loadPjs(_obj, _objData,_loc);
} else {
getTag3.push(_objData[nowAd].aid);
common.loadPjs(_obj, _objData[nowAd],_loc);
}
_obj.removeClass("union_star").removeClass("tanx").removeClass("info_tanx").addClass("reloadMedia1");
}
}
return getTag3;
},
// 百度上报
send_eater: function(param) {
if (param.length > 0) {
var get_hmt = new Image();
get_hmt.src = "//eater.xiaoxiangbz.com/11.gif?proj=news&label=ad&event=show&pos1=" + config.refer + "&tag1=&tag2=" + config.qid + "&tag3=" + param[0];
}
},
// 百度广告加载
union_tanx: function(param) {
// common.getZone();
var _param = param,getTag3 = [];
// $(".afp").each(function (j, item) {
// if ($(item).find("iframe").length > 0 && _param[$(item).attr("data-loc")]) {
// $(item).attr("data-id", _param[$(item).attr("data-loc")].aid)
// $(item).attr("data-type", _param[$(item).attr("data-loc")].ad_type)
// }
// })
$(".info_tanx").each(function (j, item) {
if ($(item).find("iframe").length > 0 && _param[$(item).attr("data-loc")]) {
$(item).attr("data-id", _param[$(item).attr("data-loc")].aid)
$(item).attr("data-type", _param[$(item).attr("data-loc")].ad_type)
}
})
//百度广告加载方式
$('.union_star,.tanx,.info_tanx').each(function (i, obj) {
var _obj = $(obj), _loc = _obj.attr('data-loc'), _suspend = _obj.attr('data_toc');
if (_param[_loc]) {
if (_param[_loc]['ad_type'] == 'original_bd') {
//百度原生广告加载方式
if (_suspend == "suspend") {
if (config.qid == 'heinotetips111111111') {
if ($(obj)[0].getBoundingClientRect().top - $(window).height() <= 10) {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
} else {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
} else {
if (_loc != "" && _loc != null) {
if (config.qid == 'heinotetips111111111') {
if ($(obj)[0].getBoundingClientRect().top - $(window).height() <= 10) {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
} else {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
}
}
} else {
if (config.qid == 'heinotetips111111111') {
if ($(obj)[0].getBoundingClientRect().top - $(window).height() <= 10) {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
} else {
getTag3 = common.lodMedia(_obj, _loc, _param);
}
}
}
//进行广告的加载的上报
common.send_eater(getTag3);
});
},
//百姓网广告加载
loadHuaYuIdcjs: function (url, pid, id) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.id = id;
$('#' + pid).attr('data-report', id)
if ($('#' + pid).length > 0) {
$('#' + pid)[0].appendChild(script);
}
},
// rendBaiDuAd: function (id, uid, flag) {
// if ($('#' + id).offset().top - 200 < $(window).scrollTop() + $(window).height()) {
// if ($('#' + id).children().length == 0) {
// if (flag) {
// common.loadPjs('http://www.nkscdn.com/smu0/o.js', id, uid)
// } else {
// common.loadHuaYuIdcjs('//ssp.huayuidc.com/js/127674.js', id, uid)
// }
// }
// }
// },
// cookie操作
checkCookie: function (key, value) {
var keys = $.cookie(key);
if (keys != "") {
return keys
}
else {
$.cookie(key, value, 365);
if (keys != "" && keys != null) {
$.cookie(key, value, 365);
}
}
},
renderNewsAndAd: function (masonryArray, list) {
masonryArray.forEach(function (item, index) {
list.splice(3 * (index + 1) + index, 0, item);
})
},
// 360广告封装
Ad360: {
Macro: {
start: "__EVENT_TIME_START__",
end: "__EVENT_TIME_END__",
x: "__OFFSET_X__",
y: "__OFFSET_Y__"
},
// init: function () {
// this.get360Ad(params, callback)
// // this.clickExposure360Ad()
// },
//生成360广告请求id
getRequestId: function () {
return (+new Date()) + Math.random().toString(10).substring(2, 6);
},
// 360广告请求
get360Ad: function (params, callback) {
var t = this;
var recommend_url = params.url || 'http://show.g.mediav.com/s',
recommend_type = 1,
recommend_of = 4,
reqtimes = t.getReqtimes(params.requests),
recommend_newf = 1,
recommend_showid = params.showId || 'dujNK0',
recommend_adnum = params.num || 2,
recommendk_uid = t.getRequestId(),
recommend_param;
if (document.location.protocol == "https:") {
recommend_param = 'https://show-g.mediav.com/s' + '?type=' + recommend_type + '&of=' + recommend_of + '&newf=' + recommend_newf + '&scheme=https&showid=' + recommend_showid + '&uid=' + recommendk_uid + '&impct=' + recommend_adnum + '&reqtimes=' + reqtimes + '&refurl=' + encodeURIComponent(document.referrer);
} else {
recommend_param = recommend_url + '?type=' + recommend_type + '&of=' + recommend_of + '&newf=' + recommend_newf + '&showid=' + recommend_showid + '&uid=' + recommendk_uid + '&impct=' + recommend_adnum + '&reqtimes=' + reqtimes + '&refurl=' + encodeURIComponent(document.referrer);
}
$.ajax({
type: 'get',
url: recommend_param,
dataType: 'jsonp',
jsonp: 'jsonp',
success: function (data) {
var d = data.ads || [];
callback && callback(d);
}
})
},
//生成360广告请求time
getReqtimes: function (requests) {
return "" + requests++;
},
//宏替换-1
mouseDownMacro: function (container, coordinateX, coordinateY) {
var downTime = Math.round(new Date()),
clickUrl = $(container).attr("click-back"),
hrefUrl = $(container).attr("href-back"),
coordinate_x = coordinateX,
coordinate_y = coordinateY;
if (clickUrl.indexOf(this.Macro.start) > -1) {
this.clktk_click = clickUrl;
if (this.clktk_click && this.clktk_click.indexOf(this.Macro.start) > -1) {
this.clktk_click = this.clktk_click.replace(this.Macro.start, downTime);
}
if (this.clktk_click && this.clktk_click.indexOf(this.Macro.x) > -1) {
this.clktk_click = this.clktk_click.replace(this.Macro.x, coordinate_x);
}
if (this.clktk_click && this.clktk_click.indexOf(this.Macro.y) > -1) {
this.clktk_click = this.clktk_click.replace(this.Macro.y, coordinate_y);
}
} else {
this.clktk_click = clickUrl;
}
if (hrefUrl.indexOf(this.Macro.start) > -1) {
this.curl_click = hrefUrl;
if (this.curl_click && this.curl_click.indexOf(this.Macro.start) > -1) {
this.curl_click = this.curl_click.replace(this.Macro.start, downTime);
}
if (this.curl_click && this.curl_click.indexOf(this.Macro.x) > -1) {
this.curl_click = this.curl_click.replace(this.Macro.x, coordinate_x);
}
if (this.curl_click && this.curl_click.indexOf(this.Macro.y) > -1) {
this.curl_click = this.curl_click.replace(this.Macro.y, coordinate_y);
}
} else {
this.curl_click = hrefUrl;
}
$(container).attr("data-click", this.clktk_click);
$(container).attr("href", this.curl_click ? this.curl_click : hrefUrl);
},
//宏替换-2
mouseUpMacro: function (container) {
var upTime = Math.round(new Date());
if (this.clktk_click && this.clktk_click.indexOf(this.Macro.end) > -1) {
this.clktk_click = this.clktk_click.replace(this.Macro.end, upTime);
}
if (this.curl_click && this.curl_click.indexOf(this.Macro.end) > -1) {
this.curl_click = this.curl_click.replace(this.Macro.end, upTime);
}
$(container).attr('data-click', this.clktk_click);
$(container).attr('href', this.curl_click ? this.curl_click : $(container).attr('href-back'));
},
// 上报
reportAd: function(id,position,type,behavior) {
var start_time = new Date().getTime();
baidu_Report.str({
ad_id:id,
position:position,
time: start_time,
ad_type: type,
behavior: behavior
})
},
// 曝光
url_scroll: function (arr) {
$.each(arr, function (index, val) {
$('body').append('<iframe src="' + val + '" style="display: none;"></iframe>');
});
},
// 滚动曝光
exposure: function (el,scrollBox) {
var t = this;
t.catched(el);
if(scrollBox) {
$('.' + scrollBox).on('scroll', function() {
t.catched(el);
})
} else {
$(window).on('scroll', function () {
t.catched(el);
});
}
},
// 曝光
catched: function (el) {
var t = this;
el.each(function (i, obj) {
if ($(obj).offset().top < $(window).scrollTop() + $(window).height()) {
if ($(obj).find('.img_click_gg').attr('data-imptk')) {
var imptk = [];
imptk = $(obj).find('.img_click_gg').attr('data-imptk').split(',');
t.url_scroll(imptk);
$(obj).find('.img_click_gg').removeAttr('data-imptk');
}
}
})
},
// 点击曝光
clickExposure360Ad: function () {
var t = this;
$('body').on('mousedown', '.img_click_gg', function (e) {
var x = Math.floor(e.pageX - $(this).offset().left),
y = Math.floor(e.pageY - $(this).offset().top);
t.mouseDownMacro($(this), x < 0 ? x = 0 : x, y);
}).on('mouseup', '.img_click_gg', function () {
t.mouseUpMacro($(this));
var str = $(this).attr('data-click');
if (str) {
var arr = str.split(',');
t.url_scroll(arr);
}
var position = $(this).attr("data-position")
t.reportAd('null',position,"360","click")
});
},
// 曝光封装
loadCatched:function(className,isAD,exposureName,scrollBox){
$('.'+className+'.'+isAD).each(function (i, res) {
if ($(res).children().length > 0) {
// $(res).removeClass(isAD);
} else {
if ($(res).not(isAD).length == 0) {
$(res).remove();
}
}
})
this.exposure($('.'+exposureName),scrollBox);
}
},
getRequestId: function (n) {
return (+new Date()) + Math.random().toString(10).substring(2, 2 + n);
},
// 嵩恒dsp
getShAd: function(reqtime,callback,num) {
var t = this;
var sh_url = 'http://pcsoftwords.dftoutiao.com/dfpcitv/pcitv',
sh_uid =t.getRequestId(6),
sh_os=t.getSystem(),
sh_thisurl =window.location.href,
sh_type="toutiao",
sh_qid="03877",
sh_newsitetype ="zhanmeng",
sh_pageposition ="ny",
sh_pgnum=reqtime||1,
sh_adnum=num||3,
sh_newstype="yule",
sh_newsuid=t.getRequestId(6);
var sh_param =sh_url+'?uid='+sh_uid+'&os='+sh_os+'&thisurl='+sh_thisurl+'&type='+sh_type+'&qid='+sh_qid+'&newsitetype='+sh_newsitetype+'&pageposition='+sh_pageposition+'&newstype='+sh_newstype+'&newsuid='+sh_newsuid;
$.ajax({
type: 'get',
url: sh_param,
dataType: 'jsonp',
jsonp: 'jsonpcallback',
success: function (res) {
var d = res.data || [];
callback && callback(d);
},
error: function (res) {
var arr=[];
callback(arr);
}
})
},
// img形式上报
reportAd_img: function(url) {
var get_hmt = new Image();
get_hmt.src = url;
}
}
})
// 新闻举报
$(function () {
var pageType = window.location.pathname.indexOf('/b/')
if(pageType >= 0) {
var _main = $('.detail_navlist').width() + 40;
} else {
var _main = $('.main').width()
? $('.main').width()
: $('.main2').width()
? $('.main2').width()
: $('.detail_lastads').width()
}
var _left = ($(window).width() - _main) / 2 + _main + 20
$('body').append(
'<div class="js_op" style="position: fixed;width: 45px;z-index: 3;left:' +
_left +
'px;top:100px"><a style="display: inline-block;width: 44px; height: 44px;" href="javascript:void(0);" class="icon_op"></a></div>'
)
$(window).resize(function () {
if(pageType >= 0) {
var _main = $('.detail_navlist').width() + 40;
} else {
var _main = $('.mainb').width() ? $('.mainb').width() : $('.main').width()
}
$('.js_op').css({
left: ($(window).width() - _main) / 2 + _main + 20 + 'px'
})
})
$('.js_op').on('click', function () {
$('body').append(
'<div class="op_wrap" style="z-index: 99999">\
<div class="error_pop"><i></i></div>\
<div class="mask_error"></div>\
<div class="error_content" style="display: block;">\
<div class="error_title">\
<h3>我要反馈</h3>\
<i class="error_close"></i>\
</div>\
<div class="proposal_content">\
<p class="proposal_tit">你要反馈的内容(可多选):</p>\
<ul class="proposal_opt clearfix">\
<li data-num="1" class="">涉政治有害</li>\
<li data-num="2">涉暴恐</li>\
<li data-num="3">涉淫秽色情</li>\
<li data-num="4">涉诈骗</li>\
<li data-num="5">涉赌博</li>\
<li data-num="6">涉侵权</li>\
<li data-num="7">虚假新闻</li>\
<li data-num="8">广告软文</li>\
<li data-num="9">新闻过时</li>\
<li data-num="10">有错别字</li>\
<li data-num="11">格式异常</li>\
<li data-num="12">标题党</li>\
<li data-num="13" class="last_check">我要吐槽</li>\
</ul>\
<span class="textarea_value ">具体内容或其他反馈内容:</span>\
<div class="proposal_textarea">\
<textarea class="proposal_textarea_val" ></textarea>\
</div>\
<div class="proposal_phone">\
<span>将有助于我们尽快解决你提出的问题,并及时与你沟通处理结果</span>\
手机号:<input class="phone_input" >\
邮箱:<input class="mail_input" >\
<div class="error_promt" ></div>\
</div>\
</div>\
<div class="error_submit">\
<button class="error_button_a" disabled="disabled">提交</button>\
<span></span>\
</div>\
</div>\
<div style="width: 100%;height: 100%;position: fixed;top:0;background-color: #000;opacity: .4;filter: alpha(opacity=40);z-index: 99998;-webkit-filter: alpha(opacity=40);" class="mask_error"></div></div>'
)
function close_error () {
$('.mask_error').hide(),
$('.error_content').hide(),
$('.error_promt').html(''),
$('.error_submit button')
.addClass('error_button_a')
.removeClass('disabled')
.attr({
disabled: !0
}),
$('.proposal_opt li').removeClass('act')
$('.op_wrap').remove()
}
var flager_num = 0
$('.proposal_opt li').on('click', function () {
$(this).toggleClass('act')
var t = $(this)
.closest('.error_content')
.find('.error_button_a')
var e = $(this)
.closest('.error_content')
.find('li')
flager_num != 1 &&
(e.hasClass('act')
? (t.addClass('disabled'), t.removeAttr('disabled'))
: (t.attr('disabled', !0), t.removeClass('disabled')))
}),
$('.proposal_textarea_val').on('focus', function () {
$(this)
.closest('.error_content')
.find('.last_check')
.addClass('act')
var t = $(this)
.closest('.error_content')
.find('li')
var e = $(this)
.closest('.error_content')
.find('.error_button_a')
$('.error_promt').html(''),
flager_num != 1 &&
(t.hasClass('act')
? (e.addClass('disabled'), e.removeAttr('disabled'))
: (e.attr('disabled', !0), e.removeClass('disabled')))
}),
$('.phone_input').on('focus', function () {
$('.error_promt').html('')
}),
$('.mask_error,.error_close').on('click', function () {
close_error()
})
var error_detail = ''
var report_url =
location.host != 'news.hoteastday.com'
? '//jenkins.hoteastday.com/api/feedback/add'
: '//news.hoteastday.com/api/feedback/add'
$('.proposal_textarea_val').on('keyup', function () {
;(error_detail = $.trim($(this).val())),
error_detail.length >= 200
? $('.error_promt').text('输入内容不能超过200个字符')
: $('.error_promt').html('')
}),
$('.error_button_a').on('click', function () {
function report_func (t) {
var data = {
tags: error_reason.join(','),
content: error_detail,
phone: error_phpone,
mail: error_mail
}
$.ajax({
type: 'post',
url: report_url,
timeout: 1e3,
dataType: 'json',
data: data,
success: function (t) {
t.code == 1
? ($('.error_promt').html(
'<i></i>提交成功,感谢你的宝贵意见!'
),
setTimeout(function () {
$('.mask_error').hide(), close_error()
}, 5e2))
: ($this.next('span').hide(),
$this.text('提交').addClass('disabled'),
$('.error_promt').html('<i></i>提交失败!'),
setTimeout(function () {
$('.error_promt').html('')
}, 5e2))
},
complete: function () {
$this.next('span').hide(),
$this
.text('提交')
.removeClass('disabled')
.addClass('error_button_a')
.addClass('disabled'),
(flager_num = 0)
},
error: function (err) {
$this.next('span').hide(),
$this.text('提交').addClass('disabled'),
$('.error_promt').html(err),
setTimeout(function () {
$('.error_promt').html('')
}, 2e3)
}
})
}
$(this).attr('disabled', !0)
var $this = $(this)
var error_reason = []
if (
((error_detail = $.trim(
$(this)
.closest('.error_content')
.find('.proposal_textarea_val')
.val()
)),
(error_detail = error_detail
.replace(/\n/gm, '')
.replace(/\t/gm, '')
.replace(/\r/gm, '')
.replace(/ /gm, '')),
error_detail.length >= 200)
) {
return void $(this).removeAttr('disabled')
}
var error_phpone = $.trim(
$(this)
.closest('.error_content')
.find('.phone_input')
.val()
)
var error_mail = $.trim(
$(this)
.closest('.error_content')
.find('.mail_input')
.val()
)
if (
((error_phpone !== '' && error_phpone !== 'undefined') ||
(error_phpone = null),
error_phpone != null)
) {
if (
error_phpone.length !== 11 &&
!/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(
error_phpone
)
) {
return (
$('.error_promt').text('手机号码格式错误'),
setTimeout(function () {
$('.error_promt').html('')
}, 3e3),
void $(this).removeAttr('disabled')
)
}
} else $('.error_promt').html('')
if (
((error_mail !== '' && error_mail !== 'undefined') ||
(error_mail = null),
error_mail != null)
) {
if (!/\w+@[a-z0-9]+\.[a-z]{2,4}/.test(error_mail)) {
return (
$('.error_promt').text('邮箱格式错误'),
setTimeout(function () {
$('.error_promt').html('')
}, 3e3),
void $(this).removeAttr('disabled')
)
}
} else $('.error_promt').html('')
$this.html('').removeClass('disabled'),
$this.next('span').show(),
(flager_num = 1)
for (var i = 0; i < $('li.act').length; i++) {
var k = $('li.act:eq(' + i + ')').data('num')
error_reason.push(k)
}
report_func()
})
})
})
js判断浏览器的一些属性
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 2017年7月19至24日.首期中国沈阳 原著: Die Seele weist den Weg. Aufstel...