diff --git a/.DS_Store b/.DS_Store index c2aab69..3df66ce 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/pages/home/xx/hy/hx/hx.js b/pages/home/xx/hy/hx/hx.js index 31835db..3bec25b 100644 --- a/pages/home/xx/hy/hx/hx.js +++ b/pages/home/xx/hy/hx/hx.js @@ -46,13 +46,25 @@ Page({ this.setData({visible: false}) }, delBtn(e){ - console.log(this.data.image); - const regex = /\d+/; - const matchResult = this.data.image.match(regex); - const number = matchResult[0]; - console.log(number); // 输出:254 - req.deleteRequest(`/api/user/curt/message/${number}`,{}).then(res => { - console.log(res,'删除成功'); + console.log('删除图片'); + console.log(e.currentTarget.dataset.item); + const url = e.currentTarget.dataset.item + const arr = url.split("/"); // 将链接按照 / 分割成数组 + const last = arr[arr.length - 1]; // 取得数组中的最后一个元素 + const num = last.split("?")[0]; // 将最后一个元素按照 ? 分割成数组,取得倒数第二个元素 + console.log(num); // 输出 128 + this.setData({delKey: e.currentTarget.dataset.item, resourceId:num}) + }, + delBtnHx(){ + const hxlist = this.data.hxlist + const id = hxlist.find(item => item.resourceId == this.data.resourceId).id + console.log(id); + req.deleteRequest(`/api/user/curt/message/${id}`,{}).then(res => { + console.log(res); + if (res.data.code === 200) { + this.getList() + this.setData({delKey: ''}) + } }) }, closeViewer(){this.setData({visible: false})}, @@ -75,6 +87,7 @@ Page({ item.createdAt = formattedDate }) console.log(list); + this.setData({hxlist: list}) const treeData = list.reduce((result, item) => { const group = result.find(group => group.createdAt === item.createdAt); if (group) { diff --git a/pages/home/xx/hy/hx/hx.wxml b/pages/home/xx/hy/hx/hx.wxml index 9738c8e..ba3d03a 100644 --- a/pages/home/xx/hy/hx/hx.wxml +++ b/pages/home/xx/hy/hx/hx.wxml @@ -9,7 +9,8 @@ {{ item.createdAt }} - + + 删除 diff --git a/pages/home/xx/hy/hx/hx.wxss b/pages/home/xx/hy/hx/hx.wxss index cb05339..975ebb8 100644 --- a/pages/home/xx/hy/hx/hx.wxss +++ b/pages/home/xx/hy/hx/hx.wxss @@ -74,6 +74,7 @@ } .block-item .item { + position: relative; width: 182rpx; height: 182rpx; margin: 4rpx 0 0 4rpx; @@ -85,6 +86,21 @@ height: 100%; } +.block-item .item .item-del{ + position: absolute; + top: -52rpx; + left: 6rpx; + width: 148rpx; + height: 84rpx; + border-radius: 10rpx; + color: #6c6c6c; + font-size: 28rpx; + display: flex; + align-items: center; + justify-content: center; + background-image: url(https://wk921-1316969570.cos.ap-nanjing.myqcloud.com/xy/ltqp.png); +} + .viewer { position: absolute; top: 0; diff --git a/pages/home/xx/lindex/lindex.js b/pages/home/xx/lindex/lindex.js index 1796ed0..4281444 100644 --- a/pages/home/xx/lindex/lindex.js +++ b/pages/home/xx/lindex/lindex.js @@ -224,7 +224,6 @@ Page({ clearInterval(this.data.timer) console.log('结束录音') this.data.RM.pause() - }, doStartLuyin(){ this.setData({RM:wx.getRecorderManager()}) diff --git a/pages/home/xx/xz/xz.js b/pages/home/xx/xz/xz.js index ecdf787..506cf76 100644 --- a/pages/home/xx/xz/xz.js +++ b/pages/home/xx/xz/xz.js @@ -11,13 +11,17 @@ Page({ to:'', from:'', content:'', - img:'https://wk921-1316969570.cos.ap-nanjing.myqcloud.com/xzimg.png', + img:'', messageList:[], sound:'', - soundTime:0, + soundTime:'00:00:00', + duration: '', + minute:0, //分 + second:0, //秒 + millisecond:0, //毫秒 showBtn:true, - showImg:true, - showLtqp:true, + showImg:false, + showLtqp:false, showImgBig:false, //图片太大弹层 showSoundMore:false, //语音太多提示 showSend:false, //寄出提示 @@ -26,13 +30,15 @@ Page({ showAlready:false, btn1:true, btn2:false, - btn3:false + btn3:false, + showSoundImg:true }, writeLetters(){ console.log('写信'); this.setData({ showImg:false, showLtqp:false, + Preview: false }) }, already(){ @@ -74,6 +80,9 @@ Page({ openPreview(){ console.log('预览'); this.setData({Preview:true}) + if(this.data.messageList.length){ + this.setData({showLtqp: true}) + } }, ClearYl(){ console.log('清除语音'); @@ -89,17 +98,15 @@ Page({ return item.type !== "graphic" }) this.setData({ - img:'https://wk921-1316969570.cos.ap-nanjing.myqcloud.com/xzimg.png', - messageList: list + img:'', + messageList: list, + showImg: false }) console.log(this.data.messageList); }, // 上传图片 addImg(){ console.log('添加图片'); - this.setData({ - showImg:true - }) wx.chooseMedia({ mediaType: 'image', success: (res) => { @@ -155,7 +162,8 @@ Page({ }) this.setData({ img:data.data.abUrl, - messageList:list + messageList:list, + showImg:true }) console.log(this.data.messageList); } @@ -186,61 +194,97 @@ Page({ }, openSound(){ console.log('添加声音'); - this.setData({showSound:true,showLtqp:true}) + this.setData({showSound:true}) }, closeSound(){ this.setData({showSound:false}) }, startSound(){ console.log('开始录音'); - const time = setInterval(()=>{ - this.setData({soundTime:this.data.soundTime + 1}) - },1000) - this.setData({ timeId: time }) - wx.startRecord({ - success: (res) => { - console.log(res.tempFilePath); - this.setData({sound:res.tempFilePath,btn1:false,btn2:true}) - } - }) + + this.setData({btn1: false, btn2: true, showSoundImg: false}) + let option = { + duration:10000, //录音的时长,之前最大值好像只有1分钟,现在最长可以录音10分钟 + format:'mp3', //录音的格式,有aac和mp3两种 + } + wx.getRecorderManager().start(option) + // 开启定时器 + this.data.timeOut = setInterval(this.counter,50) + }, + // 计时器 + counter(){ + let second = this.data.second + let minute = this.data.minute + let millisecond = this.data.millisecond + + this.setData({millisecond: millisecond + 5}) + if(millisecond > 99) { + this.setData({millisecond: 0, second : second + 1 }) + }else if(second >= 60) { + this.setData({second: 0, minute: minute + 1}) + }else if(minute === 3) { + this.second({soundTime: '03:00:00'}) + clearInterval(this.data.timeOut) + } + + let time = '0' + minute + if (second < 10) { + time = time + ':0' + second + }else { + time = time + ':' + second + } + if (millisecond < 10){ + time = time + ':0' + millisecond + } else { + time = time + ':' + millisecond + } + + this.setData({soundTime: time}) }, endSound(){ - console.log('结束录音'); - wx.stopRecord() - clearInterval(this.data.timeId) + console.log('暂停录音'); + wx.getRecorderManager().pause() + clearInterval(this.data.timeOut) + this.setData({btn2:false, btn3:true, showSoundImg:true}) }, playVoice(){ - console.log('播放录音'); - this.setData({btn2:false,btn3:true}) - wx.playVoice({ - filePath: this.data.sound, - complete: () => { - console.log('录音播放结束'); - this.setData({btn2:true,btn3:false}) - } - }); + console.log('继续录音'); + wx.getRecorderManager().resume() + this.data.timeOut = setInterval(this.counter,50) + this.setData({btn2:true, btn3:false, showSoundImg:false}) }, addSound(){ console.log('添加录音'); - this.uploadFile(this.data.sound,'audio') - this.setData({ - btn1:true, - btn2:false, - btn3:false, - soundTime:0 + console.log(this.data.soundTime); + this.setData({duration: this.data.soundTime}) + wx.getRecorderManager().stop() + clearInterval(this.data.timeOut) + // 监听结束录音 + wx.getRecorderManager().onStop((res) => { + console.log(res); + this.uploadFile(res.tempFilePath,'audio') }) - // console.log(this.data.messageList); - }, - delSound(){ - console.log('不添加该条语音'); this.setData({ - sound:'', btn1:true, btn2:false, btn3:false, - soundTime:0 + showLtqp: true, + minute:0, + second:0, + millisecond:0, + soundTime:'00:00:00' }) }, + // delSound(){ + // console.log('不添加该条语音'); + // this.setData({ + // sound:'', + // btn1:true, + // btn2:false, + // btn3:false, + // soundTime:'00:00:00' + // }) + // }, logout(){ req.deleteRequest('/api/user/logout',{}).then((res)=>{ if(res.data.code===200){ @@ -257,15 +301,15 @@ Page({ console.log('获取当前用户信札内容'); req.getRequest('/api/user/curt/letter',{}).then(res => { console.log(res); - res.data.data.messageList.forEach(item => { - if(item.type === 'text'){ - this.setData({content: item.content}) - } - }) - this.setData({ - to: res.data.data.to, - from: res.data.data.from, - }) + // res.data.data.messageList.forEach(item => { + // if(item.type === 'text'){ + // this.setData({content: item.content}) + // } + // }) + // this.setData({ + // to: res.data.data.to, + // from: res.data.data.from, + // }) }) }, /** diff --git a/pages/home/xx/xz/xz.wxml b/pages/home/xx/xz/xz.wxml index b738dfb..9a772b6 100644 --- a/pages/home/xx/xz/xz.wxml +++ b/pages/home/xx/xz/xz.wxml @@ -23,7 +23,7 @@ - 2′24″ + {{duration}} @@ -51,19 +51,22 @@ - + - 取消 + 取消 添加 {{soundTime}} - + + + + - - - + + + diff --git a/pages/home/xx/xz/xz.wxss b/pages/home/xx/xz/xz.wxss index 08639ee..89c2c8b 100644 --- a/pages/home/xx/xz/xz.wxss +++ b/pages/home/xx/xz/xz.wxss @@ -375,6 +375,32 @@ background-image: url(https://wk921-1316969570.cos.ap-nanjing.myqcloud.com/iconPark-acoustic%20Copy%203%401x.png); } +.sound-box-img2 { + width: 1000px; + height: 50rpx; + margin-top: 40rpx; + animation: move 5s infinite linear; +} + +.sound-box-img2 image { + width: 50rpx; + height: 50rpx; +} +/* 定义动画 */ + /* 定义和调用动画 */ + @keyframes move { + + /* 动画的第一个状态和盒子的默认状态相同, 可以省略动画的开始状态代码 */ + /* from { + transform: translateX(0); + } */ + to { + transform: translateX(-750rpx); + /* transform: translateX(-900px); */ + /* transform: translateX(-800px); */ + } +} + .sound-box-btn { width: 100%; height: 120rpx; diff --git a/pages/xz/index.js b/pages/xz/index.js index 1469421..d5beaaf 100644 --- a/pages/xz/index.js +++ b/pages/xz/index.js @@ -8,7 +8,7 @@ Page({ * 页面的初始数据 */ data: { - img:'https://wk921-1316969570.cos.ap-nanjing.myqcloud.com/xzimg.png', + img:'', letterMsg:{}, showLetter: true, showMore: false, diff --git a/project.private.config.json b/project.private.config.json index 1033261..bb4d0f1 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -21,6 +21,20 @@ "query": "", "launchMode": "default", "scene": null + }, + { + "name": "", + "pathName": "pages/home/xx/xz/xz", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/home/xx/hy/hx/hx", + "query": "", + "launchMode": "default", + "scene": null } ] }