userid错误

This commit is contained in:
caoqianming 2020-11-23 08:58:05 +08:00
parent 63b6290e0e
commit 5cda05b4c4
2 changed files with 16 additions and 11 deletions

View File

@ -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');

View File

@ -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']