diff --git a/miniprogram/account/pages/reset_password/reset_password.js b/miniprogram/account/pages/reset_password/reset_password.js
index 276ee5f..66924be 100644
--- a/miniprogram/account/pages/reset_password/reset_password.js
+++ b/miniprogram/account/pages/reset_password/reset_password.js
@@ -24,8 +24,7 @@ Page({
data: 1,
})
},
- login: function () {
- const { login, password } = this.data;
+ login: function ({login, password}) {
app.callApi({
name: "accounts.login", data: { login: login, password: password, autologin: 1 },
success: res => {
diff --git a/miniprogram/avatar/pages/image_crop/image_crop.js b/miniprogram/avatar/pages/image_crop/image_crop.js
index 8ca9701..08219b9 100644
--- a/miniprogram/avatar/pages/image_crop/image_crop.js
+++ b/miniprogram/avatar/pages/image_crop/image_crop.js
@@ -44,7 +44,7 @@ Page({
encoding: "base64",
success: res => {
let image = "data:image/jpeg;base64," + res.data;
- app.api("accounts.avatar")({image}).then(resolve);
+ app.api("users.accounts.avatar")({image}).then(resolve);
},
fail:reject
});
diff --git a/miniprogram/avatar/pages/image_crop/image_crop.wxml b/miniprogram/avatar/pages/image_crop/image_crop.wxml
index 91d5c35..2099d43 100644
--- a/miniprogram/avatar/pages/image_crop/image_crop.wxml
+++ b/miniprogram/avatar/pages/image_crop/image_crop.wxml
@@ -1,4 +1,4 @@
-
+
diff --git a/miniprogram/components/course-item/course-item.js b/miniprogram/components/course-item/course-item.js
index 51b53b3..1fe75dd 100644
--- a/miniprogram/components/course-item/course-item.js
+++ b/miniprogram/components/course-item/course-item.js
@@ -1,6 +1,7 @@
Component({
properties: {
+ data:Object, //@todo: simplify
course_id:Number,
teacher:Object,
name:String,
diff --git a/miniprogram/components/nav-bar/nav-bar.wxss b/miniprogram/components/nav-bar/nav-bar.wxss
index dd73b8c..9e1fd16 100644
--- a/miniprogram/components/nav-bar/nav-bar.wxss
+++ b/miniprogram/components/nav-bar/nav-bar.wxss
@@ -14,6 +14,7 @@ view.common{
}
view.c-nav {
box-sizing: border-box;
+ border-bottom: 2px solid transparent;
transition: all 0.26s ease;
}
view.c-nav.active{
@@ -21,6 +22,9 @@ view.c-nav.active{
font-size: 15px;
border-bottom: 2px solid #0080f0;
}
+view.c-plain{
+ transition: all 0.26s ease;
+}
view.c-plain.active{
color: #0080f0;
font-size: 15px;
@@ -50,7 +54,7 @@ text.c-line.active{
text.c-line::after{
transition: all 0.26s ease;
width: 0px;
- height: 5px;
+ height: 3.2px;
position: absolute;
content: "";
bottom: 0;
@@ -58,5 +62,5 @@ text.c-line::after{
}
text.c-line.active::after{
width: 22px;
- background: #0080f0;
+ background: #00a0f0;
}
\ No newline at end of file
diff --git a/miniprogram/components/rich-md/rich-md.js b/miniprogram/components/rich-md/rich-md.js
new file mode 100644
index 0000000..bcf0e83
--- /dev/null
+++ b/miniprogram/components/rich-md/rich-md.js
@@ -0,0 +1,35 @@
+if (!global.towxml)
+ global.towxml = require('../../towxml/index');
+
+Component({
+ properties: {
+ nodes:{
+ type:Object,
+ optionalTypes:[String],
+ observer:function(nodes){
+ if(typeof nodes=="string")
+ this.process(nodes);
+ }
+ },
+ base:{
+ type:String,
+ value: "https://www.educoder.net/"
+ }
+ },
+
+ data: {
+ isRich:0
+ },
+
+ methods: {
+ process(nodes){
+ if(!nodes.match(/^\s*?<.+>.*<\/.+>\s *? $ /)){
+ nodes = nodes.replace(/(#+)/g, "$1 ").replace(/`$$(.*)$$`/g, "\$$1\$").replace(/`\$\$(.*)\$\$`/g, "\$$1\$");
+ nodes = global.towxml(nodes, "markdown", {base:this.data.base});
+ this.setData({nodes});
+ }else{
+ this.setData({isRich:true})
+ }
+ }
+ }
+})
diff --git a/miniprogram/components/rich-md/rich-md.json b/miniprogram/components/rich-md/rich-md.json
new file mode 100644
index 0000000..9dc3362
--- /dev/null
+++ b/miniprogram/components/rich-md/rich-md.json
@@ -0,0 +1,6 @@
+{
+ "component": true,
+ "usingComponents": {
+ "towxml":"/towxml/towxml"
+ }
+}
\ No newline at end of file
diff --git a/miniprogram/components/rich-md/rich-md.wxml b/miniprogram/components/rich-md/rich-md.wxml
new file mode 100644
index 0000000..0014b74
--- /dev/null
+++ b/miniprogram/components/rich-md/rich-md.wxml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/miniprogram/components/rich-md/rich-md.wxss b/miniprogram/components/rich-md/rich-md.wxss
new file mode 100644
index 0000000..e69de29
diff --git a/miniprogram/course/components/common-homework-item/common-homework-item.js b/miniprogram/course/components/common-homework-item/common-homework-item.js
new file mode 100644
index 0000000..a0c3721
--- /dev/null
+++ b/miniprogram/course/components/common-homework-item/common-homework-item.js
@@ -0,0 +1,15 @@
+
+Component({
+ properties: {
+ data:Object
+ },
+ data: {
+
+ },
+
+ methods: {
+
+
+
+ }
+})
diff --git a/miniprogram/course/components/common-homework-item/common-homework-item.json b/miniprogram/course/components/common-homework-item/common-homework-item.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/miniprogram/course/components/common-homework-item/common-homework-item.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/miniprogram/course/components/common-homework-item/common-homework-item.wxml b/miniprogram/course/components/common-homework-item/common-homework-item.wxml
new file mode 100644
index 0000000..44b72e7
--- /dev/null
+++ b/miniprogram/course/components/common-homework-item/common-homework-item.wxml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/course/components/common-homework-item/common-homework-item.wxss b/miniprogram/course/components/common-homework-item/common-homework-item.wxss
new file mode 100644
index 0000000..36e36ce
--- /dev/null
+++ b/miniprogram/course/components/common-homework-item/common-homework-item.wxss
@@ -0,0 +1 @@
+/* course/components/common-homework-item/common-homework-item.wxss */
\ No newline at end of file
diff --git a/miniprogram/course/components/common-homework/common-homework.js b/miniprogram/course/components/common-homework/common-homework.js
new file mode 100644
index 0000000..f6c30af
--- /dev/null
+++ b/miniprogram/course/components/common-homework/common-homework.js
@@ -0,0 +1,22 @@
+const app = getApp();
+Component({
+ properties: {
+ course_id:Number,
+ refresh:{
+ type:Number,
+ observer:function(r){
+ if (r) {
+ this.onPullDownRefresh();
+ this.setData({ refresh: false });
+ }
+ }
+ }
+ },
+ data: {
+
+ },
+
+ methods: {
+
+ }
+})
diff --git a/miniprogram/course/components/common-homework/common-homework.json b/miniprogram/course/components/common-homework/common-homework.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/miniprogram/course/components/common-homework/common-homework.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/miniprogram/course/components/common-homework/common-homework.wxml b/miniprogram/course/components/common-homework/common-homework.wxml
new file mode 100644
index 0000000..4bdee9a
--- /dev/null
+++ b/miniprogram/course/components/common-homework/common-homework.wxml
@@ -0,0 +1,2 @@
+
+course/components/common-homework/common-homework.wxml
diff --git a/miniprogram/course/components/common-homework/common-homework.wxss b/miniprogram/course/components/common-homework/common-homework.wxss
new file mode 100644
index 0000000..aa3a31d
--- /dev/null
+++ b/miniprogram/course/components/common-homework/common-homework.wxss
@@ -0,0 +1 @@
+/* course/components/common-homework/common-homework.wxss */
\ No newline at end of file
diff --git a/miniprogram/course/images/more.png b/miniprogram/course/images/more.png
index 6aadac3..127fd7a 100644
Binary files a/miniprogram/course/images/more.png and b/miniprogram/course/images/more.png differ
diff --git a/miniprogram/exercise/components/choice-question/choice-question.js b/miniprogram/exercise/components/choice-question/choice-question.js
new file mode 100644
index 0000000..5e17617
--- /dev/null
+++ b/miniprogram/exercise/components/choice-question/choice-question.js
@@ -0,0 +1,38 @@
+const app = getApp();
+Component({
+ properties: {
+ data:Object
+ },
+
+ data: {
+
+ },
+
+ methods: {
+ answer_choice_question: function ({ detail: { value }, currentTarget: { dataset } }) {
+ console.log("answer_question");
+ console.log(value);
+ console.log(dataset);
+ let exercise_choice_id;
+ if (Array.isArray(value)) {
+ exercise_choice_id = [];
+ for (var i of value) {
+ exercise_choice_id.push(parseInt(i));
+ }
+ console.log(exercise_choice_id);
+ } else {
+ exercise_choice_id = parseInt(value);
+ console.log(exercise_choice_id);
+ }
+ app.api("exercise_questions.exercise_answers")({ question_id: dataset.question_id, exercise_choice_id })
+ .then(res => { console.log("answer_question"); console.log(res); })
+ .catch(error => {
+ console.error(error);
+ wx.showToast({
+ title: error.toString(),
+ icon: "none"
+ })
+ });
+ },
+ }
+})
diff --git a/miniprogram/exercise/components/choice-question/choice-question.json b/miniprogram/exercise/components/choice-question/choice-question.json
new file mode 100644
index 0000000..8de232c
--- /dev/null
+++ b/miniprogram/exercise/components/choice-question/choice-question.json
@@ -0,0 +1,6 @@
+{
+ "component": true,
+ "usingComponents": {
+ "rich-md": "/components/rich-md/rich-md"
+ }
+}
\ No newline at end of file
diff --git a/miniprogram/exercise/components/choice-question/choice-question.wxml b/miniprogram/exercise/components/choice-question/choice-question.wxml
new file mode 100644
index 0000000..b19e89d
--- /dev/null
+++ b/miniprogram/exercise/components/choice-question/choice-question.wxml
@@ -0,0 +1,28 @@
+
+ 第{{question.q_position}}题
+
+
+
+
+
+
+ {{choice.choice_text}}
+ 正确答案
+
+
+
+
+
+
+
+
+
+
+ {{choice.choice_text}}
+ 正确答案
+
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/exercise/components/choice-question/choice-question.wxss b/miniprogram/exercise/components/choice-question/choice-question.wxss
new file mode 100644
index 0000000..867afcb
--- /dev/null
+++ b/miniprogram/exercise/components/choice-question/choice-question.wxss
@@ -0,0 +1,50 @@
+.question{
+ background: white;
+ margin: 20rpx -6rpx;
+ padding: 4rpx 20rpx 22rpx 22rpx;
+ border-radius: 18rpx;
+}
+
+.question-title{
+ display: inline-block;
+ margin: 5rpx 0rpx 12rpx 0rpx;
+}
+
+.choices{
+ display: flex;
+ flex-direction: column;
+}
+checkbox.choice{
+ margin-bottom: 12rpx;
+}
+
+view.choice{
+ width: 600rpx;
+}
+
+.main-input{
+ height: 120rpx;
+ margin: 18rpx 0 4rpx 18rpx;
+ border: 1rpx solid lightgray;
+ border-radius: 12rpx;
+ padding: 12rpx 10rpx;
+}
+
+view.null-input{
+ align-items: center;
+}
+
+input.null-input{
+ border: 1rpx solid lightgray;
+ padding: 12rpx 6rpx;
+ margin: 6rpx 10rpx;
+ border-radius: 10rpx;
+}
+
+.standard-choice{
+ margin-left: 24rpx;
+}
+
+standard-null-input{
+ align-items: center;
+}
diff --git a/miniprogram/exercise/components/main-question/main-question.js b/miniprogram/exercise/components/main-question/main-question.js
new file mode 100644
index 0000000..9c8efd3
--- /dev/null
+++ b/miniprogram/exercise/components/main-question/main-question.js
@@ -0,0 +1,23 @@
+// exercise/components/main-question/main-question.js
+Component({
+ properties: {
+
+ },
+ data: {
+
+ },
+
+ methods: {
+ answer_main_question: function ({ detail: { value }, currentTarget: { dataset } }) {
+ console.log("answer_main_question");
+ console.log(value);
+ console.log(dataset);
+ app.api("exercise_questions.exercise_answers")({ question_id: dataset.question_id, answer_text: value })
+ .then(res => { console.log("answer_main_question"); console.log(res); })
+ .catch(e => {
+ console.error(e);
+ app.showError(e);
+ });
+ },
+ }
+})
diff --git a/miniprogram/exercise/components/main-question/main-question.json b/miniprogram/exercise/components/main-question/main-question.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/miniprogram/exercise/components/main-question/main-question.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/miniprogram/exercise/components/main-question/main-question.wxml b/miniprogram/exercise/components/main-question/main-question.wxml
new file mode 100644
index 0000000..caed1e8
--- /dev/null
+++ b/miniprogram/exercise/components/main-question/main-question.wxml
@@ -0,0 +1,12 @@
+
+
+
+ 参考答案:
+ {{question.standard_answer[0]||'暂无'}}
+
+
\ No newline at end of file
diff --git a/miniprogram/exercise/components/main-question/main-question.wxss b/miniprogram/exercise/components/main-question/main-question.wxss
new file mode 100644
index 0000000..e8fbc50
--- /dev/null
+++ b/miniprogram/exercise/components/main-question/main-question.wxss
@@ -0,0 +1 @@
+/* exercise/components/main-question/main-question.wxss */
\ No newline at end of file
diff --git a/miniprogram/exercise/components/null-question/null-question.js b/miniprogram/exercise/components/null-question/null-question.js
new file mode 100644
index 0000000..66dd759
--- /dev/null
+++ b/miniprogram/exercise/components/null-question/null-question.js
@@ -0,0 +1,25 @@
+const app = getApp();
+Component({
+ properties: {
+
+ },
+ data: {
+
+ },
+ methods: {
+ answer_null_question: function ({ detail: { value }, currentTarget: { dataset } }) {
+ console.log("answer_main_question");
+ console.log(value);
+ console.log(dataset);
+ app.api("exercise_questions.exercise_answers")({ question_id: dataset.question_id, exercise_choice_id: dataset.exercise_choice_id, answer_text: value })
+ .then(res => { console.log("answer_main_question"); console.log(res); })
+ .catch(error => {
+ console.error(error);
+ wx.showToast({
+ title: error.toString(),
+ icon: "none"
+ })
+ });
+ },
+ }
+})
diff --git a/miniprogram/exercise/components/null-question/null-question.json b/miniprogram/exercise/components/null-question/null-question.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/miniprogram/exercise/components/null-question/null-question.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/miniprogram/exercise/components/null-question/null-question.wxml b/miniprogram/exercise/components/null-question/null-question.wxml
new file mode 100644
index 0000000..fe7e240
--- /dev/null
+++ b/miniprogram/exercise/components/null-question/null-question.wxml
@@ -0,0 +1,20 @@
+
+
+
+ 填空{{null_input.choice_id}}
+
+
+
+
+
+
+ 第{{answer.choice_id}}空答案:
+ {{answer.answer_text}}
+
+
+
\ No newline at end of file
diff --git a/miniprogram/exercise/components/null-question/null-question.wxss b/miniprogram/exercise/components/null-question/null-question.wxss
new file mode 100644
index 0000000..6eb53ee
--- /dev/null
+++ b/miniprogram/exercise/components/null-question/null-question.wxss
@@ -0,0 +1 @@
+/* exercise/components/null-question/null-question.wxss */
\ No newline at end of file
diff --git a/miniprogram/exercise/pages/exercise/exercise.js b/miniprogram/exercise/pages/exercise/exercise.js
index 4e64db4..3c8ac1e 100644
--- a/miniprogram/exercise/pages/exercise/exercise.js
+++ b/miniprogram/exercise/pages/exercise/exercise.js
@@ -18,7 +18,6 @@ Page({
title: '请登陆后重试',
icon: "none"
})
- //console.log("require_login");
return;
}
let questions = res.exercise_questions;
@@ -140,64 +139,29 @@ Page({
}
})
},
- /**
- * 生命周期函数--监听页面加载
- */
onLoad: function (options) {
this.exercise_id = options.exercise_id;
this.course_name = options.exercise_name;//todo finish
},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
onShow: function () {
if(this.data.loading){
this.pull_questions();
}
},
- onError: function(e){
- console.error(e);
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
onHide: function () {
this.save_exercise({show_loading: false});
},
- /**
- * 生命周期函数--监听页面卸载
- */
onUnload: function () {
this.save_exercise({ show_loading: false });
},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
+
},
- /**
- * 用户点击右上角分享
- */
onShareAppMessage: function () {
}
diff --git a/miniprogram/exercise/pages/exercise/exercise.json b/miniprogram/exercise/pages/exercise/exercise.json
index 8835af0..ea6d585 100644
--- a/miniprogram/exercise/pages/exercise/exercise.json
+++ b/miniprogram/exercise/pages/exercise/exercise.json
@@ -1,3 +1,7 @@
{
- "usingComponents": {}
+ "usingComponents": {
+ "choice-question":"/exercise/components/choice-question/choice-question",
+ "main-question": "/exercise/components/main-question/main-question",
+ "null-question": "/exercise/components/null-question/null-question"
+ }
}
\ No newline at end of file
diff --git a/miniprogram/exercise/pages/exercise/exercise.wxml b/miniprogram/exercise/pages/exercise/exercise.wxml
index 4d035b0..409a880 100644
--- a/miniprogram/exercise/pages/exercise/exercise.wxml
+++ b/miniprogram/exercise/pages/exercise/exercise.wxml
@@ -1,73 +1,14 @@
-
-
- 第{{question.q_position}}题
-
-
-
-
-
-
- {{choice.choice_text}}
- 正确答案
-
-
-
-
-
-
-
-
-
-
- {{choice.choice_text}}
- 正确答案
-
-
-
-
-
-
-
-
- 填空{{null_input.choice_id}}
-
-
-
-
-
-
- 第{{answer.choice_id}}空答案:
- {{answer.answer_text}}
-
-
-
-
-
-
- 参考答案:
- {{question.standard_answer[0]||'暂无'}}
-
-
-
+
+
+
暂不支持实训题...
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/miniprogram/exercise/pages/exercise/exercise.wxss b/miniprogram/exercise/pages/exercise/exercise.wxss
index 10fd0fb..bb01dd9 100644
--- a/miniprogram/exercise/pages/exercise/exercise.wxss
+++ b/miniprogram/exercise/pages/exercise/exercise.wxss
@@ -11,62 +11,11 @@
width: 50%;
}
.save{
- background-color: #4797f8;
+ background-color: #00b0f0;
}
.commit{
background-color: orangered;
}
-
.container{
padding-bottom: 40px;
-}
-.question{
- background: white;
- margin: 20rpx -6rpx;
- padding: 4rpx 20rpx 22rpx 22rpx;
- border-radius: 18rpx;
-}
-
-.question-title{
- display: inline-block;
- margin: 5rpx 0rpx 12rpx 0rpx;
-}
-
-.choices{
- display: flex;
- flex-direction: column;
-}
-checkbox.choice{
- margin-bottom: 12rpx;
-}
-
-view.choice{
- width: 600rpx;
-}
-
-.main-input{
- height: 120rpx;
- margin: 18rpx 0 4rpx 18rpx;
- border: 1rpx solid lightgray;
- border-radius: 12rpx;
- padding: 12rpx 10rpx;
-}
-
-view.null-input{
- align-items: center;
-}
-
-input.null-input{
- border: 1rpx solid lightgray;
- padding: 12rpx 6rpx;
- margin: 6rpx 10rpx;
- border-radius: 10rpx;
-}
-
-.standard-choice{
- margin-left: 24rpx;
-}
-
-standard-null-input{
- align-items: center;
-}
+}
\ No newline at end of file
diff --git a/miniprogram/js/client.js b/miniprogram/js/client.js
index 549fb92..13ad1f9 100644
--- a/miniprogram/js/client.js
+++ b/miniprogram/js/client.js
@@ -38,7 +38,7 @@ export default class Client{
this.on("before","users.homepage_info", getLogin);
this.on("before","homepage_info", getLogin)
this.on("before","unread_message_info", getLogin);
- this.on("before","accounts.avatar",getLogin);
+ this.on("before","users.accounts.avatar",getLogin);
this.on("success", "accounts.logout", res=>{
this.synch = 0;
wx.setStorageSync("autologin", 0);
@@ -87,9 +87,9 @@ export default class Client{
}
return {randomcode:this.randomcode,client_key:this.client_key};
}
- api(name,config={}){
- return data=>{
- return this.callApi({name,config, data});
+ api(name,config={},data={}){
+ return ({success, fail, complete,..._data}={})=>{
+ return this.callApi({name,config, data:{...data,..._data}, success, fail, complete});
}
}
callApi({ name, data={},config={}, success, fail, complete}) {
diff --git a/miniprogram/pages/my_courses/my_courses.js b/miniprogram/pages/my_courses/my_courses.js
index a5030df..557d996 100644
--- a/miniprogram/pages/my_courses/my_courses.js
+++ b/miniprogram/pages/my_courses/my_courses.js
@@ -49,7 +49,10 @@ Page({
.then(res=>{
console.log(res);
this.setData({courses: res.courses||[]});
- }).catch(console.error);
+ }).catch(e=>{
+ this.setData({courses:[]});
+ console.error
+ });
console.log(this.data);
},
onLoad: function (options) {
diff --git a/miniprogram/pages/my_courses/my_courses.wxml b/miniprogram/pages/my_courses/my_courses.wxml
index e533610..171d7b7 100644
--- a/miniprogram/pages/my_courses/my_courses.wxml
+++ b/miniprogram/pages/my_courses/my_courses.wxml
@@ -1,7 +1,7 @@
-
+