From 959450d5885915222a2641b47e02f9ebdf74ca29 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 30 Apr 2021 11:27:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client_mp/App.vue | 39 +++++++++++++------ client_mp/pages.json | 18 ++++----- .../pages/inspectrecord/recorddetail.vue | 2 +- server/apps/system/views.py | 4 +- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/client_mp/App.vue b/client_mp/App.vue index 45c99f9..02f8d12 100644 --- a/client_mp/App.vue +++ b/client_mp/App.vue @@ -13,25 +13,40 @@ /** * h5,app-plus(nvue下也为app-plus),mp-weixin,mp-alipay...... */ - var that=this + //var that=this // 小程序自动登录 + uni.showLoading({ + title:'微信自动登录中...', + mask: true + }) uni.login({ provider: 'weixin', - success: function (loginRes) { - that.$u.api.wxmplogin({code:loginRes.code}).then(res=>{ - that.$u.vuex('vuex_token', res.data.access) - }).catch(e=>{uni.reLaunch({ + success: (loginRes)=>{ + this.$u.api.wxmplogin({code:loginRes.code}).then(res=>{ + this.$u.vuex('vuex_token', res.data.access) + this.$u.api.getUserInfo().then(res=>{ + uni.hideLoading() + uni.showToast({ + title:"登录成功", + icon:"none" + }) + uni.reLaunch({ + url:"/pages/home/home" + }) + this.$u.vuex('vuex_user', res.data) + }) + }).catch(e=>{ + uni.hideLoading() + uni.showToast({ + title:"暂未绑定微信!", + icon:"none" + }) + uni.reLaunch({ url:'/pages/login/login' })}) } }); - // this.$u.api.getUserInfo().then(res=>{ - // this.$u.vuex('vuex_user', res.data) - // }).catch(e=>{ - // uni.reLaunch({ - // url:'/pages/login/login' - // }) - // }) + }, } diff --git a/client_mp/pages.json b/client_mp/pages.json index d2c52dc..7ff9890 100644 --- a/client_mp/pages.json +++ b/client_mp/pages.json @@ -11,6 +11,15 @@ // }] // }, "pages": [ + { + "path" : "pages/login/login", + "style" : + { + "navigationBarTitleText": "验证码登录", + "enablePullDownRefresh": false + } + + }, { "path" : "pages/home/home", "style" : @@ -28,15 +37,6 @@ "enablePullDownRefresh": false } - } - ,{ - "path" : "pages/login/login", - "style" : - { - "navigationBarTitleText": "验证码登录", - "enablePullDownRefresh": false - } - } ,{ "path" : "pages/login/login_password", diff --git a/client_mp/pages/inspectrecord/recorddetail.vue b/client_mp/pages/inspectrecord/recorddetail.vue index d752926..cead268 100644 --- a/client_mp/pages/inspectrecord/recorddetail.vue +++ b/client_mp/pages/inspectrecord/recorddetail.vue @@ -20,7 +20,7 @@ + width="260rpx" height="260rpx" :src="item" v-for="(item, index) in fileList" v-bind:key="index" style="margin: 2rpx;"> diff --git a/server/apps/system/views.py b/server/apps/system/views.py index 4c2d3a7..ac8277f 100644 --- a/server/apps/system/views.py +++ b/server/apps/system/views.py @@ -315,8 +315,8 @@ class UserViewSet(PageOrNot, ModelViewSet): 'perms': perms, } try: - user = UserThird.objects.get(user=user,type='wx_mp').user - data['wxmp_openid'] = user.openid + usert = UserThird.objects.get(user=user,type='wx_mp') + data['wxmp_openid'] = usert.openid except: pass return Response(data) From e540b15b733fe793d6de89c4849e2e7d4e94388a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 30 Apr 2021 11:58:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0018_auto_20210430_1156.py | 19 +++++++++++++++++++ server/apps/system/models.py | 2 +- server/apps/system/views.py | 7 ++++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 server/apps/system/migrations/0018_auto_20210430_1156.py diff --git a/server/apps/system/migrations/0018_auto_20210430_1156.py b/server/apps/system/migrations/0018_auto_20210430_1156.py new file mode 100644 index 0000000..218b434 --- /dev/null +++ b/server/apps/system/migrations/0018_auto_20210430_1156.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.5 on 2021-04-30 03:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('system', '0017_userthird'), + ] + + operations = [ + migrations.AlterField( + model_name='userthird', + name='openid', + field=models.CharField(default='xx', max_length=200, unique=True, verbose_name='第三方账号'), + preserve_default=False, + ), + ] diff --git a/server/apps/system/models.py b/server/apps/system/models.py index 0afae87..5713fe8 100644 --- a/server/apps/system/models.py +++ b/server/apps/system/models.py @@ -229,4 +229,4 @@ class UserThird(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='关联账户', related_name='third_user') type = models.CharField('类型', max_length=50, choices=type_choices, default='wx_mp') - openid = models.CharField('第三方账号', null=True, blank=True, max_length=200) + openid = models.CharField('第三方账号', max_length=200, unique=True) diff --git a/server/apps/system/views.py b/server/apps/system/views.py index ac8277f..b3a5bba 100644 --- a/server/apps/system/views.py +++ b/server/apps/system/views.py @@ -343,7 +343,12 @@ class UserViewSet(PageOrNot, ModelViewSet): code+'&grant_type=authorization_code').content.decode('utf-8') info = json.loads(info) openid = info['openid'] - UserThird.objects.get_or_create(openid=openid, type='wx_mp', user=request.user, defaults={'openid':openid, 'user':request.user, 'type':'wx_mp'}) + if UserThird.objects.filter(openid=openid).exists(): + instance = UserThird.objects.get(openid=openid) + instance.openid = openid + instance.save() + else: + UserThird.objects.get_or_create(openid=openid, type='wx_mp', user=request.user, defaults={'openid':openid, 'user':request.user, 'type':'wx_mp'}) return Response({'wxmp_openid':openid},status=status.HTTP_200_OK) From eada0465d919d1de5328b605c028e21173fbac1c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 30 Apr 2021 12:50:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client_mp/store/index.js | 8 ++++---- server/apps/system/views.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client_mp/store/index.js b/client_mp/store/index.js index 5860176..6ece716 100644 --- a/client_mp/store/index.js +++ b/client_mp/store/index.js @@ -34,12 +34,12 @@ const store = new Vuex.Store({ vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {}, vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '', // vuex_host: 'http://127.0.0.1:8000', - // vuex_api: 'http://127.0.0.1:8000/api', - // vuex_apifile: 'http://127.0.0.1:8000/api/file/', + vuex_api: 'http://127.0.0.1:8000/api', + vuex_apifile: 'http://127.0.0.1:8000/api/file/', vuex_host: 'https://testsearch.ctc.ac.cn', - vuex_api: 'https://testsearch.ctc.ac.cn/api', - vuex_apifile: 'https://testsearch.ctc.ac.cn/api/file/', + // vuex_api: 'https://testsearch.ctc.ac.cn/api', + // vuex_apifile: 'https://testsearch.ctc.ac.cn/api/file/', // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式 // vuex_version: '1.0.1', diff --git a/server/apps/system/views.py b/server/apps/system/views.py index b3a5bba..85f2e5c 100644 --- a/server/apps/system/views.py +++ b/server/apps/system/views.py @@ -343,9 +343,10 @@ class UserViewSet(PageOrNot, ModelViewSet): code+'&grant_type=authorization_code').content.decode('utf-8') info = json.loads(info) openid = info['openid'] - if UserThird.objects.filter(openid=openid).exists(): - instance = UserThird.objects.get(openid=openid) - instance.openid = openid + instances = UserThird.objects.filter(openid=openid) + if instances.exists(): + instance = instances[0] + instance.user = request.user instance.save() else: UserThird.objects.get_or_create(openid=openid, type='wx_mp', user=request.user, defaults={'openid':openid, 'user':request.user, 'type':'wx_mp'}) From f0ec4691bc4f70f66870c85156a0ce2529369e7f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 30 Apr 2021 13:24:34 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=8A=A5=E9=80=81?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/task.js | 7 +++++++ client/src/views/supervision/taskdo.vue | 27 ++++++++++++++++++++++++- server/apps/supervision/urls.py | 5 +++-- server/apps/supervision/views.py | 23 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/client/src/api/task.js b/client/src/api/task.js index 4948c2d..c28950a 100644 --- a/client/src/api/task.js +++ b/client/src/api/task.js @@ -96,4 +96,11 @@ export function getmytasklist(query) { method: 'get', params: query }) +} + +export function confirmTaskdept(id) { + return request({ + url: `/supervision/taskdept/${id}/confirm/`, + method: 'put' + }) } \ No newline at end of file diff --git a/client/src/views/supervision/taskdo.vue b/client/src/views/supervision/taskdo.vue index b36146c..83a8725 100644 --- a/client/src/views/supervision/taskdo.vue +++ b/client/src/views/supervision/taskdo.vue @@ -124,6 +124,25 @@ {{ scope.row.confirm_rate }}% + + + @@ -309,7 +328,7 @@ }