From 9b8aa5389ae472f781ef86bb53da6d2f7a8b8ec7 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 22 Sep 2023 09:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=98=E5=8C=96,=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index f72bae2..496b143 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -60,6 +60,7 @@ content: '', c_content: '', n_content: '', + params: [], // 发送的消息内容 timer: '', socketTask: {}, TEXT: '', @@ -350,11 +351,12 @@ // } // } // }; - if (this.historyTextList.length > 8) this.historyTextList = this.historyTextList.splice(-8); + if (this.historyTextList.length > 8) this.params = JSON.parse(JSON.stringify(this.historyTextList.splice(-8))); + else this.params = JSON.parse(JSON.stringify(this.historyTextList)); + console.log(this.params); this.isSurpass(); - let params = this.historyTextList; realThis.socketTask.send({ // 发送消息,,都用uni的官方版本 - data: JSON.stringify(params), + data: JSON.stringify(this.params), success() { console.log('第一帧发送成功') } @@ -408,11 +410,11 @@ }, // 判断文字是否超过五千字 isSurpass(){ - let sum = this.historyTextList.reduce((accumulator, currentValue) => { + let sum = this.params.reduce((accumulator, currentValue) => { return accumulator + currentValue.content; }, ''); if(sum.length>5000){ - this.historyTextList.shift(); + this.params.shift(); return this.isSurpass(); }else { console.log(`本次发送${sum.length}字`);