diff --git a/test_mini/app.js b/test_mini/app.js index 1320ac0..1079cc5 100644 --- a/test_mini/app.js +++ b/test_mini/app.js @@ -31,6 +31,14 @@ App({ }) } } + }).then(res=>{ + api.request('/crm/consumer/process/', 'GET').then(res => { + for (var key in res.data) { + try { + wx.setStorageSync(key, res.data.key) + } catch (e) { } + } + }) }) } }) @@ -57,9 +65,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:8011', + 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 e8701cf..2648df4 100644 --- a/test_mini/app.json +++ b/test_mini/app.json @@ -24,7 +24,9 @@ "pages/article/detail", "pages/quota/quota", "pages/material/index", - "pages/question/detail" + "pages/question/detail", + "pages/candidate/index", + "pages/candidate/form.js" ], "window": { "backgroundTextStyle": "light", @@ -71,7 +73,7 @@ "usingComponents": { "l-toast": "/miniprogram_npm/lin-ui/toast/index", "l-message": "/miniprogram_npm/lin-ui/message/index", - "l-button":"/miniprogram_npm/lin-ui/button/index" + "l-button": "/miniprogram_npm/lin-ui/button/index" }, "style": "v2", "sitemapLocation": "sitemap.json" diff --git a/test_mini/images/candidate.svg b/test_mini/images/candidate.svg new file mode 100644 index 0000000..156861e --- /dev/null +++ b/test_mini/images/candidate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test_mini/pages/candidate/form.js.js b/test_mini/pages/candidate/form.js.js new file mode 100644 index 0000000..fea1ff8 --- /dev/null +++ b/test_mini/pages/candidate/form.js.js @@ -0,0 +1,66 @@ +// pages/candidate/form.js.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + 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/candidate/form.js.json b/test_mini/pages/candidate/form.js.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/test_mini/pages/candidate/form.js.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/test_mini/pages/candidate/form.js.wxml b/test_mini/pages/candidate/form.js.wxml new file mode 100644 index 0000000..7c13e38 --- /dev/null +++ b/test_mini/pages/candidate/form.js.wxml @@ -0,0 +1,2 @@ + +pages/candidate/form.js.wxml diff --git a/test_mini/pages/candidate/form.js.wxss b/test_mini/pages/candidate/form.js.wxss new file mode 100644 index 0000000..5a8cce2 --- /dev/null +++ b/test_mini/pages/candidate/form.js.wxss @@ -0,0 +1 @@ +/* pages/candidate/form.js.wxss */ \ No newline at end of file diff --git a/test_mini/pages/candidate/index.js b/test_mini/pages/candidate/index.js new file mode 100644 index 0000000..a9d03b8 --- /dev/null +++ b/test_mini/pages/candidate/index.js @@ -0,0 +1,69 @@ +// pages/candidate/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + form:{ + ID_number:null, + realname:null + } + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + 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/candidate/index.json b/test_mini/pages/candidate/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/test_mini/pages/candidate/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/test_mini/pages/candidate/index.wxml b/test_mini/pages/candidate/index.wxml new file mode 100644 index 0000000..6624cd2 --- /dev/null +++ b/test_mini/pages/candidate/index.wxml @@ -0,0 +1,2 @@ + +pages/candidate/index.wxml diff --git a/test_mini/pages/candidate/index.wxss b/test_mini/pages/candidate/index.wxss new file mode 100644 index 0000000..a7ac3f3 --- /dev/null +++ b/test_mini/pages/candidate/index.wxss @@ -0,0 +1 @@ +/* pages/candidate/index.wxss */ \ No newline at end of file diff --git a/test_mini/pages/cuoti/index.wxml b/test_mini/pages/cuoti/index.wxml index a8aead1..253f8ed 100644 --- a/test_mini/pages/cuoti/index.wxml +++ b/test_mini/pages/cuoti/index.wxml @@ -13,9 +13,6 @@ {{currentTm.type}} {{currentTm.questioncat_name}} - - {{currentTm.dtime}} - {{currentTm.name}} diff --git a/test_mini/pages/lianxi/index.js b/test_mini/pages/lianxi/index.js index c5b1647..043f891 100644 --- a/test_mini/pages/lianxi/index.js +++ b/test_mini/pages/lianxi/index.js @@ -14,7 +14,6 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function () { - if (getApp().globalData.userinfo.workscope) { this.setData({ workscopeId: getApp().globalData.userinfo.workscope @@ -24,7 +23,6 @@ Page({ url: '/pages/main/main', }) } - }, /** @@ -79,14 +77,30 @@ Page({ * 生命周期函数--监听页面隐藏 */ onHide: function () { - + }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { - + var process = {} + try { + const res = wx.getStorageInfoSync() + const keys = res.keys + console.log(keys) + for(var i=0;i { + }) }, /** diff --git a/test_mini/pages/lianxi/main.js b/test_mini/pages/lianxi/main.js index a5b4abc..200a5b9 100644 --- a/test_mini/pages/lianxi/main.js +++ b/test_mini/pages/lianxi/main.js @@ -8,6 +8,7 @@ Page({ */ data: { questioncat: null, + tm_current:null, tms: [], ydtms: [], ctms: [], @@ -44,7 +45,9 @@ Page({ if (value) { that.data.ydtms = value } - } catch (e) {} + } catch (e) { + + } try { var value = wx.getStorageSync('ctms') if (value) { @@ -137,15 +140,18 @@ Page({ showTm: function(index) { var that = this - var tm_current = that.data.tms[index] - that.setData({ - 'tm_index': index, - 'tm_current': tm_current - }) - that.showOptions() - if (tm_current.user_answer) { - that.showAnswer() + if(index{{to_read}}条未读 --> + + + + + 证书查询 + + + + @@ -42,12 +51,14 @@ 错题集 + {{wrongnum}} 收藏集 + {{collectnum}} diff --git a/test_mini/pages/test/detail.js b/test_mini/pages/test/detail.js index 524f623..2a072fe 100644 --- a/test_mini/pages/test/detail.js +++ b/test_mini/pages/test/detail.js @@ -7,7 +7,8 @@ Page({ */ data: { tm_index:0, - results:[] + results:[], + tm_current:null }, /** @@ -87,12 +88,15 @@ Page({ }, showTm: function (index) { var that = this - var tm_current = that.data.results[index] - that.setData({ - 'tm_index': index, - 'tm_current': tm_current - }) - that.showOptions() + if(index{{took}} {{took}} - 秒 diff --git a/test_mini/project.config.json b/test_mini/project.config.json index cf4b6c2..ff08581 100644 --- a/test_mini/project.config.json +++ b/test_mini/project.config.json @@ -23,9 +23,9 @@ "disablePlugins": [], "outputPath": "" }, - "useCompilerModule": true, - "userConfirmedUseCompilerModuleSwitch": false, - "useIsolateContext": true + "useIsolateContext": true, + "useCompilerModule": false, + "userConfirmedUseCompilerModuleSwitch": false }, "compileType": "miniprogram", "libVersion": "2.10.3", diff --git a/test_mini/utils/request.js b/test_mini/utils/request.js index 4c86143..992e769 100644 --- a/test_mini/utils/request.js +++ b/test_mini/utils/request.js @@ -18,7 +18,10 @@ function request(url, method, data) { }) } else { - var msg = JSON.stringify(res.data.msg) + var msg = '' + if(res.data.msg){ + msg = JSON.stringify(res.data.msg) + } if (msg.indexOf('该操作的权限')!=-1){ msg = '权限不足,请注册登陆或联系课程顾问' } diff --git a/test_mini/utils/util.js b/test_mini/utils/util.js index 2cbf163..c5ce85b 100644 --- a/test_mini/utils/util.js +++ b/test_mini/utils/util.js @@ -24,6 +24,12 @@ function formatmil(mil) { s = toTow(s); return h + ":" + m + ":" + s; } +function formatSecond(val) { + var m = Math.floor(val/ 60) + var s = Math.floor(val - m * 60) + return m + '分' + s + '秒' +} + function toTow(num) { if (num < 10) { return "0" + num; @@ -34,5 +40,6 @@ function toTow(num) { module.exports = { formatTime: formatTime, - formatmil: formatmil + formatmil: formatmil, + formatSecond: formatSecond } diff --git a/test_server/cms/views.py b/test_server/cms/views.py index 600f5b4..86ba268 100644 --- a/test_server/cms/views.py +++ b/test_server/cms/views.py @@ -68,7 +68,7 @@ class MaterialViewSet(ModelViewSet): filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter] search_fields = ['name','description'] ordering_fields = ['update_time', 'down_count'] - ordering = ['-update_time'] + ordering = ['-down_count'] @action(methods=['get'], detail=True, url_name='down_material', perms_map=[{'*':'down_material'}]) def down(self, request, *args, **kwargs): diff --git a/test_server/crm/migrations/0017_consumer_process.py b/test_server/crm/migrations/0017_consumer_process.py new file mode 100644 index 0000000..393973e --- /dev/null +++ b/test_server/crm/migrations/0017_consumer_process.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.5 on 2020-08-01 07:36 + +import django.contrib.postgres.fields.jsonb +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0016_consumer_role'), + ] + + operations = [ + migrations.AddField( + model_name='consumer', + name='process', + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default={}, verbose_name='练习进度'), + ), + ] diff --git a/test_server/crm/migrations/0018_auto_20200801_1537.py b/test_server/crm/migrations/0018_auto_20200801_1537.py new file mode 100644 index 0000000..58fbbc6 --- /dev/null +++ b/test_server/crm/migrations/0018_auto_20200801_1537.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.5 on 2020-08-01 07:37 + +import django.contrib.postgres.fields.jsonb +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0017_consumer_process'), + ] + + operations = [ + migrations.AlterField( + model_name='consumer', + name='process', + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, verbose_name='练习进度'), + ), + ] diff --git a/test_server/crm/migrations/0019_auto_20200802_0931.py b/test_server/crm/migrations/0019_auto_20200802_0931.py new file mode 100644 index 0000000..b99effb --- /dev/null +++ b/test_server/crm/migrations/0019_auto_20200802_0931.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.5 on 2020-08-02 01:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('crm', '0018_auto_20200801_1537'), + ] + + operations = [ + migrations.AddField( + model_name='consumer', + name='ID_number', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='身份证号'), + ), + migrations.AddField( + model_name='consumer', + name='realname', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='真实姓名'), + ), + ] diff --git a/test_server/crm/models.py b/test_server/crm/models.py index 7880d23..0027b2c 100644 --- a/test_server/crm/models.py +++ b/test_server/crm/models.py @@ -3,6 +3,7 @@ import django.utils.timezone as timezone from rbac.models import SoftCommonModel, CommonModel from question.models import Questioncat, Question from examtest.models_paper import WorkScope +from django.contrib.postgres.fields import JSONField # Create your models here. class Company(CommonModel): @@ -61,10 +62,15 @@ class Consumer(CommonModel): nickname = models.CharField(max_length=200, verbose_name='昵称', null=True, blank=True) subjects = models.ManyToManyField(Questioncat, verbose_name='付费学科', through='PaySubject') workscope = models.ForeignKey(WorkScope, verbose_name='工作类别', on_delete=models.SET_NULL, null=True, blank=True) - collects = models.ManyToManyField(Question, verbose_name='收藏试题') remain_count = models.IntegerField('体验次数', default=3) role = models.ForeignKey(ConsumerRole, verbose_name='用户角色', default=1, on_delete=models.SET_NULL, null=True, blank=True) + collects = models.ManyToManyField(Question, verbose_name='收藏试题') + process = JSONField('练习进度', blank=True, default=dict) + + ID_number = models.CharField('身份证号', max_length=100, null=True, blank=True) + realname = models.CharField('真实姓名', max_length=100, null=True, blank=True) + class Meta: verbose_name = '客户' diff --git a/test_server/crm/serializers.py b/test_server/crm/serializers.py index 9f916c9..54a20aa 100644 --- a/test_server/crm/serializers.py +++ b/test_server/crm/serializers.py @@ -37,7 +37,7 @@ class ConsumerSerializer(serializers.ModelSerializer): role_name = serializers.StringRelatedField(source='role', read_only=True) class Meta: model = Consumer - exclude = ('avatar','collects') + exclude = ('avatar','collects', 'process') @staticmethod def setup_eager_loading(queryset): diff --git a/test_server/crm/views.py b/test_server/crm/views.py index 21edbb8..348087b 100644 --- a/test_server/crm/views.py +++ b/test_server/crm/views.py @@ -209,6 +209,22 @@ class ConsumerViewSet(ModelViewSet): else: return Response({'error':'delete参数错误'}) + @action(methods=['get', 'put'], detail=False, + url_path='process', url_name='exercise_process', perms_map=[{'*':'*'}]) + def process(self, request): + ''' + 练习进度 + ''' + if request.method == 'GET': + process = {} + if hasattr(request.user, 'process'): + process = request.user.process + return Response({'process':process}) + elif request.method == 'PUT': + 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='import', url_name='import_consumer')