diff --git a/bkhumor-emojiplus/components/bkhumor-emojiplus/bkhumor-emojiplus.vue b/bkhumor-emojiplus/components/bkhumor-emojiplus/bkhumor-emojiplus.vue index 77b5768..b5d05b0 100644 --- a/bkhumor-emojiplus/components/bkhumor-emojiplus/bkhumor-emojiplus.vue +++ b/bkhumor-emojiplus/components/bkhumor-emojiplus/bkhumor-emojiplus.vue @@ -20,6 +20,7 @@ data() { return { + // windowWidth:320, emojilist:emojiList1, list1: [ [1,2,3],[4,5,6], @@ -54,9 +55,10 @@ }, onLoad() { - }, + }, mounted() { - + console.log('jihuo') + // this.windowWidth = uni.getSystemInfoSync().windowWidth; const query = uni.createSelectorQuery().in(this); query.select('.emotion-box').boundingClientRect(data => { console.log(this.windowWidth / 10); diff --git a/components/guide-pages/guide-pages.vue b/components/guide-pages/guide-pages.vue index d75f570..3c66da0 100644 --- a/components/guide-pages/guide-pages.vue +++ b/components/guide-pages/guide-pages.vue @@ -3,23 +3,23 @@ - 吴门医述, + - 吴门医述, + - 吴门医述, + diff --git a/pages/course/courseDetail.vue b/pages/course/courseDetail.vue index 01d60f1..af94328 100644 --- a/pages/course/courseDetail.vue +++ b/pages/course/courseDetail.vue @@ -100,68 +100,54 @@ + - - + + - + - 这是名字这是名字这是名字 + {{item.user.name}} - - 这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容 + + + + + + + + - - - 387 + + + {{item.supportCount}} - + - 555 + {{totalP}} - 2024-06-12 09:15 + {{item.createTime}} - - - - - - - - - - 这是名字这是名字这是名字 - - - 这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容 - - - - - - 387 - - - - - 555 - - 2024-06-12 09:15 - - - - + + + @@ -194,30 +180,78 @@ + + + 回复@:{{fatherSay.user.name}} 的留言 + + - - - - + + + - 表情图片 + + + + + + + 表情 + + + + + + + + + + + + + + + + + + 最多可上传3张图片哦 + + + + + + × + + 关闭 - + + + + - + @@ -239,7 +273,7 @@ data() { return { playData: {}, - courseId: null, + catalogueId: null, // fixed: false, bgiStyle: { background: '#fff' @@ -275,10 +309,20 @@ // 评论 readOnly: false, formats: {}, - showEmoji:false, + htmlContent: '', // 内容 + showEmoji: false, showImgType: false, - showEdit:false, - windowWidth:0, + showEdit: false, + showPicsList: false, + windowWidth: 0, + uploadPicLIst: [], // 上传的图片列表 + courseId: null, + sayList: [], + pPage: 1, + totalP: 0, + status: 88, + loadFlag: false, + fatherSay:{}, }; }, //第一次加载 @@ -288,9 +332,11 @@ this.windowWidth = uni.getSystemInfoSync().windowWidth; // this.pageTitle = e.title console.log(e, '传入分类id') + this.courseId = e.id // this.getCateList(this.courseId) this.getData(e.id) this.getSuperMarketList() + this.getSayList() }, onPageScroll(e) { this.scrollTop = e.scrollTop; @@ -309,24 +355,190 @@ uni.hideTabBar(); }, + onReachBottom() { + console.log('触底'); + if (this.status != 2) { + this.pPage++ + this.getSayList() + } + }, components: { // musicPlay emotion, - + }, //方法 methods: { // 评论 + // 提交 + submitSay() { + this.editorCtx.getContents({ + success: (res) => { + console.log("save = >", res); + this.htmlContent = res.html + }, + }) + + if (this.htmlContent == '' && this.uploadPicLIst.length == 0) { + uni.showToast({ + icon: 'none', + title: '您未输入内容哦' + }) + return + } + let images = '' + if (this.uploadPicLIst.length > 0) { + let list = this.uploadPicLIst.map(item => item.url) + + images = list.join() + } + console.log(images, 'images') + let forUserId = null + let pid = 0 + forUserId = this.userInfo.id + if(this.fatherSay.id != undefined){ + forUserId = this.fatherSay.user.id + pid = this.fatherSay.id + } + $http.request({ + url: "common/courseGuestbook/addCourseGuestbook", + method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 + data: { + "type": 0, //类型0课程1章节 + "courseId": this.courseId, + "chapterId": "", + "pid": pid, + "userId": this.userInfo.id, + "forUserId": forUserId, + "content": this.htmlContent, //内容 + "images": images //图片的合集,逗号分隔 + }, + header: { //默认 无 说明:请求头 + 'Content-Type': 'application/json' + }, + }).then(res => { + if (res.code == 0) { + this.htmlContent = '' + this.uploadPicLIst = [] + this.editorCtx.clear() + uni.showToast({ + icon: 'success', + title: '提交成功' + }) + } + this.sayList.unshift(res.courseGuestbook) + // console.log(res, '提交成功',this.sayList); + this.sayVisible = false + // this.getSayList() + // 获得的新实例,插入到数组的前面 + + }).catch(e => { + uni.showToast({ + icon: 'error', + title: '提交失败' + }) + console.log('提交报错'); + }) + }, + // 查询课程的评论 + getSayList() { + if (this.loadFlag) { + console.log('有未完成的进程'); + return + } + this.loadFlag = true + this.status = 1 + $http.request({ + url: "common/courseGuestbook/getCourseGuestbookList", + method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 + data: { + "limit": 15, + "page": this.pPage, + "courseId": this.courseId, + "chapterId": "", + "userId": this.userInfo.id //登陆人id,用与判断评论是否被登陆人点赞 + }, + header: { //默认 无 说明:请求头 + 'Content-Type': 'application/json' + }, + }).then(res => { + console.log('sayList =>', res); + if (res.code == 0) { + if (res.page.records.length > 0) { + let myList = res.page.records + this.totalP = res.page.total + myList.map((item) => { + if (item.images != '') { + item.imgList = item.images.split(',') + } + }) + this.sayList = this.sayList.concat(myList) + console.log('this.sayList处理后 =》 ', this.sayList) + if (res.page.pages > this.pPage) { + this.status = 0 + } else { + this.status = 2 + } + } else { + this.status = 3 // 暂无数据 + } + } + this.loadFlag = false + }).catch(e => { + console.log('获取留言失败'); + this.loadFlag = false + }) + }, + previewImage(url) { + console.log(url) + uni.previewImage({ + urls: [url], + longPressActions: { + itemList: ['很抱歉,暂不支持保存图片到本地'], + success: function(res) { + // console.log(res,'+++++') + } + } + }); + }, + deletePic(val, i) { + console.log('删除图片'); + this.uploadPicLIst.splice(i, 1) + }, + addPic(e) { + console.log('添加图片'); + let that = this + for (var i = 0; i < e.file.length; i++) { + //console.log(i,e.file[i].url) + uni.uploadFile({ + url: this.$baseUrl + 'oss/fileoss', + filePath: e.file[i].url, + //files:e.file, + name: 'file', + formData: {}, + success: (res) => { + that.uploadPicLIst.push({ + url: JSON.parse(res.data).url + }) + // this.showPicsList = true + console.log(that.uploadPicLIst, 'that.uploadPicLIst') + }, + fail: (error) => { + console.log('上传失败', error) + } + }); + } + }, // 获得输入的表情数组 handleEmj(i) { console.log(i, 'i---------'); this.editorCtx.insertImage({ - src: i.emotion, - alt: '图像', - success: function() { - console.log('insert image success') - } - }) + src: i.emotion, + alt: '图像', + success: function() { + console.log('insert image success') + } + }) if (i.emotioni == '[em_98]') { //匹配最后一个表情符号并删除11。 // this.formData.content = this.formData.content.replace(/(\[[^\]]+\]|[\s\S])$/, ''); @@ -334,7 +546,7 @@ // this.emoji = this.emoji.slice(0, -1) // } } else { - + // this.emoji.push({ // 'tag': i.emotion, // 'name': i.emotioni @@ -342,52 +554,54 @@ // this.formData.content += i.emotioni; } }, - chooseImg(){ + chooseImg() { this.showImgType = true this.showEdit = true + uni.hideKeyboard() // 隐藏键盘 }, - editEditor(){ + editEditor() { this.showImgType = false this.showEdit = false this.showEmoji = false - + // 显示键盘 }, - closeEmoji(){ + closeEmoji() { this.showEmoji = false this.showEdit = false }, - addPic(){ - // 上传图片 - }, - addEmoji(){ + addEmoji() { this.showEmoji = true this.showImgType = false // this.showEdit = true }, onStatusChange(e) { - const formats = e.detail - this.formats = formats - }, + const formats = e.detail + this.formats = formats + }, readOnlyChange() { this.readOnly = !this.readOnly }, onEditorReady() { - // #ifdef MP-BAIDU - this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editor'); - // #endif + // // #ifdef MP-BAIDU + // this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editor'); + // // #endif // #ifdef APP-PLUS || MP-WEIXIN || H5 uni.createSelectorQuery().select('#editor').context((res) => { this.editorCtx = res.context + this.editorCtx.clear() }).exec() // #endif }, // end - addSay(item) { + addSay(item) { this.sayVisible = true + item ? this.fatherSay = item : '' + console.log('fatherSay =>',this.fatherSay); }, sayclose() { this.sayVisible = false + this.fatherSay = {} }, getSuperMarketList() { $http.request({ @@ -430,10 +644,10 @@ this.pageTitle = this.course.title this.librayList = res.data.catalogues if (this.librayList.length > 0) { - this.courseId = this.librayList[0].id + this.catalogueId = this.librayList[0].id this.curId = this.librayList[0].id this.curIndex = 0 - this.getChapterList(this.courseId) + this.getChapterList(this.catalogueId) } } @@ -597,22 +811,172 @@ url: `${url}` }); }, + formatRichText(html) { //控制图片大小 + let newContent = html.replace(/]*>/gi, function(match, capture) { + match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); + match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); + match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); + return match; + }); + newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) { + match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, + 'max-width:100%;'); + return match; + }); + newContent = newContent.replace(/]*\/>/gi, ''); + newContent = newContent.replace(/\