From c7cc3cc5c4f49da442ebfaae2dde1c51837cb7a7 Mon Sep 17 00:00:00 2001 From: chenyang Date: Thu, 30 Jun 2022 16:48:42 +0800 Subject: [PATCH] update --- jsmindmulti/settings.py | 2 +- server/urls.py | 12 ++++++++++-- server/views/__init__.py | 0 server/{views.py => views/mind_map.py} | 0 server/views/user.py | 15 +++++++++++++++ static/html/dashboard.html | 25 ++++++++++++++++++------- 6 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 server/views/__init__.py rename server/{views.py => views/mind_map.py} (100%) create mode 100644 server/views/user.py diff --git a/jsmindmulti/settings.py b/jsmindmulti/settings.py index 5347d41..4802bce 100644 --- a/jsmindmulti/settings.py +++ b/jsmindmulti/settings.py @@ -23,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-92%z)%dv$x)-254f2ixp(ctnua4%^@=db&(ha4i-i2p2er(+^&' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True ALLOWED_HOSTS = [] diff --git a/server/urls.py b/server/urls.py index 2c88970..acd7d87 100644 --- a/server/urls.py +++ b/server/urls.py @@ -1,17 +1,25 @@ from django.urls import path -from server.views import * +from server.views.mind_map import * +from server.views.user import * from server.view_test import * urlpatterns = [ + # --------------------------------------------------- + path('test', test), # + + # --------------------------------------------------- path('', to_list), # 跳转列表界面 path('detail', to_detail), # 跳转详情界面 path('dashboard', to_dashboard), # + # --------------------------------------------------- path('create', JsMindView.as_view()), # 创建思维导图 path('delete', JsMindView.as_view()), # 删除思维导图 path('list', JsMindView.as_view()), # 查询思维导图 path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志 - path('test', test), # + # --------------------------------------------------- + path('register', MindUserView.as_view()), # 用户注册 + ] diff --git a/server/views/__init__.py b/server/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/views.py b/server/views/mind_map.py similarity index 100% rename from server/views.py rename to server/views/mind_map.py diff --git a/server/views/user.py b/server/views/user.py new file mode 100644 index 0000000..e9604b5 --- /dev/null +++ b/server/views/user.py @@ -0,0 +1,15 @@ +from rest_framework.views import APIView +from django.http import HttpResponse + + +class MindUserView(APIView): + """ + 用户注册 + """ + + def post(self, request): + data_dict = request.POST + user_name = data_dict.get('userName') + input_password = data_dict.get('inputPassword') + print('userName:%s,inputPassword:%s' % (user_name, input_password)) + return HttpResponse("success") diff --git a/static/html/dashboard.html b/static/html/dashboard.html index 12398cf..80177da 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -66,11 +66,11 @@ // 注册 $('#register_button').click(function () { - const inputEmail = $('#inputEmail').val(); + const userName = $('#userName').val(); const inputPassword = $('#inputPassword').val(); const inputPassword_ = $('#inputPassword_').val(); - if (!inputEmail) { + if (!userName) { reg_alert('请输入用户名') return } @@ -83,8 +83,19 @@ // 校验输入是否一致 const validate = validate_pw_eq(this, inputPassword, inputPassword_) if (validate) { - + $.ajax({ + type: "post", + url: "register", + data: {userName: userName, inputPassword: inputPassword}, + dataType: "json", + success: function (data) { + console.log(data) + }, + async: false + }); } + // + }); function validate_pw_eq(obj, inputPassword, inputPassword_) { @@ -138,8 +149,8 @@