$(function () { var base = "https://custproj00011-2.ceydz.com/front/" //地址前缀 var isClick = true; var pageSize = 9 //每页多少条 var currentPage = 1; //当前页 var classific //当前列表(字符串) var requestType = ["今日乐鱼", "子公司动态", "媒体上的乐鱼", "公示公告", "专题专栏"] var showList = [[], [], [], []] var navState = 0 for (var i = 0; i < requestType.length; i++) { dataFn(requestType[i], i) } function initFn() {//初始化 $(".dz_nav li:eq(0)").css({ "background-color": "#054d81", }) $(".dz_nav li a:eq(0)").css({ "color": "#fff", }) } initFn() $(".dz_nav").on("mouseenter", "li", function () { var i = $(this).index() navState = i styInit() addSty(i)//样式修改 paintFn(i) }) function styInit() {//初始化样式 $(".dz_nav li").css({ "background-color": "#fff", }) $(".dz_nav li a").css({ "color": "black", }) } function addSty(_i) {//添加样式 $(".dz_nav li:eq(" + navState + ")").css({ "background-color": "rgb(5,77,129)", }) $(".dz_nav li a:eq(" + _i + ")").css({ "color": "#fff", }) } function dataFn(classific_type, _index) {//请求,请求类型&index console.log(classific_type); dz_ajax(base + "sxjg/sxjcNewmanagements", { "params[reviewProgress]": 1, "params[classification]": classific_type, "pageSize": pageSize, "currentPage": currentPage }, "GET") .then(function (res) { console.log(86, res); showList[_index] = res.rows paintFn(0)//初始化 }).catch(function (err) { console.log(90, err) $(".dz_moudle_list").html("暂无数据!") }) } $(".dz_moudle_list").after( "" ) function paintFn(_i) {//index $(".dz_moudle_list").html("") if (_i == 4) { //console.log(1); $("#dz_module_show iframe").css({ 'display': 'block' }) return false } else { $("#dz_module_show iframe").css({ 'display': 'none' }) } for (var i = 0; i < showList[_i].length; i++) { var tempTime = showList[_i][i].createTime.split(" ") var tempId = showList[_i][i].id var tempName = showList[_i][i].name var str1 = "
  • ➠  " + tempName + ""; var str2 = "" + tempTime[0] + "
  • " $(".dz_moudle_list").append( str1 + str2 ) } } function dz_ajax(url, params, type) {//AJAX,路径,参数,类型 return new Promise(function (resolve, reject) { $.ajax({ type: type || "post", url: url, headers: { "content-type": "application/json" }, dataType: "json", data: params || {}, success: function (data) { if (data.code == "200" || data.rows) { resolve(data) } else { reject() } }, error: function (e) { reject() } }); }).catch(function (e) { }) } })