1.聊天框切换
1.1.定义全局字典
//globe chat record dic GLOBAL_CHAT_RECORD_DIC = { ‘single‘:{}, ‘group‘:{}, }
1.2.增加归档
//在切换之前把之前的聊天内容归档 var current_session_id = $(".chat-box-title").attr("contact-id"); var current_session_type = $(".chat-box-title").attr("contact-type"); if(current_session_id){ GLOBAL_CHAT_RECORD_DIC[current_session_type][current_session_id] = $(".chat-box-window").html() }
1.2.获取新内容
//获取新内容 var new_contact_chat_record = GLOBAL_CHAT_RECORD_DIC[contact_type][contact_id]; //如果是第一次从字典取值 if(typeof new_contact_chat_record == ‘undefined‘){ new_contact_chat_record = ‘‘; } //将内容赋予到对话框 $(".chat-box-window").html(new_contact_chat_record)
1.4.测试切换