diff --git a/api/question.js b/api/question.js index 1202e25..ecc8725 100755 --- a/api/question.js +++ b/api/question.js @@ -34,4 +34,12 @@ export const getAnswerByFreId = (data) => { url: 'small/questionAnswer/add', data }) +} + +/** 获取答题顺序 */ +export const queryQAByFreId = (data) => { + return $http({ + method: 'POST', + url: 'small/questionAnswer/queryQAByFreId/'+data + }) } \ No newline at end of file diff --git a/components/s-video/res-s-video.vue b/components/s-video/res-s-video.vue new file mode 100644 index 0000000..82c9ae9 --- /dev/null +++ b/components/s-video/res-s-video.vue @@ -0,0 +1,334 @@ + + + + + \ No newline at end of file diff --git a/components/s-video/s-video.vue b/components/s-video/s-video.vue index 633c4de..03bb2a5 100644 --- a/components/s-video/s-video.vue +++ b/components/s-video/s-video.vue @@ -1,18 +1,18 @@ @@ -37,7 +37,10 @@ data() { return { isLoop: false, - play_time: 0, + resVideoUrl: "", + resVideoUrlTmp: "", + resNodeId: 2, + resNodeIdTmp: 2, videoHeight: 300, videoObjList: [], videoObj:{}, @@ -50,6 +53,9 @@ preQuestionId: "", correct: "", ask: "", + isOk: false, + isError: false, + resCheck: false, }; }, computed: { @@ -90,15 +96,33 @@ this.getAnswer(this.videoObj.outs[i]) } } else { - this.end = true; - this.answerList = []; - this.question = false; - uni.navigateTo({ - url: '/subpkg/complete/complete?questionFreId='+this.questionFreId+'&roleId='+this.jsonId - }) + if(this.resVideoUrl == "") { + // 为空表示答题正确正常跳转 + this.end = true; + this.answerList = []; + this.question = false; + uni.navigateTo({ + url: '/subpkg/complete/complete?questionFreId='+this.questionFreId+'&roleId='+this.jsonId + }) + } else { + // 不为空表示答题错误展示返回重新选择 + this.resCheck = true; + this.question = false; + } } }, + toResVideo() { + // 返回播放上一视频 + this.hasNodeId(this.resNodeId); + this.videoObj.videoUrl = this.resVideoUrl; + this.start = false; + this.question = false; + this.auto = true; + this.resCheck = false; + this.resVideoUrl = ""; + }, nextQuestion(outId, obj) { + // 点击开始后先增加题次 if(2==outId) { this.$api.addQuestionFre({ roleId : this.jsonId, @@ -115,7 +139,14 @@ if(null!=obj) { // 判断答题是否正确 if(this.correct == obj.channel.slice(0, 1)) { + // 控制选中答案单条显示对错 + this.$set(obj, 'choose', 'true'); isCorrect = 1 + this.isError = false; + this.isOk = true; + } else { + // 控制选中答案单条显示对错 + this.$set(obj, 'choose', 'false'); } var param = { answer : obj.channel, @@ -131,18 +162,46 @@ }).catch((e) => console.log(e)); //捕获异常 } - // 答案错误则重播当前视频 + // 所选答案错误处理1: 用于之前的对错提示展示 if(isCorrect == 0 && 2 != outId) { - this.play_time = 0; - this.auto = true; + this.isError = true; + this.isOk = false; } else { - // 播放下一视频 - this.hasNodeId(outId); - this.videoObj.videoUrl = uni.$http.baseUrl + this.videoObj.videoUrl - this.start = false; - this.question = false; - this.auto = true; + this.isError = false; + this.isOk = true; } + + // 延长0.5秒播放下一视频 + const that = this; + setTimeout(function () { // setInterval同理 + that.isError = false; + that.isOk = false; + that.hasNodeId(outId); + that.videoObj.videoUrl = uni.$http.baseUrl + that.videoObj.videoUrl + + // 用于记录上一个视频 + if(null==obj) { + that.resVideoUrl = that.videoObj.videoUrl; + that.resNodeId = outId; + that.resVideoUrlTmp = that.resVideoUrl; + that.resNodeIdTmp = that.resNodeId; + } else if(isCorrect == 1) { + that.resVideoUrl = that.videoObj.videoUrl; + that.resNodeId = outId; + that.resVideoUrlTmp = that.resVideoUrl; + that.resNodeIdTmp = that.resNodeId; + } else if(isCorrect != 1) { + that.resVideoUrl = that.resVideoUrlTmp; + that.resNodeId = that.resNodeIdTmp; + } else if(obj != null && obj.questionId =='google') { + that.resVideoUrl = ""; + that.resNodeId = ""; + } + + that.start = false; + that.question = false; + that.auto = true; + },300); }, getBindJson() { this.start = true; @@ -174,6 +233,14 @@ this.answerList.push(this.videoObjList[i]); } } + if(this.answerList.length == 1 && this.answerList[0].questionId == 'google') { + this.end = true; + this.answerList = []; + this.question = false; + uni.navigateTo({ + url: '/subpkg/complete/complete?questionFreId='+this.questionFreId+'&roleId='+this.jsonId + }) + } } } } diff --git a/main.js b/main.js index 9ae0e69..ce5fa7e 100644 --- a/main.js +++ b/main.js @@ -13,8 +13,8 @@ import * as filters from '@/utils/formatFilter' uni.$http = $http Vue.prototype.$api = api -$http.baseUrl = 'http://146.56.223.227:9527' -// $http.baseUrl = 'http://localhost:85' +// $http.baseUrl = 'http://146.56.223.227:9527' +$http.baseUrl = 'http://localhost:9527' $http.beforeRequest = function(options) { uni.showLoading({ diff --git a/pages.json b/pages.json index fa3e7c9..3956d8b 100644 --- a/pages.json +++ b/pages.json @@ -112,7 +112,17 @@ "style" : { "navigationBarTitleText" : "", - "enablePullDownRefresh" : false + "enablePullDownRefresh" : false, + "navigationStyle": "custom" + } + }, + { + "path" : "respractice/respractice", + "style" : + { + "navigationBarTitleText" : "", + "enablePullDownRefresh" : false, + "navigationStyle": "custom" } }, { diff --git a/subpkg/practice/practice.vue b/subpkg/practice/practice.vue index 1bf7aaa..42b7681 100644 --- a/subpkg/practice/practice.vue +++ b/subpkg/practice/practice.vue @@ -1,8 +1,12 @@ @@ -35,6 +39,11 @@ // } // }) }, + back(){ + uni.navigateBack({ + delta:1,//返回层数,2则上上页 + }) + }, }, components: { sVideo @@ -44,4 +53,31 @@ \ No newline at end of file diff --git a/subpkg/respractice/respractice.vue b/subpkg/respractice/respractice.vue new file mode 100644 index 0000000..e3ad804 --- /dev/null +++ b/subpkg/respractice/respractice.vue @@ -0,0 +1,83 @@ + + + + + \ No newline at end of file diff --git a/subpkg/role/role.vue b/subpkg/role/role.vue index 6afc6ce..81e80fb 100644 --- a/subpkg/role/role.vue +++ b/subpkg/role/role.vue @@ -108,7 +108,8 @@ return uni.$showMsg('请先选择一个角色') } uni.navigateTo({ - url: '/subpkg/practice/practice?roleId='+this.roleId + // url: '/subpkg/practice/practice?roleId='+this.roleId + url: '/subpkg/practice/respractice?roleId='+this.roleId }) }, back(){ diff --git a/utils/config.js b/utils/config.js index 7765cc0..cca2440 100755 --- a/utils/config.js +++ b/utils/config.js @@ -1,3 +1,3 @@ -let url_config = 'http://146.56.223.227:9527/' -// let url_config = 'http://localhost:85/' +// let url_config = 'http://146.56.223.227:9527/' +let url_config = 'http://localhost:9527/' export default url_config \ No newline at end of file