123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- /**
- * [ONEMAP.M.user]
- * @return {[object]}
- */
- define(['html!templates/user',
- 'css!styles/user',
- 'css!styles/tools/toolPublicPopup',
- 'modDir/tools/toolDraw_new'
- ], function(tplLayout) {
- var status = {
- userContentShow: false,
- netType: null,
- // showhideAll:true
- }
- function init() {
- setLayout();
- subscribe();
- bindEvents();
- };
- function setLayout() {
- // $(tplLayout).appendTo($("#wrapper"));
- $(tplLayout).appendTo($("#userInfo"));
- //$('#userContent .userLink .cover-content').html(ONEMAP.D.user.name);
- //拖拽
- $(".userInfo .popup-ct").dragmove($('.userInfo'));
- if(ONEMAP.D.isLoad){//判断是否登录,ture 登录
- var role_list = ONEMAP.D.user.roles;
- // 只有admin用户才有地图设置选项
- $.each(role_list, function(i, t) {
- switch (t) {
- case "admin":
- $('#userContent .userInfo .moreLink .linkList li.set').css("display", "inline-block");
- break;
- }
- })
- }
- if (map23DConfig.netType == 1) {
- $("#userInfo .check-button").html("离线");
- $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
- status.netType = 1;
- } else {
- $("#userInfo .check-button").html("在线");
- $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
- status.netType = 2;
- }
- if (ONEMAP.D.user.username != "map_super_user") {
- $('#userContent .userInfo .moreLink .linkList li.set').hide();
- }
- if (!map23DConfig.showSourceCenter) {
- $('#userContent .share').hide();
- }
- };
- function fullMap(option) {
- if (option) {
- $("#userContent").fadeOut('slow')
- } else {
- $("#userContent").fadeIn('slow')
- }
- }
- function change23D(options) {
- if (options == '2d') {
- $('#userContent').removeClass('class3d');
- // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('active');
- } else {
- $('#userContent').addClass('class3d');
- // $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('active');
- }
- }
- function remove() {
- ONEMAP.M.toolDraw.remove({ modName: 'cleanMap' });
- }
- function subscribe() {
- // ONEMAP.C.publisher.subscribe(remove,'tools:active');
- ONEMAP.C.publisher.subscribe(layoutesize, 'seitchNetwork');
- ONEMAP.C.publisher.subscribe(closeLeft, 'layout::closeLeft');
- ONEMAP.C.publisher.subscribe(change23D, 'change23D');
- ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
- };
- function bindEvents() {
- //用户左上面板开关
- $('#userContent .userLink').bind('click', function() {
- var userInfo = $("#userContent .userInfo");
- if (userInfo.hasClass("active")) {
- userInfo.removeClass("active");
- } else {
- userInfo.addClass("active");
- $("#searchresult").hide();
- }
- //关掉menu
- if ($("#menu").hasClass("moveOut")) {
- $("#menu").animate({
- left: "-340px"
- }, 200)
- $("#menu").removeClass("moveOut");
- var layer = $("#layerControlMenu");
- var layerLeft = parseFloat($("#layerControlMenu").css("left"));
- if (layerLeft <= 0) {
- layer.animate({
- left: "-340px"
- }, 200)
- }
- // $("#menu .arrow").removeClass("left");
- }
- })
- //用户面板中我的收藏
- $("#userContent .userInfo .moreLink .linkList li.collect").bind("click", function() {
- require(['modDir/user/userSideBar'], function(userSideBar) {
- userSideBar.init();
- });
- if ($("#toolsBar").hasClass('cur')) {
- $("#toolsBar p").click();
- }
- // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
- })
- $(".data-share-link").attr("href", onemapUrlConfig.shareUrl);
- $('#userContent .userLink').bind('click', function() {
- if (ONEMAP.D.isLoad) {
- $('#userContent .userInfo .moreLink,.lgtop').show();
- $('#userContent .popup-lt,#userContent .popup-lb,#userContent .popup-rt,#userContent .popup-rb').show();
- $('#userContent .username').html(ONEMAP.D.user.name);//填入用户名
- // $('#userContent .username').html();//疑惑操作
- // $("#userContent .userInfo .moreLink .collect").show();
- $("#userContent .mt10").show();//展示上次登录时间
- $("#userContent").removeClass("no-login");//无实际用途
- $("#userContent .quit").show();//展示退出登录
- $("#userContent .userInfo .login").hide();//隐藏提示登录信息
- $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
- } else {
- $('#userContent .userInfo .login').show();//展示提示登录信息
- $("#userContent .mt10").hide();//隐藏上次登录时间
- // $("#userContent").addClass("no-login");//无实际用途
- // $('#userContent .userInfo .moreLink,.lgtop').show();//疑惑操作
- $("#userContent .userInfo .moreLink").hide();//隐藏用户中心
- $("#userContent .quit").hide();//隐藏退出登录
- $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('uFavo').removeClass('active');//隐藏我的标注
- }
- $('#userContent .userLink').addClass('active');
- status.userContentShow = true;
- })
- //登录
- $('#userContent .userInfo .login a').bind('click', function() {
- ONEMAP.C.gotoLogin();
- // require(['modDir/user/userLogin'], function (userLogin) {
- // userLogin.init();
- // });
- // $("#userLogin").show();
- })
- $("#userContent .userInfo .moreLink .linkList li").bind('click', function() {
- var curmid = $(this).attr('mid');
- if (curmid == 'logout') {
- ONEMAP.C.logout();
- } else if (curmid == 'setting') {
- require(['modDir/user/userSetting'], function(userSetting) {
- userSetting.init();
- });
- }
- // else if (curmid == 'userCenter') {
- // require(['modDir/user/userCenter'], function(userCenter) {
- // userCenter.init('userFav');
- // });
- // }
- else if (curmid == 'set') {
- require(['modDir/user/userSetting'], function(userSetting) {
- userSetting.init();
- });
- }
- })
- // 退出登录
- $("#userContent .quit").bind('click', function() {
- ONEMAP.C.logout();
- // $("#userContent .mt10").hide();
- })
- // 标注显隐
- $("#userContent .userInfo .moreLink .linkList li.myBh").unbind("click").bind("click", function() {
- if ($(this).hasClass('uFavo')) {
- // if(status.showhideAll){
- //加载全部
- ONEMAP.M.toolDraw.addAllCollect("show");
- // }
- //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").show(); // 二维
- $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass("uFavo");
- // status.showhideAll = false;
- } else {
- ONEMAP.M.toolDraw.addAllCollect("hide");
- //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").hide(); // 二维
- $("#userContent .userInfo .moreLink .linkList li.myBh").addClass("uFavo");
- }
- })
- // 关闭左侧栏
- $("#userInfo .arrow").bind('click', function() {
- ONEMAP.M.user.closeLeft();
- })
- //切换网络
- $("#switchInter").bind('click', function() {
- if (status.netType == 1) {
- curNetType = 2;
- } else {
- curNetType = 1
- }
- require(['layoutDir/switchNetwork'], function(switchNetwork) {
- switchNetwork.init(curNetType);
- });
- })
- //新登录
- // $("#userInfo").bind('click',function(){
- // require(['modDir/user/userLogin'], function (userLogin) {
- // userLogin.init();
- // });
- // })
- };
- function layoutesize(type) {
- if (type == "network") {
- status.netType = 1;
- $("#userInfo .check-button").html("离线");
- $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
- } else {
- status.netType = 2;
- $("#userInfo .check-button").html("在线");
- $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
- }
- }
- function closeLeft() {
- $("#menu").animate({
- left: "-340px"
- }, 200)
- $("#menu").removeClass("moveOut");
- var layer = $("#layerControlMenu");
- var layerLeft = parseFloat($("#layerControlMenu").css("left"));
- if (layerLeft <= 0) {
- layer.animate({
- left: "-340px"
- }, 200)
- }
- }
- return ONEMAP.M.user = {
- init: init,
- closeLeft: closeLeft
- }
- })
|