cache.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. var cacheStr = window.sessionStorage.getItem("cache"),
  2. oneLoginStr = window.sessionStorage.getItem("oneLogin");
  3. layui.use(['form','jquery',"layer"],function() {
  4. var form = layui.form,
  5. $ = layui.jquery,
  6. layer = parent.layer === undefined ? layui.layer : top.layer;
  7. //判断是否web端打开
  8. if(!/http(s*):\/\//.test(location.href)){
  9. layer.alert("请先将项目部署到 localhost 下再进行访问【建议通过tomcat、webstorm、hb等方式运行,不建议通过iis方式运行】,否则部分数据将无法显示");
  10. }else{ //判断是否处于锁屏状态【如果关闭以后则未关闭浏览器之前不再显示】
  11. if(window.sessionStorage.getItem("lockcms") != "true" && window.sessionStorage.getItem("showNotice") != "true"){
  12. // showNotice();
  13. }
  14. }
  15. //判断是否设置过头像,如果设置过则修改顶部、左侧和个人资料中的头像,否则使用默认头像
  16. if(window.sessionStorage.getItem('userFace') && $(".userAvatar").length > 0){
  17. $("#userFace").attr("src",window.sessionStorage.getItem('userFace'));
  18. $(".userAvatar").attr("src",$(".userAvatar").attr("src").split("images/")[0] + "images/" + window.sessionStorage.getItem('userFace').split("images/")[1]);
  19. }else{
  20. $("#userFace").attr("src","../../images/face.jpg");
  21. }
  22. /*****************************************************************************************************************************************/
  23. /*
  24. * 可以不管这块
  25. */
  26. //公告层
  27. /*
  28. function showNotice(){
  29. layer.open({
  30. type: 1,
  31. title: "系统公告",
  32. area: '300px',
  33. shade: 0.8,
  34. id: 'LAY_layuipro',
  35. btn: ['火速围观'],
  36. moveType: 1,
  37. content: '<div style="padding:15px 20px; text-align:justify; line-height: 22px; text-indent:2em;border-bottom:1px solid #e2e2e2;"><p class="layui-red">请使用模版前请务必仔细阅读首页右下角的《更新日志》,避免使用中遇到一些简单的问题造成困扰。</p></pclass></p><p>1.0发布以后发现很多朋友将代码上传到各种素材网站,当然这样帮我宣传我谢谢大家,但是有部分朋友上传到素材网站后将下载分值设置的相对较高,需要朋友们充钱才能下载。本人发现后通过和站长、网站管理员联系以后将分值调整为不需要充值才能下载或者直接免费下载。在此郑重提示各位:<span class="layui-red">本模版已进行作品版权证明,不管以何种形式获取的源码,请勿进行出售或者上传到任何素材网站,否则将追究相应的责任。</span></p></div>',
  38. success: function(layero){
  39. var btn = layero.find('.layui-layer-btn');
  40. btn.css('text-align', 'center');
  41. btn.on("click",function(){
  42. tipsShow();
  43. });
  44. },
  45. cancel: function(index, layero){
  46. tipsShow();
  47. }
  48. });
  49. }
  50. function tipsShow(){
  51. window.sessionStorage.setItem("showNotice","true");
  52. if($(window).width() > 432){ //如果页面宽度不足以显示顶部“系统公告”按钮,则不提示
  53. layer.tips('系统公告躲在了这里', '#userInfo', {
  54. tips: 3,
  55. time : 1000
  56. });
  57. }
  58. }
  59. $(".showNotice").on("click",function(){
  60. showNotice();
  61. })*/
  62. /*
  63. * 锁屏调用
  64. <li class="layui-nav-item lockcms" pc>
  65. <a href="javascript:;"><i class="seraph icon-lock"></i><cite>锁屏</cite></a>
  66. </li>
  67. */
  68. //锁屏
  69. /*
  70. function lockPage(){
  71. layer.open({
  72. title : false,
  73. type : 1,
  74. content : '<div class="admin-header-lock" id="lock-box">'+
  75. '<div class="admin-header-lock-img"><img src="images/face.jpg" class="userAvatar"/></div>'+
  76. '<div class="admin-header-lock-name" id="lockUserName">驊驊龔頾</div>'+
  77. '<div class="input_btn">'+
  78. '<input type="password" class="admin-header-lock-input layui-input" autocomplete="off" placeholder="请输入密码解锁.." name="lockPwd" id="lockPwd" />'+
  79. '<button class="layui-btn" id="unlock">解锁</button>'+
  80. '</div>'+
  81. '<p>请输入“123456”,否则不会解锁成功哦!!!</p>'+
  82. '</div>',
  83. closeBtn : 0,
  84. shade : 0.9,
  85. success : function(){
  86. //判断是否设置过头像,如果设置过则修改顶部、左侧和个人资料中的头像,否则使用默认头像
  87. if(window.sessionStorage.getItem('userFace') && $(".userAvatar").length > 0){
  88. $(".userAvatar").attr("src",$(".userAvatar").attr("src").split("images/")[0] + "images/" + window.sessionStorage.getItem('userFace').split("images/")[1]);
  89. }
  90. }
  91. })
  92. $(".admin-header-lock-input").focus();
  93. }
  94. $(".lockcms").on("click",function(){
  95. window.sessionStorage.setItem("lockcms",true);
  96. lockPage();
  97. })
  98. // 判断是否显示锁屏
  99. if(window.sessionStorage.getItem("lockcms") == "true"){
  100. lockPage();
  101. }
  102. // 解锁
  103. $("body").on("click","#unlock",function(){
  104. if($(this).siblings(".admin-header-lock-input").val() == ''){
  105. layer.msg("请输入解锁密码!");
  106. $(this).siblings(".admin-header-lock-input").focus();
  107. }else{
  108. if($(this).siblings(".admin-header-lock-input").val() == "123456"){
  109. window.sessionStorage.setItem("lockcms",false);
  110. $(this).siblings(".admin-header-lock-input").val('');
  111. layer.closeAll("page");
  112. }else{
  113. layer.msg("密码错误,请重新输入!");
  114. $(this).siblings(".admin-header-lock-input").val('').focus();
  115. }
  116. }
  117. });
  118. */
  119. /****************************************************************** end ************************************************************************/
  120. $(document).on('keydown', function(event) {
  121. var event = event || window.event;
  122. if(event.keyCode == 13) {
  123. $("#unlock").click();
  124. }
  125. });
  126. //退出
  127. $(".signOut").click(function(){
  128. window.sessionStorage.removeItem("menu");
  129. menu = [];
  130. window.sessionStorage.removeItem("curmenu");
  131. })
  132. /*
  133. //功能设定 不用这块功能
  134. $(".functionSetting").click(function(){
  135. layer.open({
  136. title: "功能设定",
  137. area: ["380px", "280px"],
  138. type: "1",
  139. content : '<div class="functionSrtting_box">'+
  140. '<form class="layui-form">'+
  141. '<div class="layui-form-item">'+
  142. '<label class="layui-form-label">开启Tab缓存</label>'+
  143. '<div class="layui-input-block">'+
  144. '<input type="checkbox" name="cache" lay-skin="switch" lay-text="开|关">'+
  145. '<div class="layui-word-aux">开启后刷新页面不关闭打开的Tab页</div>'+
  146. '</div>'+
  147. '</div>'+
  148. '<div class="layui-form-item">'+
  149. '<label class="layui-form-label">Tab切换刷新</label>'+
  150. '<div class="layui-input-block">'+
  151. '<input type="checkbox" name="changeRefresh" lay-skin="switch" lay-text="开|关">'+
  152. '<div class="layui-word-aux">开启后切换窗口刷新当前页面</div>'+
  153. '</div>'+
  154. '</div>'+
  155. '<div class="layui-form-item">'+
  156. '<label class="layui-form-label">单一登陆</label>'+
  157. '<div class="layui-input-block">'+
  158. '<input type="checkbox" name="oneLogin" lay-filter="multipleLogin" lay-skin="switch" lay-text="是|否">'+
  159. '<div class="layui-word-aux">开启后不可同时多个地方登录</div>'+
  160. '</div>'+
  161. '</div>'+
  162. '<div class="layui-form-item skinBtn">'+
  163. '<a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" lay-filter="settingSuccess">设定完成</a>'+
  164. '<a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit="" lay-filter="noSetting">朕再想想</a>'+
  165. '</div>'+
  166. '</form>'+
  167. '</div>',
  168. success : function(index, layero){
  169. //如果之前设置过,则设置它的值
  170. $(".functionSrtting_box input[name=cache]").prop("checked",cacheStr=="true" ? true : false);
  171. $(".functionSrtting_box input[name=changeRefresh]").prop("checked",changeRefreshStr=="true" ? true : false);
  172. $(".functionSrtting_box input[name=oneLogin]").prop("checked",oneLoginStr=="true" ? true : false);
  173. //设定
  174. form.on("submit(settingSuccess)",function(data){
  175. window.sessionStorage.setItem("cache",data.field.cache=="on" ? "true" : "false");
  176. window.sessionStorage.setItem("changeRefresh",data.field.changeRefresh=="on" ? "true" : "false");
  177. window.sessionStorage.setItem("oneLogin",data.field.oneLogin=="on" ? "true" : "false");
  178. window.sessionStorage.removeItem("menu");
  179. window.sessionStorage.removeItem("curmenu");
  180. location.reload();
  181. return false;
  182. });
  183. //取消设定
  184. form.on("submit(noSetting)",function(){
  185. layer.closeAll("page");
  186. });
  187. //单一登陆提示
  188. form.on('switch(multipleLogin)', function(data){
  189. layer.tips('温馨提示:此功能需要开发配合,所以没有功能演示,敬请谅解', data.othis,{tips: 1})
  190. });
  191. form.render(); //表单渲染
  192. }
  193. })
  194. })
  195. */
  196. //判断是否修改过系统基本设置,去显示底部版权信息
  197. if(window.sessionStorage.getItem("systemParameter")){
  198. systemParameter = JSON.parse(window.sessionStorage.getItem("systemParameter"));
  199. $(".footer p span").text(systemParameter.powerby);
  200. }
  201. /*
  202. //更换皮肤
  203. function skins(){
  204. var skin = window.sessionStorage.getItem("skin");
  205. if(skin){ //如果更换过皮肤
  206. if(window.sessionStorage.getItem("skinValue") != "自定义"){
  207. $("body").addClass(window.sessionStorage.getItem("skin"));
  208. }else{
  209. $(".layui-layout-admin .layui-header").css("background-color",skin.split(',')[0]);
  210. $(".layui-bg-black").css("background-color",skin.split(',')[1]);
  211. $(".hideMenu").css("background-color",skin.split(',')[2]);
  212. }
  213. }
  214. }
  215. skins();
  216. $(".changeSkin").click(function(){
  217. layer.open({
  218. title : "更换皮肤",
  219. area : ["310px","280px"],
  220. type : "1",
  221. content : '<div class="skins_box">'+
  222. '<form class="layui-form">'+
  223. '<div class="layui-form-item">'+
  224. '<input type="radio" name="skin" value="默认" title="默认" lay-filter="default" checked="">'+
  225. '<input type="radio" name="skin" value="橙色" title="橙色" lay-filter="orange">'+
  226. '<input type="radio" name="skin" value="蓝色" title="蓝色" lay-filter="blue">'+
  227. '<input type="radio" name="skin" value="自定义" title="自定义" lay-filter="custom">'+
  228. '<div class="skinCustom">'+
  229. '<input type="text" class="layui-input topColor" name="topSkin" placeholder="顶部颜色" />'+
  230. '<input type="text" class="layui-input leftColor" name="leftSkin" placeholder="左侧颜色" />'+
  231. '<input type="text" class="layui-input menuColor" name="btnSkin" placeholder="顶部菜单按钮" />'+
  232. '</div>'+
  233. '</div>'+
  234. '<div class="layui-form-item skinBtn">'+
  235. '<a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" lay-filter="changeSkin">确定更换</a>'+
  236. '<a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit="" lay-filter="noChangeSkin">朕再想想</a>'+
  237. '</div>'+
  238. '</form>'+
  239. '</div>',
  240. success : function(index, layero){
  241. var skin = window.sessionStorage.getItem("skin");
  242. if(window.sessionStorage.getItem("skinValue")){
  243. $(".skins_box input[value="+window.sessionStorage.getItem("skinValue")+"]").attr("checked","checked");
  244. };
  245. if($(".skins_box input[value=自定义]").attr("checked")){
  246. $(".skinCustom").css("visibility","inherit");
  247. $(".topColor").val(skin.split(',')[0]);
  248. $(".leftColor").val(skin.split(',')[1]);
  249. $(".menuColor").val(skin.split(',')[2]);
  250. };
  251. form.render();
  252. $(".skins_box").removeClass("layui-hide");
  253. $(".skins_box .layui-form-radio").on("click",function(){
  254. var skinColor;
  255. if($(this).find("div").text() == "橙色"){
  256. skinColor = "orange";
  257. }else if($(this).find("div").text() == "蓝色"){
  258. skinColor = "blue";
  259. }else if($(this).find("div").text() == "默认"){
  260. skinColor = "";
  261. }
  262. if($(this).find("div").text() != "自定义"){
  263. $(".topColor,.leftColor,.menuColor").val('');
  264. $("body").removeAttr("class").addClass("main_body "+skinColor+"");
  265. $(".skinCustom").removeAttr("style");
  266. $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
  267. }else{
  268. $(".skinCustom").css("visibility","inherit");
  269. }
  270. })
  271. var skinStr,skinColor;
  272. $(".topColor").blur(function(){
  273. $(".layui-layout-admin .layui-header").css("background-color",$(this).val()+" !important");
  274. })
  275. $(".leftColor").blur(function(){
  276. $(".layui-bg-black").css("background-color",$(this).val()+" !important");
  277. })
  278. $(".menuColor").blur(function(){
  279. $(".hideMenu").css("background-color",$(this).val()+" !important");
  280. })
  281. form.on("submit(changeSkin)",function(data){
  282. if(data.field.skin != "自定义"){
  283. if(data.field.skin == "橙色"){
  284. skinColor = "orange";
  285. }else if(data.field.skin == "蓝色"){
  286. skinColor = "blue";
  287. }else if(data.field.skin == "默认"){
  288. skinColor = "";
  289. }
  290. window.sessionStorage.setItem("skin",skinColor);
  291. }else{
  292. skinStr = $(".topColor").val()+','+$(".leftColor").val()+','+$(".menuColor").val();
  293. window.sessionStorage.setItem("skin",skinStr);
  294. $("body").removeAttr("class").addClass("main_body");
  295. }
  296. window.sessionStorage.setItem("skinValue",data.field.skin);
  297. layer.closeAll("page");
  298. });
  299. form.on("submit(noChangeSkin)",function(){
  300. $("body").removeAttr("class").addClass("main_body "+window.sessionStorage.getItem("skin")+"");
  301. $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
  302. skins();
  303. layer.closeAll("page");
  304. });
  305. },
  306. cancel : function(){
  307. $("body").removeAttr("class").addClass("main_body "+window.sessionStorage.getItem("skin")+"");
  308. $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
  309. skins();
  310. }
  311. })
  312. })
  313. */
  314. })