This commit is contained in:
@fawn-nine
2024-09-25 10:19:44 +08:00
parent 6ef6e4e725
commit c0b696aa15

View File

@@ -299,6 +299,7 @@
readOnly: false, readOnly: false,
formats: {}, formats: {},
myAnswer: {}, // 我的思考题回答 myAnswer: {}, // 我的思考题回答
oldContent:'', // 老的内容
}; };
}, },
onLoad(options) { onLoad(options) {
@@ -355,7 +356,7 @@
console.log('zouzheli .....................'); console.log('zouzheli .....................');
if (val) { if (val) {
this.answerForm = val this.answerForm = val
this.editorCtx = val.content // this.editorCtx = val.content
this.fileList1 = [...val.fileList] this.fileList1 = [...val.fileList]
} else { } else {
this.answerForm = { this.answerForm = {
@@ -366,10 +367,12 @@
img: "", img: "",
id: undefined id: undefined
}, },
this.editorCtx = '' // this.editorCtx = ''
this.fileList1 = [] this.fileList1 = []
// console.log('this.answerForm++++', this.answerForm); // console.log('this.answerForm++++', this.answerForm);
} }
// 赋值给编辑器
this.onEditorReady()
this.showEditBlank = true this.showEditBlank = true
}, },
gotoClass(item){ gotoClass(item){
@@ -377,18 +380,28 @@
url: `/pages/miniClass/classInfo?id=${item.id}` url: `/pages/miniClass/classInfo?id=${item.id}`
}); });
}, },
closePup() { async closePup() {
this.showEditBlank = false this.showEditBlank = false
this.answerForm = { let data = await this.getHtml();
relationId: undefined, var _data = data.html.replace(/<.*?>/g, "")
type: "1", //类型0任务1课后题 if (!_data || _data == '') {
display: "1", //0不展示1展示 uni.showToast({
content: "", title: '请输入您的答案',
img: "", icon: 'none'
id: undefined })
return
} }
this.fileList1 = [] this.oldContent = data.html
// this.answerForm = {
// relationId: undefined,
// type: "1", //类型0任务1课后题
// display: "1", //0不展示1展示
// content: "",
// img: "",
// id: undefined
// }
// this.fileList1 = []
}, },
getMyQuestAnswer(chapterId) { getMyQuestAnswer(chapterId) {
$http.request({ $http.request({
@@ -405,8 +418,10 @@
.then(res => { .then(res => {
if (res.code == 0 && res.classTaskAndQuesReply != null) { if (res.code == 0 && res.classTaskAndQuesReply != null) {
this.myAnswer = res.classTaskAndQuesReply this.myAnswer = res.classTaskAndQuesReply
// 赋值给编辑器 this.oldContent = this.myAnswer.content
this.onEditorReady() console.log('回复的内容',this.oldContent);
// // 赋值给编辑器
// this.onEditorReady()
this.myAnswer.fileList = [] this.myAnswer.fileList = []
if (res.classTaskAndQuesReply.img != '') { if (res.classTaskAndQuesReply.img != '') {
var imgList = res.classTaskAndQuesReply.img.split(',') var imgList = res.classTaskAndQuesReply.img.split(',')
@@ -563,9 +578,10 @@
// #ifdef APP-PLUS || MP-WEIXIN || H5 // #ifdef APP-PLUS || MP-WEIXIN || H5
uni.createSelectorQuery().select('#editor').context((res) => { uni.createSelectorQuery().select('#editor').context((res) => {
this.editorCtx = res.context this.editorCtx = res.context
if (this.myAnswer.content == '') return console.log('编辑器实例', res.context);
if (this.oldContent == '') return
res.context.setContents({ res.context.setContents({
html: this.myAnswer.content html: this.oldContent
}) })
}).exec() }).exec()
// #endif // #endif