john 2 năm trước cách đây
mục cha
commit
6e68876e26

+ 3 - 3
ClientPlatform/config/webpack.dev.js

@@ -16,15 +16,15 @@ module.exports = merge(baseConfig(false), {
         throw new Error("webpack-dev-server is not defined");
       }
       mock(devServer.app);
-      /*devServer.app.get("/some/path", function (req, res) {
+      /* devServer.app.get("/some/path", function (req, res) {
        res.json({ custom: "response" });
-       });*/
+       }); */
     },
     proxy: {
       // 接口代理
       "/api": {
         // 统一api前缀都代理掉
-        target: "http://api.github.com", // 代理的目标地址
+        target: "http://localhost:8000", // 代理的目标地址
         changeOrigin: true, // 改变来源信息
         pathRewrite: {
           // 因前缀为自己增加,因此重写地址

+ 13 - 6
ClientPlatform/src/api/index.js

@@ -54,8 +54,19 @@ export function pushComment(params) {
   return post("/pushComment", params);
 }
 
-export function loginOrRegister(params) {
-  return post("/login", params);
+export function login(params) {
+  return post("/user/login", params);
+}
+
+export function register(params) {
+  return post("/user/register", params);
+}
+export function userInfo(params) {
+  return post("/user/info", params);
+}
+
+export function userUpdate(params) {
+  return post("/user/update", params);
 }
 
 export function updateUserInfo(params) {
@@ -65,7 +76,3 @@ export function updateUserInfo(params) {
 export function uploadFile(params) {
   return upload("/uploadFile", params);
 }
-
-export function userInfo(params) {
-  return post("/userInfo", params);
-}

+ 40 - 10
ClientPlatform/src/components/login.vue

@@ -11,8 +11,8 @@
       label-width="120px"
       v-if="useType === 'login'"
     >
-      <el-form-item label="邮箱/UID/名称">
-        <el-input v-model="form.name"></el-input>
+      <el-form-item label="邮箱">
+        <el-input type="email" v-model="form.email"></el-input>
       </el-form-item>
       <el-form-item label="密码">
         <el-input type="password" v-model="form.password"></el-input>
@@ -20,7 +20,7 @@
     </el-form>
     <el-form ref="form" :model="form" label-width="80px" v-else>
       <el-form-item label="登陆邮箱">
-        <el-input type="email" v-model="form.name"></el-input>
+        <el-input type="email" v-model="form.email"></el-input>
       </el-form-item>
       <el-form-item label="输入密码">
         <el-input type="password" v-model="form.password"></el-input>
@@ -50,7 +50,7 @@
   </el-dialog>
 </template>
 <script>
-import { loginOrRegister } from "../api";
+import { login, register } from "../api";
 
 export default {
   name: "login",
@@ -73,23 +73,28 @@ export default {
       this.useType = "register";
       this.title = "注册";
     },
-    handleClose() {},
+    handleClose() {
+      this.dialogVisible = false;
+    },
     toLogin() {
       this.useType = "login";
       this.title = "登陆";
     },
     async toLoginFn() {
-      if (!this.form.name) {
-        this.$message.error("请输入用户名称!");
+      if (!this.form.email) {
+        this.$message.error("请输入邮箱!");
         return;
       }
       if (!this.form.password) {
-        this.$message.error("请输入用户密码!");
+        this.$message.error("请输入密码!");
         return;
       }
-      const res = await loginOrRegister(this.form);
+      const res = await login({
+        email: this.form.email,
+        password: this.form.password,
+      });
       console.log("loginOrRegister", res);
-      window.localStorage.setItem("userInfo", JSON.stringify(res.data));
+      // window.localStorage.setItem("userInfo", JSON.stringify(res.data));
       window.localStorage.setItem("token", res.data.token);
       window.location.reload();
     },
@@ -104,6 +109,31 @@ export default {
       if (this.form.password !== this.form.password2) {
         this.$message.error("2次输入密码不一致!");
       }
+      const res = await register({
+        email: this.form.email,
+        password: this.form.password,
+      });
+      console.log(108, res);
+      if (res.data) {
+        console.log(115);
+        this.$alert("注册成功是否现在登陆!", "提示", {
+          confirmButtonText: "确定",
+          callback: (action) => {
+            console.log(123, action);
+            if (action === "confirm") {
+              this.toLogin();
+            }
+            // this.$message({
+            //   type: "info",
+            //   message: `删除成功!`,
+            // });
+            // localStorage.clear();
+            // this.toHome({
+            //   type: "reload",
+            // });
+          },
+        });
+      }
     },
   },
 };

+ 60 - 34
ClientPlatform/src/components/user-header.vue

@@ -1,27 +1,48 @@
 <template>
-    <div>
-        <header class="header-box">
-            <div class="logo">DeepBIO</div>
-            <div class="nav-box">
-                <div @click="toNewPage('home')" :class="[active === 'home' &&'active', 'item']"><i class="el-icon-s-home"></i>Home</div>
-<!--                <div @click="toNewPage('server')" :class="[active === 'server' &&'active', 'item']"><i class="el-icon-s-operation"></i>Server</div>-->
-                <div @click="toNewPage('order')" :class="[active === 'order' &&'active', 'item']"><i class="el-icon-s-claim"></i>Order</div>
-                <div @click="toNewPage('task')" :class="[active === 'task' &&'active', 'item']"><i class="el-icon-s-order"></i>Task</div>
-                <div @click="toNewPage('about')" :class="[active === 'about' &&'active', 'item']"><i class="el-icon-s-order"></i>Contact us</div>
-            </div>
-            <div class="user-box">
-                <div class="login" @click="settingFn" v-if="userInfo && userInfo.name">{{ userInfo.name }}</div>
-                <div class="login" v-else @click="$refs.loginCom.show()">login</div>
-            </div>
-
-        </header>
-        <loginCom ref="loginCom"></loginCom>
-    </div>
+  <div>
+    <header class="header-box">
+      <div class="logo">DeepBIO</div>
+      <div class="nav-box">
+        <div
+          @click="toNewPage('home')"
+          :class="[active === 'home' && 'active', 'item']"
+        >
+          <i class="el-icon-s-home"></i>Home
+        </div>
+        <!--                <div @click="toNewPage('server')" :class="[active === 'server' &&'active', 'item']"><i class="el-icon-s-operation"></i>Server</div>-->
+        <div
+          @click="toNewPage('order')"
+          :class="[active === 'order' && 'active', 'item']"
+        >
+          <i class="el-icon-s-claim"></i>Order
+        </div>
+        <div
+          @click="toNewPage('task')"
+          :class="[active === 'task' && 'active', 'item']"
+        >
+          <i class="el-icon-s-order"></i>Task
+        </div>
+        <div
+          @click="toNewPage('about')"
+          :class="[active === 'about' && 'active', 'item']"
+        >
+          <i class="el-icon-s-order"></i>Contact us
+        </div>
+      </div>
+      <div class="user-box">
+        <div class="login" @click="settingFn" v-if="userInfo && userInfo.id">
+          {{ userInfo.name || "暂无名称" }}
+        </div>
+        <div class="login" v-else @click="$refs.loginCom.show()">login</div>
+      </div>
+    </header>
+    <loginCom ref="loginCom"></loginCom>
+  </div>
 </template>
 
 <script>
-
-import loginCom from './login.vue'
+import { userInfo } from "../api";
+import loginCom from "./login.vue";
 
 export default {
   name: "userHeader",
@@ -35,11 +56,15 @@ export default {
   },
   components: { loginCom },
   mounted() {
-    setTimeout(() => {
+    setTimeout(async () => {
       this.active = this.$route.name;
-      const userInfoStr = localStorage.getItem('userInfo')
-      if (userInfoStr) {
-        this.userInfo = JSON.parse(userInfoStr)
+
+      const token = localStorage.getItem("token");
+      // const userInfoStr = localStorage.getItem("userInfo");
+      if (token) {
+        const res = await userInfo({ token });
+        console.log(61616111, res);
+        this.userInfo = res.data;
       }
     }, 300);
   },
@@ -57,16 +82,16 @@ export default {
     toNewPage(name) {
       // 判断是否登录
       if (!this.userInfo?.id && !/home|about/.test(name)) {
-        this.$refs.loginCom.show()
-        return
+        this.$refs.loginCom.show();
+        return;
       }
       this.$router.push({
-        path: `/${name}`
-      })
+        path: `/${name}`,
+      });
     },
     settingFn() {
-      this.$router.push({ name: 'userInfo' })
-    }
+      this.$router.push({ name: "userInfo" });
+    },
   },
 };
 </script>
@@ -80,7 +105,8 @@ export default {
   padding: 10px 40px;
   flex-direction: row;
   transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
-  box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px;
+  box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px,
+    rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px;
   position: fixed;
   z-index: 100;
   right: 0;
@@ -104,7 +130,7 @@ export default {
 
       &.active {
         //color: #f6903d;
-        color: #409EFF;
+        color: #409eff;
         position: relative;
 
         &:after {
@@ -112,7 +138,7 @@ export default {
           position: absolute;
           width: 100%;
           height: 2px;
-          background-color: #409EFF;
+          background-color: #409eff;
           bottom: -20px;
           left: 0;
           right: 0;
@@ -128,7 +154,7 @@ export default {
     align-items: center;
 
     .login {
-        cursor: pointer;
+      cursor: pointer;
     }
 
     //font-size: ;

+ 46 - 15
ClientPlatform/src/pages/userInfo/userInfo.vue

@@ -1,8 +1,10 @@
 <template>
   <div class="page-box">
-    <el-card class="title"> 用户详情-{{ detail.id }} </el-card>
+    <el-card class="title">
+      用户详情-<span v-if="detail && detail.id">{{ detail.id }}</span>
+    </el-card>
     <br />
-    <el-card class="el-input">
+    <el-card class="el-input" v-if="detail && detail.id">
       <el-form ref="detail" :model="detail" label-width="80px">
         <el-form-item label="邮箱">
           <div>{{ detail.email }}</div>
@@ -22,15 +24,17 @@
             >
               {{ tag }}
             </el-tag>
-            <el-input
-              class="input-new-tag"
-              v-if="inputVisible"
-              v-model="inputValue"
-              ref="saveTagInput"
-              size="small"
-              @keyup.enter.native="handleInputConfirm"
-              @blur="handleInputConfirm"
-            />
+            <span v-if="inputVisible">
+              <el-input
+                class="input-new-tag"
+                v-model="inputValue"
+                ref="saveTagInput"
+                size="small"
+                @keyup.enter.native="handleInputConfirm"
+                @blur="handleInputConfirm"
+              />
+              <el-button @click="inputVisible = false">取消</el-button>
+            </span>
             <el-button
               v-else
               class="button-new-tag"
@@ -65,7 +69,7 @@
   </div>
 </template>
 <script>
-import { userInfo } from "../../api";
+import { userInfo, userUpdate } from "../../api";
 
 export default {
   data() {
@@ -93,12 +97,31 @@ export default {
     this.pageInit();
   },
   methods: {
-    onSubmit() {},
+    async onSubmit() {
+      const params = {
+        ...this.detail,
+      };
+      // if (this.inputValue) {
+      //   params.isSick = true;
+      // }
+      if (!this.detail.isSick) {
+        this.detail.sick = [];
+      }
+      console.log(110, this.detail.isSick);
+      const res = await userUpdate(params);
+      if (res.data) {
+        window.location.reload();
+      }
+    },
     async pageInit() {
       const token = localStorage.getItem("token");
       const res = await userInfo({ token });
-      // console.log(61616111, res)
       this.detail = res.data;
+      console.log(117, this.detail);
+      if (this.detail.isSick && this.detail.isSick === "true") {
+        // this.inputValue = this.detail.sick;
+      }
+      this.$set(this.detail, "isSick", this.detail.isSick === "true");
     },
     toHome(query) {
       console.log(101);
@@ -132,12 +155,20 @@ export default {
     },
     showInput() {
       this.inputVisible = true;
+      const detail = {
+        ...this.detail,
+        // sick: [],
+      };
+      if (detail?.sick) {
+        detail.sick = [];
+      }
+      this.detail = { ...detail };
       this.$nextTick((_) => {
         this.$refs.saveTagInput.$refs.input.focus();
       });
     },
     handleInputConfirm() {
-      const sick = new Set([...this.detail.sick, this.inputValue]);
+      const sick = new Set([...(this.detail?.sick || []), this.inputValue]);
       this.detail.sick = this.detail = {
         ...this.detail,
         sick: [...sick],

+ 3 - 0
ClientPlatform/src/utils/config.js

@@ -13,6 +13,9 @@ const STAGE_CONFIG = {
 let stageKey = window.localStorage.getItem("stage");
 if (process.env.NODE_ENV === "production") {
   stageKey = "prod";
+} else {
+  stageKey = "dev";
 }
+
 const stage = STAGE_CONFIG[stageKey || "api-mock"];
 export { stage };

+ 2 - 1
admin_site/admin_site/settings.py

@@ -35,6 +35,7 @@ INSTALLED_APPS = [
     'user',
     'order',
     'files',
+    'sick',
     'django_celery_beat',
     'django_celery_results',
     'corsheaders',
@@ -149,7 +150,7 @@ CELERY_TASK_SERIALIZER = 'json'
 CELERY_BEAT_SCHEDULE = {
     'task-name': {
         'task': 'files.tasks.del_file',
-        'schedule': crontab(hour='*/1'), # 每隔1小时删除用户未使用的,且上传时间大于4小时的文件
+        'schedule': crontab(hour='*/1'),  # 每隔1小时删除用户未使用的,且上传时间大于4小时的文件
         # 'args': (1, 2),
     },
 }

+ 2 - 0
admin_site/admin_site/urls.py

@@ -18,6 +18,7 @@ from django.urls import path,include,re_path
 from user import urls as user_urls
 from order import urls as order_urls
 from files import urls as files_urls
+from sick import urls as sick_urls
 # urlpatterns = [
 #     path('admin/', admin.site.urls),
 #     path(r'user/*', include('user.urls')),
@@ -33,6 +34,7 @@ urlpatterns = [
     re_path(r'^files/?', include(files_urls)),
     re_path(r'^download/?', include(files_urls)),
     re_path(r'^user/?', include(user_urls)),
+    re_path(r'^skit/?', include(sick_urls)),
     # path(r'order/info', order_views.info),
     # path(r'order/list', order_views.list),
     # path(r'order/add', order_views.add),

+ 10 - 0
admin_site/admin_site/utils.py

@@ -41,6 +41,7 @@ def userPersonToDictionary(person):
     dictionary["type"] = person.type
     dictionary["sex"] = person.sex
     dictionary["disease"] = person.disease
+    dictionary["isSick"] = person.is_sick
     return dictionary
 
 
@@ -91,3 +92,12 @@ def timestamp_to_timezone_obj(time):
     timezone_obj = utc_time.replace(tzinfo=datetime.timezone.utc).astimezone()
     # 返回timezone对象
     return timezone_obj
+
+def user_to_dict(user_obj):
+    user_dict = {}
+    for field in user_obj._meta.fields:
+        field_name = field.name
+        field_value = getattr(user_obj, field_name)
+        if field_name != 'password' and field_name != 'is_delete'and field_name != 'create_time'and field_name != 'update_time':
+            user_dict[field_name] = field_value
+    return user_dict

BIN
admin_site/mysite


+ 0 - 0
admin_site/sick/__init__.py


+ 3 - 0
admin_site/sick/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 6 - 0
admin_site/sick/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class SickConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'sick'

+ 25 - 0
admin_site/sick/migrations/0001_initial.py

@@ -0,0 +1,25 @@
+# Generated by Django 4.1.7 on 2023-04-09 15:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Sick',
+            fields=[
+                ('id', models.BigAutoField(primary_key=True, serialize=False)),
+                ('user_id', models.CharField(blank=True, max_length=200)),
+                ('name', models.CharField(blank=True, max_length=10)),
+                ('create_time', models.DateTimeField(auto_now_add=True)),
+                ('update_time', models.DateTimeField(auto_now=True)),
+                ('is_delete', models.IntegerField(default=0)),
+            ],
+        ),
+    ]

+ 0 - 0
admin_site/sick/migrations/__init__.py


+ 11 - 0
admin_site/sick/models.py

@@ -0,0 +1,11 @@
+from django.db import models
+
+
+# Create your models here.
+class Sick(models.Model):
+    id = models.BigAutoField(primary_key=True)  # id
+    user_id = models.CharField(max_length=200, blank=True)  # 用户id
+    name = models.CharField(max_length=10, blank=True)  # 名称
+    create_time = models.DateTimeField(auto_now_add=True)  # 创建时间
+    update_time = models.DateTimeField(auto_now=True)  # 更新时间
+    is_delete = models.IntegerField(default=0)  # 是否删除: 0:未删除;1:删除

+ 3 - 0
admin_site/sick/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 8 - 0
admin_site/sick/urls.py

@@ -0,0 +1,8 @@
+from django.urls import path, re_path
+from rest_framework import routers, serializers, viewsets
+
+from . import views
+
+urlpatterns = [
+    re_path('^add_sick', views.add_sick),
+]

+ 18 - 0
admin_site/sick/views.py

@@ -0,0 +1,18 @@
+from django.views.decorators.http import require_http_methods
+from django.views.decorators.csrf import csrf_exempt
+from .models import Sick as Sick_models
+import re
+
+@csrf_exempt
+@require_http_methods(["POST"])
+def add_sick(request):
+    body = request.POST;
+    print(10, body.get('id'))
+    objs = []
+    Sick_models.objects.filter(user_id=body.get('id')).delete()
+    for field in body:
+        match = re.search(r'\bsick\b', field)
+        if match:
+            objs.append(Sick_models(name = body[field], user_id=body.get('id')))
+    Sick_models.objects.bulk_create(objs)
+

+ 18 - 0
admin_site/user/migrations/0010_user_is_sick.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.1.7 on 2023-04-09 15:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('user', '0009_alter_user_token_exit_time'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='user',
+            name='is_sick',
+            field=models.BooleanField(blank=True, null=True),
+        ),
+    ]

+ 18 - 0
admin_site/user/migrations/0011_user_tasks.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.1.7 on 2023-04-09 15:41
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('user', '0010_user_is_sick'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='user',
+            name='tasks',
+            field=models.IntegerField(default=10),
+        ),
+    ]

+ 18 - 0
admin_site/user/migrations/0012_alter_user_is_sick.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.1.7 on 2023-04-09 16:00
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('user', '0011_user_tasks'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='user',
+            name='is_sick',
+            field=models.CharField(blank=True, max_length=255, null=True),
+        ),
+    ]

+ 3 - 1
admin_site/user/models.py

@@ -1,5 +1,4 @@
 # 创建模型
-from multiprocessing.sharedctypes import Value
 from django.db import models
 
 # 人员信息表
@@ -20,4 +19,7 @@ class User(models.Model):
     token = models.FileField(max_length=255,null=True) # 用户的token
     token_exit_time = models.DateTimeField(auto_now_add=False, null=True) # 用户的token
 
+    is_sick = models.CharField(max_length=255, blank=True, null=True)  # 用户是否患病:用户|
     disease = models.CharField(max_length=200, blank=True, null=True)  # 用户是否患病:用户|
+    tasks = models.IntegerField(default=10) # 每个用户默认分配一个任务数
+    # sick = ArrayField(models.CharField(max_length=200, blank=True, null=True)) # 所患疾病

+ 57 - 30
admin_site/user/views.py

@@ -9,8 +9,12 @@ from django.http import HttpResponse, JsonResponse
 from django.views.decorators.http import require_http_methods
 from django.views.decorators.csrf import csrf_exempt
 from django.core import serializers  # 序列化 QuerySet
-from admin_site.utils import setError, setSuccess, userPersonToDictionary, get_timestamp
+from admin_site.utils import setError, setSuccess, userPersonToDictionary, get_timestamp,user_to_dict
+from sick.views import add_sick
+from sick.models import Sick as Sick_models
+from rest_framework.parsers import JSONParser
 import jwt
+import re
 import pytz
 
 # from rest_framework.views import APIView
@@ -21,69 +25,92 @@ def index(request):
 
 
 @csrf_exempt
-@require_http_methods(["POST", "GET"])
+@require_http_methods(["POST"])
 def info(request):
-    if len(request.body) == 0:
-        return HttpResponse(setError("请传入数据!"))
-    body = json.loads(request.body)
-    if body.get('id') == None:
+    # print(26, request.POST.get('token'))
+    if request.POST.get('token') == None:
         return HttpResponse(setError("该用户不存在!"))
-    user_info = userPersonToDictionary(User_models.objects.get(id=body.get('id')))
-    print(user_info)
-    return HttpResponse(setSuccess(data=user_info))
+    user_info = userPersonToDictionary(User_models.objects.get(token=request.POST.get('token')))
+    print(34343, user_info['id'])
+    if user_info['isSick'] == 'true':
+        sick_list_dic = Sick_models.objects.filter(user_id=user_info['id'])
+        sick_list = []
+        for key in sick_list_dic:
+            print(39, key.name)
+            sick_list.append(key.name)
+        print(42, sick_list)
+        if len(sick_list) > 0:
+            user_info.setdefault('sick', sick_list)
 
+    print('user_info', user_info)
+    return JsonResponse(setSuccess(data=user_info))
 
 """ 用户登陆 """
-
-
 @csrf_exempt
 @require_http_methods(["POST"])
 def login(request):
-    body = json.loads(request.body)
+    body = request.POST
     if body.get('email') == None:
         return HttpResponse(setError("该用户不存在!"))
     if body.get('password') == None:
         return HttpResponse(setError("该用户不存在!"))
-    user_info = userPersonToDictionary(User_models.objects.get(email=body.get('email'), password=body.get('password')))
+    user_info = User_models.objects.get(email=body.get('email'), password=body.get('password'))
     name = body.get("name", None)
     password = body.get("password", None)
     now_time = timezone.localtime()
     user_str = {'username': name, 'password': password, 'now_time': get_timestamp(now_time)}
     token = jwt.encode(user_str, 'sercet', algorithm='HS256')
-    print('user_info', user_info)
     params = {
         "token": token,
         'token_exit_time': now_time
     }
-    print(56, params)
-    User_models.objects.filter(id=user_info['id']).update(**params)
-    return JsonResponse(setSuccess(data={**user_info,"token": token,}))
+    User_models.objects.filter(id=user_info.id).update(**params)
+    new_user_info = user_to_dict(user_info)
+    params = {**new_user_info,**params}
+    return JsonResponse(setSuccess(data=params))
 
 
 @csrf_exempt
 @require_http_methods(["POST"])
 def register(request):
-    body = json.loads(request.body)
-    is_add = User_models.objects.all().filter(email=body.get('email', None))
+    body = request.POST
+    is_add = User_models.objects.all().filter(email=body.get('email'))
     if len(is_add) > 0:
         return JsonResponse(setError("当前邮箱已存在,添加失败"))
-    user_add = User_models(name=body.get("name", None), nickname=body.get("nickname", None),
-                           address=body.get("address", None), email=body.get("email", None),
-                           password=body.get("password", None), type=body.get("type", None), sex=body.get("sex", None))
+    params = {
+        'email': body.get('email'),
+        'password': body.get('email'),
+    }
+    user_add = User_models(**params)
     user_add.save()
-    return JsonResponse(setSuccess(msg='添加成功', data=True))
+    return JsonResponse(setSuccess(msg='注册成功', data=True))
 
 
 @csrf_exempt
 @require_http_methods(["POST"])
 def update(request):
-    body = copy.deepcopy(json.loads(request.body))
-    if body.get('id') == None or body['id'] == '':
+    body = request.POST.dict()
+    print(80808080, body)
+    if body['id'] == None or body['id'] == '':
         return JsonResponse(setError("用户不存在"))
+    # if(body['id'])
+    new_body = {}
+    body.setdefault('is_sick', body['isSick'])
+    print(99, body['is_sick'])
+    del body['isSick']
+    if body['is_sick'] == 'true':
+        add_sick(request)
+        for field in body:
+            match = re.search(r'\bsick\[\b', field)
+            if match == None:
+                new_body[field] = body[field]
+    else:
+        print(107, body['is_sick'])
+        Sick_models.objects.filter(user_id=body.get('id')).delete()
+        new_body = body
     # type
-    print(body.get('type'))
-    field_list = ['address', 'password', 'nickname', 'mobile']
-    params = {}
+    # field_list = ['address', 'password', 'nickname', 'mobile']
+    # params = {}
     # # 用户信息更新
     # if (body.get('type') == 'Fl001'):
     #     # 如果字段中存在未完成订单,不允许修改地址,联系方式
@@ -105,6 +132,6 @@ def update(request):
     #         #     setattr(params, key, body.get(key))
     #         if params.get(key) == None and body.get(key) != None and key != 'address':
     #             params.setdefault(key, body.get(key))
-    Order_models.objects.filter(user_id=body['id'], status__lte=1)
-    User_models.objects.filter(id=body['id']).update(**body,**params)
+    # Order_models.objects.filter(user_id=body['id'], status__lte=1)
+    User_models.objects.filter(id=body['id']).update(**new_body)
     return JsonResponse(setSuccess(msg='更新成功', data=True))