diff --git a/app/home/view/index/index.html b/app/home/view/index/index.html index 72ba28e..78bf75b 100644 --- a/app/home/view/index/index.html +++ b/app/home/view/index/index.html @@ -23,17 +23,17 @@
- + - + - + @@ -151,6 +151,19 @@ var msgStatus=0,isClose=0,msgNum = 0; const moduleInit = ['tool','admin']; function gouguInit() { + let admin = layui.admin; + let tabs = admin.getCookie('gougutab'); + if(tabs && tabs!=''){ + let tab_parse = JSON.parse(tabs); + let tab_id = tab_parse.tab_id,tab_array = tab_parse.tab_array; + if(tab_array.length>0){ + for(let a=0; a layui.use(['form'], function() { var form = layui.form, - $ = layui.$; + $ = layui.$, layer = layui.layer; // 登录过期的时候,跳出ifram框架 if (top.location != self.location) top.location = self.location; @@ -87,10 +87,13 @@ success: function(res) { layer.tips(res.msg, '#login-submit'); if (res.code === 0) { + var date = new Date(); + date.setTime(date.getTime() + (-1 * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + document.cookie = "gougutab=''" + expires + "; path=/"; setTimeout(function() { - // parent.document.location.reload(); parent.document.location.href="/"; - }, 1500); + }, 1200); } else { $('[alt="captcha"]').click(); } diff --git a/public/static/assets/gougu/module/admin.js b/public/static/assets/gougu/module/admin.js index 3292c4b..9cb17cd 100644 --- a/public/static/assets/gougu/module/admin.js +++ b/public/static/assets/gougu/module/admin.js @@ -17,6 +17,7 @@ layui.define(['element'], function (exports) { } element.tabAdd('gg-admin-tab', { id: id, + url:url, title: '' + title, content: '', }); @@ -92,6 +93,51 @@ layui.define(['element'], function (exports) { var src = parent.document.getElementById(id).contentWindow.location.href ? parent.document.getElementById(id).contentWindow.location.href : iframe.src; document.getElementById(id).src = src; } + }, + tabCookie:function(){ + let thetabs = $('#pageTabUl').find('li'); + let tab_id = 0,tab_array=[]; + $('#pageTabUl li').each(function(index,item){ + let _id = $(item).attr('lay-id'),_url = $(item).attr('lay-url'),_title = $(item).text(); + if(_id>0){ + tab_array.push({'id':_id,'url':_url,'title':_title}); + } + if($(item).hasClass('layui-this')){ + tab_id = _id; + } + }) + if(tab_array.length>0){ + let tabs_obj = { + 'tab_id':tab_id, + 'tab_array':tab_array + } + //console.log(tabs_obj); + tab.setCookie('gougutab',JSON.stringify(tabs_obj)); + } + else{ + tab.delCookie('gougutab'); + } + }, + setCookie: function (name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else { + var expires = ""; + } + document.cookie = name + "=" + value + expires + "; path=/"; + }, + getCookie: function (name) { + var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); + if (arr != null) { + return unescape(arr[ 2 ]); + } + return null; + }, + delCookie: function (name) { + this.setCookie(name, "", -1); } }; //切换tab @@ -99,11 +145,13 @@ layui.define(['element'], function (exports) { $('#GouguAppBody').find('.gg-tab-page').removeClass('layui-show'); $('#GouguAppBody').find('.gg-tab-page').eq(data.index).addClass('layui-show'); tab.tabRoll("auto", data.index); + tab.tabCookie(); }); //删除tab element.on('tabDelete(gg-admin-tab)', function (data) { $('#GouguAppBody').find('.gg-tab-page').eq(data.index).remove(); tab.tabRoll("auto", data.index); + tab.tabCookie(); }); //右滚动tab