$(function(){
var classid=getClassID();
var aid=getInfoID();
if(aid!="0"){
artclick(classid,aid)
}else{
if(classid!="0"){
classclick(classid);
}
}
})
function getinterface_data(id,key,lti){
$.ajax({
type: "post",
url: "../index.php?a=getdata_interface",
data: {
key: key,
lti: lti
},
success: function (msg) {
var obj = eval('(' + msg + ')');
$("#"+id).html(obj.ListHtml);
}
})
}
/*栏目点击率方法*/
function classclick(cid){
$.ajax({
type: "POST",
dataType: "json",
url: '../index.php?a=hits',
data: {catid:cid},
success: function (data) {
}
});
}
/*文章页浏览量*/
function artclick(cid,aid){
$.ajax({
type: "POST",
dataType: "json",
url: '../index.php?a=hit',
data: {
id:aid,
catid:cid
},
success: function (data) {
$("#hitid").html("浏览量:"+data);
}
});
}
var Request = {
QueryString: function (key) {
var svalue = window.location.search.match(new RegExp("[\?\&]" + key + "=([^\&]*)(\&?)", "i"));
return svalue ? svalue[1] : svalue;
}
}
//回车事件
function EnterFunction(ElementInput, ElementBtn) {
$(ElementInput).keydown(function (e) {
var curKey = e.which;
if (curKey == 13) {
$(ElementBtn).click();
}
});
}
$(function () {
EnterFunction("#formd_search_id", "#btnSearch");
EnterFunction("#formd_search_id1", "#btnSearch1");
EnterFunction("#search-field", "#btnSearch");
EnterFunction("#keywords", ".go_page");
EnterFunction("#publicKey","#publicSearch");
})
//$(document).on("click", "#text4>li,#text5>li", function () {
// alert(123);
// productSearchSolution(1);
//})
//产品方案
function productSearchSolution(pageindex) {
var pagesize = 10;
var text4 = "";
$("#text4>li.on").each(function () {
if ($(this).attr("data-val") != 0) {
text4 += $(this).attr("data-val") + ",";
}
})
text4 = text4.substring(0, text4.length - 1);
var text5 = "";
$("#text5>li.on").each(function () {
if ($(this).attr("data-val") != 0) {
text5 += $(this).attr("data-val") + ",";
}
})
text5 = text5.substring(0, text5.length - 1);
//console.log("类型:" + text4);
//console.log("格式:" + text5);
var attrArgs = "text4|search|text5|search|pageindex|search|pagesize";
var valArgs = text4 + "|search|" + text5 + "|search|" + pageindex + "|search|" + pagesize;
var data = "attrArgs=" + encryption(attrArgs) + "&valArgs=" + encryption(valArgs) + "";
var url = "/index.php?g=Contents&m=Index&a=public_productSearch";
ajaxhelpS(data, url, function (msg) {
var obj = eval('(' + msg + ')');
var HtmlList = '';
if (obj.data != null) {
$("#resultNum").html(obj.count);
$(".material_tit").show();
for (var i = 0; i < obj.data.length; i++) {
HtmlList += '
';
HtmlList += ' ';
HtmlList += ' - ';
//视频
if (obj.data[i]["text5"] == '116') {
HtmlList += ' ';
} else if (obj.data[i]["text5"] == '119') {
HtmlList += ' ';
} else {
HtmlList += ' ';
}
HtmlList += '
';
HtmlList += ' ' + obj.data[i]["updatetime"] + ' ';
HtmlList += ' ' + obj.data[i]["text3"] + ' ';
HtmlList += '
';
HtmlList += ' ';
HtmlList += ' - ';
if (obj.data[i]["text5"] == '116') {
HtmlList += '
查看
';
} else if (obj.data[i]["text5"] == '119') {
HtmlList += ' 查看
';
} else {
HtmlList += ' 查看
';
}
HtmlList += ' 下载
';
HtmlList += ' ';
HtmlList += '
';
HtmlList += ' ';
}
} else {
$(".material_tit").hide();
HtmlList = '抱歉,没有找到相关信息';
}
$("#PublicSearch_Html").html(HtmlList);
var PageList = '';
if (obj.pagecount > 1) {
pageinfo = obj.data_page;
PageList += '';
PageList += '
';
PageList += '
';
PageList += pageinfo["list"];
PageList += '
';
PageList += '
';
PageList += '
';
PageList += pageinfo['PageHtml'];
$("#PublicSearch_Page").html(PageList);
} else {
$("#PublicSearch_Page").html("");
}
});
}
function ajaxhelpS(data, url, fn) {
//var thisIndex = -1;
//if (showLoading) {
// thisIndex = layer.msg('数据请求中,请稍后…', {
// time: 0,
// icon: 16
// });
//}
$.ajax({
"type": "post",
"url": url,
"data": data,
"datatype": "html",
"success": function (msg) {
//if (showLoading) {
// layer.close(thisIndex);
//}
if (fn) {
fn(msg)
}
},
"error": function () {
//if (showLoading) {
// layer.close(thisIndex)
//}
}
})
}
$(document).on("click", "#publicSearch", function () {
productSearch(1);
})
$(document).on("click", "#text3>li", function () {
//alert($(this).attr("data-val"));
productSearch(1);
})
$(document).on("click", "#api_text3>li", function () {
//alert($(this).attr("data-val"));
productApiSearch(1);
})
function productSearch(pageindex) {
//var pageindex = 1;
var pagesize = 12;
var isRelationChild = 0;
var catid = $.trim($("#catid").val());
var pcatid = 14;
var title = $("#publicKey").val();
var text3 = "";
$("#text3>li.on").each(function () {
if ($(this).attr("data-val") != 0) {
text3 += $(this).attr("data-val") + ",";
}
})
text3 = text3.substring(0, text3.length - 1);
var text3Condition = "";
if (text3 != "") {
text3Condition = ',{"field":"text3","value":"' + text3 + '","symbol":"like","isRelationChild":' + isRelationChild + '}';
}
var titleCondition = "";
if (title != '') {
titleCondition = ',{"field":"title","value":"' + title + '","symbol":"like","isRelationChild":' + isRelationChild + '}';
}
var pagecmd = "productSearch";
var condition = '[{"condition":[{"field":"catid","value":"' + catid + '","symbol":"in","isRelationChild":' + isRelationChild + '}' + text3Condition + titleCondition + '],"condition_type":1,"pagesize":' + pagesize + ',"pageindex":' + pageindex + '}]';
//console.log(condition);
var attrArgs = "cmd|search|pagecmd|search|condition|search|pcatid";//为了转换数组与json中的逗号冲突,此处用|search|分隔
var valArgs = "getConditionResult" + "|search|" + pagecmd + "|search|" + condition + "|search|" + pcatid;
var data = "attrArgs=" + encryption(attrArgs) + "&valArgs=" + encryption(valArgs) + "";
ajaxPublicSearch(data, function (msg) {
var obj = eval('(' + msg + ')');
var HtmlList = '';
var PageList = '';
$(".pharmacy_tab").hide();
if (obj.data != null) {
for (var i = 0; i < obj.data.length; i++) {
HtmlList += '';
HtmlList += ' ';
HtmlList += ' - ';
HtmlList += ' ';
HtmlList += ' ';
HtmlList += ' ';
HtmlList += '
';
HtmlList += ' - ';
HtmlList += ' ';
HtmlList += '
' + obj.data[i]["description"] +'
';
HtmlList += ' ';
HtmlList += ' ';
HtmlList += '
';
HtmlList += ' ';
}
} else {
//$(".pharmacy_tab").show();
HtmlList = '抱歉,没有找到相关信息';
}
//console.log(obj.data);
$("#PublicSearch_Html").html(HtmlList);
imgratio();
$("#PublicSearch_Page").html("");
if (obj.pagecount > 1) {
pageinfo = obj.data_page;
PageList += '';
PageList += '
';
PageList += '
';
PageList += pageinfo["list"];
PageList += '
';
PageList += '
';
PageList += '
';
//PageList += pageinfo['PageHtml'];
$("#PublicSearch_Page").html(PageList);
}
});
}
function productApiSearch(pageindex) {
//var pageindex = 1;
var pagesize = 12;
var isRelationChild = 0;
var catid = $.trim($("#catid").val());
var pcatid = 14;
var text3 = "";
$("#api_text3>li.on").each(function () {
if ($(this).attr("data-val") != 0) {
text3 += $(this).attr("data-val") + ",";
}
})
text3 = text3.substring(0, text3.length - 1);
var text3Condition = "";
if (text3 != "") {
text3Condition = ',{"field":"text3","value":"' + text3 + '","symbol":"like","isRelationChild":' + isRelationChild + '}';
}
var pagecmd = "productApiSearch";
var condition = '[{"condition":[{"field":"catid","value":"' + catid + '","symbol":"in","isRelationChild":' + isRelationChild + '}' + text3Condition + '],"condition_type":1,"pagesize":' + pagesize + ',"pageindex":' + pageindex + '}]';
//console.log(condition);
var attrArgs = "cmd|search|pagecmd|search|condition|search|pcatid";//为了转换数组与json中的逗号冲突,此处用|search|分隔
var valArgs = "getConditionResult" + "|search|" + pagecmd + "|search|" + condition + "|search|" + pcatid;
var data = "attrArgs=" + encryption(attrArgs) + "&valArgs=" + encryption(valArgs) + "";
ajaxPublicSearch(data, function (msg) {
var obj = eval('(' + msg + ')');
var HtmlList = '';
var PageList = '';
$(".pharmacy_tab").hide();
if (obj.data != null) {
for (var i = 0; i < obj.data.length; i++) {
HtmlList += '';
HtmlList += ' ';
HtmlList += ' - ';
HtmlList += ' ';
HtmlList += ' ';
HtmlList += ' ';
HtmlList += '
';
HtmlList += ' - ';
HtmlList += ' ';
HtmlList += '
' + obj.data[i]["description"] + '
';
HtmlList += ' ';
HtmlList += '
';
HtmlList += '';
}
} else {
//$(".pharmacy_tab").show();
HtmlList = '抱歉,没有找到相关信息';
}
//console.log(obj.data);
$("#PublicSearch_Html").html(HtmlList);
imgratio();
$("#PublicSearch_Page").html("");
if (obj.pagecount > 1) {
pageinfo = obj.data_page;
PageList += '';
PageList += '
';
PageList += '
';
PageList += pageinfo["list"];
PageList += '
';
PageList += '
';
PageList += '
';
//PageList += pageinfo['PageHtml'];
$("#PublicSearch_Page").html(PageList);
}
});
}
function ajaxPublicSearch(data, fn) {
$.ajax({
"type": "post",
"url": "/index.php?g=Contents&m=Index&a=public_ajax_search",
"data": data,
"datatype": "html",
"success": function (msg) {
if (fn) {
fn(msg);
}
},
"error": function () {
/*alert("对不起,服务器繁忙请稍后重试");*/
}
});
}
/*-----------------------------搜索结果绑定-------------------------------------------------------------------------*/
$(function () {
$('#btnSearch').click(function () {
search();
});
function search() {
if ($.trim($("#formd_search_id").val()) == '' || $.trim($("#formd_search_id").val()) == "search...") {
$('#formd_search_id').focus();
alert("请输入关键词!");
return false;
}
else {
window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id").val()));
}
}
})
$(function () {
$('#btnSearch1').click(function () {
search1();
});
function search1() {
if ($.trim($("#formd_search_id1").val()) == '' || $.trim($("#formd_search_id1").val()) == "search...") {
$('#formd_search_id1').focus();
alert("请输入关键词!");
return false;
}
else {
window.location = "/other/search.html?key=" + encodeURIComponent($.trim($("#formd_search_id1").val()));
}
}
})
//危险字符过滤
$(function () {
$(document).on('keyup', 'input[type=text],textarea,input[type=password]', function () {
var val = $(this).val().toLocaleLowerCase();
var otherKey = " and | exec | count | chr | mid | master | or | truncate | char | declare | join |<|>|/*|*/|;|\\u|insert|select|delete|update|create|drop|script|javascript|alert";
var goon = true;
for (var i = 0; i < otherKey.split('|').length ; i++) {
if (goon) {
if (val.indexOf(otherKey.split('|')[i]) != -1) {
alert("不能包含危险字符!");
$(this).val('');
goon = false;
return;
}
}
}
});
})
function checkSQL(tempKey) {
var val = tempKey;
var otherKey = " and | exec | count | chr | mid | master | or | truncate | char | declare | join |<|>|*|/*|*/|;|\\u|insert|select|delete|update|create|drop|script|javascript|alert";
var goon = true;
for (var i = 0; i < otherKey.split('|').length ; i++) {
if (goon) {
if (val.indexOf(otherKey.split('|')[i]) != -1) {
goon = false;
}
}
}
return goon;
}
var classid = '';
var key = '';
var ToPage = function (pageIndex) {
console.log(pageIndex);
if (!checkSQL(key)) {
alert("请不要包含危险字符!");
window.location.href="../index.html";
return false;
}
if(pageIndex==1){
$("#AjaxList").html("");
}
var html_start=$("#html_start").val();
var html_end=$("#html_end").val();
var pageclass=$("#pageClass").val();
var pagesize=$("#pagesize").val();
var updatetime=$("#updatetime").val();
var listhtml=$("#listhtml").val();
var pagehtml=$("#pagehtml").val();
$.ajax({
type: "post",
url: "../index.php?a=qwsearch",
data: {
pageindex: pageIndex,
pagesize: pagesize,
key: key,
html_start: html_start,
html_end: html_end,
pageclass: pageclass,
updatetime: updatetime,
listhtml: listhtml,
pagehtml: pagehtml
},
success: function (msg) {
var obj = eval('(' + msg + ')');
$('#AjaxList').html(obj.ListHtml.toString());
$('#AjaxPageList').html(obj.PageHtml.toString());
$('#searchNum').html(obj.RecordCount);
$('#formd_search_id').val(key);
$('#searchText').html('"'+key+'"');
$('#formd_search_id1').val(key);
}
})
}
/*-----------------------------利用cookie保存浏览记录-------------------------------*/
function SetMyCollect(id,url,photo){
$.ajax({
type: "post",
url: "../index.php?a=history",
data: {
id: id,
url: url,
photo: photo
},
success: function (msg) {
}
})
}
/*-----------------------------获取浏览记录-------------------------------*/
function getMyCollect() {
$.ajax({
type: "post",
url: "../index.php?a=gethistory",
data:"",
success: function (msg) {
var obj = eval('(' + msg + ')');
$('#GetMyCollect').html(obj.ListHtml);
}
})
}
/*----------------------当前位置定位-------------------*/
$(function () {
var MenuName = $.trim($("div.site>a:eq(1)").text());
$('nav.nav>ul>li>a').map(function () {
if ($.trim($(this).text()) == MenuName) {
$(this).parent().addClass('on').siblings().removeClass('on');
}
});
var MenuName = $.trim($("div.site>span").text());
$('nav.nav>ul>li>a').map(function () {
if ($.trim($(this).text()) == MenuName) {
$(this).parent().addClass('on').siblings().removeClass('on');
}
})
var MenuName = $.trim($("div.site>span").text());
$('div.nav>ul>li>a').map(function () {
if ($.trim($(this).text()) == MenuName) {
$(this).parent().addClass('on').siblings().removeClass('on');
}
})
var MenuName = $.trim($("div.site>a:eq(3)").text());
$('div.pharmacy_tab>div.wrap>ul>li>a').map(function () {
if ($.trim($(this).text()) == MenuName) {
$(this).parent().addClass('on').siblings().removeClass('on');
}
});
})
/*----------------------点击下载及时更新下载次数-------------------*/
$(document).on('click', '.Mylike', function () {
var strid = $(this).attr("data-id");//ID
var strurl =$(this).attr("data-url");
var stremid = $(this).parents('.AForm').find('.Mylikelist');
var objMylike = $(this);
data = "id=" + strid;
$.ajax({
type: "post",
url: "../index.php?a=downloadnum",
data:data,
success: function (msg) {
var obj = eval('(' + msg + ')');
if(obj.status==1){
stremid.text(Number(stremid.text()) + Number(1));
window.location = "" + strurl;
}
}
})
});
/*----------------------获取下载次数-------------------*/
$(function () {
var ids = '';
$('.Mylikelist').map(function () {
ids += $(this).attr('data-id') + ',';
});
if (ids.length == 0) {
return;
}
data="ids="+ids;
$.ajax({
type: "post",
url: "../index.php?a=getdownloadnum",
data:data,
success: function (msg) {
var obj = eval('(' + msg + ')');
var hits=(obj.info);
for (var i = 0; i < hits.split(',').length; i++) {
$('.Mylikelist').eq(i).text(hits.split(',')[i]);
}
}
})
});
/*----------------------动态加载公共模板--------------------*/
function getAajaxInclude(dataUrl,element) {
$.ajax({
"type": "get",
"url": "" + dataUrl+"",
"datatype": "html",
"success": function (msg) {
$(element).html(msg);
},
"error": function (e) {
}
})
}
/*------------------文字转语音------------------------*/
$(".audio_btn").click(function () {
var count = 0;
var Timer = null;
var target = $("#audiodiv audio:eq(" + count + ")").get(0);
if (target.paused) {
target.play();
$(".audio_btn").addClass("pause");
} else {
target.pause();
$(".audio_btn").removeClass("pause");
}
Timer = setInterval(function () {
$("#audiodiv audio:eq(" + count + ")").get(0).onended = function () {
$("#audiodiv audio:eq(" + count + ")").get(0).pause();
count = count + 1;
$("#audiodiv audio:eq(" + count + ")").get(0).play();
};
$("#audiodiv audio:last").get(0).onended = function () {
$(".audio_btn").removeClass("pause");
};
}, 10)
})
function getdata() {
$.ajax({
type: "get",
url: "/index.php?a=currgp",
data: "",
success: function (msg) {
var obj = eval('(' + msg + ')');
if (obj.data != null) {
$("#investName").text(obj.data[1] + "(" + obj.data[2] + ")");
$("#xianjia").text(obj.data[3]);
if (obj.data[31] < 0) {
$("#color").attr("class", "green");
$("#color1").attr("class", "stock_num green");
$(".icon-shangjiantou").hide();
$(".icon-xiajiantou").show();
$("#jiantou").text("↓");
} else {
$("#color").attr("class", "red");
$("#color1").attr("class", "stock_num red");
$(".icon-shangjiantou").show();
$(".icon-xiajiantou").hide();
$("#jiantou").text("↑");
}
$("#zhangfuBFB").text(obj.data[32] + "%");
$("#zhangfu").html(obj.data[31] + "(" + obj.data[32] +"%)");
$("#xianjia").text(obj.data[3]);
$("#zuigao").text(obj.data[41]);
$("#zuidi").text(obj.data[42]);
$("#chengjiaoliang").text(obj.data[36]);
$("#zongshizhi").text(Math.round(parseInt(obj.data[45]))+"亿");
var timecurr = obj.data[30];
var dataCurr = timecurr.substring(0, 4) + "/" + timecurr.substring(4, 6) + "/" + timecurr.substring(6, 8) + " " + timecurr.substring(8, 10) + ":" + timecurr.substring(10, 12) + ":" + timecurr.substring(12, 14);
$("#investTime").text(dataCurr);
}
console.log(obj.data);
}
})
}