优化聊天界面
This commit is contained in:
@@ -19,11 +19,14 @@ Page({
|
||||
conversationList: [],
|
||||
message_inquiry_type: 1,
|
||||
system_notice_unreadnnum: "",
|
||||
service_notice_unreadnnum: ""
|
||||
service_notice_unreadnnum: "",
|
||||
hasOnShow: false
|
||||
},
|
||||
onLoad() {
|
||||
console.log("wenzhen onload");
|
||||
let userID = wx.getStorageSync('user_id');
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let userID = wx.getStorageSync('user_id_'+usertype);
|
||||
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived, this);
|
||||
setInterval(() => {
|
||||
let system_notice_unreadnnum = wx.getStorageSync(userID+"_system_notice_unreadnnum");
|
||||
let service_notice_unreadnnum = wx.getStorageSync(userID+"_service_notice_unreadnnum");
|
||||
@@ -35,13 +38,28 @@ Page({
|
||||
},
|
||||
onShow: function () {
|
||||
console.log("onShow from wenzhen V2")
|
||||
if(this.data.hasOnShow){
|
||||
return;
|
||||
}
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
this.getTabBar().setData({
|
||||
active: 1 //数字是当前页面在tabbar的索引,如我的查询页索引是2,因此这边为2,同理首页就为0,审批页面为1
|
||||
})
|
||||
}
|
||||
this.getConversationList();
|
||||
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived, this);
|
||||
//避免onshow加载多次
|
||||
this.setData({
|
||||
hasOnShow: true
|
||||
})
|
||||
},
|
||||
onHide(){
|
||||
console.log("onHideonHide from wenzhen")
|
||||
this.setData({hasOnShow: false})
|
||||
},
|
||||
onUnload(){
|
||||
console.log("onUnload from wenzhen")
|
||||
this.setData({hasOnShow: false})
|
||||
// wx.$TUIKit.off(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, this.$onMessageReceived);
|
||||
},
|
||||
getConversationList(){
|
||||
wx.$TUIKit.getConversationList().then((imResponse) => {
|
||||
@@ -234,6 +252,11 @@ Page({
|
||||
session_list.push(session_data_list_4);
|
||||
session_list.push(session_data_list_5);
|
||||
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let userID = wx.getStorageSync('user_id_'+usertype);
|
||||
let wenzhen_info = 0;
|
||||
let message_inquiry_type = this.data.message_inquiry_type;
|
||||
|
||||
this.data.conversationList.forEach(item => {
|
||||
let conversationID = item.conversationID;
|
||||
if(conversationID == "C2Cadministrator") return;//如果是管理员消息直接跳过
|
||||
@@ -249,8 +272,11 @@ Page({
|
||||
let inquiry_type = cloudCustomDataJson.inquiry_type;
|
||||
if(!inquiry_type) return;
|
||||
if(inquiry_type > 4) return;
|
||||
if(inquiry_type < message_inquiry_type){
|
||||
message_inquiry_type = inquiry_type;
|
||||
}
|
||||
let patient_family_data = cloudCustomDataJson.patient_family_data;
|
||||
if(!patient_family_data) return;
|
||||
if(patient_family_data == undefined) return;
|
||||
console.log("patient_family_data: ", patient_family_data);
|
||||
let session_item = {};
|
||||
session_item.inquiry_status = item.inquiry_status;//订单状态暂无
|
||||
@@ -267,17 +293,23 @@ Page({
|
||||
session_item.from_account = userProfile.userID;
|
||||
let unreadCount = item.unreadCount;
|
||||
if(unreadCount > 0){
|
||||
wenzhen_info = wenzhen_info + unreadCount;
|
||||
session_item.message_dot = true;
|
||||
}else{
|
||||
session_item.message_dot = false;
|
||||
}
|
||||
session_list[inquiry_type - 1].push(session_item);
|
||||
})
|
||||
|
||||
if(wenzhen_info == 0) wenzhen_info = "";
|
||||
wx.setStorageSync(userID+'_wenzhen_info', wenzhen_info);
|
||||
|
||||
this.setData({
|
||||
data_list_1: session_data_list_1,
|
||||
data_list_2: session_data_list_2,
|
||||
data_list_3: session_data_list_3,
|
||||
data_list_4: session_data_list_4,
|
||||
message_inquiry_type: message_inquiry_type
|
||||
})
|
||||
|
||||
if(this.data.data_list_1.length == 0 && this.data.data_list_2.length == 0 && this.data.data_list_3.length == 0 && this.data.data_list_4.length == 0 && this.data.data_list_5.length == 0){
|
||||
|
||||
Reference in New Issue
Block a user