From e630e70376991dc805c1d522eb687fa6a0857abd Mon Sep 17 00:00:00 2001 From: "@fawn-nine" <1271023382@qq.com> Date: Fri, 22 Sep 2023 11:15:25 +0800 Subject: [PATCH] 09-22 --- pages/clock/clock.vue | 679 +++++++++++++++++++++++++----------------- pages/clock/index.vue | 23 +- 2 files changed, 418 insertions(+), 284 deletions(-) diff --git a/pages/clock/clock.vue b/pages/clock/clock.vue index bb3f2f7..20a4089 100644 --- a/pages/clock/clock.vue +++ b/pages/clock/clock.vue @@ -2,6 +2,11 @@ + + 正在参与{{bookInfo.name}}的打卡任务 + @@ -11,52 +16,56 @@ 返回今天 - - + + 补卡 - - + + 签到 - + - - - + + - + - + linshiDay == item1 ? 'linshiDay':'']" @click="getInfo(item1)"> {{item1}} - - 未签 + + 未签 未开始 - 签到 + 签到 - + - - + + {{taskInfo.heading}} - - - + + @@ -65,46 +74,49 @@ -- 我的签到 -- - +

#{{item.TaskHeading}}#

- + - + - + - {{item.createTime}} + {{item.createTime}} -
+
- - -- 更多签到记录 -- - - - - - - {{item.name}} - - -
- - - - -
- - {{item.createdate}} -
-
- - + +
+
+
-
- -
- +
@@ -153,7 +165,8 @@ - + @@ -173,39 +186,40 @@ export default { data() { return { - dayCurrent:0, // 载入页面时的显示页数 - showBack:false, - currentIndex:0, - dayList:[], + dayCurrent: 0, // 载入页面时的显示页数 + showBack: false, + currentIndex: 0, + dayList: [], indicatorDots: false, - autoplay: false, - interval: 2000, - duration: 500, - commentsList:[], // 他人的打卡列表 + autoplay: false, + interval: 2000, + duration: 500, + commentsList: [], // 他人的打卡列表 addTextShow: false, // 说点什么弹出层 show: false, scrollLeft: 0, // 距离左侧的距离 - currentDay:0, // 当前打卡位置 - currentTid:null, // 今天的任务id - emojiIcon: 'cuIcon-emoji', + currentDay: 0, // 当前打卡位置 + currentTid: null, // 今天的任务id + emojiIcon: 'cuIcon-emoji', windowWidth: 0, - taskInfo:{ - id:null, - heading:'' + taskInfo: { + id: null, + heading: '' }, - list3:[], // 时间日期 + list3: [], // 时间日期 emoji: [], - signList:[], // 已打卡天 - linshiDay:null, + signList: [], // 已打卡天 + linshiDay: null, page: 1, bookid: null, windowHeight: 500, isShowEmj: false, playData: {}, + bookInfo: {}, // 书籍信息 videoContext: null, innerAudioContext: null, // 音频对象 poster: '', - myword:[], // 我的打卡内容 + myword: [], // 我的打卡内容 formData: { // 打卡表单 content: '', @@ -228,16 +242,18 @@ required: true, errorMessage: '内容不能为空' }] - }, + }, }, } }, onLoad(e) { this.bookid = e.bookid - this.windowWidth = uni.getSystemInfoSync().windowWidth; + this.windowWidth = uni.getSystemInfoSync().windowWidth; + }, + onShow() { + this.getBookInfo() this.initDay() this.getmySign() - }, onReady() { this.videoContext = uni.createVideoContext('myVideo') @@ -248,34 +264,55 @@ ...mapState(['userInfo']) }, methods: { - swiperChange(e){ - console.log(e,'change') + // 获取书籍信息 + getBookInfo() { + this.$http + .post('book/book/appinfo/' + this.bookid + '/' + this.userInfo.id) + .then(res => { + if (res.code == 0) { + console.log(res, 'res') + this.bookInfo = res.book + } else { + console.log(res.msg) + } + console.log(res, 'res基本信息') + }).catch((error) => { + console.log(error) + }) }, - backTo(){ - // console.log('') - // this.currentIndex++ - this.currentIndex = this.dayCurrent - console.log(this.currentIndex,'点击了') + gotoDetail() { + uni.navigateTo({ + url: '../eBook/bookContent?Id=' + this.bookInfo.id + }); }, - animationfinish(e){ + swiperChange(e) { + console.log(e, 'change') + }, + backTo() { + // console.log('') + // this.currentIndex++ + this.currentIndex = this.dayCurrent + console.log(this.currentIndex, '点击了') + }, + animationfinish(e) { //console.log(e.detail.current,e) this.currentIndex = e.detail.current e.detail.current != this.dayCurrent ? this.showBack = true : this.showBack = false }, group(array, subGroupLength) { - let index = 0; - let newArray = []; - while(index < array.length) { - newArray.push(array.slice(index, index += subGroupLength)); - } - return newArray; + let index = 0; + let newArray = []; + while (index < array.length) { + newArray.push(array.slice(index, index += subGroupLength)); + } + return newArray; }, // 初始化day - initDay(){ + initDay() { var listint = 1 var arr = [] - var arr1 = [] - for (var i= 1; i<=365; i++) { + var arr1 = [] + for (var i = 1; i <= 365; i++) { arr.push(i) } arr1 = this.group(arr, 5) @@ -283,69 +320,70 @@ // console.log(arr1,'+++++++++++++') }, // 放大图片 - previewImage(url){ + previewImage(url) { console.log(url) uni.previewImage({ urls: [url] }); }, // 获取打卡参数 - getmySign(){ + getmySign() { let data = { - 'bookId': this.bookid, + 'bookId': this.bookid, 'userId': this.userInfo.id } this.$http .post('book/clockinPunch/clockindays', data) .then(res => { if (res.code == 0) { - this.currentDay = res.daysBetween + this.currentDay = res.daysBetween this.linshiDay = res.daysBetween this.signList = res.dayslist - console.log(res, '打卡参数') + console.log(res, '打卡参数') let zheng = Math.floor(this.currentDay / 5) this.currentIndex = zheng let yu = this.currentDay % 5 //if(this.currentDay <=5){this.scrollLeft = 0} - - if(zheng >= 1 && yu > 0){ + + if (zheng >= 1 && yu > 0) { // 不是前五个,并且不能整除 // this.scrollLeft = (this.windowWidth - 30) * zheng } - if(zheng > 1 && yu == 0){ - // this.scrollLeft = (this.windowWidth - 30) * (zheng - 1) + if (zheng > 1 && yu == 0) { + // this.scrollLeft = (this.windowWidth - 30) * (zheng - 1) this.currentIndex -= 1 } this.dayCurrent = this.currentIndex console.log(this.currentIndex, 'this.scrollLeft') this.getTask(this.currentDay) - - + + } - + }); }, - + // 获取当天我的发布内容 - getmyWord(){ + getmyWord() { this.$http - .post('book/clockin/myinfolist?userid='+this.userInfo.id+'&taskid='+ this.taskInfo.id + '&bookid='+this.bookid) + .post('book/clockin/myinfolist?userid=' + this.userInfo.id + '&taskid=' + this.taskInfo.id + + '&bookid=' + this.bookid) .then(res => { - console.log(res,'当天我的打卡内容') - if(res.code == 0 && res.productlist.length > 0 ){ + console.log(res, '当天我的打卡内容') + if (res.code == 0 && res.productlist.length > 0) { var arr = [] - res.productlist.forEach((item1)=>{ - var pjstr = '' - var imgs = [] - imgs = item1.clockinimages.split(',') - pjstr = this.getHtmlComment(item1.content) - item1.clockinimages = imgs - item1.phtml = pjstr - arr.push(item1) + res.productlist.forEach((item1) => { + var pjstr = '' + var imgs = [] + imgs = item1.clockinimages.split(',') + pjstr = this.getHtmlComment(item1.content) + item1.clockinimages = imgs + item1.phtml = pjstr + arr.push(item1) }) this.myword = arr // console.log(this.myword,'this.myword') - }else{ + } else { this.myword = [] } }) @@ -354,60 +392,60 @@ }) }, // 获取签到详情 - getInfo(index){ - if(this.currentDay < index){ + getInfo(index) { + if (this.currentDay < index) { uni.showToast({ - title:'未来日期不可签到', + title: '未来日期不可签到', icon: 'none' }) - }else{ - this.getTask(index) + } else { + this.getTask(index) } }, // 获取某天的签到列表信息 - getAllSign(val){ - console.log(val,'-----------') + getAllSign(val) { + console.log(val, '-----------') let data = { - 'bookid': this.bookid, + 'bookid': this.bookid, 'limit': 5, 'page': this.page, 'taskid': val.id } - + this.$http .post('book/clockin/applist', data) .then(res => { if (res.code == 0) { console.log(res, '所有人打卡信息') - if(res.list.length > 0){ - var arr = res.list - for (var i=0; i 0) { + var arr = res.list + for (var i = 0; i < arr.length; i++) { var arr1 = [] var pjstr = '' // console.log(arr[i].content,'arr[i].content') - pjstr = this.getHtmlComment(arr[i].content) + pjstr = this.getHtmlComment(arr[i].content) // console.log(pjstr,'pjstr') - arr1 = arr[i].images.split(',') + arr1 = arr[i].images.split(',') arr[i].images = arr1 arr[i].phtml = pjstr // console.log(arr1,'arr1') - + } // console.log(arr,'res.page.list') this.commentsList = arr - }else{ + } else { this.commentsList = [] - } - + } + } - + }); }, // 获取对应签到内容 - getTask(index){ + getTask(index) { uni.showLoading() let data = { - 'bookid': this.bookid, + 'bookid': this.bookid, 'days': index } console.log(data) @@ -417,132 +455,144 @@ .then(res => { if (res.code == 0) { console.log(res, '任务信息') - if(res.page.list.length > 0){ - this.taskInfo = res.page.list[0] - this.taskInfo.video != ''? this.poster = this.taskInfo.video + "?x-oss-process=video/snapshot,t_0,f_jpg" : '' - this.getmyWord() - this.getAllSign(this.taskInfo) - }else{ + if (res.page.list.length > 0) { + this.taskInfo = res.page.list[0] + this.taskInfo.video != '' ? this.poster = this.taskInfo.video + + "?x-oss-process=video/snapshot,t_0,f_jpg" : '' + this.getmyWord() + this.getAllSign(this.taskInfo) + } else { this.taskInfo = {} this.poster = '' } } uni.hideLoading() - + }).catch(e => { uni.hideLoading() }) }, // 补卡 - buSign(day){ - console.log('正在补卡',this.taskInfo) - if(!this.taskInfo.id){ + buSign(day) { + console.log('正在补卡', this.taskInfo) + if (!this.taskInfo.id) { uni.showToast({ - title:'当天未发布打卡任务', - icon:'none' + title: '当天未发布打卡任务,不可补卡哦', + icon: 'none' }) - return + return } let data = { "bookId": this.bookid, - "userId": this.userInfo.id, + "userId": this.userInfo.id, "tid": this.taskInfo.id, - "days":this.linshiDay + "days": this.linshiDay } - console.log(data,'data') + console.log(data, 'data') $http.request({ - url : 'book/clockinPunch/save', + url: 'book/clockinPunch/save', method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 data, header: { //默认 无 说明:请求头 'Content-Type': 'application/json' }, }).then(res => { - if (res.code == 0) { - //console.log(res, '快捷签到') - uni.showToast({ - title:'签到成功' - }) - this.addTextShow = false - this.formData.content = '' - this.formData.images = [] - this.getmySign() - this.getAllSign(this.taskInfo) - } - + if (res.code == 0) { + //console.log(res, '快捷签到') + uni.showToast({ + title: '签到成功' + }) + this.addTextShow = false + this.formData.content = '' + this.formData.images = [] + this.getmySign() + this.getAllSign(this.taskInfo) + } + }); }, // 快捷签到 - kuickSign(){ - let data = { - "bookId": this.bookid, - "userId": this.userInfo.id, - "tid": this.taskInfo.id, - "days":this.currentDay + kuickSign() { + + if (!this.taskInfo.id) { + uni.showToast({ + title: '当天未发布打卡任务,不可签到哦', + icon: 'none' + }) + return false } - $http.request({ - url : 'book/clockinPunch/save', - method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 - data, - header: { //默认 无 说明:请求头 - 'Content-Type': 'application/json' - }, - }).then(res => { + let data = { + "bookId": this.bookid, + "userId": this.userInfo.id, + "tid": this.taskInfo.id, + "days": this.currentDay + } + $http.request({ + url: 'book/clockinPunch/save', + method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 + data, + header: { //默认 无 说明:请求头 + 'Content-Type': 'application/json' + }, + }).then(res => { if (res.code == 0) { //console.log(res, '快捷签到') uni.showToast({ - title:'签到成功' + title: '签到成功', + icon: 'success' }) + return false this.addTextShow = false this.formData.content = '' this.formData.images = [] this.getmySign() this.getAllSign(this.taskInfo) } - - }); + + }); + }, // 说点什么 - goToSign() { + goToSign() { let data = { 'bookId': this.bookid, "userId": this.userInfo.id, "taskId": this.taskInfo.id, - "dayId": this.currentDay, + "dayId": this.currentDay, "content": this.formData.content, // "images": this.formData.imagesStr.join(), - "imageeStrings": this.formData.images, - } - - console.log(data,'data') + "imageeStrings": this.formData.images, + } + + console.log(data, 'data') $http.request({ - url : 'book/clockin/save', + url: 'book/clockin/save', method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 data, header: { //默认 无 说明:请求头 'Content-Type': 'application/json' }, }).then(res => { - if (res.code == 0) { - //console.log(res, '快捷签到') - uni.showToast({ - title:'发布成功', - icon:'success' - }) - this.addTextShow = false - this.formData.content = '' - this.formData.images = [] - this.formData.imagesStr = [] - this.getmySign() - this.getTask() - - } - + if (res.code == 0) { + //console.log(res, '快捷签到') + uni.showToast({ + title: '发布成功', + icon: 'success' + }) + this.addTextShow = false + this.formData.content = '' + this.formData.images = [] + this.formData.imagesStr = [] + this.getmySign() + this.getTask() + + } + }); }, scroll(e) { - - }, + + }, // 获得输入的表情数组 handleEmj(i) { console.log(i, 'i---------'); @@ -637,8 +687,8 @@ success: (res) => { that.formData.images.push({ url: JSON.parse(res.data).url - }) - console.log(that.formData.images,'that.formData.images') + }) + console.log(that.formData.images, 'that.formData.images') } }); } @@ -660,48 +710,103 @@ zsyCalendar, emotion, clockDate - }, + }, } \ No newline at end of file diff --git a/pages/clock/index.vue b/pages/clock/index.vue index 424f4ea..1aebcba 100644 --- a/pages/clock/index.vue +++ b/pages/clock/index.vue @@ -8,11 +8,11 @@ - - + + - {{item.book.name}} + {{item.name}} @@ -66,19 +66,16 @@ // 获取打卡图书 getfreeBook(){ this.$http - .post('book/userebookbuy/appbooklist', { - // .post('book/userebookbuy/buylist', { - // .post('book/buyorderdetail/querybuy', { - 'userId': this.userInfo.id, - // 'page':this.page, - // 'limit':100 + .post('book/userebookbuy/getUserClockBookList', { // 磊哥新写 + // .post('book/userebookbuy/appbooklist', { 原接口 + 'userId': this.userInfo.id, }) .then(res => { if(res.code == 0){ //this.ygtotalPage = res.resultlist.totalCount - this.bookList = res.resultlist - console.log(res,'已购买') - this.status = 3 + this.bookList = res.books + console.log(this.bookList,'打卡列表') + // this.status = 3 } }); @@ -124,7 +121,7 @@ height: 350rpx; } .u-row{flex-wrap: wrap;} - .u-col{overflow: hidden; height: 250px; margin-bottom: 30rpx; } + .u-col{overflow: hidden; margin-bottom: 30rpx; } .listenList{padding: 10rpx; box-sizing: border-box; width: calc(100% - 10rpx);} .flexbox{display: flex;} .scroll-Y {