From f18efe69ed5f5a970b684d4a869b3eb7a72a4f65 Mon Sep 17 00:00:00 2001
From: chen <1498780478@qq.com>
Date: Tue, 18 May 2021 11:05:11 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=EF=BC=9Afix=20type=20bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../manage-team/manage-team-info/manage-team-info.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/miniprogram/pages/user-center/manage-team/manage-team-info/manage-team-info.js b/miniprogram/pages/user-center/manage-team/manage-team-info/manage-team-info.js
index a5077b0..4616b72 100644
--- a/miniprogram/pages/user-center/manage-team/manage-team-info/manage-team-info.js
+++ b/miniprogram/pages/user-center/manage-team/manage-team-info/manage-team-info.js
@@ -257,9 +257,9 @@ Page({
/**
* 保存职位信息
*/
- saveRecruitment(e){
+ saveRecruitment(e) {
let params = e.detail.value;
- params.teamId = this.data.teamId - '0';
+ params.teamId = this.data.teamId + "";
if(!params.id){
delete params.id;
};
--
Gitee
From e504b280f1ef6e740b7670fe43bba3fdf45e26a5 Mon Sep 17 00:00:00 2001
From: chen <1498780478@qq.com>
Date: Thu, 20 May 2021 16:30:10 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E6=A1=86=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
miniprogram/pages/chat-room/chat-room.wxml | 9 ++++-----
miniprogram/pages/chat-room/chat-room.wxss | 4 +++-
miniprogram/utils/Notify.js | 2 +-
project.config.json | 3 +--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/miniprogram/pages/chat-room/chat-room.wxml b/miniprogram/pages/chat-room/chat-room.wxml
index cca5251..1dccbe4 100644
--- a/miniprogram/pages/chat-room/chat-room.wxml
+++ b/miniprogram/pages/chat-room/chat-room.wxml
@@ -8,13 +8,12 @@
-
-
-
-
+
+
-
+
diff --git a/miniprogram/pages/chat-room/chat-room.wxss b/miniprogram/pages/chat-room/chat-room.wxss
index 3cca79a..7d686a4 100644
--- a/miniprogram/pages/chat-room/chat-room.wxss
+++ b/miniprogram/pages/chat-room/chat-room.wxss
@@ -58,8 +58,10 @@ page {
}
.tui-input-box {
- width: 78%;
+ width: 85%;
justify-content: flex-start;
+ margin-left: 10px;
+ margin-right: 10px;
}
.tui-chat-input {
diff --git a/miniprogram/utils/Notify.js b/miniprogram/utils/Notify.js
index d2a820a..0475b34 100644
--- a/miniprogram/utils/Notify.js
+++ b/miniprogram/utils/Notify.js
@@ -176,7 +176,7 @@ export default class Notify {
}
});
// 缓存最新聊天id todo 暂时注释掉,便于测试
- wx.setStorageSync('lastChat:' + targetUid, chatId);
+ // wx.setStorageSync('lastChat:' + targetUid, chatId);
console.log("注意目前关闭了最新chatId缓存,请注意试验完后打开");
}
diff --git a/project.config.json b/project.config.json
index 06fd218..ca2875e 100644
--- a/project.config.json
+++ b/project.config.json
@@ -13,7 +13,7 @@
"minified": true,
"newFeature": true,
"coverView": true,
- "nodeModules": false,
+ "nodeModules": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
@@ -31,7 +31,6 @@
"outputPath": ""
},
"enableEngineNative": false,
- "bundle": false,
"useIsolateContext": true,
"useCompilerModule": false,
"userConfirmedUseCompilerModuleSwitch": false,
--
Gitee
From 10a4b856b443cece941a6bbdbef5101715df3343 Mon Sep 17 00:00:00 2001
From: chen <1498780478@qq.com>
Date: Sat, 22 May 2021 21:43:14 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=EF=BC=9A=E6=8E=A5=E6=94=B6?=
=?UTF-8?q?=E5=88=B0=E8=81=8A=E5=A4=A9=E6=B6=88=E6=81=AF=E5=90=8E=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E4=B8=8B=E6=8B=89=E8=87=B3=E5=BA=95=E9=83=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
miniprogram/app.wxss | 13 +++
miniprogram/pages/chat-room/chat-room.js | 106 ++++++++++++++++++---
miniprogram/pages/chat-room/chat-room.wxml | 30 +++---
miniprogram/pages/post/post.js | 9 +-
4 files changed, 128 insertions(+), 30 deletions(-)
diff --git a/miniprogram/app.wxss b/miniprogram/app.wxss
index 0482564..6c6bcca 100644
--- a/miniprogram/app.wxss
+++ b/miniprogram/app.wxss
@@ -143,3 +143,16 @@
.text-light {
font-weight: 300;
}
+
+.reset_btn {
+ margin:0;
+ padding:0;
+ border-radius:0;
+ border:none;
+ font-size:1em;
+ background-color:transparent;
+}
+
+.reset_btn::after{
+ border: none;
+}
\ No newline at end of file
diff --git a/miniprogram/pages/chat-room/chat-room.js b/miniprogram/pages/chat-room/chat-room.js
index 3a2abe0..372228c 100644
--- a/miniprogram/pages/chat-room/chat-room.js
+++ b/miniprogram/pages/chat-room/chat-room.js
@@ -14,10 +14,13 @@ Page({
socket: null, // websocket对象
watcherIndex: null, // 监听器下标
targetUid: null, // 当前聊天对象uid
+ selfUid: null,// 自己uid
msgCount: 20, // 默认拉取的消息数
chatList: [], // 聊天消息列表
targetUserInfo: null, // 当前聊天对象信息
- selfUserInfo: null // 用户自己的信息
+ selfUserInfo: null, // 用户自己的信息
+ isFocus: false,
+ clearValue: "",
},
onLoad: function (options) {
@@ -34,6 +37,7 @@ Page({
socket: socket,
finish_load: true,
targetUid: targetUid,
+ selfUid: selfUid
});
// 获取缓存最后的chatId,拉取历史聊天记录,跟websocket收到的消息重排序,防止消息乱序
let chatId = wx.getStorageSync('lastChat:' + targetUid);
@@ -44,6 +48,20 @@ Page({
this.getHistoryMsgList(chatId, type); // 这一步之后,新来的websocket消息如果id大于历史最大id则直接尾插,不再排序
},
+ onShow: function(options) {
+ this.onMessage();
+ },
+
+ // 页面返回事件
+ onUnload: function() {
+ app.$notify.delWatcher(this.data.watcherIndex);
+ app.$notify.setNotHandleUid(null);
+ this.setData({
+ watcherIndex: null
+ });
+ console.log('关闭页面监听的websocket');
+ },
+
// 获取用户信息
getUserInfo: function(uid, self) {
let that = this;
@@ -134,7 +152,8 @@ Page({
let msgType = config.MSG_TYPE;
if(
type == msgType.SINGLE_TEXT_MSG.type ||
- type == msgType.SINGLE_IMG_MSG.type
+ type == msgType.SINGLE_IMG_MSG.type ||
+ type == msgType.SERVER_ACK.type
) {
return true;
}
@@ -157,9 +176,14 @@ Page({
// 处理消息
handleMessage: function(data, pageObj) {
if (
- (!this.data.open_listen && this.data.targetUid != data.fromUid) ||
- data.fromUid != pageObj.data.targetUid
+ this.data.open_listen &&
+ (
+ (data.toUid == this.data.selfUid && data.fromUid == this.data.targetUid) ||
+ (data.fromUid == this.data.selfUid && data.toUid == this.data.targetUid)
+ )
) {
+ // none
+ } else {
return
}
let type = data.type;
@@ -168,22 +192,74 @@ Page({
this.setData({
chatList: this.data.chatList.concat([data])
})
+ this.pageScrollToBottom();
console.log("页面监听消息,id:" + chatId + ",内容:" + data.content);
}
app.$notify.ack(chatId, pageObj.data.targetUid);
},
- onShow: function(options) {
- this.onMessage();
- },
-
- // 页面返回事件
- onUnload: function() {
- app.$notify.delWatcher(this.data.watcherIndex);
- app.$notify.setNotHandleUid(null);
+ // 文本框聚焦回调
+ focusInput() {
this.setData({
- watcherIndex: null
+ isFocus: true
});
- console.log('关闭页面监听的websocket');
- }
+ },
+
+ // 文本框取消聚焦回调
+ blurInput() {
+ let that = this;
+ setTimeout(function() {
+ that.setData({
+ isFocus: false
+ })
+ }, 200);
+ },
+
+ // 发送文本消息
+ sendTextMsg(e) {
+ if(!app.checkedUserLoading()){
+ return;
+ }
+ let params = e.detail.value;
+ if(typeof params !== 'object'){
+ let content = params;
+ params = { content };
+ }
+ params.type = config.MSG_TYPE.SINGLE_TEXT_MSG.type;
+ params.toUid = this.data.targetUid;
+ params.timeStamp = new Date().getTime().toString();
+ let msg = JSON.stringify(params);
+ this.sendMsg(msg);
+ },
+
+ // 发送消息
+ sendMsg(msg) {
+ let that = this;
+ // todo 成功和失败都要重试
+ this.data.socket.send({
+ data: msg,
+ success: function (res) {
+ console.log("发送消息成功,消息内容:" + msg);
+ that.setData({
+ clearValue: ""
+ });
+ },
+ fail: function (res) {
+ console.warn("发送消息失败,消息内容:" + msg)
+ }
+ })
+ },
+
+ // 获取容器高度,使页面滚动到容器底部
+ pageScrollToBottom: function() {
+ wx.createSelectorQuery().select('#chat_panel').boundingClientRect(function(rect) {
+ if (rect){
+ // 使页面滚动到底部
+ console.log(rect.height);
+ wx.pageScrollTo({
+ scrollTop: rect.height
+ })
+ }
+ }).exec()
+ },
})
\ No newline at end of file
diff --git a/miniprogram/pages/chat-room/chat-room.wxml b/miniprogram/pages/chat-room/chat-room.wxml
index 1dccbe4..ac3faa9 100644
--- a/miniprogram/pages/chat-room/chat-room.wxml
+++ b/miniprogram/pages/chat-room/chat-room.wxml
@@ -3,21 +3,27 @@
-
-
-
-
+
+
-
+
diff --git a/miniprogram/pages/post/post.js b/miniprogram/pages/post/post.js
index 7bfc3ce..9d0d707 100644
--- a/miniprogram/pages/post/post.js
+++ b/miniprogram/pages/post/post.js
@@ -239,9 +239,12 @@ Page({
* 评论文本框失去焦点
*/
blurComment(){
- this.setData({
- isFocus: false
- })
+ let that = this;
+ setTimeout(function() {
+ that.setData({
+ isFocus: false
+ })
+ }, 200);
},
/**
--
Gitee