user.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /**
  2. * [ONEMAP.M.user]
  3. * @return {[object]}
  4. */
  5. define(['html!templates/user',
  6. 'css!styles/user',
  7. 'css!styles/tools/toolPublicPopup',
  8. 'modDir/tools/toolDraw_new'
  9. ], function(tplLayout) {
  10. var status = {
  11. userContentShow: false,
  12. netType: null,
  13. // showhideAll:true
  14. }
  15. function init() {
  16. setLayout();
  17. subscribe();
  18. bindEvents();
  19. };
  20. function setLayout() {
  21. // $(tplLayout).appendTo($("#wrapper"));
  22. $(tplLayout).appendTo($("#userInfo"));
  23. //$('#userContent .userLink .cover-content').html(ONEMAP.D.user.name);
  24. //拖拽
  25. $(".userInfo .popup-ct").dragmove($('.userInfo'));
  26. if(ONEMAP.D.isLoad){//判断是否登录,ture 登录
  27. var role_list = ONEMAP.D.user.roles;
  28. // 只有admin用户才有地图设置选项
  29. $.each(role_list, function(i, t) {
  30. switch (t) {
  31. case "admin":
  32. $('#userContent .userInfo .moreLink .linkList li.set').css("display", "inline-block");
  33. break;
  34. }
  35. })
  36. }
  37. if (map23DConfig.netType == 1) {
  38. $("#userInfo .check-button").html("离线");
  39. $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
  40. status.netType = 1;
  41. } else {
  42. $("#userInfo .check-button").html("在线");
  43. $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
  44. status.netType = 2;
  45. }
  46. if (ONEMAP.D.user.username != "map_super_user") {
  47. $('#userContent .userInfo .moreLink .linkList li.set').hide();
  48. }
  49. if (!map23DConfig.showSourceCenter) {
  50. $('#userContent .share').hide();
  51. }
  52. };
  53. function fullMap(option) {
  54. if (option) {
  55. $("#userContent").fadeOut('slow')
  56. } else {
  57. $("#userContent").fadeIn('slow')
  58. }
  59. }
  60. function change23D(options) {
  61. if (options == '2d') {
  62. $('#userContent').removeClass('class3d');
  63. // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('active');
  64. } else {
  65. $('#userContent').addClass('class3d');
  66. // $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('active');
  67. }
  68. }
  69. function remove() {
  70. ONEMAP.M.toolDraw.remove({ modName: 'cleanMap' });
  71. }
  72. function subscribe() {
  73. // ONEMAP.C.publisher.subscribe(remove,'tools:active');
  74. ONEMAP.C.publisher.subscribe(layoutesize, 'seitchNetwork');
  75. ONEMAP.C.publisher.subscribe(closeLeft, 'layout::closeLeft');
  76. ONEMAP.C.publisher.subscribe(change23D, 'change23D');
  77. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  78. };
  79. function bindEvents() {
  80. //用户左上面板开关
  81. $('#userContent .userLink').bind('click', function() {
  82. var userInfo = $("#userContent .userInfo");
  83. if (userInfo.hasClass("active")) {
  84. userInfo.removeClass("active");
  85. } else {
  86. userInfo.addClass("active");
  87. $("#searchresult").hide();
  88. }
  89. //关掉menu
  90. if ($("#menu").hasClass("moveOut")) {
  91. $("#menu").animate({
  92. left: "-340px"
  93. }, 200)
  94. $("#menu").removeClass("moveOut");
  95. var layer = $("#layerControlMenu");
  96. var layerLeft = parseFloat($("#layerControlMenu").css("left"));
  97. if (layerLeft <= 0) {
  98. layer.animate({
  99. left: "-340px"
  100. }, 200)
  101. }
  102. // $("#menu .arrow").removeClass("left");
  103. }
  104. })
  105. //用户面板中我的收藏
  106. $("#userContent .userInfo .moreLink .linkList li.collect").bind("click", function() {
  107. require(['modDir/user/userSideBar'], function(userSideBar) {
  108. userSideBar.init();
  109. });
  110. if ($("#toolsBar").hasClass('cur')) {
  111. $("#toolsBar p").click();
  112. }
  113. // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
  114. })
  115. $(".data-share-link").attr("href", onemapUrlConfig.shareUrl);
  116. $('#userContent .userLink').bind('click', function() {
  117. if (ONEMAP.D.isLoad) {
  118. $('#userContent .userInfo .moreLink,.lgtop').show();
  119. $('#userContent .popup-lt,#userContent .popup-lb,#userContent .popup-rt,#userContent .popup-rb').show();
  120. $('#userContent .username').html(ONEMAP.D.user.name);//填入用户名
  121. // $('#userContent .username').html();//疑惑操作
  122. // $("#userContent .userInfo .moreLink .collect").show();
  123. $("#userContent .mt10").show();//展示上次登录时间
  124. $("#userContent").removeClass("no-login");//无实际用途
  125. $("#userContent .quit").show();//展示退出登录
  126. $("#userContent .userInfo .login").hide();//隐藏提示登录信息
  127. $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
  128. } else {
  129. $('#userContent .userInfo .login').show();//展示提示登录信息
  130. $("#userContent .mt10").hide();//隐藏上次登录时间
  131. // $("#userContent").addClass("no-login");//无实际用途
  132. // $('#userContent .userInfo .moreLink,.lgtop').show();//疑惑操作
  133. $("#userContent .userInfo .moreLink").hide();//隐藏用户中心
  134. $("#userContent .quit").hide();//隐藏退出登录
  135. $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('uFavo').removeClass('active');//隐藏我的标注
  136. }
  137. $('#userContent .userLink').addClass('active');
  138. status.userContentShow = true;
  139. })
  140. //登录
  141. $('#userContent .userInfo .login a').bind('click', function() {
  142. ONEMAP.C.gotoLogin();
  143. // require(['modDir/user/userLogin'], function (userLogin) {
  144. // userLogin.init();
  145. // });
  146. // $("#userLogin").show();
  147. })
  148. $("#userContent .userInfo .moreLink .linkList li").bind('click', function() {
  149. var curmid = $(this).attr('mid');
  150. if (curmid == 'logout') {
  151. ONEMAP.C.logout();
  152. } else if (curmid == 'setting') {
  153. require(['modDir/user/userSetting'], function(userSetting) {
  154. userSetting.init();
  155. });
  156. }
  157. // else if (curmid == 'userCenter') {
  158. // require(['modDir/user/userCenter'], function(userCenter) {
  159. // userCenter.init('userFav');
  160. // });
  161. // }
  162. else if (curmid == 'set') {
  163. require(['modDir/user/userSetting'], function(userSetting) {
  164. userSetting.init();
  165. });
  166. }
  167. })
  168. // 退出登录
  169. $("#userContent .quit").bind('click', function() {
  170. ONEMAP.C.logout();
  171. // $("#userContent .mt10").hide();
  172. })
  173. // 标注显隐
  174. $("#userContent .userInfo .moreLink .linkList li.myBh").unbind("click").bind("click", function() {
  175. if ($(this).hasClass('uFavo')) {
  176. // if(status.showhideAll){
  177. //加载全部
  178. ONEMAP.M.toolDraw.addAllCollect("show");
  179. // }
  180. //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").show(); // 二维
  181. $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass("uFavo");
  182. // status.showhideAll = false;
  183. } else {
  184. ONEMAP.M.toolDraw.addAllCollect("hide");
  185. //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").hide(); // 二维
  186. $("#userContent .userInfo .moreLink .linkList li.myBh").addClass("uFavo");
  187. }
  188. })
  189. // 关闭左侧栏
  190. $("#userInfo .arrow").bind('click', function() {
  191. ONEMAP.M.user.closeLeft();
  192. })
  193. //切换网络
  194. $("#switchInter").bind('click', function() {
  195. if (status.netType == 1) {
  196. curNetType = 2;
  197. } else {
  198. curNetType = 1
  199. }
  200. require(['layoutDir/switchNetwork'], function(switchNetwork) {
  201. switchNetwork.init(curNetType);
  202. });
  203. })
  204. //新登录
  205. // $("#userInfo").bind('click',function(){
  206. // require(['modDir/user/userLogin'], function (userLogin) {
  207. // userLogin.init();
  208. // });
  209. // })
  210. };
  211. function layoutesize(type) {
  212. if (type == "network") {
  213. status.netType = 1;
  214. $("#userInfo .check-button").html("离线");
  215. $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
  216. } else {
  217. status.netType = 2;
  218. $("#userInfo .check-button").html("在线");
  219. $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
  220. }
  221. }
  222. function closeLeft() {
  223. $("#menu").animate({
  224. left: "-340px"
  225. }, 200)
  226. $("#menu").removeClass("moveOut");
  227. var layer = $("#layerControlMenu");
  228. var layerLeft = parseFloat($("#layerControlMenu").css("left"));
  229. if (layerLeft <= 0) {
  230. layer.animate({
  231. left: "-340px"
  232. }, 200)
  233. }
  234. }
  235. return ONEMAP.M.user = {
  236. init: init,
  237. closeLeft: closeLeft
  238. }
  239. })