/********************************************
* 前台展示 - 地图服务 *
*******************************************/
//控制器:DiTuFuWuController
//------------------------------------------
//F1.页面初始化
//F2.访问排行
//F3.最新资源
//F4.我的收藏夹
//F5.资源使用情况
//F6.初始化热门搜索关键字
//F7.热门搜索
//F8.定向推送
//F9.我的申请
//F10 跳转地图
//F11 阻止事件冒泡
//F12 换一批(0定向推送1资源推荐)
//F13 资源推荐
//------------------------------------------
//F1.页面初始化
$(function() {
FangWenPaiHang(); //访问排行
ZuiXinZiYuan(); //最新资源
WoDeShouCangJia(); //我的收藏夹
ZiYuanShiYongQingKuang();
DirectionalPush(0,0);
WoDeShenQing();
$('.txt').css('width', $('.img').width() + 'px');
var width1 = ($('.YWJC_Img').width() - $('.img').width()) / 2;
$('.txt').css('left', width1 + 'px');
$('.noanimate').css('width', $('.img').width() + 'px');
var width1 = ($('.YWJC_Img').width() - $('.img').width()) / 2;
$('.noanimate').css('left', width1 + 'px');
var width = $(".YWJC_Img").width();
//var RowCount = $(".lanren").width() >= (width * 3) ? 3 : ($(".lanren").width() >= (width * 2) ? 2 : 1);
var margin_L_R = ($(".lanren").width() - width * 3) / 6;
$(".lanren ul li").css("margin-left", margin_L_R + "px");
$(".lanren ul li").css("margin-right", margin_L_R + "px");
$(".lanren ul li").hover(function () {
$(this).find(".txt").stop().animate({height: "170px"}, 400);
$(this).find(".txt h3").stop().animate({paddingTop: "30px"}, 400);
}, function () {
$(this).find(".txt").stop().animate({height: "40px"}, 400);
$(this).find(".txt h3").stop().animate({paddingTop: "0"}, 400);
});
// ZiYuanShiYongQingKuang();
InitTopHotSearchKey();
ZiYuanRecommend(0,0);
});
//F2.访问排行
function FangWenPaiHang() {
$.ajax({
url: '/res/ditufuwu/getTopListFWPH',
type: 'get',
success: function(data) {
var html = "";
var jsonb = data.result;
if(jsonb.length < 5) {
$("#fwph").css("height","275px");
}
var len = jsonb.length > 5?5:jsonb.length;
for (var i = 0; i < len; i++) {
var num = i+1;
var tit = htmlEncodeByRegExp(jsonb[i].fulltitle);
if (i == 0) {
html += "
" +
"" +
"
" +
"" + tit + "" +
"" +
"";
continue;
}
if (i == 1) {
html += "" +
"" +
"
" +
"" + jsonb[i].fulltitle + "" +
"" +
"";
continue;
}
if (i == 2) {
html += "" +
"" +
"
" +
"" + jsonb[i].fulltitle + "" +
"" +
"";
continue;
}
else {
html += "" +
"" +
"" + num + "" +
" " + jsonb[i].fulltitle + "" +
"" +
"";
}
}
$("#fwph").append(html);
},
error: function(e) {
alert(e.message);
}
});
}
//F3.最新资源
function ZuiXinZiYuan() {
$.ajax({
url: '/res/ditufuwu/getTopListZXZY',
type: 'get',
success: function(data) {
var html = "";
var jsonb = data.result;
var today = new Date();
var year = today.getFullYear() + "-";
var month = today.getMonth() + 1;
if(month <10) {
month = "0" + month;
}
var day = today.getDate();
if(day < 10 ){
day = "0" + day;
}
var newday = year + month + "-" + day;
if(jsonb.length < 7) {
$("#zxzy").css("height","385px");
}
var len = jsonb.length > 7?7:jsonb.length;
for (var i = 0; i < len; i++) {
var tit = htmlEncodeByRegExp(jsonb[i].fulltitle);
html += "" +
"" +
"";
}
$("#zxzy").append(html);
},
error: function(e) {
alert(e.message);
}
});
}
//F4.我的收藏夹
function WoDeShouCangJia() {
$.ajax({
url: '/res/ditufuwu/getTopListWDSCJ',
type: 'post',
// dataType: 'text',
data: {'actiontype': '收藏'},
success: function(data) {
var html = "";
var jsona = data.result;
if(jsona.length < 5) {
$(".mtree").css("height","275px");
}
var len = jsona.length > 5?5:jsona.length;
for(var i=0;i" +
// "" +
"" +
"
" + tit +
"" +
" ";
}
$(".mtree").append(html);
},
error: function(e) {
alert(e.message);
}
});
}
//F5.资源使用情况
function ZiYuanShiYongQingKuang() {
var ziyuan = echarts.init(document.getElementById("divziyuantongji"));
option = {
title : {
text: '资源使用情况',
x: 43,
y: 33,
textStyle:{
fontSize: 20,
fontWeight:"bold",
color: "#4777FF"
}
},
color: ['#C1D2FF', '#82A4FE'],
tooltip: {
trigger: 'axis'
},
legend: {
data: ['浏览次数', '收藏次数'],
show:true,
x:'right',
padding: [40,50,0,0],
},
grid: {
borderWidth: 0,
width:520,
y:100,
},
xAxis: [
{
type: 'category',
data: eval('(' + BianMu + ')'),
axisLabel:{
textStyle: {
fontSize: 14,
color:'#bfbfbf'
},
}
}
],
yAxis: [
{
type: 'value',
axisLabel:{
textStyle: {
fontSize: 14,
color:'#bfbfbf'
},
}
}
],
series: [
{
name: '浏览次数',
type: 'bar',
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data: eval('(' + Liulan + ')')
},
{
name: '收藏次数',
type: 'bar',
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data: eval('(' + ShouCang + ')')
}
]
};
ziyuan.setOption(option);
}
//F6.初始化热门搜索关键字
function InitTopHotSearchKey() {
$.ajax({
url: '/res/ditufuwu/getTopHotSearchKey',
type: 'get',
success: function (data) {
if (data != "") {
var list = data.result;
var html = "热门搜索:";
var num = 0;
for (var i = 0; i < list.length; i++) {
// num += list[i].keyword.replace(/[^\x00-\xff]/g, 'xx').length;
// num += list[i].keyword.length;
// if(num > 50) break;
html += "" + list[i].keyword + "";
}
// $("#ReMenSouSuoBox").css("width",window.innerWidth);
$("#ReMenSouSuoBox ul").append(html);
}
},
error: function (e) {
alert(e.message);
}
});
}
//F7.热门搜索(way:0为输入搜索;1为热门关键字搜索)
function HotSearch(way, obj) {
if (way == 0) {
var searchKey = document.getElementById("txtSearchKey").value;
// if (searchKey != "") {
$.ajax({
url: '/res/ditufuwu/saveHotSearch',
type: 'post',
data: {"searchKey": searchKey},
success: function (data) {
}
});
window.open("/res/ziyuanmulu/index?Menu=ZYZX&menuId=08&Message=" + encodeURIComponent(searchKey) + "&isDiTuwu=1");
// }
} else if (way == 1) {
var keyword = $(obj).attr("title");
window.open("/res/ziyuanmulu/index?Menu=ZYZX&menuId=08&Message=" + encodeURIComponent(keyword) + "&isDiTuwu=1");
}
}
//F8.定向推送
function DirectionalPush(type,num) {
var url = (type == 0 ?'/res/ZiYuan/getTopRecommend?isDiTuFuwu=true':('/res/ditufuwu/getTuiJianZiYuanByIndex?isDiTuFuwu=true&limit=3&page='+num));
$.ajax({
url: url,
type: 'get',
success: function (data) {
var html = "";
var jsonb = data.result;
for (var i = 0; i < (jsonb.length>3?3:jsonb.length); i++) {
var description = decodeURIComponent(jsonb[i].description);
var fulldescription = decodeURIComponent(jsonb[i].fulldescription);
var onclick = "";
// if(jsonb[i].isquanxian == 1){
// onclick = "showMap("+jsonb[i].resourceid+",'"+jsonb[i].resourceclass+"','"+jsonb[i].firstMapUrl+"')";
// }else{
onclick = "OpenZiYuan('"+jsonb[i].resourceid+"')";
// }
html += ""
+ "";
html += "

";
html += "
"
+ "
"
+ "
" + jsonb[i].title + "
"
+ "
" + description + "
"
+ "
"
+ "
"
+ "";
}
$("#tjzy").html(html);
var width = $(".YWJC_Img").width();
$(".lanren ul li").hover(function () {
$(this).find(".txt").stop().animate({height: "100px"}, 400,function(){
$(this).find("i").show();
});
$(this).find(".txt h3").stop().animate({marginTop: "10px"}, 400);
},
function () {
$(this).find(".txt").stop().animate({height: "25px"}, 400);
$(this).find(".txt h3").stop().animate({marginTop: "0"}, 400);
$(this).find("i").hide();
});
},
error: function (e) {
alert(e.message);
}
});
}
//F9.我的申请
function WoDeShenQing() {
//我的申请资源
$.ajax({
// url: '/res/resApplyRecommend/shenQingZiYuan',
url: '/res/ditufuwu/getTopWDZY/8',
type: 'get',
success: function (sqzy) {
var html = "";
var jsonzy = sqzy.result;
if(jsonzy.length < 7) {
$("#sqzy").css("height","385px");
}
var len = jsonzy.length > 7?7:jsonzy.length;
for (var i = 0; i < len; i++) {
if(jsonzy.length==0){
break;
}
var tit = htmlEncodeByRegExp(jsonzy[i].fulltitle);
html += "";
if (jsonzy[i].auditresult == "0") {
html += "
" +
"
" + tit + " " +
"

";
} else if (jsonzy[i].auditresult == "1") {
html += "
" +
"
" + tit + " " +
"

";
} else if (jsonzy[i].auditresult == "2") {
html += "
" +
"
" + tit + " " +
"

";
} else if (jsonzy[i].auditresult == "null" ||jsonzy[i].auditresult == null) {
html += "
" +
"
" + tit + " " +
"

";
}
html += "
";
}
$("#sqzy").append(html);
},
error: function (e) {
alert(e.message);
}
});
}
//F10 跳转地图
function showMap(resourceid,resourcetype,firsturl){
if (resourcetype == "KJ_JCDT" || resourcetype == "KJ_YWTC" || resourcetype == "KJ_ZTDT") {
var url = "";
if(firsturl != null && firsturl != ""){
url = firsturl;
}else{
url = gisPortal + "leafportal.html?resourceid=" + resourceid + "&uid=" + userId;
}
window.open(url);
}
else{
OpenZiYuan(resourceid);
}
}
//F11 阻止事件冒泡
function OpenOnlyZiYuan(ziyuanid){
event.stopPropagation();
OpenZiYuan(ziyuanid);
}
//F12 换一批(0定向推送1资源推荐)
var indexp = 2;
var indexr = 2;
function ChangeNext(type) {
var totalIndex = 0;
if(type == 0) {
totalIndex = (totalpNum % 3) > 0 ? (totalpNum / 3) + 1 : (totalpNum / 3);
if(indexp > totalIndex){
indexp = 1;
}
DirectionalPush(1,indexp);
indexp++;
}else {
totalIndex = (totalrNum % 3) > 0 ? (totalrNum / 3) + 1 : (totalrNum / 3);
if(indexr > totalIndex){
indexr = 1;
}
ZiYuanRecommend(1,indexr);
indexr++;
}
}
//F13 资源推荐
function ZiYuanRecommend(type,num) {
var url = (type == 0 ?'/res/ditufuwu/getMainInfoRecommends?isDiTuFuwu=false&limit=4&page=1':('/res/ditufuwu/getMainInfoRecommends?isDiTuFuwu=false&limit=4&page='+num));
$.ajax({
url: url,
type: 'get',
success: function (data) {
var html = "";
var jsonb = data.result;
for (var i = 0; i < (jsonb.length>6?6:jsonb.length); i++) {
var description = decodeURIComponent(jsonb[i].description);
var fulldescription = decodeURIComponent(jsonb[i].fulldescription);
var onclick = "";
if(jsonb[i].isquanxian == 1){
onclick = "showMap("+jsonb[i].resourceid+",'"+jsonb[i].resourceclass+"','"+jsonb[i].firstMapUrl+"')";
}else{
onclick = "OpenZiYuan('"+jsonb[i].resourceid+"')";
}
html += "";
html += ""
html += "
";
html += getTypeName(jsonb[i].resourceclass);
html += jsonb[i].title+"";
html += "";
}
$("#rrzy").html(html);
},
error: function (e) {
alert(e.message);
}
});
}
function getTypeName(name) {
var typeName = "";
var html = "";
if(name == "JKFW") {
typeName = "接口";
html = "接口";
}
if(name == "SJWJ") {
typeName = "文件";
html = "数据"
}
if(name == "SJKB") {
typeName = "库表";
html = "库表"
}
if(name == "YWJC") {
typeName = "集成";
html = "集成"
}
if(name == "KJ_JCDT") {
typeName = "地图";
html = "底图"
}
if(name == "KJ_ZTDT") {
typeName = "专题";
html = "专题"
}
if(name == "KJ_KJFX") {
typeName = "空间";
html = "空间"
}
if(name == "KJ_SWFW") {
typeName = "三维";
html = "三维"
}
if(name == "KJ_YWTC") {
typeName = "业务";
html = "业务"
}
return html;
}