/* try { require("../jquery") } catch (error) { console.log(error) } */ /** * 页面加载时 */ window.onload = function () { $(".top :first-child").addClass("cycle") $(".mapButton :first-child").addClass("mapButtonColor") } /** * 头部四个标题点击事件 */ $(".top") .children() .click(function () { $(".top").children().removeClass("cycle") $(this).addClass("cycle") }) /** * 保障性住房按钮切换 */ $(".mapButton") .children() .click(function (e) { $(".mapButton").children().removeClass("mapButtonColor") $(e.target).addClass("mapButtonColor") if (e.target.innerText == "实物配租") { $(".peizu").css("display", "flex") $(".zulin").css("display", "none") // $(".p0").text("单位:户") } else { $(".peizu").css("display", "none") $(".zulin").css("display", "flex") // $(".p0").text("单位:元") } }) /** * 实物配租按钮切换 */ $(".mapButton") .children() .click(function () { $(".mapButton").children().removeClass("mapButtonColor") $(this).addClass("mapButtonColor") if (this.innerText == "实物配租") { $(".echart2").css("display", "block") $(".echart3").css("display", "none") $(".peizu").css("display", "flex") $(".zulin").css("display", "none") } else { $(".echart3").css("display", "block") $(".echart2").css("display", "none") $(".peizu").css("display", "none") $(".zulin").css("display", "flex") } }) //重设echart宽度 $(".echart3").css("width", $("#county").width()) var myChart2 = echarts.init(document.querySelector(".echart2")) var myChart3 = echarts.init(document.querySelector(".echart3")) var quotaCode3 = "Q249971129640398848" var baseUrl = "https://sznbs.ningbo.gov.cn:89/nbszhjkzz/tojcms/getQuotaByTaksIdOrQuotaCode.do?parentQuotaCode=" var url3 = baseUrl + quotaCode3 + "&systemName=government" $.post(url3, function (data) { d = unique(data.infoList) $.get("https://sznbs.ningbo.gov.cn:89/szzf/zdrw/fj_zhujianjun/330200_full.json", function (mapJson) { // 地图2 echarts.registerMap("宁波市", mapJson) var option2 = { title: { text: "", x: "left", }, tooltip: { trigger: "item", // formatter: function(params, ticket, callback) { // if (params.data !== undefined) { // let currentValue = d[params.dataIndex]["currentValue"] // let targetValue = d[params.dataIndex]["targetValue"] // return ( // params.name + // " 政府投资公租房" + // currentValue + // "套" // ) // } // }, }, geo: { show: true, map: "宁波市", emphasis: { label: { show: true, }, }, roam: false, //不开启缩放和平移 zoom: 1.23, //视角缩放比例 label: { normal: { show: true, fontSize: "10", color: "white", }, }, itemStyle: { normal: { color: "red", borderColor: "rgba(0, 0, 0, 0.2)", }, emphasis: { label: { show: true, position: "top", color: "red", }, areaColor: "#ccc", //鼠标选择区域颜色 shadowOffsetX: 0, shadowOffsetY: 0, shadowBlur: 20, borderWidth: 0, shadowColor: "rgba(0, 0, 0, 0.5)", }, }, regions: [], }, series: [ { mapType: "宁波市", name: "实物配租", type: "map", label: { show: true, }, geoIndex: 0, data: [ { name: "鄞州区", value: 5332, }, { name: "海曙区", value: 3930, }, { name: "象山县", value: 3033, }, { name: "江北区", value: 2222, }, { name: "宁海县", value: 1357, }, { name: "北仑区", value: 1140, }, { name: "镇海区", value: 1112, }, { name: "奉化区", value: 1107, }, { name: "慈溪市", value: 1079, }, { name: "余姚市", value: 886, }, ], }, ], } d.forEach(function (item) { // debugger let c = parseFloat((item["currentValue"] / item["targetValue"]) * 100).toFixed(0) < 100 ? "#FF5C11" : "#15BE50" option2.geo.regions.push({ name: ningbo_allareas[item["areaCode"]], itemStyle: { normal: { areaColor: "#8BCCFE", }, emphasis: { areaColor: "#8BCCFE", }, }, label: { show: true, }, }) // myColor1.push(c) }) myChart2.setOption(option2) // 地图3 echarts.registerMap("宁波市", mapJson) var option3 = { title: { text: "", x: "left", }, tooltip: { trigger: "item", // formatter: function(params, ticket, callback) { // if (params.data !== undefined) { // let currentValue = d[params.dataIndex]["currentValue"] // let targetValue = d[params.dataIndex]["targetValue"] // return ( // params.name + // " 政府投资公租房" + // currentValue + // "套" // ) // } // }, }, geo: { show: true, map: "宁波市", emphasis: { label: { show: true, // position: '', // color: 'red' }, }, roam: false, //不开启缩放和平移 zoom: 1.23, //视角缩放比例 label: { normal: { show: true, fontSize: "10", color: "white", }, }, itemStyle: { normal: { color: "#8BCCFE", borderColor: "rgba(0, 0, 0, 0.2)", }, emphasis: { label: { show: true, position: "top", color: "red", }, areaColor: "#ccc", //鼠标选择区域颜色 shadowOffsetX: 0, shadowOffsetY: 0, shadowBlur: 20, borderWidth: 0, shadowColor: "rgba(0, 0, 0, 0.5)", }, }, // data:this.dataList // 地图区域 regions: [], }, series: [ { mapType: "宁波市", name: "租赁补贴", type: "map", //map: '宁波市',//要和echarts.registerMap()中第一个参数一致 label: { show: true, }, geoIndex: 0, data: [ { name: "鄞州区", value: 2605, }, { name: "海曙区", value: 2971, }, { name: "象山县", value: 0, }, { name: "江北区", value: 2463, }, { name: "宁海县", value: 877, }, { name: "北仑区", value: 1626, }, { name: "镇海区", value: 577, }, { name: "奉化区", value: 403, }, { name: "慈溪市", value: 1043, }, { name: "余姚市", value: 68, }, ], }, ], } d.forEach(function (item) { // debugger let c = parseFloat((item["currentValue"] / item["targetValue"]) * 100).toFixed(0) < 100 ? "#FF5C11" : "#15BE50" option2.geo.regions.push({ name: ningbo_allareas[item["areaCode"]], itemStyle: { normal: { areaColor: "#8BCCFE", }, emphasis: { areaColor: "#8BCCFE", }, }, label: { show: true, }, }) // myColor1.push(c) }) myChart3.setOption(option3) }) }) /** * 统一后端数据 */ $.get(" https://dingdingoa.nbjs.gov.cn/yidongduanapi/api/pr-housing", function ({ data }) { // console.log(data) data.forEach(function (item) { $(".peizu").append("" + item.area + "" + item.mdaLease + "") $(".zulin").append("" + item.area + "" + item.smAssistance + "") }) }) $.get(" https://dingdingoa.nbjs.gov.cn/yidongduanapi/api/housing-s", function ({ data }) { console.log("得到的数据",data) $("#level>.card i").text(data[0].housingArea) $("#guarantee>:last-child").find("i").text(data[0].rate) $("#goverment").children().eq(1).find("i").text(data[0].rent) $("#goverment").children().eq(2).find("i").text(data[0].rental) $("#goverment").children().eq(3).find("i").text(data[0].information) })