You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

workspace.js 8.2 KiB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. (function () {
  2. var custmerform = {};
  3. var $scroll = '';
  4. var page = {
  5. init: function ($page) {
  6. var _html = '';
  7. _html += '<div class="scanner">';
  8. _html += '<i class="iconfont icon-scan"></i>';
  9. _html += '</div>';
  10. _html += '\
  11. <div class="searchBox">\
  12. <i class="iconfont icon-search"></i>\
  13. <div class="search" >搜索应用</div>\
  14. </div>';
  15. _html += '<div class="message">';
  16. _html += '<i class="iconfont icon-mail"></i>';
  17. _html += '<span class="red"></span>';
  18. _html += '</div>';
  19. $page.parent().find('.f-page-header').addClass('lr-workspace-header').html(_html);
  20. // 点击搜索框
  21. $page.parent().find('.searchBox').on('tap', function () {
  22. learun.nav.go({ path: 'workspace/search', title: '', isBack: true, isHead: true });
  23. });
  24. // 点击消息图标
  25. $page.parent().find('.message').on('tap', function () {
  26. learun.nav.go({ path: 'message', title: '消息', isBack: true, isHead: true,type:'right' });
  27. });
  28. // 注册扫描
  29. $page.parent().find('.scanner').on('tap', function () {
  30. learun.code.scan(function (res) {
  31. if (res.status === 'success') {
  32. learun.layer.toast(res.msg);
  33. }
  34. else {
  35. learun.layer.toast('扫描失败:' + res.msg);
  36. }
  37. });
  38. });
  39. // 图片加载
  40. $page.find('.banner').slider({ data: ['images/banner.png'], indicator: true, interval: 10000 });
  41. // 基础数据初始化
  42. learun.clientdata.init();
  43. // 加载功能列表
  44. learun.clientdata.get('module', {
  45. callback: function (data) {
  46. learun.myModule.get(data, function (myModules) {
  47. var mylen = parseInt((myModules.length + 1) / 4) + ((myModules.length + 1) % 4 > 0 ? 1 : 0);
  48. switch (mylen) {
  49. case 1:
  50. $page.find('.lr-workspace-page').css('padding-top', '210px');
  51. break;
  52. case 2:
  53. $page.find('.lr-workspace-page').css('padding-top', '290px');
  54. break;
  55. case 3:
  56. $page.find('.lr-workspace-page').css('padding-top', '370px');
  57. break;
  58. }
  59. var map = {};
  60. $.each(data, function (_index, _item) {
  61. map[_item.F_Id] = _item;
  62. });
  63. var $appbox = $page.find('.appbox');
  64. var $last = null;
  65. $.each(myModules, function (_index, _id) {
  66. var item = map[_id];
  67. if (item) {
  68. var _html = '\
  69. <div class="appitem appitem2" data-value="'+ item.F_Id + '">\
  70. <div><i class="'+ item.F_Icon + '"></i></div>\
  71. <span>'+ item.F_Name + '</span>\
  72. </div>';
  73. var _$html = $(_html);
  74. _$html[0].item = item;
  75. if ($last === null) {
  76. $appbox.prepend(_$html);
  77. }
  78. else {
  79. $last.after(_$html);
  80. }
  81. $last = _$html;
  82. }
  83. });
  84. $last = null;
  85. });
  86. }
  87. });
  88. // 注册更多功能按钮
  89. $page.find('#lr_more_app').on('tap', function () {
  90. learun.nav.go({ path: 'workspace/modulelist', title: "", type: 'right' });
  91. });
  92. // 点击功能按钮
  93. $page.delegate('.appitem2', 'tap', function () {
  94. var $this = $(this);
  95. var item = $this[0].item;
  96. if (item.F_IsSystem === 1) {// 代码开发功能
  97. learun.nav.go({ path: item.F_Url, title: item.F_Name, isBack: true, isHead: true, type: 'right' });
  98. }
  99. else {// 自定义表单开发功能
  100. learun.nav.go({ path: 'custmerform', title: item.F_Name, param: { formSchemeId: item.F_FormId, girdScheme: item.F_Scheme }, isBack: true, isHead: true, type: 'right' });
  101. }
  102. return false;
  103. });
  104. },
  105. reload: function ($page, pageinfo) {
  106. if (learun.isOutLogin) {// 如果是重新登录的情况刷新下桌面数据
  107. learun.isOutLogin = false;
  108. learun.clientdata.clear('module');
  109. learun.myModule.states = -1;
  110. // 图片加载
  111. learun.httpget(config.webapi + "learun/adms/desktop/imgid", null, function (data) {
  112. if (data) {
  113. var _list = [];
  114. $.each(data, function (_index, _item) {
  115. _list.push(config.webapi + "learun/adms/desktop/img?data=" + _item);
  116. });
  117. $page.find('.banner').after('<div class="banner"></div>').remove();
  118. $page.find('.banner').slider({ data: _list, indicator: true, interval: 10000 });
  119. }
  120. });
  121. }
  122. // 加载功能列表
  123. learun.clientdata.get('module', {
  124. callback: function (data) {
  125. learun.myModule.get(data, function (myModules) {
  126. var mylen = parseInt((myModules.length + 1) / 4) + ((myModules.length + 1) % 4 > 0 ? 1 : 0);
  127. switch (mylen) {
  128. case 1:
  129. $page.find('.lr-workspace-page').css('padding-top', '210px');
  130. break;
  131. case 2:
  132. $page.find('.lr-workspace-page').css('padding-top', '290px');
  133. break;
  134. case 3:
  135. $page.find('.lr-workspace-page').css('padding-top', '370px');
  136. break;
  137. }
  138. var map = {};
  139. $.each(data, function (_index, _item) {
  140. map[_item.F_Id] = _item;
  141. });
  142. var $appbox = $page.find('.appbox');
  143. var $last = null;
  144. $appbox.find(".appitem2").remove();
  145. $.each(myModules, function (_index, _id) {
  146. var item = map[_id];
  147. if (item) {
  148. var _html = '\
  149. <div class="appitem appitem2" data-value="'+ item.F_Id + '">\
  150. <div><i class="'+ item.F_Icon + '"></i></div>\
  151. <span>'+ item.F_Name + '</span>\
  152. </div>';
  153. var _$html = $(_html);
  154. _$html[0].item = item;
  155. if ($last === null) {
  156. $appbox.prepend(_$html);
  157. }
  158. else {
  159. $last.after(_$html);
  160. }
  161. $last = _$html;
  162. }
  163. });
  164. $last = null;
  165. });
  166. }
  167. });
  168. }
  169. };
  170. return page;
  171. })();