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.

main.js 8.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // JavaScript Document localStorage
  2. var skinLink = $('#skinLink');
  3. var skins = localStorage.getItem('skinLink');
  4. skins ? skinLink.attr('href', '/Content/css/DragSSO/' + skins + '.css') : '';
  5. $(document).ready(function () {
  6. if (skins) {
  7. skinLink.attr('href', '/Content/css/DragSSO/' + skins + '.css');
  8. $('.skins[skin="' + skins + '"]').addClass('active').siblings().removeClass('active');
  9. }
  10. var qrCodeBox = $('.qrCodeBox');
  11. var loginForm = $('#loginForm');
  12. //var qrcode = new QRCode(document.getElementById("qrCode"), {
  13. // width: 200,
  14. // height: 200
  15. //});
  16. //makeCode('http://192.168.1.126:8081/Login/Index');
  17. // header search
  18. $(document).on('click', function () {
  19. $('.skinBox').removeClass('active');
  20. }).on('click', '.headSearch', function () {
  21. $('body').addClass('active');
  22. }).on('click', '.headSearchImg', function () {
  23. if ($('body').hasClass('active')) {
  24. var keyword = $('#headSearchInput').val();
  25. if ($.trim(keyword) != "") {
  26. $.each($('.search').find('.searchLi'), function (i, item) {
  27. if ($(item).find('.searchLiTxt').html().indexOf(keyword) != -1) {
  28. $(item).show();
  29. } else {
  30. $(item).hide();
  31. }
  32. });
  33. } else {
  34. $('.search').find('.searchLi').show();
  35. }
  36. }
  37. }).on('click', '.searchTopList li', function () {
  38. if ($(this).hasClass('active')) return;
  39. $(this).addClass('active').siblings().removeClass('active');
  40. }).on('click', '.headSearchClose', function (e) {
  41. //阻止默认浏览器动作(W3C)
  42. if (e && e.preventDefault) {
  43. e.preventDefault();
  44. } else { //IE中阻止函数器默认动作的方式
  45. window.e.returnValue = false;
  46. }
  47. e.stopPropagation();
  48. $('body').removeClass('active');
  49. //清空搜索
  50. if ($.trim($('#headSearchInput').val()) != "") {
  51. setTimeout(function () {
  52. $('#headSearchInput').val('');
  53. $('.search').find('.searchLi').show();
  54. }, 50);
  55. }
  56. }).on('click', '.signOut', function () { //退出登录
  57. //ajax退出操作
  58. layer.msg('退出中...', {
  59. icon: 16
  60. , shade: 0.01
  61. });
  62. $.ajax({
  63. url: "/Login/OutLogin",
  64. headers: { __RequestVerificationToken: $.lrToken },
  65. data: {},
  66. type: "post",
  67. dataType: "json",
  68. success: function (res) {
  69. if (res.code == 200) {
  70. location.href = "/SSOSystem/DragNoLogin";
  71. }
  72. else if (res.code == 400) {
  73. layer.msg(res.info);
  74. }
  75. else if (res.code == 500) {
  76. layer.msg('服务端异常,请联系管理员');
  77. }
  78. }
  79. });
  80. }).on('click', '#flowList .fa', function () {//可用应用
  81. //是否收藏
  82. var modelCode = $('#ModelCode').val();
  83. var userId = $('#UserId').val();
  84. var Id = $(this).parent('li').attr('data-Id');
  85. var isCollect = true;
  86. var tipMsg = "";
  87. if ($(this).hasClass('fa-heart')) {
  88. //ajax取消收藏操作
  89. isCollect = false;
  90. tipMsg = "取消收藏成功!";
  91. } else {
  92. //ajax收藏操作
  93. isCollect = true;
  94. tipMsg = "收藏成功!";
  95. }
  96. if (userId != "" && userId != undefined && modelCode != "" && modelCode != undefined && Id != "" && Id != undefined) {
  97. $.ajax({
  98. url: "/SSOSystem/DoCollectFlow",
  99. headers: { __RequestVerificationToken: $.lrToken },
  100. data: { userId: userId, modelCode: modelCode, id: Id, isCollect: isCollect },
  101. type: "post",
  102. dataType: "json",
  103. success: function (res) {
  104. if (res.code == 200) {
  105. //操作成功执行代码
  106. layer.msg(tipMsg);
  107. //刷新可用应用列表
  108. flowListJson = res.data.flowList;
  109. $("#flowTypeList").find("li.active .itemName").trigger("click");
  110. //刷新我的收藏列表
  111. flowListOfCollectJson = res.data.flowListOfCollect;
  112. updateCollectCount(flowListOfCollectJson);
  113. $("#flowTypeListOfCollect").find("li.active .itemName").trigger("click");
  114. }
  115. else if (res.code == 400) {
  116. layer.msg(res.info);
  117. }
  118. else if (res.code == 500) {
  119. layer.msg('服务端异常,请联系管理员');
  120. }
  121. }
  122. });
  123. }
  124. }).on('click', '#flowListOfCollect .fa', function () {//我的收藏
  125. //是否收藏
  126. var modelCode = $('#ModelCode').val();
  127. var userId = $('#UserId').val();
  128. var Id = $(this).parent('li').attr('data-Id');
  129. if ($(this).hasClass('fa-heart')) {
  130. //ajax取消收藏操作
  131. if (userId != "" && userId != undefined && modelCode != "" && modelCode != undefined && Id != "" && Id != undefined) {
  132. $.ajax({
  133. url: "/SSOSystem/DoCollectFlow",
  134. headers: { __RequestVerificationToken: $.lrToken },
  135. data: { userId: userId, modelCode: modelCode, id: Id, isCollect: false },
  136. type: "post",
  137. dataType: "json",
  138. success: function (res) {
  139. if (res.code == 200) {
  140. //操作成功执行代码
  141. layer.msg('取消收藏成功!');
  142. //刷新我的收藏列表
  143. flowListOfCollectJson = res.data.flowListOfCollect;
  144. updateCollectCount(flowListOfCollectJson);
  145. $("#flowTypeListOfCollect").find("li.active .itemName").trigger("click");
  146. //刷新可用应用列表
  147. flowListJson = res.data.flowList;
  148. $("#flowTypeList").find("li.active .itemName").trigger("click");
  149. }
  150. else if (res.code == 400) {
  151. layer.msg(res.info);
  152. }
  153. else if (res.code == 500) {
  154. layer.msg('服务端异常,请联系管理员');
  155. }
  156. }
  157. });
  158. }
  159. }
  160. });
  161. //登录
  162. $('.loginTab > div').click(function () {
  163. var ind = $(this).index();
  164. $(this).addClass('active').siblings().removeClass('active');
  165. if (ind == 0) {
  166. qrCodeBox.css('display', 'none');
  167. loginForm.stop().fadeIn();
  168. } else {
  169. loginForm.css('display', 'none');
  170. qrCodeBox.stop().fadeIn();
  171. }
  172. })
  173. //皮肤点击
  174. var skinT = null;
  175. $('.skinBox').on('click', 'img', function (e) {
  176. //阻止默认浏览器动作(W3C)
  177. if (e && e.preventDefault) {
  178. e.preventDefault();
  179. } else { //IE中阻止函数器默认动作的方式
  180. window.e.returnValue = false;
  181. }
  182. e.stopPropagation();
  183. var parents = $(this).parent();
  184. if (parents.hasClass('active')) {
  185. parents.removeClass('active');
  186. } else {
  187. parents.addClass('active');
  188. }
  189. }).hover(function () {
  190. clearTimeout(skinT)
  191. }, function () {
  192. var _this = $(this);
  193. skinT = setTimeout(function () {
  194. _this.removeClass('active');
  195. }, 2000)
  196. }).on('click', '.skins', function (e) {
  197. //阻止默认浏览器动作(W3C)
  198. if (e && e.preventDefault) {
  199. e.preventDefault();
  200. } else { //IE中阻止函数器默认动作的方式
  201. window.e.returnValue = false;
  202. }
  203. e.stopPropagation();
  204. $(this).addClass('active').siblings().removeClass('active');
  205. var skin = $(this).attr('skin');
  206. localStorage.setItem('skinLink', skin);
  207. skinLink.attr('href', '/Content/css/DragSSO/' + skin + '.css');
  208. }).on('click', '.skinT img', function () {
  209. $('.skinBox').removeClass('active');
  210. })
  211. function makeCode(urls) {
  212. qrcode.makeCode(urls);
  213. }
  214. })