From fbdb8fe8c656c7fe77c5ceef8eaf11c23c76b382 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 22 Sep 2023 09:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9=E8=AF=9D=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87,=E9=99=90=E5=88=B6=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=E6=9C=80=E5=A4=9A5000=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 84 ++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 8aa5fc5..f72bae2 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -49,7 +49,7 @@ return { talkList: [], ajax: { - rows: 100, //每页数量 + rows: 15, //每页数量 page: 1, //页码 flag: false, // 请求开关 loading: false, // 加载中 @@ -76,8 +76,8 @@ uni.onKeyboardHeightChange(e => { let h = this.keyboardHeight; this.keyboardHeight = e.height; - this.$nextTick(()=>{ - setTimeout(()=>{ + this.$nextTick(() => { + setTimeout(() => { uni.pageScrollTo({ scrollTop: 9999999, // 当前位置向下滚动 duration: 300 // 滚动过渡时间为300ms,默认值为300ms @@ -106,7 +106,7 @@ if (cl < nc.length) { this.c_content += nc[cl]; cl++; - if (cl % 6 == 0) this.$nextTick(()=>{ + if (cl % 6 == 0) this.$nextTick(() => { uni.pageScrollTo({ scrollTop: 999999, }) @@ -136,7 +136,7 @@ }, // 获取历史消息 getHistoryMsg() { - return ; + return; if (this.ajax.flag) { return; // } @@ -222,7 +222,7 @@ }, 1500); }) }, - focus(){ + focus() { // this.$nextTick(()=>{ // setTimeout(()=>{ // uni.pageScrollTo({ @@ -263,13 +263,13 @@ }) return; } - try{ + try { clearInterval(this.timer); - this.talkList[this.talkList.length-1].content = this.c_content+''; + this.talkList[this.talkList.length - 1].content = this.c_content + ''; this.c_content = ''; this.n_content = ''; this.socketTask.close({ - success:(res)=> { + success: (res) => { console.log('关闭成功', res); this.wsLiveFlag = false; }, @@ -277,7 +277,7 @@ console.log('关闭失败', err) } }) - }catch(e){ + } catch (e) { //TODO handle the exception } // 将当前发送信息 添加到消息列表。 @@ -307,7 +307,7 @@ // }); }) this.sendToSpark(); - + }, async sendToSpark() { // let myUrl = await this.getWebSocketUrl(); @@ -350,7 +350,9 @@ // } // } // }; - let params = this.TEXT + if (this.historyTextList.length > 8) this.historyTextList = this.historyTextList.splice(-8); + this.isSurpass(); + let params = this.historyTextList; realThis.socketTask.send({ // 发送消息,,都用uni的官方版本 data: JSON.stringify(params), success() { @@ -404,6 +406,19 @@ } }) }, + // 判断文字是否超过五千字 + isSurpass(){ + let sum = this.historyTextList.reduce((accumulator, currentValue) => { + return accumulator + currentValue.content; + }, ''); + if(sum.length>5000){ + this.historyTextList.shift(); + return this.isSurpass(); + }else { + console.log(`本次发送${sum.length}字`); + return sum; + } + }, // 鉴权 getWebSocketUrl() { return new Promise((resolve, reject) => { @@ -429,17 +444,17 @@ }, // 滚动到头部 bindScroll() { - if (this.userId == 0) { - this.getHistory(); - this.getproductInfo(); - this.getOrderInfo(); - this.getRefundDetail(); - this.getStoreDetail(); - } else { - this.getMerHistory(); - } + if (this.userId == 0) { + this.getHistory(); + this.getproductInfo(); + this.getOrderInfo(); + this.getRefundDetail(); + this.getStoreDetail(); + } else { + this.getMerHistory(); + } }, - touchmove(e){ + touchmove(e) { uni.hideKeyboard() } } @@ -453,13 +468,21 @@ background-color: #f5f5f5; font-size: 28rpx; } - + @keyframes blink { - 0% { opacity: 1; } - 50% { opacity: 0; } - 100% { opacity: 1; } + 0% { + opacity: 1; + } + + 50% { + opacity: 0; + } + + 100% { + opacity: 1; + } } - + .blinking-box { background-color: #333; color: #333; @@ -521,8 +544,10 @@ border-top: #e5e5e5 solid 1px; box-sizing: content-box; background-color: #f5f5f5; - transform: translateY(0); /* 初始化 transform 属性 */ - transition: transform 0.3s ease; /* 添加过渡效果 */ + transform: translateY(0); + /* 初始化 transform 属性 */ + transition: transform 0.3s ease; + /* 添加过渡效果 */ /* 兼容iPhoneX */ padding-bottom: 0; @@ -640,6 +665,7 @@ margin: 0 !important; padding: 0 !important; } + .placeholder { width: 100vw; background-color: #1573fb;