var downinfo = {
pc: 'http://app.autohome.com.cn/apps/1.html',
android: 'http://app.autohome.com.cn/download/Autohome_4.2.5_share.apk',
ios: 'https://itunes.apple.com/cn/app/qi-che-zhi-jia/id385919493?mt=8',
weixin: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.cubic.autohome&ckey=CK1286547003996',
peccancypc: 'http://app.wz.qichecdn.com/down/?from=ceshiaaa',
peccancyweixin: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.autohome.mycar&g_f=991653'
};
var browser = {
versions: function () {
var u = navigator.userAgent,
app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1,
presto: u.indexOf('Presto') > -1,
webKit: u.indexOf('AppleWebKit') > -1,
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/),
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,
iPad: u.indexOf('iPad') > -1,
webApp: u.indexOf('Safari') == -1,
QQbrw: u.indexOf('MQQBrowser') > -1,
ucLowEnd: u.indexOf('UCWEB7.') > -1,
ucSpecial: u.indexOf('rv:1.2.3.4') > -1,
safari: u.indexOf('Safari') > -1 && u.indexOf("Chrome") < 1,
chrome: u.indexOf("Chrome") > -1,
weixinweibo: u.toLowerCase().indexOf("weibo") > -1 || u.toLowerCase().indexOf("micromessenger") > -1,
ucweb: function () {
try {
return parseFloat(u.match(/ucweb\d+\.\d+/gi).toString().match(/\d+\.\d+/).toString()) >= 8.2
} catch (e) {
if (u.indexOf('UC') > -1) {
return true
} else {
return false
}
}
}(),
Symbian: u.indexOf('Symbian') > -1,
ucSB: u.indexOf('Firefox/1.') > -1
}
}()
};
function dealImg(screenWidth, widths) {
var arr = widths.split(",");
for (var i = 0; i < arr.length; i++) {
if (parseInt(arr[i]) > 0 || arr[i] == "") {
var id = "img_" + arr[i] + "_";
var width = arr[i] == "" ? screenWidth - 20 : ((parseInt(arr[i]) > screenWidth - 20) ? screenWidth - 20 : arr[i]);
var iswidthEmpty = arr[i] == "";
$("img[id^='" + id + "']").each(function () {
var heightValue = iswidthEmpty ? "auto" : width * parseFloat(this.id.split("_")[2]) / parseFloat(this.id.split("_")[1]);
$(this).css({
'width': width + 'px',
'height': heightValue + 'px'
})
})
}
}
}
function dealVideoImg(screenWidth, ispc) {
var height = ispc ? "500px" : "185px";
$(".picboxvideo a img").css({
"width": screenWidth + "px",
"height": height
});
if ($(".objectVideo").length > 0) $(".objectVideo").css({
"height": height
});
if ($(".picboxvideo a").length > 0) $(".picboxvideo a").attr("href", $(".picboxvideo a").attr("href").replace('insidebrowser:', ''))
}
function dealArtileLink(sharedType) {
$("a").each(function () {
var curHref = $(this).attr("href");
if (sharedType == 5 && curHref.indexOf('cont.app') > 0) {
//不做替换
}
else if (curHref.indexOf('.autohome.com.cn') > -1 && curHref.indexOf('.m.autohome.com.cn')==-1) {
$(this).attr("href", curHref.replace('.autohome.com.cn', '.m.autohome.com.cn').replace('www.', ''));
if (sharedType == 2) $(this).attr("href", $(this).attr("href").replace('shuoke.', '').replace('article', 'shuoke'))
}
if (curHref.indexOf('actionfrom:browser㊣') > -1 || curHref.indexOf('insidebrowser:') > -1) {
$(this).attr("href", curHref.replace('actionfrom:browser㊣.', '').replace('insidebrowser:', ''))
}
})
}
function applink(fail) {
var link = setTimeout(function () {
window.location = fail
},
2000)
}
function dealDownLoad(ischeckbrowser, isweixin, isPc, isApple, platForm, sharedType, id, title, bbsid, bbstype,appid) {
var downloadLink = "";
var btnTip = sharedType == 4 ? "下载汽车之家客户端看回帖" : "下载汽车之家客户端看评论";
if (sharedType == 5) btnTip = "下载汽车之家客户端看直播快报";
var openAppurl = "autohome://open?type=" + sharedType + "&id=" + id;
//当是快报详情页分享页面时,在传一个消息id
if (sharedType == 6) {
var messagetype = bbstype.split('|')[0];
var shareimg = bbstype.split('|')[1];
openAppurl = openAppurl + "&messageid=" + bbsid + "&messagetype=" + messagetype + "&title=" + title + "&shareimg=" + shareimg;
}
if (appid == '8')
{
if (isPc) {
downloadLink = downinfo.peccancypc
} else {
downloadLink = downinfo.peccancyweixin;
if (sharedType == 4) openAppurl += "&smallpic=0&title=" + title + "&bbsid=" + bbsid + "&bbstype=" + bbstype
}
}
else
{
if (isPc) {
downloadLink = downinfo.pc
} else {
downloadLink = downinfo.weixin;
if (sharedType == 4) openAppurl += "&smallpic=0&title=" + title + "&bbsid=" + bbsid + "&bbstype=" + bbstype
}
}
if (appid == '8') {
$(".comment-btn-main").html("");
$(".app-btn").attr("href", downloadLink).text("立即下载")
}
else {
if (ischeckbrowser) {
$(".comment-btn").attr("href", openAppurl).html("立即打开汽车之家客户端").click(function () {
applink(downloadLink)
});
$(".app-btn").attr("href", openAppurl).text("立即打开").click(function () {
applink(downloadLink)
})
} else {
$(".comment-btn").attr("href", downloadLink).html("" + btnTip);
$(".app-btn").attr("href", downloadLink).text("立即下载")
}
}
}