提交 9961d787 编写于 作者: W weizhiqiang

解决连续多次点击表格下一页时,自动退出的问题

上级 5668f7ce
...@@ -297,14 +297,14 @@ layui.config({ ...@@ -297,14 +297,14 @@ layui.config({
}}, function (index) { }}, function (index) {
layer.close(index); layer.close(index);
AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) { AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) {
$.cookie('userToken', "", {path: '/' }); localStorage.setItem('userToken', "");
location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/apiPage/apiPage.html"); location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/apiPage/apiPage.html");
}}); }});
}); });
}); });
$("body").on("click", ".menu-box-none", function (e) { $("body").on("click", ".menu-box-none", function (e) {
if($(this).parent().hasClass("layui-nav-itemed")){ if ($(this).parent().hasClass("layui-nav-itemed")) {
$(this).parent().removeClass("layui-nav-itemed"); $(this).parent().removeClass("layui-nav-itemed");
} else { } else {
$(this).parent().addClass("layui-nav-itemed"); $(this).parent().addClass("layui-nav-itemed");
......
...@@ -35,7 +35,7 @@ layui.config({ ...@@ -35,7 +35,7 @@ layui.config({
//手机端加载该页面时加载userToken //手机端加载该页面时加载userToken
var userToken = GetUrlParam("userToken"); var userToken = GetUrlParam("userToken");
if(!isNull(userToken)){ if(!isNull(userToken)){
setCookie('userToken', userToken, 's1800'); setCookie('userToken', userToken);
} }
var fileUrl = GetUrlParam("fileUrl"); var fileUrl = GetUrlParam("fileUrl");
var title = decodeURIComponent(GetUrlParam("title")); var title = decodeURIComponent(GetUrlParam("title"));
......
...@@ -211,7 +211,7 @@ layui.config({ ...@@ -211,7 +211,7 @@ layui.config({
}}, function (index) { }}, function (index) {
layer.close(index); layer.close(index);
AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) { AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) {
$.cookie('userToken', "", {path: '/' }); localStorage.setItem('userToken', "");
$("#operatorBtn").html('<font id="loginBtn">登陆</font>'); $("#operatorBtn").html('<font id="loginBtn">登陆</font>');
$("#file-operator").html(""); $("#file-operator").html("");
}}); }});
......
...@@ -739,9 +739,9 @@ ...@@ -739,9 +739,9 @@
var $ = layui.$, var $ = layui.$,
form = layui.form; form = layui.form;
//手机端加载该页面时加载userToken //手机端加载该页面时加载userToken
var userToken = GetUrlParam("userToken") + '-APP'; var userToken = GetUrlParam("userToken");
if(!isNull(userToken)){ if(!isNull(userToken)){
setCookie('userToken', userToken, 's1800'); setCookie('userToken', userToken);
} }
showGrid({ showGrid({
id: "wrap", id: "wrap",
......
...@@ -706,9 +706,9 @@ ...@@ -706,9 +706,9 @@
var $ = layui.$, var $ = layui.$,
form = layui.form; form = layui.form;
//手机端加载该页面时加载userToken //手机端加载该页面时加载userToken
var userToken = GetUrlParam("userToken") + '-APP'; var userToken = GetUrlParam("userToken");
if(!isNull(userToken)){ if(!isNull(userToken)){
setCookie('userToken', userToken, 's1800'); setCookie('userToken', userToken);
} }
bgAnDate = getFormatDate(); bgAnDate = getFormatDate();
AjaxPostUtil.request({url:schoolBasePath + "exam028", params: {surveyId: getUrlParam("rowId")}, type: 'json', callback: function (json) { AjaxPostUtil.request({url:schoolBasePath + "exam028", params: {surveyId: getUrlParam("rowId")}, type: 'json', callback: function (json) {
......
...@@ -252,7 +252,7 @@ layui.config({ ...@@ -252,7 +252,7 @@ layui.config({
}}, function (index) { }}, function (index) {
layer.close(index); layer.close(index);
AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) { AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) {
$.cookie('userToken', "", {path: '/' }); localStorage.setItem('userToken', "");
location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/note/shareNote.html?id=" + rowId); location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/note/shareNote.html?id=" + rowId);
}}); }});
}); });
......
...@@ -91,7 +91,7 @@ layui.config({ ...@@ -91,7 +91,7 @@ layui.config({
}}, function (index) { }}, function (index) {
layer.close(index); layer.close(index);
AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) { AjaxPostUtil.request({url: reqBasePath + "login003", params: {}, type: 'json', method: "POST", callback: function (json) {
$.cookie('userToken', "", {path: '/' }); localStorage.setItem('userToken', "");
location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/note/shareNote.html?id=" + rowId); location.href = "../../tpl/index/login.html?url=" + escape("../../tpl/note/shareNote.html?id=" + rowId);
}}); }});
}); });
......
var basePath = getBaseRootPath();//上传文件展示路径 var basePath = getBaseRootPath();//上传文件展示路径
function getBaseRootPath(){
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPaht = curWwwPath.substring(0, pos);
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
return(localhostPaht + "/");//http://127.0.0.1:8080/
}
/**
* Created by HANZO on 2016/6/17.
*/
/** /**
* *
* @param url * @param url
...@@ -21,8 +8,6 @@ function getBaseRootPath(){ ...@@ -21,8 +8,6 @@ function getBaseRootPath(){
* @param callback * @param callback
* @returns {*} * @returns {*}
*/ */
//(function ($) {
function loadPage(url, container) { function loadPage(url, container) {
if (!container) if (!container)
container = "#mainDiv"; container = "#mainDiv";
...@@ -144,33 +129,6 @@ function deleteEmptyProp(obj) { ...@@ -144,33 +129,6 @@ function deleteEmptyProp(obj) {
return obj; return obj;
} }
/**
* 获取cookie值
* @param name
* @returns
*/
function getCookie(name){
var strcookie = document.cookie;//获取cookie字符串
var arrcookie = strcookie.split("; ");//分割
//遍历匹配
for ( var i = 0; i < arrcookie.length; i++) {
var arr = arrcookie[i].split("=");
if (arr[0] == name){
return arr[1];
}
}
return "";
}
//判断内容是否为空
function isNull(str){
if(str == null || str == "" || str == '' || str == "null" || str == "undefined"){
return true;
} else {
return false;
}
}
function ajaxPost(url, params, callback) { function ajaxPost(url, params, callback) {
var result = null; var result = null;
var headers = getRequestHeaders(); var headers = getRequestHeaders();
...@@ -341,27 +299,6 @@ function getNextCode(prefix, maxCode, length) { ...@@ -341,27 +299,6 @@ function getNextCode(prefix, maxCode, length) {
} }
/**
* 收缩左边栏时,触发markdown编辑的resize
*/
/*$("[data-toggle='offcanvas']").click(function () {
if (editor) {
setTimeout(function () {
editor.resize()
}, 500);
}
});*/
//获取布尔值
/*String.prototype.BoolValue=function(){
if(this==undefined)
return false;
if(this=="false"||this=="0")
return false;
return true;
}*/
var HtmlUtil = { var HtmlUtil = {
/*1.用浏览器内部转换器实现html转码*/ /*1.用浏览器内部转换器实现html转码*/
htmlEncode: function (html) { htmlEncode: function (html) {
...@@ -407,6 +344,3 @@ String.prototype.format = function () { ...@@ -407,6 +344,3 @@ String.prototype.format = function () {
s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
return s; return s;
}; };
//})(jQuery)
\ No newline at end of file
...@@ -752,7 +752,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports) ...@@ -752,7 +752,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports)
('返回的数据不符合规范,正确的成功状态码应为:"' + response.statusName + '": ' + response.statusCode) ('返回的数据不符合规范,正确的成功状态码应为:"' + response.statusName + '": ' + response.statusCode)
); );
} else { } else {
that.renderData(res, curr, res[response.countName]), sort(); that.renderData(res, curr, res[response.countName], opts.type), sort();
options.time = (new Date().getTime() - that.startTime) + ' ms'; //耗时(接口请求+视图渲染) options.time = (new Date().getTime() - that.startTime) + ' ms'; //耗时(接口请求+视图渲染)
} }
that.setColsWidth(); that.setColsWidth();
...@@ -761,19 +761,19 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports) ...@@ -761,19 +761,19 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports)
, error: function (e, msg) { , error: function (e, msg) {
//移除请求遮罩层 //移除请求遮罩层
$("body").find(".mask-req-str").remove(); $("body").find(".mask-req-str").remove();
var sessionstatus = e.getResponseHeader('SESSIONSTATUS'); // var sessionstatus = e.getResponseHeader('SESSIONSTATUS');
if (sessionstatus == "TIMEOUT") { // if (sessionstatus == "TIMEOUT") {
// 超时跳转 // // 超时跳转
var win = window; // var win = window;
while (win != win.top) { // while (win != win.top) {
win = win.top; // win = win.top;
} // }
win.location.href = "../../tpl/index/login.html"; // win.location.href = "../../tpl/index/login.html";
} else if (sessionstatus == "NOAUTHPOINT") { // } else if (sessionstatus == "NOAUTHPOINT") {
that.errorView('您不具备该权限。'); // that.errorView('您不具备该权限。');
} else { // } else {
that.errorView('请求异常,错误提示:' + msg); that.errorView('请求异常,错误提示:' + msg);
} // }
that.renderForm(); that.renderForm();
that.setColsWidth(); that.setColsWidth();
...@@ -793,7 +793,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports) ...@@ -793,7 +793,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports)
res[response.totalRowName] = $.extend({}, options.totalRow); res[response.totalRowName] = $.extend({}, options.totalRow);
} }
that.renderData(res, curr, res[response.countName]), sort(); that.renderData(res, curr, res[response.countName], opts.type), sort();
that.setColsWidth(); that.setColsWidth();
typeof options.done === 'function' && options.done(res, curr, res[response.countName]); typeof options.done === 'function' && options.done(res, curr, res[response.countName]);
} }
...@@ -807,7 +807,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports) ...@@ -807,7 +807,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports)
}; };
//数据渲染 //数据渲染
Class.prototype.renderData = function (res, curr, count, sort) { Class.prototype.renderData = function (res, curr, count, sort, type) {
var that = this var that = this
, options = that.config , options = that.config
, data = res[options.response.dataName] || [] //列表数据 , data = res[options.response.dataName] || [] //列表数据
...@@ -913,7 +913,14 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports) ...@@ -913,7 +913,14 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function (exports)
trs_fixed_r.push('<tr data-index="' + i1 + '">' + tds_fixed_r.join('') + '</tr>'); trs_fixed_r.push('<tr data-index="' + i1 + '">' + tds_fixed_r.join('') + '</tr>');
}); });
that.layBody.scrollTop(0); // 容器的滚动条位置
if(!(options.scrollPos === 'fixed' && type === 'reloadData')){
that.layBody.scrollTop(0);
}
if(options.scrollPos === 'reset'){
that.layBody.scrollLeft(0);
}
that.layMain.find('.' + NONE).remove(); that.layMain.find('.' + NONE).remove();
that.layMain.find('tbody').html(trs.join('')); that.layMain.find('tbody').html(trs.join(''));
that.layFixLeft.find('tbody').html(trs_fixed.join('')); that.layFixLeft.find('tbody').html(trs_fixed.join(''));
......
...@@ -25,7 +25,7 @@ if(!getCookiesByUrl){//跨域获取 ...@@ -25,7 +25,7 @@ if(!getCookiesByUrl){//跨域获取
if(isNull(GetUrlParam("userToken"))){//如果url后面没有跟usertoken,返回404页面 if(isNull(GetUrlParam("userToken"))){//如果url后面没有跟usertoken,返回404页面
location.href = '../../tpl/sysmessage/500.html'; location.href = '../../tpl/sysmessage/500.html';
} else { } else {
setCookie('userToken', GetUrlParam("userToken"), 's1800'); setCookie('userToken', GetUrlParam("userToken"));
} }
} }
} }
...@@ -101,9 +101,9 @@ var sysActivitiModel = getAndWriteLocal('sysActivitiModel'); ...@@ -101,9 +101,9 @@ var sysActivitiModel = getAndWriteLocal('sysActivitiModel');
var sysDictData = getAndWriteLocal('sysDictData'); var sysDictData = getAndWriteLocal('sysDictData');
function getAndWriteLocal(key) { function getAndWriteLocal(key) {
if(isNull(localStorage.getItem(key))){ if (isNull(localStorage.getItem(key))) {
var url = lacolMap[key]; var url = lacolMap[key];
jsGetJsonFile(url, function(data) { jsGetJsonFile(url, function (data) {
localStorage.setItem(key, JSON.stringify(data)); localStorage.setItem(key, JSON.stringify(data));
return data; return data;
}); });
...@@ -176,9 +176,9 @@ var getFileContent = function(url){ ...@@ -176,9 +176,9 @@ var getFileContent = function(url){
return content; return content;
} }
//判断内容是否为空 // 判断内容是否为空
function isNull(str){ function isNull(str) {
if(str == null || str == "" || str == '' || str == "null" || str == "undefined"){ if (str == null || str == "" || str == '' || str == "null" || str == "undefined") {
return true; return true;
} else { } else {
return false; return false;
...@@ -841,20 +841,6 @@ function isNull(str){ ...@@ -841,20 +841,6 @@ function isNull(str){
if(isNum.test(v2)) v2 = parseFloat(v2); if(isNum.test(v2)) v2 = parseFloat(v2);
return v1 - v2; return v1 - v2;
/*if(v1 && !v2) {
return 1;
} else if(!v1 && v2) {
return -1;
}
if(v1 > v2) {
return 1;
} else if(v1 < v2) {
return -1;
} else {
return 0;
}*/
}); });
desc && clone.reverse(); // 倒序 desc && clone.reverse(); // 倒序
...@@ -946,23 +932,8 @@ function isNull(str){ ...@@ -946,23 +932,8 @@ function isNull(str){
* h是指小时,如12小时则是:h12 * h是指小时,如12小时则是:h12
* d是天数,30天则:d30 * d是天数,30天则:d30
*/ */
function setCookie(name, value, time) { function setCookie(name, value) {
var strsec = getsec(time); localStorage.setItem(name, value);
var exp = new Date();
exp.setTime(exp.getTime() + strsec * 1);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
}
function getsec(str) {
var str1 = str.substring(1, str.length) * 1;
var str2 = str.substring(0, 1);
if(str2 == "s") {
return str1 * 1000;
} else if(str2 == "h") {
return str1 * 60 * 60 * 1000;
} else if(str2 == "d") {
return str1 * 24 * 60 * 60 * 1000;
}
} }
/** /**
...@@ -970,17 +941,8 @@ function getsec(str) { ...@@ -970,17 +941,8 @@ function getsec(str) {
* @param name * @param name
* @returns * @returns
*/ */
function getCookie(name){ function getCookie(name) {
var strcookie = document.cookie;//获取cookie字符串 return localStorage.getItem(name);
var arrcookie = strcookie.split("; ");//分割
//遍历匹配
for ( var i = 0; i < arrcookie.length; i++) {
var arr = arrcookie[i].split("=");
if (arr[0] == name){
return arr[1];
}
}
return "";
} }
...@@ -1404,10 +1404,10 @@ layui.config({ ...@@ -1404,10 +1404,10 @@ layui.config({
var nowType = isNull(getCookie("languageType")) ? "zh" : getCookie("languageType"); var nowType = isNull(getCookie("languageType")) ? "zh" : getCookie("languageType");
if(nowType == "zh"){ if(nowType == "zh"){
// 中文,设置为英文 // 中文,设置为英文
setCookie('languageType', "cn", 'd30'); setCookie('languageType', "cn");
} else { } else {
// 英文,设置为中文 // 英文,设置为中文
setCookie('languageType', "zh", 'd30'); setCookie('languageType', "zh");
} }
window.location.reload(); window.location.reload();
}); });
......
...@@ -59,40 +59,40 @@ layui.config({ ...@@ -59,40 +59,40 @@ layui.config({
$(".lock-body").css({'background-image': 'url("/images/upload/winbgpic/default.jpg")'}); $(".lock-body").css({'background-image': 'url("/images/upload/winbgpic/default.jpg")'});
$.cookie('userToken', "", {path: '/' }); localStorage.setItem('userToken', "");
matchingLanguage(); matchingLanguage();
form.render(); form.render();
form.on('submit(login)', function (data) { form.on('submit(login)', function (data) {
if (winui.verifyForm(data.elem)) { if (winui.verifyForm(data.elem)) {
$("#loginBtn").find("i").attr("class", "fa fa-spin fa-spinner fa-fw"); $("#loginBtn").find("i").attr("class", "fa fa-spin fa-spinner fa-fw");
if(!isLogin){ if (!isLogin) {
if(isNull($("#userCode").val())){ if (isNull($("#userCode").val())) {
top.winui.window.msg("请输入用户名", {icon: 2, time: 2000}); top.winui.window.msg("请输入用户名", {icon: 2, time: 2000});
}else if(isNull($("#password").val())){ } else if (isNull($("#password").val())) {
top.winui.window.msg("请输入密码", {icon: 2, time: 2000}); top.winui.window.msg("请输入密码", {icon: 2, time: 2000});
} else { } else {
var params = { var params = {
userCode:$("#userCode").val(), userCode: $("#userCode").val(),
password:$("#password").val() password: $("#password").val()
}; };
isLogin = true; isLogin = true;
AjaxPostUtil.request({url: reqBasePath + "login001", params: params, type: 'json', callback: function (json) { AjaxPostUtil.request({url: reqBasePath + "login001", params: params, type: 'json', callback: function (json) {
isLogin = false; isLogin = false;
$("#loginBtn").find("i").attr("class", "fa fa-arrow-right"); $("#loginBtn").find("i").attr("class", "fa fa-arrow-right");
if(json.rows != null){ if (json.rows != null) {
localStorage.setItem("authpoints", JSON.stringify(json.rows)); localStorage.setItem("authpoints", JSON.stringify(json.rows));
} }
$.cookie('userToken', json.bean.userToken, {path: '/' }); localStorage.setItem('userToken', json.bean.userToken);
if(!isNull(json.bean.id)){ if (!isNull(json.bean.id)) {
if(checkURL(url)){ if (checkURL(url)) {
location.href = url; location.href = url;
} else { } else {
location.href = "index.html"; location.href = "index.html";
} }
} }
}}); }});
} }
} }
} }
return false; return false;
......
...@@ -354,10 +354,10 @@ layui.config({ ...@@ -354,10 +354,10 @@ layui.config({
var nowType = isNull(getCookie("languageType")) ? "zh" : getCookie("languageType"); var nowType = isNull(getCookie("languageType")) ? "zh" : getCookie("languageType");
if(nowType == "zh"){ if(nowType == "zh"){
// 中文,设置为英文 // 中文,设置为英文
setCookie('languageType', "cn", 'd30'); setCookie('languageType', "cn");
} else { } else {
// 英文,设置为中文 // 英文,设置为中文
setCookie('languageType', "zh", 'd30'); setCookie('languageType', "zh");
} }
window.location.reload(); window.location.reload();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册