zmz 1 year ago
parent c68a6ba539
commit 4aaecb4fd8

@ -7,4 +7,8 @@ from manage.views import *
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.ChooseLoginView.as_view()),
path('Customer_login/', views.CustomerLoginView.as_view()),
path('Employee_login/', views.EmployeeLoginView.as_view()),
path('customercenter/', views.CustomerCenterView.as_view()),
path('employeecenter/', views.EmployeeCenterView.as_view()),
]

@ -20,14 +20,19 @@ class CustomerLoginView(View):
def post(self, request):
id = request.POST.get('id', "")
customer_name = request.POST.get('customer_name', "")
customer_list = customer.objects.filter(id=id, customer_name=customer_name)
if customer_list:
print(type(customer_list[0]))
request.session.clear()
request.session['customer'] = customer_list[0].name
# print(id, customer_name)
# customer_list = customer.objects.filter(id=id, customer_name=customer_name)
# print(customer_list)
# if customer_list:
# print(type(customer_list[0]))
# request.session.clear()
# request.session['customer'] = customer_list[0].id
if id == '1' and customer_name == '张三':
request.session['customer'] = '1'
return HttpResponseRedirect('/customercenter/')
else:
return HttpResponseRedirect('/customerlogin/')
# return HttpResponseRedirect('/customercenter/')
return HttpResponseRedirect('/Customer_login/')
#员工登录
@ -38,33 +43,36 @@ class EmployeeLoginView(View):
def post(self,request):
id = request.POST.get('id',"")
password = request.POST.get('password',"")
employee_list =employee.objects.filter(id=id,password=password)
if employee_list:
request.session['employee'] = employee_list[0].name
request.session['employee_image'] = str(employee_list[0].img)
# employee_list =employee.objects.filter(id=id,password=password)
# if employee_list:
# request.session['employee'] = employee_list[0].name
# request.session['employee_image'] = str(employee_list[0].img)
# return HttpResponseRedirect('/employeecenter/')
if id == '1' and password == '123':
request.session['employee'] = '123'
return HttpResponseRedirect('/employeecenter/')
else:
return HttpResponseRedirect('/employeelogin/')
return HttpResponseRedirect('/Employee_login/')
#客户注册
class CustomerRegisterView(View):
def get(self,request):
return render(request, 'Customerregister.html')
def post(self, request, customer):#customer引用失败
# 只能注册客户账号,不能注册员工账号,员工账号只能由管理员创建
id = request.POST.get('id',"")
customer_list = customer.objects.filter(id=id)
if customer_list:
return render(request, 'Customerregister.html'),{"err":1, "tips": "该客户账号已存在"}
else:
customer_name = request.POST.get('customer_name',"")
customer_age = request.POST.get('customer_age',"")
customer_priority = request.POST.get('customer_priority',"")
customer = customer.objects.create(id=id,customer_name=customer_name,customer_age=customer_age,customer_priority=customer_priority)
if customer:
return HttpResponseRedirect('/customerlogin/')
return HttpResponseRedirect('/customerregister/')
# #客户注册
# class CustomerRegisterView(View):
# def get(self,request):
# return render(request, 'Customerregister.html')
# def post(self, request, customer):#customer引用失败
# # 只能注册客户账号,不能注册员工账号,员工账号只能由管理员创建
# id = request.POST.get('id',"")
# customer_list = customer.objects.filter(id=id)
# if customer_list:
# return render(request, 'Customerregister.html'),{"err":1, "tips": "该客户账号已存在"}
# else:
# customer_name = request.POST.get('customer_name',"")
# customer_age = request.POST.get('customer_age',"")
# customer_priority = request.POST.get('customer_priority',"")
# customer = customer.objects.create(id=id,customer_name=customer_name,customer_age=customer_age,customer_priority=customer_priority)
# if customer:
# return HttpResponseRedirect('/customerlogin/')
# return HttpResponseRedirect('/customerregister/')
#客户界面
class CustomerCenterView(View):

@ -22,6 +22,6 @@ from manage.views import ChooseLoginView
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('manage.url')),
# path('user/',include('manage.url')),
path('user/', ChooseLoginView.as_view()),
path('user/',include('manage.url')),
# path('user/', ChooseLoginView.as_view()),
]

@ -31,10 +31,10 @@
<!-- 管理员登录 -->
<div class="Administrator">
{# <a href="admin">#}
<a href="/admin/">
{# <img src="/static/images/admin.png" alt=""/>#}
{# <p class="Administrator">管理员登录</p>#}
{# </a>#}
<p class="Administrator">管理员登录</p>
</a>
</div>
</div>

@ -5,6 +5,6 @@
<title>客户界面</title>
</head>
<body>
<h3>这里是客户界面</h3>
</body>
</html>

@ -5,6 +5,16 @@
<title>客户登录</title>
</head>
<body>
<div>
<form class="login_box" method="POST" action="/Customer_login/">
<h1 class="title">欢迎登录</h1>
{% csrf_token %}
<input class="input_box" type="text" name="id" placeholder="请输入客户编号" />
<input class="input_box" type="text" name="customer_name" placeholder="请输入客户名" />
<input class="button" type="submit" value="登录" />
<a href="/">返回</a>
</form>
</div>
<h3>这里是客户登录页面</h3>
</body>
</html>

@ -5,6 +5,6 @@
<title>员工界面</title>
</head>
<body>
<h3>这里是员工界面</h3>
</body>
</html>

@ -3,18 +3,23 @@
<head>
<meta charset="UTF-8">
<title>员工登录</title>
<link rel="stylesheet" type="text/css" href="/static/css/emplyeelogin.css/">
{# <link rel="stylesheet" type="text/css" href="/static/css/emplyeelogin.css/">#}
</head>
<body>
{% load static %}
<div class="logo_box">
<img src="/static/images/employee.png" alt=""/>
</div>
{# {% load static %}#}
{# <div class="logo_box">#}
{# <img src="/static/images/employee.png" alt=""/>#}
{# </div>#}
<div>
<form action="login_box" method="POST" action="/employeelogin/">
<form class="login_box" method="POST" action="/Employee_login/">
<h1 class="title">欢迎登录</h1>
{% csrf_token %}
<input class="input_box" type="text" name="id" placeholder="请输入员工编号" />
<input class="input_box" type="password" name="password" placeholder="请输入密码" />
<input class="button" type="submit" value="登录" />
<a href="/">返回</a>
</form>
</div>
<h3>这里是员工登录页面</h3>
</body>
</html>
Loading…
Cancel
Save