From f62731e1a39618062bb3e1169cb6181ae2e6f0c2 Mon Sep 17 00:00:00 2001 From: educoder_weapp Date: Tue, 28 Apr 2020 12:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=99=E5=B8=88=E5=8A=A0=E5=85=A5=E8=AF=BE?= =?UTF-8?q?=E5=A0=82=E5=AE=A1=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 7 +++ miniprogram/app.json | 13 ++-- .../modal/join-course/join-course.js | 2 +- miniprogram/components/rich-md/rich-md.js | 13 ++-- .../components/tiding-item/tiding-item.js | 6 ++ miniprogram/config.js | 2 +- .../components/index-list/index-list.js | 4 +- .../activity/activity_item/activity_item.js | 19 +++++- .../course/modules/students/students.js | 10 +-- .../course/modules/students/students.json | 3 +- .../course/modules/students/students.wxml | 4 +- .../teachers/teacher-item/teacher-item.js | 18 ++++-- .../teachers/teacher-item/teacher-item.json | 4 +- .../teachers/teacher-item/teacher-item.wxml | 4 +- .../course/modules/teachers/teachers.js | 16 +++-- .../course/modules/teachers/teachers.json | 1 + .../course/modules/teachers/teachers.wxml | 13 ++-- .../course/modules/teachers/teachers.wxss | 4 ++ .../teacher_apply/apply-item/apply-item.js | 33 ++++++++++ .../teacher_apply/apply-item/apply-item.json | 4 ++ .../teacher_apply/apply-item/apply-item.wxml | 11 ++++ .../teacher_apply/apply-item/apply-item.wxss | 48 ++++++++++++++ .../pages/teacher_apply/teacher_apply.js | 28 +++++++++ .../pages/teacher_apply/teacher_apply.json | 6 ++ .../pages/teacher_apply/teacher_apply.wxml | 8 +++ .../pages/teacher_apply/teacher_apply.wxss | 14 +++++ miniprogram/js/apiConfig.js | 2 +- miniprogram/js/utils.js | 28 ++++++++- miniprogram/pages/home/home.wxml | 2 +- miniprogram/task/pages/task/task.js | 62 +++++++++++++++---- miniprogram/task/pages/task/task.json | 3 +- miniprogram/task/pages/task/task.wxml | 1 + project.config.json | 11 +++- 33 files changed, 346 insertions(+), 58 deletions(-) create mode 100644 miniprogram/course/pages/teacher_apply/apply-item/apply-item.js create mode 100644 miniprogram/course/pages/teacher_apply/apply-item/apply-item.json create mode 100644 miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxml create mode 100644 miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxss create mode 100644 miniprogram/course/pages/teacher_apply/teacher_apply.js create mode 100644 miniprogram/course/pages/teacher_apply/teacher_apply.json create mode 100644 miniprogram/course/pages/teacher_apply/teacher_apply.wxml create mode 100644 miniprogram/course/pages/teacher_apply/teacher_apply.wxss diff --git a/changelog.md b/changelog.md index 52767a2..ea30f03 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +## v0.15.1 + * A 教师加入课堂审批 + * A 熬夜睡觉提醒 + * A markdown中URL链接解析与跳转 + * F index-list滑动与窗口滚动冲突 + * F 加入课堂时多身份bug + ## v0.15.0 * A 实训关卡黑暗模式 * A 学生管理模块 diff --git a/miniprogram/app.json b/miniprogram/app.json index 96282d5..d01a7e6 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -42,7 +42,9 @@ "pages/course_invite/course_invite", "pages/attendance_detail/attendance_detail", "modules/attendance/attendance", - "pages/attendances/attendances" + "modules/students/students", + "pages/attendances/attendances", + "pages/teacher_apply/teacher_apply" ] }, { @@ -82,10 +84,11 @@ "pages": [ "search" ] - },{ - "name":"feedback", - "root":"pages/feedback", - "pages":[ + }, + { + "name": "feedback", + "root": "pages/feedback", + "pages": [ "feedback" ] } diff --git a/miniprogram/components/modal/join-course/join-course.js b/miniprogram/components/modal/join-course/join-course.js index 8f82d5e..1d9c6f0 100644 --- a/miniprogram/components/modal/join-course/join-course.js +++ b/miniprogram/components/modal/join-course/join-course.js @@ -93,7 +93,7 @@ Component({ }) }, cancel() { - this.setData({ hidden: true,invite_code:'', assistant_professor:0, student:0, assistant_professor:0 }); + this.setData({ hidden: true,invite_code:'', assistant_professor:"", student:"", assistant_professor:"" }); }, onTapButton({detail:{index}}){ if(index==0) diff --git a/miniprogram/components/rich-md/rich-md.js b/miniprogram/components/rich-md/rich-md.js index a486b61..572424e 100644 --- a/miniprogram/components/rich-md/rich-md.js +++ b/miniprogram/components/rich-md/rich-md.js @@ -1,5 +1,6 @@ if (!global.towxml) global.towxml = require('../../towxml/index'); +import {navigateToUrl} from "../../js/utils"; Component({ externalClasses: ['my-class',"class"], @@ -49,14 +50,18 @@ Component({ methods: { handleTap(e){ //console.log(this.data); - console.log("handleTap",e, this.data,this); - var {target:{dataset:{data}}} = e; + console.log("handleTap",e); + var {target:{dataset:{data}},currentTarget:{dataset:{data:_data}}} = e; var key = "RICHMDKEY"; - //console.log(data); + //console.log(_data); + let {tag, attr} = _data; + if(tag=='navigator'&&attr.href) + navigateToUrl({url: attr.href}); + //this.triggerEvent('click',{},{bubbles:true}); if(data&&data._e.tag=="code") data={attr:{class:"h2w__pre"},child:[data],tag:"view",type:"tag",_e:{type:"tag",attr:{},tag:"pre", child:[data]}} if(data&&data._e.tag=='pre'){ - data = {theme:this.data.theme,child:[data],_e:{child:[data]}} + data = {theme:'light',child:[data],_e:{child:[data]}} wx.setStorage({ key,data,success:res=>{ wx.navigateTo({ diff --git a/miniprogram/components/tiding-item/tiding-item.js b/miniprogram/components/tiding-item/tiding-item.js index e53f681..2538980 100644 --- a/miniprogram/components/tiding-item/tiding-item.js +++ b/miniprogram/components/tiding-item/tiding-item.js @@ -10,6 +10,12 @@ const ROUTE = { __:"{course}?module_type=common_homework&course_id=${belong_container_id}", practice: "{shixun_homework}?homework_id=${container_id}" }, + JoinCourse:{ + __:"{teacher_apply}?course_id=${belong_container_id}" + }, + StudentJoinCourse:{ + __:"{students}?course_id=${belong_container_id}&course_identity=2" + }, StudentWork:{ __:"{course}?module_type=common_homework&course_id=${belong_container_id}", } diff --git a/miniprogram/config.js b/miniprogram/config.js index 22ab99f..883ce2f 100644 --- a/miniprogram/config.js +++ b/miniprogram/config.js @@ -5,7 +5,7 @@ const developUrl = "https://test-newweb.educoder.net"; const trialUrl = "https://pre-newweb.educoder.net"; const releaseUrl = "https://www.educoder.net"; -let _version = "0.15.0"; +let _version = "0.15.1"; var eduUrl = releaseUrl; /** */ diff --git a/miniprogram/course/components/index-list/index-list.js b/miniprogram/course/components/index-list/index-list.js index 218e7d6..3ad6ee2 100644 --- a/miniprogram/course/components/index-list/index-list.js +++ b/miniprogram/course/components/index-list/index-list.js @@ -92,7 +92,7 @@ Component({ _scrollTo: function _scrollTo(e) { var data = this.data; var clientY = e.changedTouches[0].clientY; - console.log(clientY); + //console.log(clientY); var index = Math.floor((clientY - data._anchorTop) / data._anchorItemH); if(index<0||index>=data.alphabet.length) return; @@ -131,6 +131,8 @@ Component({ this.__onScroll(e); }, _onScroll: function _onScroll(e) { + if(this.data.touching) + return; var data = this.data; var _tops = data._tops, alphabet = data.alphabet; diff --git a/miniprogram/course/modules/activity/activity_item/activity_item.js b/miniprogram/course/modules/activity/activity_item/activity_item.js index 4e04b65..dee534d 100644 --- a/miniprogram/course/modules/activity/activity_item/activity_item.js +++ b/miniprogram/course/modules/activity/activity_item/activity_item.js @@ -28,7 +28,11 @@ const configMap={ CourseMessage: { type:"课堂申请", text:"申请加入课堂", - color:"#3333FF" + color:"#3333FF", + url:"{teacher_apply}?course_id=${course_id}", + cd:[ + {key:"course_identity", value:[2]} + ] }, Course: { type:"创建课堂", @@ -67,10 +71,19 @@ Component({ }, methods: { onTap(){ - let {url} = this.config; + //console.log(this.config); + let url = this.config.url; + let cd = this.config.cd; + //console.log(url, cd); if(!url) return; + if(cd){ + for(var i of cd){ + if(i.value.indexOf(this.data[i.key])==-1) + return; + } + } url = format(url, this.data); - console.log(url); + console.log(url, this.data); app.navigateTo({url}); } } diff --git a/miniprogram/course/modules/students/students.js b/miniprogram/course/modules/students/students.js index 3fbc133..728dc37 100644 --- a/miniprogram/course/modules/students/students.js +++ b/miniprogram/course/modules/students/students.js @@ -20,9 +20,7 @@ Component({ }, attached(){ - let {course_id, course_identity} = this.data; - let ext = {course_id, course_identity}; - this.setData({ext}); + this.refresh(); }, @@ -31,12 +29,14 @@ Component({ console.log(e); }, refresh(){ - let {course_id} = this.data; + let {course_id, course_identity} = this.data; app.api("weapps.courses.students")({course_id,limit:1000}).then(res=>{ console.log(res); let {students,students_count} = res; this.setData({students,students_count}); - }) + }); + let ext = {course_id, course_identity}; + this.setData({ext}); } } }) diff --git a/miniprogram/course/modules/students/students.json b/miniprogram/course/modules/students/students.json index 1fc8cfc..e5afcf9 100644 --- a/miniprogram/course/modules/students/students.json +++ b/miniprogram/course/modules/students/students.json @@ -3,5 +3,6 @@ "usingComponents": { "mp-index-list":"../../components/index-list/index-list", "student-item":"./student-item/student-item" - } + }, + "navigationBarTitleText": "学生管理" } \ No newline at end of file diff --git a/miniprogram/course/modules/students/students.wxml b/miniprogram/course/modules/students/students.wxml index f274c7b..9f73bfa 100644 --- a/miniprogram/course/modules/students/students.wxml +++ b/miniprogram/course/modules/students/students.wxml @@ -1,10 +1,10 @@ - + 学生人数: {{students_count}} - + diff --git a/miniprogram/course/modules/teachers/teacher-item/teacher-item.js b/miniprogram/course/modules/teachers/teacher-item/teacher-item.js index 74b98f5..4a3b124 100644 --- a/miniprogram/course/modules/teachers/teacher-item/teacher-item.js +++ b/miniprogram/course/modules/teachers/teacher-item/teacher-item.js @@ -16,16 +16,26 @@ Component({ let {course_id} = this.data.ext; let {course_member_id} = this.data.data; console.log(course_id, course_member_id); - let students = [{course_member_id}]; - app.api("courses.delete_from_course")({course_id,students}) + let teachers = [{course_member_id}]; + app.api("courses.delete_course_teacher")({course_id,course_member_id}) .then(res=>{ this.triggerEvent("delete",{},{bubbles:true,composed:true}); - //console.log(res); - //res.message='删除成功'; app.showMsg(res); }).catch(e=>{ app.showError(e); }) + }, + onButtonTap(e){ + //console.log(e,this.data); + wx.showModal({ + title:"提示", + content:"确认删除所选教师吗?", + success:res=>{ + if(res.confirm){ + this.delete(); + } + } + }) } } }) diff --git a/miniprogram/course/modules/teachers/teacher-item/teacher-item.json b/miniprogram/course/modules/teachers/teacher-item/teacher-item.json index e8cfaaf..cbf84d2 100644 --- a/miniprogram/course/modules/teachers/teacher-item/teacher-item.json +++ b/miniprogram/course/modules/teachers/teacher-item/teacher-item.json @@ -1,4 +1,6 @@ { "component": true, - "usingComponents": {} + "usingComponents": { + "mp-slideview": "/weui-miniprogram/slideview/slideview" + } } \ No newline at end of file diff --git a/miniprogram/course/modules/teachers/teacher-item/teacher-item.wxml b/miniprogram/course/modules/teachers/teacher-item/teacher-item.wxml index 313ba8b..4565b31 100644 --- a/miniprogram/course/modules/teachers/teacher-item/teacher-item.wxml +++ b/miniprogram/course/modules/teachers/teacher-item/teacher-item.wxml @@ -1,7 +1,9 @@ + {{data.name}} {{data.school}} - \ No newline at end of file + + \ No newline at end of file diff --git a/miniprogram/course/modules/teachers/teachers.js b/miniprogram/course/modules/teachers/teachers.js index 51b6da2..0061489 100644 --- a/miniprogram/course/modules/teachers/teachers.js +++ b/miniprogram/course/modules/teachers/teachers.js @@ -20,23 +20,27 @@ Component({ }, attached(){ - let {course_id, course_identity} = this.data; - let ext = {course_id, course_identity}; - this.setData({ext}); this.refresh(); }, + pageLifetimes: { + show: function () { + this.refresh(); + } + }, methods: { onChoose(e){ console.log(e); }, refresh(){ - let {course_id} = this.data; + let {course_id,course_identity} = this.data; app.api("weapps.courses.teachers")({course_id,limit:1000}).then(res=>{ console.log(res); - let {teacher_list:teachers,teacher_list_size:teachers_count} = res; - this.setData({teachers,teachers_count}); + let {teacher_list, teacher_list_size, apply_size} = res; + this.setData({teacher_list, teacher_list_size, apply_size}); }) + let ext = {course_id, course_identity}; + this.setData({ext}); } } }) diff --git a/miniprogram/course/modules/teachers/teachers.json b/miniprogram/course/modules/teachers/teachers.json index 3f6bbb5..93c0ce1 100644 --- a/miniprogram/course/modules/teachers/teachers.json +++ b/miniprogram/course/modules/teachers/teachers.json @@ -2,6 +2,7 @@ "component": true, "usingComponents": { "mp-index-list":"../../components/index-list/index-list", + "mp-badge": "/weui-miniprogram/badge/badge", "teacher-item":"./teacher-item/teacher-item" } } \ No newline at end of file diff --git a/miniprogram/course/modules/teachers/teachers.wxml b/miniprogram/course/modules/teachers/teachers.wxml index a85937d..c5e5c14 100644 --- a/miniprogram/course/modules/teachers/teachers.wxml +++ b/miniprogram/course/modules/teachers/teachers.wxml @@ -1,11 +1,12 @@ - + 教师人数: - {{teachers_count}} + {{teacher_list_size}} + + + 待审批({{apply_size}}) + - - - - + \ No newline at end of file diff --git a/miniprogram/course/modules/teachers/teachers.wxss b/miniprogram/course/modules/teachers/teachers.wxss index 8c91318..54febdf 100644 --- a/miniprogram/course/modules/teachers/teachers.wxss +++ b/miniprogram/course/modules/teachers/teachers.wxss @@ -9,3 +9,7 @@ justify-content: space-between; align-items: center; } +.apply-text{ + font-size: 14px; + margin-left: 6px; +} \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/apply-item/apply-item.js b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.js new file mode 100644 index 0000000..7f54643 --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.js @@ -0,0 +1,33 @@ +const app = getApp(); +Component({ + properties: { + data:Object, + course_id:Number + }, + data: { + eduImgDir: global.config.eduImgDir + }, + methods: { + review_application({approval}){ + let {application_id, user_id} = this.data.data; + let {course_id} = this.data; + app.api("courses.teacher_application_review")({course_id, approval, application_id, user_id}) + .then(res=>{ + this.triggerEvent("review",{},{bubbles:true}); + console.log(res); + res.message = approval==1?'已同意':approval==2?'已拒绝':res.message; + app.showMsg(res); + }).catch(e=>{ + app.showError(e); + }) + }, + approval(e){ + console.log(e); + this.review_application({approval:1}); + }, + deny(e){ + console.log(e); + this.review_application({approval:2}); + } + } +}) diff --git a/miniprogram/course/pages/teacher_apply/apply-item/apply-item.json b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxml b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxml new file mode 100644 index 0000000..aa49614 --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxml @@ -0,0 +1,11 @@ + + + + {{data.name}} + {{data.school_name}} + + + + + + \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxss b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxss new file mode 100644 index 0000000..7fbc709 --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/apply-item/apply-item.wxss @@ -0,0 +1,48 @@ +.apply-body{ + display: flex; + padding: 12px; + align-items: center; +} +.avatar{ + width: 44px; + height: 44px; + border-radius: 50%; + flex: none; +} +.detail{ + margin-left: 12px; + flex: auto; +} +.school{ + color: dimgray; + font-size: 14px; +} +.opertions{ + flex: none; +} +.opertion{ + transform: scale(0.8); +} +.thin-border-bottom { + position: relative +} + +.thin-border-bottom::after { + content: ""; + position: absolute; + left: 0; + bottom: 0; + right: 0; + height: 1px; + border-bottom: 1px solid #EAEAEA; + color: #e5e5e5; + -webkit-transform-origin: 0 0; + transform-origin: 0 0; + -webkit-transform: scaleY(.5); + transform: scaleY(.5); + z-index: 2 +} + +.apply-body.thin-border-bottom::after{ + left: 64px; +} \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/teacher_apply.js b/miniprogram/course/pages/teacher_apply/teacher_apply.js new file mode 100644 index 0000000..338f51f --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/teacher_apply.js @@ -0,0 +1,28 @@ +const app = getApp(); +Page({ + + data: { + + }, + + onLoad: function (options) { + let {course_id} = options; + this.setData({course_id}); + this.refresh(); + }, + refresh(){ + let {course_id} = this.data; + app.api("courses.apply_teachers")({course_id}) + .then(res=>{ + console.log(res); + this.setData(res); + }).catch(e=>{ + app.showError(e); + }) + }, + + onShow: function () { + + } + +}) \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/teacher_apply.json b/miniprogram/course/pages/teacher_apply/teacher_apply.json new file mode 100644 index 0000000..1d40c6d --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/teacher_apply.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "apply-item":"./apply-item/apply-item" + }, + "navigationBarTitleText": "教师审批" +} \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/teacher_apply.wxml b/miniprogram/course/pages/teacher_apply/teacher_apply.wxml new file mode 100644 index 0000000..5ff2c88 --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/teacher_apply.wxml @@ -0,0 +1,8 @@ + + 待审批:{{apply_size}}人 + + + + + + \ No newline at end of file diff --git a/miniprogram/course/pages/teacher_apply/teacher_apply.wxss b/miniprogram/course/pages/teacher_apply/teacher_apply.wxss new file mode 100644 index 0000000..6eb68f2 --- /dev/null +++ b/miniprogram/course/pages/teacher_apply/teacher_apply.wxss @@ -0,0 +1,14 @@ +page{ + background: white; +} + +.header{ + padding: 12px; + background: white; + border-bottom: #dddddd 1.5px solid; +} + +.count{ + font-size: 14px; + margin-left: 12px; +} diff --git a/miniprogram/js/apiConfig.js b/miniprogram/js/apiConfig.js index 5013a76..55d77a2 100644 --- a/miniprogram/js/apiConfig.js +++ b/miniprogram/js/apiConfig.js @@ -164,7 +164,7 @@ weapps:{ }, basic_info:{url:"{course_id}/*",query,disp:"课堂基本信息"}, course_activities:{url:"{course_id}/*",query,form:{page:1, limit:20}}, - delete_course_teachers:{url:"{course_id}/*",query, form:{course_member_id:null},config:{method:"DELETE"}}, + delete_course_teachers:{url:"{course_id}/*",query, form:{course_member_ids:null},config:{method:"DELETE"}}, students: {url:"{course_id}/*", query, form:{page:1, limit: void 0}}, teachers: {url:"{course_id}/*", query, form:{page:1, limit: void 0}}, }, diff --git a/miniprogram/js/utils.js b/miniprogram/js/utils.js index 14c16df..3c4bd19 100644 --- a/miniprogram/js/utils.js +++ b/miniprogram/js/utils.js @@ -1,3 +1,4 @@ + export function deprecate(name=""){ try{ throw new Error(name + "这个方法或界面被弃用了"); @@ -69,7 +70,7 @@ export function getResConstruction(res = "") { export function processObj(obj) { for (var key in obj) { - if (!obj.hasOwnProperty(key) || typeof obj[key] != "object") + if (!obj.hasOwnProperty(key) || typeof obj[key] != "object" ||obj.constructor!=Object) continue processObj(obj[key]); obj[key].__proto__ = obj; @@ -209,4 +210,29 @@ export const accountManager = global.accountManager = new AccountManager(); export function getWXACodeUrl({url, scene}){ return global.config.imgDir + "wxacode/" + (url + "?" + scene).replace(/[\/?&]/g, "_") + ".jpeg"; +} +//https://www.educoder.net/shixuns/ac46rzbw/challenges/3481 +export function parseUrl({url}){ + var match = url.match(/https:\/\/www.educoder.net\/(.*)/); + if(!match) + return ''; + const route = match[1]; // 路径 + // case 1: + match = route.match(/shixuns\/(.*)\/challenges\/(.*)/); + if(match){ + var identifier = match[1] + return `{shixun}?identifier=${identifier}&cate_type=task` + } + return '' +} + +export function navigateToUrl({url,open_type='navigateTo'}){ + url = parseUrl({url}); + console.log(url); + const app = getApp(); + if(url){ + app.navigateTo({url}); + return true; + }else + return false; } \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index e8fc7b6..bd68e6e 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -32,7 +32,7 @@ - + EduCoder云网 推荐使用 diff --git a/miniprogram/task/pages/task/task.js b/miniprogram/task/pages/task/task.js index 5742e05..fdb773b 100644 --- a/miniprogram/task/pages/task/task.js +++ b/miniprogram/task/pages/task/task.js @@ -1,4 +1,5 @@ const app = getApp(); +import {navigateToUrl} from '../../../js/utils'; Page({ data: { theme: 'light', @@ -7,10 +8,46 @@ Page({ titles: ["任务描述", "代码文件", "测评结果"], can_use_editor:wx.canIUse("editor") }, - initTheme(){ + /*onTap(e){ + console.log(e); + let {detail:{tag, attr}} = e; + if(tag=='navigator'&&attr.href) + navigateToUrl({url: attr.href}); + //console.log(detail); + },*/ + checkTime(){ + if(this.timeChecked) + return; + let date = new Date(); + let hours = date.getHours(); + let min = date.getMinutes(); + if(hours>=0&&hours<=3||hours>=23&&min>=30){ + this.timeChecked = true; + let y = date.getFullYear(); + let m = date.getMonth(); + let d = date.getDate(); + if(hours>=23) + d += 1; + let t = y+'-'+m+'-'+d; + let key = 'task-show-go-to-sleep-last-time' + let last = wx.getStorageSync(key); + if(last==t) + return + this.setData({showGoToSleep:true}); + wx.reportAnalytics('show_go_to_sleep_in_task', {}); + wx.setStorageSync(key, t); + }else if(hours<=21){ + this.timeChecked = true; + } + }, + onTapTopTip(){ + this.setData({showGoToSleep:false}); + wx.reportAnalytics('tap_go_to_sleep', {}); + }, + setNavigationTheme(){ let {theme} = this.data; if(theme=='dark'){ - wx.setNavigationBarColor({backgroundColor:"#333333",frontColor:"#ffffff",animation:'linear'}); + wx.setNavigationBarColor({backgroundColor:"#303030",frontColor:"#ffffff",animation:'linear'}); }else{ wx.setNavigationBarColor({backgroundColor:"#fbfbfb",frontColor:"#000000",animation:"linear"}); } @@ -20,7 +57,7 @@ Page({ let {value} = detail; let theme = value?'dark':'light'; this.setData({theme}); - this.initTheme(); + this.setNavigationTheme(); wx.setStorageSync('config-task-theme', theme); }, enterTask(e){ @@ -52,9 +89,6 @@ Page({ if(this.modified) this.content = value; }, - addIndent(){ - this.editor.insertText({text:" "}); - }, onEditorInput(e){ let {text} = e.detail; //console.log(e.detail.text); @@ -152,13 +186,16 @@ Page({ }) }, 1000); }, - onSwiperChange({detail:{current,source}}){ + onSwiperChange(e){ + //console.log(e); + let {detail:{current,source}} = e; if(source=="touch"){ this.setData({current}); } if(current==1&&!this.content){ this.pullContent(); } + this.checkTime(); }, async pullTask(){ let {identifier} = this.data; @@ -168,7 +205,7 @@ Page({ }, async pullContent(){ - console.log("pullContent", this.editor); + //console.log("pullContent", this.editor); let {path} = this.data.challenge; path = this.processPath(path); let {identifier} = this.data; @@ -186,7 +223,7 @@ Page({ } }else this.setData({content}); - console.log("pullContent"); + //console.log("pullContent"); }, onEditorReady({pullContent=0}={}) { //console.log("editor-ready") @@ -204,12 +241,15 @@ Page({ //console.log("onload") let theme = wx.getStorageSync('config-task-theme'); this.setData({theme}); - this.initTheme(); + this.setNavigationTheme(); + let {identifier} = options; this.setData({identifier}); this.pullTask(); }, - + onReady(){ + this.checkTime(); + }, onHide: function () { this.updateFile(); }, diff --git a/miniprogram/task/pages/task/task.json b/miniprogram/task/pages/task/task.json index 0813de0..6be0469 100644 --- a/miniprogram/task/pages/task/task.json +++ b/miniprogram/task/pages/task/task.json @@ -1,7 +1,8 @@ { "usingComponents": { "rich-md":"/components/rich-md/rich-md", - "test-set":"/task/components/test_set/test_set" + "test-set":"/task/components/test_set/test_set", + "mp-toptips":"/weui-miniprogram/toptips/toptips" }, "navigationBarTitleText": "实训关卡" } \ No newline at end of file diff --git a/miniprogram/task/pages/task/task.wxml b/miniprogram/task/pages/task/task.wxml index e2648a8..2f812da 100644 --- a/miniprogram/task/pages/task/task.wxml +++ b/miniprogram/task/pages/task/task.wxml @@ -1,6 +1,7 @@ + diff --git a/project.config.json b/project.config.json index 5ab61a0..a5b5500 100644 --- a/project.config.json +++ b/project.config.json @@ -148,10 +148,10 @@ "scene": null }, { - "id": -1, + "id": 12, "name": "task/pages/task/task", "pathName": "task/pages/task/task", - "query": "identifier=ji2wy8sqkou5", + "query": "identifier=ocsejtwkaxhq", "scene": null }, { @@ -167,6 +167,13 @@ "pathName": "account/pages/profile/profile", "query": "course_id=5876", "scene": null + }, + { + "id": -1, + "name": "course/pages/teacher_apply/teacher_apply", + "pathName": "course/pages/teacher_apply/teacher_apply", + "query": "course_id=5141", + "scene": null } ] }