question search
This commit is contained in:
parent
1837f67df5
commit
8c1f912bc6
|
@ -63,6 +63,10 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"useExtendedLib": {
|
||||||
|
"kbone": true,
|
||||||
|
"weui": true
|
||||||
|
},
|
||||||
"style": "v2",
|
"style": "v2",
|
||||||
"sitemapLocation": "sitemap.json"
|
"sitemapLocation": "sitemap.json"
|
||||||
}
|
}
|
|
@ -5,9 +5,7 @@
|
||||||
<view class="weui-article">
|
<view class="weui-article">
|
||||||
<view class="weui-article__h2">{{tm_index+1}}.
|
<view class="weui-article__h2">{{tm_index+1}}.
|
||||||
<span class="txlabel">{{tm_current.type}}</span>
|
<span class="txlabel">{{tm_current.type}}</span>
|
||||||
</view>
|
<span style="color:gray"> {{tm_current.questioncat_name}}</span>
|
||||||
<view style="text-align:center">
|
|
||||||
<span style="color:drakblue;font-weight:bold;font-size:14px">{{tm_current.questioncat_name}}</span>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-article__title">{{tm_current.name}}</view>
|
<view class="weui-article__title">{{tm_current.name}}</view>
|
||||||
<view wx:if="{{tm_current.img}}" style="text-align:center"><image src="{{tm_current.img}}" mode="aspectFit"></image></view>
|
<view wx:if="{{tm_current.img}}" style="text-align:center"><image src="{{tm_current.img}}" mode="aspectFit"></image></view>
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
<view class="weui-article">
|
<view class="weui-article">
|
||||||
<view class="weui-article__h2">{{tm_index+1}}.
|
<view class="weui-article__h2">{{tm_index+1}}.
|
||||||
<span class="txlabel">{{currentTm.type}}</span>
|
<span class="txlabel">{{currentTm.type}}</span>
|
||||||
|
<span style="color:gray"> {{currentTm.questioncat_name}}</span>
|
||||||
</view>
|
</view>
|
||||||
<view style="text-align:center">
|
<view style="text-align:center">
|
||||||
<span style="color:drakblue;font-weight:bold;font-size:14px">{{currentTm.questioncat_name}}</span>
|
|
||||||
(
|
|
||||||
<span style="color:orange;font-weight:bold;font-size:14px">{{currentTm.dtime}}</span>
|
<span style="color:orange;font-weight:bold;font-size:14px">{{currentTm.dtime}}</span>
|
||||||
)
|
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-article__title">{{currentTm.name}}</view>
|
<view class="weui-article__title">{{currentTm.name}}</view>
|
||||||
<view wx:if="{{currentTm.img}}" style="text-align:center"><image src="{{currentTm.img}}" mode="aspectFit"></image></view>
|
<view wx:if="{{currentTm.img}}" style="text-align:center"><image src="{{currentTm.img}}" mode="aspectFit"></image></view>
|
||||||
|
|
|
@ -42,6 +42,9 @@ Page({
|
||||||
background: images
|
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) {
|
||||||
|
|
||||||
|
},
|
||||||
})
|
})
|
|
@ -1,3 +1,5 @@
|
||||||
{
|
{
|
||||||
"usingComponents": {}
|
"usingComponents": {
|
||||||
|
"mp-searchbar": "weui-miniprogram/searchbar/searchbar"
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
<view class="page">
|
<view class="page">
|
||||||
|
<view>
|
||||||
|
<mp-searchbar bindselectresult="selectResult" search="{{search}}" placeholder="搜题"></mp-searchbar>
|
||||||
|
</view>
|
||||||
<view class="page-section page-section-spacing swiper">
|
<view class="page-section page-section-spacing swiper">
|
||||||
<swiper indicator-dots="{{indicatorDots}}"
|
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" style='height:{{Hei}}'>
|
||||||
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" style='height:{{Hei}}'>
|
|
||||||
<block wx:for="{{background}}" wx:key="*this">
|
<block wx:for="{{background}}" wx:key="*this">
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<image style="width: 100%;" src="{{item}}" bindload='imgH'></image>
|
<image style="width: 100%;" src="{{item}}" bindload='imgH'></image>
|
||||||
|
@ -9,24 +11,24 @@
|
||||||
</block>
|
</block>
|
||||||
</swiper>
|
</swiper>
|
||||||
</view>
|
</view>
|
||||||
<swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="3000">
|
<swiper class="swiper_container1" vertical="true" autoplay="true" circular="true" interval="3000">
|
||||||
<block wx:for="{{msgList}}" wx:key="title">
|
<block wx:for="{{msgList}}" wx:key="title">
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<view class="swiper_item">{{item.title}}</view>
|
<view class="swiper_item1">{{item.title}}</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</block>
|
</block>
|
||||||
</swiper>
|
</swiper>
|
||||||
<view class="weui-cells weui-cells_after-title">
|
<view class="weui-cells weui-cells_after-title">
|
||||||
<navigator url="/pages/quota/quota" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
<navigator url="/pages/quota/quota" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||||
<view class="weui-cell__hd">
|
<view class="weui-cell__hd">
|
||||||
<image src="/images/quota.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
<image src="/images/quota.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-cell__bd">考试名额监控</view>
|
<view class="weui-cell__bd">考试名额监控</view>
|
||||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red" >
|
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red">
|
||||||
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
||||||
</view>
|
</view>
|
||||||
</navigator>
|
</navigator>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-cells weui-cells_after-title">
|
<view class="weui-cells weui-cells_after-title">
|
||||||
<view class="weui-grids">
|
<view class="weui-grids">
|
||||||
<a class="weui-grid" bindtap="goLianxi">
|
<a class="weui-grid" bindtap="goLianxi">
|
||||||
|
@ -55,13 +57,13 @@
|
||||||
<view class="weui-grid__label">自助模考</view>
|
<view class="weui-grid__label">自助模考</view>
|
||||||
</a>
|
</a>
|
||||||
<a class="weui-grid" bindtap="goYati">
|
<a class="weui-grid" bindtap="goYati">
|
||||||
<view class="weui-grid__icon" >
|
<view class="weui-grid__icon">
|
||||||
<image src="/images/yati.svg" alt></image>
|
<image src="/images/yati.svg" alt></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-grid__label">押卷模考</view>
|
<view class="weui-grid__label">押卷模考</view>
|
||||||
</a>
|
</a>
|
||||||
<a class="weui-grid" bindtap="testList">
|
<a class="weui-grid" bindtap="testList">
|
||||||
<view class="weui-grid__icon" >
|
<view class="weui-grid__icon">
|
||||||
<image src="/images/ksjl.svg" alt></image>
|
<image src="/images/ksjl.svg" alt></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-grid__label">考试记录</view>
|
<view class="weui-grid__label">考试记录</view>
|
||||||
|
@ -69,8 +71,8 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view style="margin-top:6px">
|
<view style="margin-top:6px">
|
||||||
<!-- <a class="weui-btn weui-btn_primary" bindtap="Baoming" >前往正式报名</a> -->
|
<!-- <a class="weui-btn weui-btn_primary" bindtap="Baoming" >前往正式报名</a> -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
|
@ -1,10 +1,10 @@
|
||||||
.swiper_container {
|
.swiper_container1 {
|
||||||
margin-top:12rpx;
|
margin-top:12rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center
|
text-align: center
|
||||||
}
|
}
|
||||||
.swiper_item {
|
.swiper_item1 {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color:darkblue;
|
color:darkblue;
|
||||||
|
|
|
@ -2,6 +2,7 @@ from rbac.permission import RbacPermission
|
||||||
from rbac.models import UserProfile
|
from rbac.models import UserProfile
|
||||||
from crm.models import Consumer
|
from crm.models import Consumer
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
# 学员接口列表
|
# 学员接口列表
|
||||||
ConsumerPerms = [
|
ConsumerPerms = [
|
||||||
|
@ -20,6 +21,10 @@ VistorPerms = [
|
||||||
'questioncat_view',
|
'questioncat_view',
|
||||||
'my_examtest',
|
'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):
|
class MyPermission(RbacPermission):
|
||||||
|
|
||||||
|
@ -37,10 +42,10 @@ class MyPermission(RbacPermission):
|
||||||
# perms = get_permission_list(request.user)
|
# perms = get_permission_list(request.user)
|
||||||
return True
|
return True
|
||||||
elif isinstance(request.user,Consumer):
|
elif isinstance(request.user,Consumer):
|
||||||
if request.user.workscope:
|
if cache.get(request.user.username + '__perms'):
|
||||||
perms = ConsumerPerms
|
perms = cache.get(request.user.username + '__perms')
|
||||||
else:
|
else:
|
||||||
perms = VistorPerms
|
perms = get_consumerperm_list(request.user)
|
||||||
if perms:
|
if perms:
|
||||||
if not hasattr(view, 'perms_map'):
|
if not hasattr(view, 'perms_map'):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from .models import Company, Consumer, PaySubject, ConsumerPerm, ConsumerRole
|
from .models import Company, Consumer, PaySubject, ConsumerPerm, ConsumerRole
|
||||||
from question.models import Question, Questioncat
|
from question.models import Question, Questioncat
|
||||||
|
from .permission import get_consumerperm_list
|
||||||
|
|
||||||
|
|
||||||
class ConsumerPermSerializer(serializers.ModelSerializer):
|
class ConsumerPermSerializer(serializers.ModelSerializer):
|
||||||
|
@ -35,7 +35,7 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
||||||
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
||||||
workscope_name = serializers.StringRelatedField(source='workscope', read_only=True)
|
workscope_name = serializers.StringRelatedField(source='workscope', read_only=True)
|
||||||
role_name = serializers.StringRelatedField(source='role', read_only=True)
|
role_name = serializers.StringRelatedField(source='role', read_only=True)
|
||||||
|
perms = serializers.SerializerMethodField(read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Consumer
|
model = Consumer
|
||||||
exclude = ('avatar','collects')
|
exclude = ('avatar','collects')
|
||||||
|
@ -46,3 +46,6 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
||||||
queryset = queryset.select_related('company','workscope')
|
queryset = queryset.select_related('company','workscope')
|
||||||
queryset = queryset.prefetch_related('subjects',)
|
queryset = queryset.prefetch_related('subjects',)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
def get_perms(self,obj):
|
||||||
|
return get_consumerperm_list(obj)
|
|
@ -293,9 +293,11 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
@action(methods=['get'], detail=False,
|
@action(methods=['get'], detail=False,
|
||||||
url_path='correctrole', url_name='correct_role', perms_map=[{'*':'correct_role'}])
|
url_path='correctrole', url_name='correct_role', perms_map=[{'*':'correct_role'}])
|
||||||
def correctrole(self, request):
|
def correctrole(self, request):
|
||||||
|
role0 = ConsumerRole.objects.get(name='游客')
|
||||||
role1 = ConsumerRole.objects.get(name='付费学员')
|
role1 = ConsumerRole.objects.get(name='付费学员')
|
||||||
role2 = 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:
|
if i.workscope and i.username:
|
||||||
i.role = role1
|
i.role = role1
|
||||||
elif i.username and i.openid:
|
elif i.username and i.openid:
|
||||||
|
|
|
@ -101,7 +101,7 @@ class QuestionViewSet(ModelViewSet):
|
||||||
ordering = ['-create_time']
|
ordering = ['-create_time']
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_fields = ['questioncat','level', 'type']
|
filterset_fields = ['questioncat','level', 'type']
|
||||||
search_fields = ['^name']
|
search_fields = ['name', 'options', 'resolution']
|
||||||
|
|
||||||
@action(methods=['post'], detail=False,
|
@action(methods=['post'], detail=False,
|
||||||
url_path='count', url_name='question_count')
|
url_path='count', url_name='question_count')
|
||||||
|
|
Loading…
Reference in New Issue