diff --git a/test_mini/app.json b/test_mini/app.json index 1dc2b63..5f1bf4d 100644 --- a/test_mini/app.json +++ b/test_mini/app.json @@ -63,6 +63,10 @@ } ] }, + "useExtendedLib": { + "kbone": true, + "weui": true + }, "style": "v2", "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/test_mini/pages/collect/main.wxml b/test_mini/pages/collect/main.wxml index 0308101..e638cf8 100644 --- a/test_mini/pages/collect/main.wxml +++ b/test_mini/pages/collect/main.wxml @@ -5,9 +5,7 @@ {{tm_index+1}}. {{tm_current.type}} - - - {{tm_current.questioncat_name}} + {{tm_current.questioncat_name}} {{tm_current.name}} diff --git a/test_mini/pages/cuoti/index.wxml b/test_mini/pages/cuoti/index.wxml index 509170e..a8aead1 100644 --- a/test_mini/pages/cuoti/index.wxml +++ b/test_mini/pages/cuoti/index.wxml @@ -11,12 +11,10 @@ {{tm_index+1}}. {{currentTm.type}} + {{currentTm.questioncat_name}} - {{currentTm.questioncat_name}} - ( {{currentTm.dtime}} - ) {{currentTm.name}} diff --git a/test_mini/pages/main/main.js b/test_mini/pages/main/main.js index 6a8d940..b3a565c 100644 --- a/test_mini/pages/main/main.js +++ b/test_mini/pages/main/main.js @@ -42,6 +42,9 @@ Page({ background: images }) }) + that.setData({ + search: this.search.bind(this) + }) }, /** @@ -236,5 +239,18 @@ Page({ // }) } }) - } + }, + search: function (value) { + api.request('/question/question/', 'GET', {search:value}).then(res => { + + }) + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve([{text: '搜索结果', value: 1}, {text: '搜索结果2', value: 2}]) + }, 200) + }) + }, + selectResult: function (e) { + + }, }) \ No newline at end of file diff --git a/test_mini/pages/main/main.json b/test_mini/pages/main/main.json index 8835af0..476c94b 100644 --- a/test_mini/pages/main/main.json +++ b/test_mini/pages/main/main.json @@ -1,3 +1,5 @@ { - "usingComponents": {} + "usingComponents": { + "mp-searchbar": "weui-miniprogram/searchbar/searchbar" + } } \ No newline at end of file diff --git a/test_mini/pages/main/main.wxml b/test_mini/pages/main/main.wxml index 1835961..90eb611 100644 --- a/test_mini/pages/main/main.wxml +++ b/test_mini/pages/main/main.wxml @@ -1,76 +1,78 @@ - - - - - - - - - - - - -{{item.title}} - - - - - - - - - 考试名额监控 - - - - + + - - - - - - - 练习 - - - - - - 错题集 - - - - - - 收藏集 - + + + + + + + + + + + + + {{item.title}} + + + + + + + + + 考试名额监控 + + + + + + + + + + + + 练习 + + + + + + 错题集 + + + + + + 收藏集 + - - - - - 自助模考 - - - - - - 押卷模考 - - - - - - 考试记录 - - - - - - + + + + + 自助模考 + + + + + + 押卷模考 + + + + + + 考试记录 + + + + + + \ No newline at end of file diff --git a/test_mini/pages/main/main.wxss b/test_mini/pages/main/main.wxss index f6933b3..6091d36 100644 --- a/test_mini/pages/main/main.wxss +++ b/test_mini/pages/main/main.wxss @@ -1,10 +1,10 @@ -.swiper_container { +.swiper_container1 { margin-top:12rpx; height: 50rpx; width: 100%; text-align: center } -.swiper_item { +.swiper_item1 { font-size: 30rpx; font-weight: bold; color:darkblue; diff --git a/test_server/crm/permission.py b/test_server/crm/permission.py index 6dec745..f96b9fe 100644 --- a/test_server/crm/permission.py +++ b/test_server/crm/permission.py @@ -2,6 +2,7 @@ from rbac.permission import RbacPermission from rbac.models import UserProfile from crm.models import Consumer from rest_framework.permissions import IsAuthenticated +from django.core.cache import cache # 学员接口列表 ConsumerPerms = [ @@ -20,6 +21,10 @@ VistorPerms = [ 'questioncat_view', 'my_examtest', ] +def get_consumerperm_list(consumer): + perms = consumer.role.perms.values_list('code', flat=True) + cache.get_or_set(consumer.username + '__perms', perms) + return perms class MyPermission(RbacPermission): @@ -37,10 +42,10 @@ class MyPermission(RbacPermission): # perms = get_permission_list(request.user) return True elif isinstance(request.user,Consumer): - if request.user.workscope: - perms = ConsumerPerms + if cache.get(request.user.username + '__perms'): + perms = cache.get(request.user.username + '__perms') else: - perms = VistorPerms + perms = get_consumerperm_list(request.user) if perms: if not hasattr(view, 'perms_map'): return True diff --git a/test_server/crm/serializers.py b/test_server/crm/serializers.py index 1d79fed..4021c0c 100644 --- a/test_server/crm/serializers.py +++ b/test_server/crm/serializers.py @@ -1,7 +1,7 @@ from rest_framework import serializers from .models import Company, Consumer, PaySubject, ConsumerPerm, ConsumerRole from question.models import Question, Questioncat - +from .permission import get_consumerperm_list class ConsumerPermSerializer(serializers.ModelSerializer): @@ -35,7 +35,7 @@ class ConsumerSerializer(serializers.ModelSerializer): subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True) workscope_name = serializers.StringRelatedField(source='workscope', read_only=True) role_name = serializers.StringRelatedField(source='role', read_only=True) - + perms = serializers.SerializerMethodField(read_only=True) class Meta: model = Consumer exclude = ('avatar','collects') @@ -46,3 +46,6 @@ class ConsumerSerializer(serializers.ModelSerializer): queryset = queryset.select_related('company','workscope') queryset = queryset.prefetch_related('subjects',) return queryset + + def get_perms(self,obj): + return get_consumerperm_list(obj) \ No newline at end of file diff --git a/test_server/crm/views.py b/test_server/crm/views.py index 267e373..b03516e 100644 --- a/test_server/crm/views.py +++ b/test_server/crm/views.py @@ -293,9 +293,11 @@ class ConsumerViewSet(ModelViewSet): @action(methods=['get'], detail=False, url_path='correctrole', url_name='correct_role', perms_map=[{'*':'correct_role'}]) def correctrole(self, request): + role0 = ConsumerRole.objects.get(name='游客') role1 = ConsumerRole.objects.get(name='付费学员') role2 = ConsumerRole.objects.get(name='注册用户') - for i in Consumer.objects.all(): + for i in Consumer.objects.filter(role__isnull = True): + i.role = role0 if i.workscope and i.username: i.role = role1 elif i.username and i.openid: diff --git a/test_server/question/views.py b/test_server/question/views.py index de10033..556fe82 100644 --- a/test_server/question/views.py +++ b/test_server/question/views.py @@ -101,7 +101,7 @@ class QuestionViewSet(ModelViewSet): ordering = ['-create_time'] filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter] filterset_fields = ['questioncat','level', 'type'] - search_fields = ['^name'] + search_fields = ['name', 'options', 'resolution'] @action(methods=['post'], detail=False, url_path='count', url_name='question_count')