diff --git a/test_mini/app.js b/test_mini/app.js index 4e9ce27..75f30df 100644 --- a/test_mini/app.js +++ b/test_mini/app.js @@ -69,9 +69,9 @@ App({ globalData: { userInfo: {}, userinfo: {}, // 服务器传回的消费者信息 - host: 'https://apitest.ahctc.cn', + //host: 'https://apitest.ahctc.cn', mediahost: 'https://apitest.ahctc.cn', - //host: 'http://127.0.0.1:8000', + host: 'http://127.0.0.1:8000', //mediahost: 'http://127.0.0.1:8000', token : '', } diff --git a/test_mini/app.json b/test_mini/app.json index 46dc036..1101528 100644 --- a/test_mini/app.json +++ b/test_mini/app.json @@ -29,7 +29,8 @@ "pages/candidate/detail", "pages/material/video", "pages/qtest/form", - "pages/main/start" + "pages/main/start", + "pages/exam/index" ], "window": { "backgroundTextStyle": "light", diff --git a/test_mini/images/exam.svg b/test_mini/images/exam.svg new file mode 100644 index 0000000..599d430 --- /dev/null +++ b/test_mini/images/exam.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test_mini/pages/exam/index.js b/test_mini/pages/exam/index.js new file mode 100644 index 0000000..5adcf8a --- /dev/null +++ b/test_mini/pages/exam/index.js @@ -0,0 +1,119 @@ +// pages/qtest/form.js +const api = require("../../utils/request.js"); +Page({ + + /** + * 页面的初始数据 + */ + data: { + userInfo:{}, + form:{ + deptname:null, + code:null + } + }, + + + deptInput: function(e){ + this.data.form.deptname = e.detail.value + }, + codeinput: function(e){ + this.data.form.code = e.detail.value + }, + submit: function(){ + if(this.data.form.deptname&&this.data.form.code){ + wx.showToast({ + title: '加入考试成功', + icon:'none' + }) + let data = this.data.form + api.request('/examtest/exam/attend/','POST', data).then(res=>{ + wx.showLoading({ + title: '正在组卷。。。', + mask:true + }) + let exam = res.data.exam + api.request(`/examtest/exam/${exam}/init/`,'POST', data).then(res=>{ + console.log(res.data) + wx.hideLoading({ + success: (res) => {}, + }) + }).catch(e=>{ + wx.hideLoading({ + success: (res) => {}, + }) + }) + }) + }else{ + wx.showToast({ + title: '信息不完整', + icon:'none' + }) + } + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + api.request('/crm/consumer/info/','GET').then(res=>{ + getApp().globalData.userinfo = res.data.userinfo + this.setData( + { + userinfo: res.data.userinfo, + form:{ + deptname:res.data.userinfo.deptname + }, + } + ) + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/test_mini/pages/exam/index.json b/test_mini/pages/exam/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/test_mini/pages/exam/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/test_mini/pages/exam/index.wxml b/test_mini/pages/exam/index.wxml new file mode 100644 index 0000000..c537529 --- /dev/null +++ b/test_mini/pages/exam/index.wxml @@ -0,0 +1,61 @@ + + +

正式考试

+ 请确认和完善个人信息,并输入考试号加入考试,如有问题请及时联系老师 +
+ + + 个人信息 + + + + + {{userinfo.name}} + + + + + + {{userinfo.ID_number1}} + + + + + + + + {{userinfo.company_name}} + + + + + + + + {{userinfo.deptname}} + + {{userinfo.deptname}} + + + + + + + + + + + + + + + + + + + + 确认 + +
\ No newline at end of file diff --git a/test_mini/pages/exam/index.wxss b/test_mini/pages/exam/index.wxss new file mode 100644 index 0000000..a6a15b8 --- /dev/null +++ b/test_mini/pages/exam/index.wxss @@ -0,0 +1 @@ +/* pages/exam/index.wxss */ \ No newline at end of file diff --git a/test_mini/pages/my/index.wxml b/test_mini/pages/my/index.wxml index 66393a8..79baef9 100644 --- a/test_mini/pages/my/index.wxml +++ b/test_mini/pages/my/index.wxml @@ -4,21 +4,21 @@ - + 账号: {{userinfo.username}} - 账号: - 未登陆 + 账号: + 未登陆 昵称: - 单位: - {{ userinfo.company_name }} + 单位: + {{ userinfo.company_name }} 如需解绑账号请联系课程顾问 @@ -28,46 +28,55 @@ 统计分析 - + - + + 工作类别 - {{userinfo.workscope_name}} - + + {{userinfo.workscope_name}} + - + + - 模考次数 + 考试次数 {{total}} - - - + + + + 通过率 {{pass_rate}}% - - - + + + + 平均分 {{avg_score}} + + + + + + 正式考试入口 + + - - - 更多服务请联系课程顾问 - - - + + + 更多服务请联系课程顾问 + + + \ No newline at end of file diff --git a/test_server/crm/migrations/0027_consumer_deptname.py b/test_server/crm/migrations/0027_consumer_deptname.py new file mode 100644 index 0000000..f2959a4 --- /dev/null +++ b/test_server/crm/migrations/0027_consumer_deptname.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2021-03-17 14:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0026_auto_20210313_1109'), + ] + + operations = [ + migrations.AddField( + model_name='consumer', + name='deptname', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='所在部门'), + ), + ] diff --git a/test_server/crm/views.py b/test_server/crm/views.py index c8f5ace..ca7e493 100644 --- a/test_server/crm/views.py +++ b/test_server/crm/views.py @@ -9,7 +9,7 @@ from django.db.models import Q from django_filters.rest_framework import DjangoFilterBackend from openpyxl import Workbook, load_workbook from rest_framework import status -from rest_framework.decorators import action +from rest_framework.decorators import action, authentication_classes, permission_classes from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response @@ -365,17 +365,6 @@ class ConsumerViewSet(ModelViewSet): request.user.save() return Response(status=status.HTTP_200_OK) - # @action(methods=['put'], detail=False, - # url_path='process', url_name='exercise_processcat', perms_map=[{'*':'*'}]) - # def processcat(self, request): - # ''' - # 练习进度单类别修改 - # ''' - # if hasattr(request.user, 'process'): - # request.user.process = request.data['process'] - # request.user.save() - # return Response(status=status.HTTP_200_OK) - @action(methods=['post'], detail=False, url_path='realinfo', url_name='get_realinfo', perms_map=[{'*':'*'}]) def realinfo(self, request): @@ -547,6 +536,11 @@ class ConsumerViewSet(ModelViewSet): except: raise Http404 + @action(methods=['get'], detail = False, perms_map=[{'*':'*'}]) + def info(self, request, *args, **kwargs): + serializer = ConsumerDetailSerializer(instance=request.user) + return Response({"userinfo":serializer.data}) + from .permission import get_consumerperm_list class ConsumerMPLoginView(APIView): """ diff --git a/test_server/examtest/views.py b/test_server/examtest/views.py index 1e0eedd..70720ca 100644 --- a/test_server/examtest/views.py +++ b/test_server/examtest/views.py @@ -72,7 +72,7 @@ class ExamViewSet(ModelViewSet): return Response(status=status.HTTP_204_NO_CONTENT) - @action(methods=['post'], detail = False,perms_map=[{'get':'exam_attend'}]) + @action(methods=['post'], detail = False,perms_map=[{'post':'exam_attend'}]) def attend(self, request, *args, **kwargs): """ 参加考试 @@ -89,20 +89,21 @@ class ExamViewSet(ModelViewSet): exam = Exam.objects.get(code=code, opentime__lt=now, closetime__gt=now) return Response({'exam':exam.pk}) except: - return Response({'error':'考试编号错误'}) + return Response({'error':'考试编号不存在'}) return Response({'error':'操作失败'}) - @action(methods=['post'], detail = True,perms_map=[{'get':'exam_init'}]) + @action(methods=['post'], detail = True,perms_map=[{'post':'exam_attend'}]) def init(self, request, *args, **kwargs): """ 生成考试卷 """ - obj = self.get_object() + obj = Exam.objects.get(pk=kwargs['pk']) workscope = obj.workscope + ret = {} if workscope.name in ['医学Ⅲ类', '非医学Ⅲ类']: - ret['name'] = '正式考试' + datetime.now().strftime('%Y%m%d%H%M') + ret['name'] = obj.name ret['type'] = '正式考试' # 正式考试 - ret['exam'] = obj.id + ret['exam'] = ExamListSerializer(instance=obj).data ret['workscope'] = workscope.id ret['limit'] = 60 ret['total_score'] = 120 @@ -130,6 +131,7 @@ class ExamViewSet(ModelViewSet): i['total_score'] = 4 ret['questions'] = questions return Response(ret) + return Response({'error':'生成试卷失败'})