diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index 0470b57e..8994ce4a 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -4,18 +4,19 @@ $.ajaxSetup({ xhr.setRequestHeader("X-CSRFToken", csrftoken); }, complete:function(xhr, status){ - if(xhr.status==405){ - $.messager.alert('错误','超时请重新登陆!','error',function(){ - top.location = "http://" + window.location.host; - }); - } + // if(xhr.status==405){ + // $.messager.alert('错误','超时请重新登陆!','error',function(){ + // top.location = "http://" + window.location.host; + // }); + // } try{ var jsonData = JSON.parse(xhr.responseText); if(jsonData.code == -1){ //如果超时就处理 ,指定要跳转的页面(比如登陆页) - $.messager.alert('错误','请重新登陆!','error',function(){ - location.reload() - }); + location.reload() + // $.messager.alert('错误','请重新登陆!','error',function(){ + + // }); }else if(jsonData.code == 0){ //其他的异常情况,给个提示。 // $.messager.alert('错误','操作失败!','error'); diff --git a/safesite/views.py b/safesite/views.py index e26b9bb0..8141b4f2 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -137,7 +137,7 @@ def check_session(req): if req.session.get('userid', None): return JsonResponse({"code": 1}) else: - return JsonResponse({"code": 0}) + return JsonResponse({"code": -1}) @@ -4056,7 +4056,11 @@ def apisocert(req): return HttpResponse(transjson(total, a), content_type="application/json") elif a == 'listself': userid = req.session['userid'] - cardnum = Userprofile.objects.get(user__userid=userid).cardnum + userprofile = Userprofile.objects.filter(user__userid=userid) + if userprofile.exists(): + cardnum = userprofile[0].cardnum + else: + return JsonResponse({'code':0,'msg':'信息不全'}) a = Socertificate.objects.filter( cardnum=cardnum).order_by('id') # 无deletemark total = a.count() @@ -6818,7 +6822,7 @@ def apiarea(req): Area.objects.filter(id=data['id']).update(name=name, order=order) return JsonResponse({"code": 1}) - +@apicheck_login def apimapshow(req): a = req.GET.get('a') userid = req.session['userid']