userCenter.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * [ONEMAP.M.mod]
  3. * @return {[object]}
  4. */
  5. define(['css!styles/user/userCenter',
  6. 'css!styles/user/userFav'],
  7. function(){
  8. /**
  9. * 模块数据 用于数据存储和外部调用
  10. * @type {Object}
  11. * 数据存放
  12. */
  13. var modValue = {
  14. subModName:null,
  15. modName:""
  16. }
  17. /**
  18. * 模块界面样式 例如:宽,高
  19. * @type {Object}
  20. */
  21. var styles = {}
  22. /**
  23. * 模块状态,用于存储模块的状态 例如:收起,关闭
  24. * @type {Object}
  25. */
  26. var status = {
  27. initialized:false,
  28. appdDom:''
  29. }
  30. //分页
  31. var pageContainer,
  32. favPageBtnGroup,
  33. pageJump;
  34. /**
  35. * 初始化并订阅事件
  36. * @return {[type]} [description]
  37. */
  38. function init(options){
  39. // console.log("userCenterinit");
  40. // status.appdDom = options.appdDom;
  41. //未初始化,初始化布局
  42. // if (!status.initialized) {
  43. //设置容器布局
  44. // setLayout();
  45. bindEvent();
  46. //订阅推送
  47. subscribe();
  48. modValue.modName = options.modName
  49. setMod(modValue);
  50. status.initialized = true;
  51. // }
  52. // setMod(options.modName);
  53. //设置zIndex 为最高
  54. var zIndex = ONEMAP.M.sideBar.getZIndex();
  55. $('#userCenter').css({zIndex:zIndex});
  56. // ONEMAP.D.currentSideBarMod = 'userCenter';
  57. // 开启侧栏
  58. // ONEMAP.C.publisher.publish('handShow','layout::sideBar');
  59. }
  60. /**
  61. * 初始化布局
  62. */
  63. // function setLayout(){
  64. // if(status.appdDom == 'userSideBar'){
  65. // $(tplLayout).appendTo($("#usdFavor"));
  66. // } else{
  67. // $(tplLayout).appendTo($("#sideBarBody"));
  68. // }
  69. // };
  70. /**
  71. * 窗口布局重置
  72. * @type {Function}
  73. */
  74. function layoutResize() {
  75. };
  76. /**
  77. * 界面事件绑定
  78. * @return {[type]} [description]
  79. */
  80. function bindEvent(){
  81. $("#userCenter .nav-userRoute").unbind('click').bind('click',function(){
  82. modValue.modName = 'userRoute';
  83. setMod(modValue);
  84. });
  85. $("#userCenter .nav-userPoint").unbind('click').bind('click',function(){
  86. modValue.modName = 'userPoint';
  87. setMod(modValue);
  88. });
  89. $("#userCenter .nav-userThematic").unbind('click').bind('click',function(){
  90. modValue.modName = 'userThematic';
  91. setMod(modValue);
  92. });
  93. $("#userCenter .nav-userDraw").unbind('click').bind('click',function(){
  94. // console.log("userDraw");
  95. modValue.modName = 'userDraw';
  96. setMod(modValue);
  97. // if($("#toolsBar").hasClass('cur')){
  98. // $("#toolsBar p").click();
  99. // }
  100. });
  101. }
  102. /**
  103. * 显示相应模块的内容
  104. * @type {Function}
  105. * @private
  106. */
  107. function setMod(options){
  108. //移除上一个模块
  109. if(modValue.subModName && modValue.subModName !== options.modName){
  110. ONEMAP.M[modValue.subModName].remove();
  111. }
  112. modValue.subModName = options.modName;
  113. $('#userCenter .nav .active').removeClass('active');
  114. $('#userCenter .nav-'+modValue.subModName).addClass('active');
  115. switch (modValue.subModName){
  116. // case "userFav":
  117. // require(['modDir/user/userFav'],function(userFav){
  118. // userFav.init();
  119. // });
  120. // break;
  121. case "userRoute":
  122. require(['modDir/user/userRoute'],function(userRoute){
  123. userRoute.init();
  124. });
  125. break;
  126. case "userPoint":
  127. require(['modDir/user/userPoint'],function(userPoint){
  128. userPoint.init();
  129. });
  130. break;
  131. case "userThematic":
  132. require(['modDir/user/userThematic'],function(userThematic){
  133. userThematic.init();
  134. });
  135. break;
  136. case "userDraw":
  137. require(['modDir/user/userDraw'],function(userDraw){
  138. userDraw.init();
  139. });
  140. break;
  141. }
  142. }
  143. /**
  144. * 注册订阅
  145. * @type {Function}
  146. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  147. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  148. */
  149. function subscribe(){
  150. ONEMAP.C.publisher.subscribe(setMod,'showCenter');
  151. }
  152. /**
  153. * 取消订阅
  154. * @type {Function}
  155. * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
  156. */
  157. function unSubscribe(){}
  158. /**
  159. * 模块移除
  160. * @return {[type]} [description]
  161. */
  162. function remove(){
  163. //取消订阅
  164. unSubscribe();
  165. }
  166. return ONEMAP.M.userCenter = {
  167. init:init,
  168. layoutResize:layoutResize,
  169. setMod:setMod
  170. }
  171. });