💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# updateHistoryMessages(更新历史消息) ``` //更新历史消息 function updateHistoryMessages(data) { if (data) { var myUserid = user.id; // var messageList = data.sort(getSortFun('asc', 'sendTime')); // TOOD 待测试 var messageList = data; var html = ''; for (var i in messageList) { if (messageList[i].senderUserId == myUserid) { //console.log('messageList[i]' + JSON.stringify(messageList[i])); //当前发送用户 html += '<div class="aui-chat-sender" id="message-' + messageList[i].messageId + '">'; html += '<div class="aui-chat-sender-avatar" tapmode onclick="weiboUserIntroduce('+ myUserid +')"><img src="' + myAvatar + '"></div>'; html += '<div class="aui-chat-sender-cont">'; html += '<div class="aui-chat-right-triangle"></div>'; } else { html += '<div class="aui-chat-receiver" id="message-' + messageList[i].messageId + '">'; html += '<div class="aui-chat-receiver-avatar" tapmode onclick="weiboUserIntroduce('+ targetId +')"><img src="' + targetAvatar + '"></div>'; html += '<div class="aui-chat-receiver-cont">'; html += '<div class="aui-chat-left-triangle"></div>'; } var message = JSON.stringify({event:messageList[i].conversationType,from:messageList[i].senderUserId,to:messageList[i].targetId,msgType:messageList[i].objectName,content:messageList[i].content,msgId:messageList[i].messageId,time:messageList[i].sendTime}); switch (messageList[i].objectName) { //文字消息 case '1' : if(messageList[i].sendStatus == 'sending'){ html += '<div class="aui-chat-status" onclick = sendMessageToServer(\''+ message +'\') id="messageStatus-' + messageList[i].messageId + '" ><i class="aui-iconfont aui-icon-info aui-text-danger"></i></div>'; } html += '<span>' + transText(messageList[i].content) + '</span>'; break; //图片消息 case '2' : if(messageList[i].sendStatus == 'sending'){ html += '<div class="aui-chat-status" tapmode onclick= uploadPicture(\'' + message + '\') id="messageStatus-' + messageList[i].messageId + '" ><i class="aui-iconfont aui-icon-info aui-text-danger"></i></div>'; } html += '<span class="aui-chat-img chat-img" onclick ="photoBrowser(\''+ messageList[i].content + '\')"><img src="' + messageList[i].content + '" /></span>'; break; //语音消息 case '3' : messageList[i].content = JSON.parse(messageList[i].content.replace(/\\/g,'')); //html += '<span>[语音消息]</span>'; if(messageList[i].sendStatus == 'sending'){ html += '<div class="aui-chat-status" tapmode onclick= uploadVoice(\'' + message + '\') id="messageStatus-' + messageList[i].messageId + '" ><i class="aui-iconfont aui-icon-info aui-text-danger"></i></div>'; }else{ html += '<div class="aui-chat-status">' + messageList[i].content.duration + 's</div>'; } html += '<span tapmode onclick="playVoice(\'' + messageList[i].content.path + '\',\'' + messageList[i].messageId + '\',\'' + messageList[i].content.duration + '\')"><i class="aui-iconfont aui-icon-sound" id="messageVoice-' + messageList[i].messageId + '"></i></span>'; break; //图文消息 case '4' : html += '<span>[图文消息]</span>'; break; //位置消息 case '5' : html += '<span class="aui-chat-img"><img src="http://api.map.baidu.com/staticimage?center=' + messageList[i].content.longitude + ',' + messageList[i].content.latitude + '&width=300&height=180&zoom=15&copyright=1" /></span>'; html += '<p>' + messageList[i].content.poi + '</p>'; break; } html += '</div>'; html += '</div>'; } // $api.prepend($api.byId("messageList"), html); $api.html($api.byId("messageList"), html); api.parseTapmode(); setTimeout(function() { window.scrollTo(0, $api.offset($api.byId("messageList")).h); }, 300) } } ```