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