From dfeedbd5f8bb26026b37c65df232aa157097c5c6 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 17 Sep 2019 14:35:19 +0800 Subject: [PATCH] login --- safesite/static/safesite/mystatic/js/util.js | 10 +++- safesite/templates/companyinfo.html | 2 +- safesite/templates/index.html | 3 +- safesite/views.py | 53 +++++++++++--------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index b7b2c57e..35f76255 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -1,10 +1,16 @@ var csrftoken = $.cookie('csrftoken'); $.ajaxSetup({ beforeSend: function(xhr, settings) { - if (!csrfSafeMethod(settings.type) && !this.crossDomain) { - xhr.setRequestHeader("X-CSRFToken", csrftoken); + xhr.setRequestHeader("X-CSRFToken", csrftoken); + }, + complete:function(xhr, status){ + if(xhr.status==405){ + $.messager.alert('错误','超时请重新登陆!','error',function(){ + top.location = "http://" + window.location.host; + }); } } + }); function photoCompress(file, w, objDiv) { var ready = new FileReader(); diff --git a/safesite/templates/companyinfo.html b/safesite/templates/companyinfo.html index 27b8f255..97c3f746 100644 --- a/safesite/templates/companyinfo.html +++ b/safesite/templates/companyinfo.html @@ -31,7 +31,7 @@ function submitForm() { // jquery 表单提交 $("#companyform").ajaxSubmit(function(result) { // 对于表单提交成功后处理,result为表单正常提交后返回的内容 - if (result.code === 1) { + if (result.code == 1) { $.messager.show({ msg:'保存成功', timeout:1000, diff --git a/safesite/templates/index.html b/safesite/templates/index.html index 8aeacfe2..0fbc5a5c 100644 --- a/safesite/templates/index.html +++ b/safesite/templates/index.html @@ -18,7 +18,6 @@ - @@ -26,6 +25,8 @@ + +