diff --git a/pages/course/chapterDetailAndorid.vue b/pages/course/chapterDetailAndorid.vue index 3bf67b0..164003e 100644 --- a/pages/course/chapterDetailAndorid.vue +++ b/pages/course/chapterDetailAndorid.vue @@ -4,15 +4,12 @@ @@ -164,16 +167,17 @@ }, data() { return { - answerForm:{ + showEditBlank: false, + answerForm: { relationId: undefined, - type: "1", //类型0任务1课后题 - display: "1", //0不展示1展示 - content: "", - img: "", - id:undefined - + type: "1", //类型0任务1课后题 + display: "1", //0不展示1展示 + content: "", + img: "", + id: undefined + }, - fileList1:[], + fileList1: [], tabList: [{ name: '章节介绍', id: '0' @@ -189,10 +193,10 @@ required: true, errorMessage: '请输入回答内容', } - + ] }, - + }, activeStyle: { color: '#333', @@ -239,6 +243,7 @@ show: false, playData: {}, + isInClass:false, // 是否加入了班级 taiHuClassInfo: {}, searchValue: "", ordersTabs: [{ @@ -274,7 +279,7 @@ readOnly: false, formats: {}, - myAnswer:{}, // 我的思考题回答 + myAnswer: {}, // 我的思考题回答 }; }, onLoad(options) { @@ -315,21 +320,56 @@ // this.showSearchList = false // this.searchList = [] }, - onPullDownRefresh(){ + onPullDownRefresh() { uni.stopPullDownRefresh(); }, onShow() { // #endif + this.getClassList() }, computed: { ...mapState(["userInfo"]), }, methods: { - getMyQuestAnswer(chapterId){ + showBlank(val) { + console.log('zouzheli .....................'); + if (val) { + this.answerForm = val + this.editorCtx = val.content + this.fileList1 = [...val.fileList] + } else { + this.answerForm = { + relationId: this.options.id, + type: "1", //类型0任务1课后题 + display: "1", //0不展示1展示 + content: "", + img: "", + id: undefined + }, + this.editorCtx = '' + this.fileList1 = [] + // console.log('this.answerForm++++', this.answerForm); + } + this.showEditBlank = true + }, + closePup() { + this.showEditBlank = false + this.answerForm = { + relationId: undefined, + type: "1", //类型0任务1课后题 + display: "1", //0不展示1展示 + content: "", + img: "", + id: undefined + + } + this.fileList1 = [] + }, + getMyQuestAnswer(chapterId) { $http.request({ url: "/common/class/getQuesReplyInfo", method: "POST", - data:{ + data: { "relationId": chapterId, "userId": this.userInfo.id }, @@ -337,24 +377,35 @@ 'Content-Type': 'application/json' }, }) - .then(res => { - if(res.code == 0 && res.classTaskAndQuesReply != null){ - this.myAnswer = res.classTaskAndQuesReply - this.answerForm = res.classTaskAndQuesReply - this.editorCtx = res.classTaskAndQuesReply.content - }else{ + .then(res => { + if (res.code == 0 && res.classTaskAndQuesReply != null) { + this.myAnswer = res.classTaskAndQuesReply + this.myAnswer.fileList = [] + if (res.classTaskAndQuesReply.img != '') { + var imgList = res.classTaskAndQuesReply.img.split(',') + imgList.forEach((item, index) => { + this.myAnswer.fileList.push({ + url: item + }) + this.fileList1.push({ + url: item + }) + }) + } + } else { + this.fileList1 = [] this.myAnswer = {} this.answerForm = {} this.editorCtx = '' } - console.log('我的思考题提交情况',res); - }).catch(e => { - console.log('我的思考题提交情况报错',e); + console.log('我的思考题提交情况', res); + }).catch(e => { + console.log('我的思考题提交情况报错', e); // uni.showToast({ // title: '操作失败', // icon: 'error' // }) - }); + }); }, async checkPermision() { var result = await permission.premissionCheck("CAMERA_EXTERNAL_STORAGE") @@ -364,9 +415,9 @@ }, addPic(e) { let that = this; - console.log("添加图片", that.fileList1); + console.log("添加图片", that.fileList1); for (var i = 0; i < e.file.length; i++) { - console.log(i,e.file[i].url) + console.log(i, e.file[i].url) uni.uploadFile({ url: this.$baseUrl + "oss/fileoss", filePath: e.file[i].url, @@ -389,75 +440,77 @@ deletePic(event) { this.fileList1.splice(event.index, 1) }, - radioChange(e){ - if(this.answerForm.display == e.detail.value) {return} + radioChange(e) { + if (this.answerForm.display == e.detail.value) { + return + } this.answerForm.display = e.detail.value }, - async onSubmit(){ + async onSubmit() { let data = await this.getHtml(); - var _data = data.html.replace(/<.*?>/g,"") - if(!_data || _data == ''){ + var _data = data.html.replace(/<.*?>/g, "") + if (!_data || _data == '') { uni.showToast({ - title:'请输入您的答案', - icon:'none' + title: '请输入您的答案', + icon: 'none' }) return - } + } this.answerForm.content = data.html if (this.fileList1.length > 0) { - let _list = this.fileList1 - _list = _list.map(item => item.url) - // console.log('this.fileList1',_list); - this.answerForm.img = _list.join(',') - }else{ - this.answerForm.img = '' - } - var _url = "" - this.answerForm.id ? _url = - 'common/class/editClassTaskAndQuesReply' : _url = 'common/class/addClassTaskAndQuesReply' - // this.form.id ? _url = - // 'common/class/editClassTaskReply' : _url = 'common/class/addClassTaskReply' - - - var data1 = { - "relationId": this.answerForm.id ? undefined : this.curriculumData.id, - "id": this.answerForm.id, - "type": this.answerForm.type, //类型0任务1课后题 - "display": this.answerForm.display, //0不展示1展示 - "content": this.answerForm.content, - "img": this.answerForm.img - } - - console.log('data',data1); - $http.request({ - url: _url, - method: "POST", - data:data1, - header: { //默认 无 说明:请求头 - 'Content-Type': 'application/json' - }, + let _list = this.fileList1 + _list = _list.map(item => item.url) + // console.log('this.fileList1',_list); + this.answerForm.img = _list.join(',') + } else { + this.answerForm.img = '' + } + var _url = "" + this.answerForm.id ? _url = + 'common/class/editClassTaskAndQuesReply' : _url = 'common/class/addClassTaskAndQuesReply' + // this.form.id ? _url = + // 'common/class/editClassTaskReply' : _url = 'common/class/addClassTaskReply' + + + var data1 = { + "relationId": this.answerForm.id ? undefined : this.curriculumData.id, + "id": this.answerForm.id, + "type": this.answerForm.type, //类型0任务1课后题 + "display": this.answerForm.display, //0不展示1展示 + "content": this.answerForm.content, + "img": this.answerForm.img + } + + console.log('data', data1); + $http.request({ + url: _url, + method: "POST", + data: data1, + header: { //默认 无 说明:请求头 + 'Content-Type': 'application/json' + }, + }) + .then(res => { + uni.showToast({ + title: '操作成功!', + icon: 'success' }) - .then(res => { - uni.showToast({ - title: '操作成功!', - icon: 'success' - }) - this.fileList1 = [] - // this.closePup() - setTimeout(()=>{ - this.getMyQuestAnswer(this.curriculumData.id) - // this.pPage = 0 - // this.zuoyeList = [] - // this.getTaskInfo() - // this.getZuoyeList() - },200) - }).catch(e => { - uni.showToast({ - title: '操作失败', - icon: 'error' - }) - }); - + this.fileList1 = [] + setTimeout(() => { + this.getMyQuestAnswer(this.curriculumData.id) + this.closePup() + // this.pPage = 0 + // this.zuoyeList = [] + // this.getTaskInfo() + // this.getZuoyeList() + }, 200) + }).catch(e => { + uni.showToast({ + title: '操作失败', + icon: 'error' + }) + }); + // console.log('data',data.html.replace(/<.*?>/g,"")); }, getHtml() { @@ -472,16 +525,21 @@ }); }); }, + goClassLIst(url, id,title){ + uni.navigateTo({ + url: `${url}?courseId=${this.options.id}&courseTitle=${this.options.navTitle}`, + }); + }, readOnlyChange() { this.readOnly = !this.readOnly }, - onEditorReady() { + onEditorReady() { // #ifdef APP-PLUS || MP-WEIXIN || H5 uni.createSelectorQuery().select('#editor').context((res) => { this.editorCtx = res.context - if(this.myAnswer.content == '') return + if (this.myAnswer.content == '') return res.context.setContents({ - html:this.myAnswer.content + html: this.myAnswer.content }) }).exec() // #endif @@ -505,24 +563,7 @@ const formats = e.detail this.formats = formats }, - // clear() { - // uni.showModal({ - // title: '清空编辑器', - // content: '确定清空编辑器全部内容?', - // success: res => { - // if (res.confirm) { - // this.editorCtx.clear({ - // success: function(res) { - // console.log("clear success") - // } - // }) - // } - // } - // }) - // }, - // removeFormat() { - // this.editorCtx.removeFormat() - // }, + insertImage() { uni.chooseImage({ count: 1, @@ -647,13 +688,7 @@ this.isOpenMp3 = false; }, 500); } - // else { - // this.currentVideo = data; - // this.initVideo(); - // this.isOpenMp3 = false; - // } - // console.log("data at line 380111111111111111111:", data.type); }, hancleModalCancel() { this.show = false; @@ -672,12 +707,7 @@ ...this.taiHuClassInfo, }, }; - // $mars.progressBegin('申请中...'); - // $mars.post(customerType, 'applyRelearn', data, function (ret) { - // api.hideProgress(); - // fnLoadDataGrid(); - // }); }, //课程详情 @@ -752,21 +782,32 @@ checkDisable() { console.log("点击了"); }, - // 显示无权限弹窗 - // showNoRights() { - // let that = this - // uni.showModal({ - // content: "", - // confirmText: '好的', - // showCancel: false, - // success: function(res) { - // if (res.confirm) { - // // console.log('用户点击确定'); - // that.clear() - // } - // } - // }) - // }, + // 判断用户是否加入了小班 小班列表为0 表示已经加入 + getClassList(){ + $http.request({ + url: '/common/class/getClassByCourseIdNoUser', + method: "POST", + data: { + "courseId": this.options.id, + "state": "", //小班状态0待开班1已开班2完成 + "type": "" // 班类型 0小班 1联合班 2精英班 + }, + header: { //默认 无 说明:请求头 + 'Content-Type': 'application/json' + }, + }) + .then(res => { + if(res.code == 0){ + if(res.result.length > 0){ + this.isInClass = false + }else{ + this.isInClass = true + } + } + }).catch(e => { + console.log('获取班级列表失败',e); + }); + }, // 获取用户详情 getUserInfo() { // 用户详情 @@ -801,69 +842,14 @@ // socket.init(); }); - // this.$nextTick(() => { - // switch (item.type) { - // case 1: - // // allDataList - // this.dataList = that.allDataList.result1Lst - // break; - // case 2: - // this.dataList = that.allDataList.result2Lst - // break; - // case 3: - // this.dataList = that.allDataList.result3Lst - // break; - // case 4: - // this.dataList = that.allDataList.result4Lst.filter(e => - // e.oid != '5fcf991c027b11e7ae62008cfae40c18' && e.oid != 'b3d8a938b8e147bc877613bb712a9cb3' && e.oid != '4d4730163135420ea962bfac4805e026' && e.oid != '49fb76ca3d6b43718d78c6aa9a3003c2' && e.oid != 'c7b047ed9246469b9ae2b1013fc3df9c' - // ) - - // console.log(this.dataList.length, 6666666) - // break; - - // } - - // this.currentCateIndex = item.index - // }) console.log(this.allDataList, this.dataList, "1688"); - // if(this.userMes.tgdzPower == 0){ - // let that = this - // uni.showModal({ - // content: "购买 针灸六经法要上册和下册 后方可使用此功能", - // confirmText: '好的', - // showCancel: false, - // success: function(res) { - // if (res.confirm) { - // // console.log('用户点击确定'); - // } - // } - // }) - // return - // } - // if(item.title == "时辰取穴"){ - // uni.navigateTo({ - // url: "../timeAcupoint/timeAcupoint" - // }) - // return - // } - // this.currentStatusIndex = index this.searchValue = ""; this.searchList = []; this.showSearchList = false; - // if (index != 2) { - // uni.createSelectorQuery().select('.statusList').boundingClientRect(function (rect) { - // var height = rect.height - // console.log('元素高度:',); - - // }).exec(); - - // } else { - // this.getJFList(dictType) - // } return data; }, @@ -872,27 +858,6 @@ console.log(index, 99999); var that = this; - // if(this.userMes.tgdzPower == 0){ - // let that = this - // uni.showModal({ - // content: "购买 针灸六经法要上册和下册 后方可使用此功能", - // confirmText: '好的', - // showCancel: false, - // success: function(res) { - // if (res.confirm) { - // // console.log('用户点击确定'); - // } - // } - // }) - // return - // } - // if(item.title == "时辰取穴"){ - // uni.navigateTo({ - // url: "../timeAcupoint/timeAcupoint" - // }) - // return - // } - this.currentStatusIndex = index; // this.currentCateIndex = 0 @@ -905,18 +870,6 @@ this.$forceUpdate(); }); - // this.handleselectCate(this.cateList[this.currentCateIndex]) - // if (index != 2) { - - // uni.createSelectorQuery().select('.statusList').boundingClientRect(function (rect) { - // var height = rect.height - // console.log('元素高度:',); - - // }).exec(); - - // } else { - // this.getJFList(dictType) - // } }, transformData(inputData) { @@ -933,59 +886,12 @@ // const finalResult = Object.keys(result).map(key => ({ [key]: result[key] })); return result; }, - // getJFList(id) { - // $http.request({ - // url: "book/prescript/prescriptListForJF", - // method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 - // data: { - // loadAnimate: 'none', // 请求加载动画 - // 'categoryId': id - // }, - // header: { //默认 无 说明:请求头 - // 'Content-Type': 'application/json' - // }, - // }).then(res => { - // if (res.code == 0 && res.list.length > 0) { - // this.twoCateList = [] - // this.dataList = this.transformData(res.list) - // console.log('JF经方', this.dataList) - // } else { - // this.twoCateList = [] - // this.dataList = [] - // } - // }).catch(e => { - // this.twoCateList = [] - // this.dataList = [] - // console.log(e) - // }) - // }, + getCateList(id) { id ? "" : (id = 0); this.twoCateList = []; this.curTwoCateIndex = 0; - // 0为获取顶级分类,其他为搜索下级分类,目前的逻辑,顶级是写死的,所以可能只会涉及到搜索第二级 - // $http.request({ - // url: "book/prescript/prescriptCategoryList", - // method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 - // data: { - // loadAnimate: 'none', // 请求加载动画 - // 'categoryId': id - // }, - // header: { //默认 无 说明:请求头 - // 'Content-Type': 'application/json' - // }, - // }).then(res => { - // console.log(res, '脉穴分类获取成功') - // if (res.code == 0 && res.list.length > 0) { - // this.statusList = res.list - // this.getTowCateList(this.statusList[0].type) - // } else { - // this.statusList = [] - // } - // }).catch(e => { - // this.statusList = [] - // console.log(e) - // }) + }, // 放大图片 @@ -1001,88 +907,7 @@ }, }); }, - // getSearch() { - // $http.request({ - // url: "book/prescript/searchPrescript", - // method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 - // data: { - // loadAnimate: 'none', // 请求加载动画 - // 'keywords': this.searchValue, - // type: this.currentStatusIndex + 1 - // }, - // header: { //默认 无 说明:请求头 - // 'Content-Type': 'application/json' - // }, - // }).then(res => { - // console.log(res, '搜索结果') - // if (res.code == 0 && res.list.length >= 0) { - // this.showSearchList = true - // this.searchList = res.list - // } else { - // this.searchList = [] - // } - // }).catch(e => { - // // this.dataList = [] - // this.searchList = [] - // console.log(e) - // }) - // }, - // search(res) { - // console.log(res, 'res') - // // uni.showToast({ - // // title: '搜索:' + res, - // // icon: 'none' - // // }) - // if (res == '') { - // this.showSearchList = false - // this.searchList = [] - // } else { - // this.getSearch() - // } - // }, - // input(res) { - // console.log('----input:', res) - // if (res == '') { - // this.searchList = [] - // } else { - // this.getSearch() - // } - // }, - // clear(res) { - // console.log('----clear:', res) - // // uni.showToast({ - // // title: 'clear事件,清除值为:', - // // icon: 'none' - // // }) - // this.searchValue = '' - // this.showSearchList = false - // }, - // blur(res) { - // // console.log('----blur:', res) - // // if (res == '') { - // // this.showSearchList = false - // // this.searchList = [] - // // } else { - // // this.getSearch() - // // } - // }, - // focus(e) { - // console.log('----focus:') - // // uni.showToast({ - // // title: 'focus事件,输出值为:' + e.value, - // // icon: 'none' - // // }) - // // 等于1 就是有权限 - // // this.showSearchList = true - - // }, - // cancel(res) { - // uni.showToast({ - // title: '点击取消,输入值为:' + res.value, - // icon: 'none' - // }) - // } }, onBackPress() { // #ifdef APP-PLUS @@ -1133,7 +958,7 @@ font-style: normal !important; line-height: 1.5; overflow-y: scroll; - border:1px solid #eee + border: 1px solid #eee } .ql-active { @@ -1159,6 +984,58 @@ padding: 10rpx; } + .imgBox { + flex-wrap: wrap; + + .item { + width: 20%; + margin-right: 10rpx; + border: 1px solid #eee; + padding: 0 !important; + + image { + width: 100%; + } + } + } + + .haveAnswer { + background-color: #f1f1f1; + border-radius: 10rpx; + padding: 10rpx; + margin-top: 20rpx; + .htmlText { + margin-bottom: 20rpx; + } + + } + .noanser.lock { position: relative; align-items: center; + .lockView{ height: 300rpx; display: block !important; padding: 20rpx; color: #fff; border-radius: 10rpx; + position: absolute; top: 0; left: 0; z-index: 2; width: 100%; background-color: rgba(0, 0, 0, .8); + .btnBox{ + padding-top: 20rpx; + } + } + } + .noanser { + padding: 20rpx; + background-color: rgba(255, 255, 255, .6); + text-align: center; + border-bottom: 1px solid #eee; + .lockView{display: none;} + .btn { + display: inline-block; + border-radius: 20rpx; + padding: 10rpx 20rpx; + background-color: $themeColor; + color: #fff; + } + } +// .noanser{ +// display: block; +// content: '加入小班学习后,即可答题'; +// background-color:rgba(255, 255, 255, .4); +// } .contentBox { height: 100vh; @@ -1266,7 +1143,21 @@ } } } -.btn_box { + + .rightBtn { + float: right; + + text { + display: inline-block; + border: 1px solid #06c; + border-radius: 10rpx; + padding: 4rpx 10rpx; + color: #06c; + } + + } + + .btn_box { margin-top: 70rpx; padding-bottom: 20rpx; @@ -1278,6 +1169,7 @@ border-radius: 50rpx; } } + .search_box { margin: 0 auto; overflow: hidden;