var defaultclassification = ""; //默认分类ID var modelId = -1; //在DOM树加载完成之后(DOM树加载完不代表全部资源加载完,例如图片,音频和视频等还没加载)就会执行,简写成$(function(){}); let query = {}; //URL参数 let scr = $(location).prop('href').split("?")[1]; Array.prototype.myForEach = function myForEach(callback, context) { context = context || window; if (Array.prototype.forEach) { // 调用forEach方法,不做任何处理 this.forEach(callback, context); return; } } if (scr) { scr = scr.split("&").join("=").split("=") scr.myForEach(function(item, index, arr) { if (index % 2 === 0) { query[item] = "" } else { query[scr[index - 1]] = item } }); } query.new_Name = decodeURI(query.new_Name); let new_name_date = []; $(document).ready(function() { classificationList(); //左侧分类 }); //获取分类列表 function classificationList() { let data = { "status": 1, "pageIndex": 1, "pageOrder": "field1;field2:1", "pageRows": 1000000, } let postList = new AJAX_OBJ(AgencyAddress + "business/guide/queryList", BusinessGuide, onUrlError); postList.postRequestData(JSON.stringify(data)); function BusinessGuide(xmlHttp) { let res = eval('(' + xmlHttp.responseText + ')'); if (res.resultCode === "00000000") { if(res.data.pageDataList.length != 0){ let prostr = ''; let leftList = res.data.pageDataList; leftList.myForEach(function(item, index, arr) { new_name_date.push(item.classId); if (index == 0) { defaultclassification = item.className; defaulid = item.classId; } prostr += '
' + item.className + '
'; // prostr += '
' + item.className + '
'; }); // leftList.forEach((item, index) => { // if (index == 0) { // defaultclassification = item.className; // } // prostr += '
' + item.className + '
'; // // prostr += '
' + item.className + '
'; // }) $('.left_center').html(prostr); // $(".cen_ter").click((data)=>{ // console.log($("#"+data.target.id).text()) // }) if (query.new_Name == undefined || query.new_Name == null || query.new_Name == "undefined") { contextList(defaultclassification, defaulid); } else { contextList(query.new_Name, query.classId); } }else{ let rightml = '
暂无数据
'; $('.list_main_right').html(rightml); } } else { Dreamer.error(res.resultMsg); } }; } //点击左侧分类 function contextList(value, classid, index) { $(".left_center").children("div").eq(index).attr("class", "cen_ter_true"); if (modelId >= 0) { $(".left_center").children("div").eq(modelId).attr("class", "cen_ter"); } //默认刚进入页面第一个加背景颜色 if (classid == new_name_date[0]) { $(".left_center div").get(0).style.background = "#999999"; } else if (index != undefined || index != "undefined" || index != 0) { $(".left_center div").get(0).style.background = "rgba(229, 229, 229, 1)"; } new_name_date.myForEach(function(item, index, arr) { if (item == classid) { $(".left_center").children("div").eq(index).attr("class", "cen_ter_true"); } else { $(".left_center").children("div").eq(index).attr("class", "cen_ter"); } }); modelId = index; let postList = new AJAX_OBJ(AgencyAddress + "business/guide/queryTittles?busguideBelongClass=" + encodeURI(value), queryTittles, onUrlError); postList.postRequestData(); function queryTittles(xmlHttp) { let res = eval('(' + xmlHttp.responseText + ')'); if (res.resultCode === "00000000") { let rigreally = ''; res.data.myForEach(function(item, index, arr) { rigreally += '
' + '
' + '
标题名称:' + item .busguideTitle + '
' + '
发布时间:' + item .busguideTime + '
' + '
' + '
' + '
' }); // res.data.forEach((item, index) => { // rigreally += '
' + // '
' + // '
标题名称:' + item // .busguideTitle + '
' + // '
发布时间:' + item // .busguideTime + '
' + '
' + // '
' + // '
' // }) $('.list_main_right').html(rigreally); } else { let rightml = '
暂无数据
'; $('.list_main_right').html(rightml); } }; } function detilsList(value, classid) { location.href = "SinGuideDetails.html?new_nameId=" + value + '&classid=' + classid + '&time=' + new Date().getTime(); }