|
@@ -25,7 +25,7 @@
|
|
|
<scroll-view class="cs-chat-list" :scroll-y="true" :scroll-with-animation="true"
|
|
|
:scroll-into-view="scrollToView" :style="{
|
|
|
paddingBottom: (keyboardHeight ? keyboardHeight + 100 : 100) + 'rpx',
|
|
|
- }">
|
|
|
+ }" @refresherrefresh="loadMoreHistory" :refresher-enabled="true" :refresher-triggered="triggered" enable-back-to-top ref="scrollView">
|
|
|
<view v-for="(msg, idx) in chatList" :key="msg.id">
|
|
|
<template v-if="msg.message_type == 1 || msg.message_type == 2 || msg.message_type == 3 || msg.message_type == 4 || msg.message_type == 5 ">
|
|
|
|
|
@@ -184,15 +184,19 @@ export default {
|
|
|
orderCardHeight: 260,
|
|
|
showEmojiPanel: false,
|
|
|
showDropdown: false,
|
|
|
- emojiList: ["😀", "😁", "😂", "🤣", "😃", "😄", "😅", "😆", "😉", "😊", "😋", "😎", "😍", "😘", "🥰", "😗", "😙", "😚", "🙂", "🤗", "🤩", "🤔", "🤨", "😐", "😑", "😶", "🙄", "😏", "😣", "😥", "😮", "🤐", "😯", "😪", "😫", "🥱", "😴", "😌", "😛", "😜", "😝", "🤤", "😒", "😓", "😔", "😕", "🙃", "🤑", "😲", "☹️", "🙁", "😖", "😞", "😟", "😤", "😢", "😭", "😦", "😧", "😨", "😩", "🤯", "😬", "😰", "😱", "🥵", "🥶", "😳", "🤪", "😵", "😡", "😠", "🤬", "😷", "🤒", "🤕", "🤢", "🤮", "🥴", "😇", "🥳", "🥺", "🤠", "😈", "👿", "👹", "👺", "💀", "👻", "👽", "🤖", "💩", "😺", "😸", "😹", "😻", "😼", "😽", "🙀", "😿", "😾", "🙈", "🙉", "🙊", "💋", "💌", "💘", "💝", "💖", "💗", "💓", "💞", "💕", "💟", "❣️", "💔", "❤️", "🧡", "💛", "💚", "💙", "💜", "🤎", "🖤", "🤍", "💯", "💢", "💥", "💫", "💦", "💨", "🕳️", "💣", "💬", "👋", "🤚", "🖐️", "✋", "🖖", "👌", "🤏", "✌️", "🤞", "🤟", "🤘", "🤙", "👈", "👉", "👆", "🖕", "👇", "☝️", "👍", "👎", "✊", "👊", "🤛", "🤜", "👏", "🙌", "👐", "🤲", "🙏", "✍️", "💅", "🤳", "💪", "🦾", "🦵", "🦶", "👂", "👃", "🧠", "🦷", "🦴", "��", "👁️", "👅", "👄"],
|
|
|
+ emojiList: ["😀", "😁", "😂", "🤣", "😃", "😄", "😅", "😆", "😉", "😊", "😋", "😎", "😍", "😘", "🥰", "😗", "😙", "😚", "🙂", "🤗", "🤩", "🤔", "🤨", "😐", "😑", "😶", "🙄", "😏", "😣", "😥", "😮", "🤐", "😯", "😪", "😫", "🥱", "😴", "😌", "😛", "😜", "😝", "🤤", "😒", "😓", "😔", "😕", "🙃", "🤑", "😲", "☹️", "🙁", "😖", "😞", "😟", "😤", "😢", "😭", "😦", "😧", "😨", "😩", "🤯", "😬", "😰", "😱", "🥵", "🥶", "😳", "🤪", "😵", "😡", "😠", "🤬", "😷", "🤒", "🤕", "🤢", "🤮", "🥴", "😇", "🥳", "🥺", "🤠", "😈", "👿", "👹", "👺", "💀", "👻", "👽", "🤖", "💩", "😺", "😸", "😹", "😻", "😼", "😽", "🙀", "😿", "😾", "🙈", "🙉", "🙊", "💋", "💌", "💘", "💝", "💖", "💗", "💓", "💞", "💕", "💟", "❣️", "💔", "❤️", "🧡", "💛", "💚", "💙", "💜", "🤎", "🖤", "🤍", "💯", "💢", "💥", "💫", "💦", "💨", "🕳️", "💣", "💬", "👋", "🤚", "🖐️", "✋", "🖖", "👌", "🤏", "✌️", "🤞", "🤟", "🤘", "🤙", "👈", "👉", "👆", "🖕", "👇", "☝️", "👍", "👎", "✊", "👊", "🤛", "🤜", "👏", "🙌", "👐", "🤲", "🙏", "✍️", "💅", "🤳", "💪", "🦾", "🦵", "🦶", "👂", "👃", "🧠", "🦷", "🦴", "", "👁️", "👅", "👄"],
|
|
|
conversationId: 0,
|
|
|
creatorId: 0,
|
|
|
zcId: 0,
|
|
|
lastMsgId: 0,
|
|
|
- pageSize: 20,
|
|
|
+ pageSize: 5,
|
|
|
userInfo: {},
|
|
|
showRealInput: false, // 控制显示真输入框还是假输入框
|
|
|
orderCardData: {},
|
|
|
+ page: 1, // 当前页码
|
|
|
+ hasMoreHistory: true, // 是否还有更多历史消息
|
|
|
+ triggered: false, // 是否触发下拉刷新
|
|
|
+ messageIds: new Set(), // 保存已查询到的消息 ID
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
@@ -215,8 +219,8 @@ export default {
|
|
|
// 轮询获取消息
|
|
|
startPolling() {
|
|
|
this.clearPolling();
|
|
|
- this.pollTimer = setInterval(() => this.fetchMessages(false), 5000);
|
|
|
- this.fetchMessages(false);
|
|
|
+ this.pollTimer = setInterval(() => this.fetchMessages(false), 5 * 1000);
|
|
|
+ // this.fetchMessages(false);
|
|
|
},
|
|
|
clearPolling() {
|
|
|
if (this.pollTimer) {
|
|
@@ -236,7 +240,7 @@ export default {
|
|
|
conversation_id: this.conversationId,
|
|
|
last_id: isAppend ? this.lastMsgId : 0,
|
|
|
page_size: this.pageSize,
|
|
|
- // page_size: 40,
|
|
|
+ page: 1,
|
|
|
zc_id: this.zcId
|
|
|
},
|
|
|
success: (res) => {
|
|
@@ -267,7 +271,10 @@ export default {
|
|
|
const tempMsgs = this.chatList.filter(m => m.uploading);
|
|
|
let newList;
|
|
|
if (isAppend) {
|
|
|
- newList = [...msgList, ...this.chatList.filter(m => !m.uploading), ...tempMsgs];
|
|
|
+ // 轮询时只追加新消息,不覆盖历史消息
|
|
|
+ const newMsgs = msgList.filter(msg => !this.messageIds.has(msg.id));
|
|
|
+ newMsgs.forEach(msg => this.messageIds.add(msg.id));
|
|
|
+ newList = [...this.chatList.filter(m => !m.uploading), ...newMsgs, ...tempMsgs];
|
|
|
} else {
|
|
|
newList = [...msgList, ...tempMsgs];
|
|
|
}
|
|
@@ -290,6 +297,69 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 加载更多历史消息
|
|
|
+ loadMoreHistory() {
|
|
|
+ // 立即开启动画,防止动画失效
|
|
|
+ this.triggered = true;
|
|
|
+ if (!this.hasMoreHistory) {
|
|
|
+ this.triggered = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.page++;
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + '/App/kefuGetMessages',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ creator_id: this.creatorId,
|
|
|
+ conversation_id: this.conversationId,
|
|
|
+ page_size: this.pageSize,
|
|
|
+ page: this.page,
|
|
|
+ zc_id: this.zcId
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data && res.data.success === 'yes' && res.data.data) {
|
|
|
+ const { messages } = res.data.data;
|
|
|
+ if (messages && messages.length > 0) {
|
|
|
+ const msgList = messages.map(msg => {
|
|
|
+ let returnValue = {
|
|
|
+ id: msg.id,
|
|
|
+ content: msg.content,
|
|
|
+ type: msg.from_type === 1 ? 'user' : 'customerService',
|
|
|
+ avatar: msg.from_type === 1 ? (this.userInfo.avatar || '/static/makedetail/characterProfilePicture.png') : '/static/home/avator.png',
|
|
|
+ time: msg.create_time,
|
|
|
+ message_type: msg.message_type,
|
|
|
+ media_url: msg.media_url,
|
|
|
+ progress: msg.progress,
|
|
|
+ uploading: msg.uploading
|
|
|
+ }
|
|
|
+ if (msg.message_type == 5) {
|
|
|
+ returnValue.order = JSON.parse(msg.content);
|
|
|
+ }
|
|
|
+ return returnValue;
|
|
|
+ });
|
|
|
+ msgList.forEach(msg => this.messageIds.add(msg.id));
|
|
|
+ this.chatList = [...msgList, ...this.chatList];
|
|
|
+ } else {
|
|
|
+ this.hasMoreHistory = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.hasMoreHistory = false;
|
|
|
+ }
|
|
|
+ // 数据渲染后再关闭动画
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.triggered = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ uni.showToast({ title: '加载历史消息失败', icon: 'none' });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.triggered = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 发送消息
|
|
|
sendMsg(message_type) {
|
|
|
|
|
@@ -453,13 +523,13 @@ export default {
|
|
|
try {
|
|
|
if (sourceType === 'camera') {
|
|
|
hasPermission = await permission.request(permission.PermissionType.CAMERA, {
|
|
|
- title: '“萌创星球”想访问你的相机',
|
|
|
- describe: '萌创星球想访问您的摄像头,便于拍摄获取图片来与其他用户进行交流'
|
|
|
+ title: '"萌创星球"想访问你的相机',
|
|
|
+ describe: '"萌创星球"想访问您的摄像头,便于拍摄获取图片来与其他用户进行交流'
|
|
|
});
|
|
|
} else {
|
|
|
hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
|
|
|
- title: '“萌创星球”想访问你的照片图库',
|
|
|
- describe: '萌创星球想访问您本地照片图库,便于获取图片来与其他用户进行交流'
|
|
|
+ title: '"萌创星球"想访问你的照片图库',
|
|
|
+ describe: '"萌创星球"想访问您本地照片图库,便于获取图片来与其他用户进行交流'
|
|
|
});
|
|
|
}
|
|
|
if (!hasPermission) {
|