mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-09 02:18:55 +08:00
fix(buyer): 未登录联系客服时提示登录
- 将登录提示由 Message 改为 Modal - 新增 promptLogin 方法处理登录跳转 - IMService 增加 accessToken 校验,未登录时提示登录 - 改进用户信息获取的错误处理 - 重构 IM 链接 URL 拼接,提升可读性
This commit is contained in:
@@ -284,6 +284,9 @@ export default {
|
||||
|
||||
// 置底按钮是否显示
|
||||
tipsBoard: false,
|
||||
|
||||
// 防止并发请求导致 loading 状态错乱
|
||||
recordsRequestId: 0,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -301,22 +304,15 @@ export default {
|
||||
}),
|
||||
},
|
||||
watch: {
|
||||
// 监听面板传递参数
|
||||
params () {
|
||||
this.loadRecord.minRecord = 0;
|
||||
this.tipsBoard = false;
|
||||
this.multiSelect = {
|
||||
isOpen: false,
|
||||
items: [],
|
||||
mode: 0,
|
||||
};
|
||||
this.loadChatRecords();
|
||||
|
||||
// 监听面板传递参数(含首次挂载)
|
||||
params: {
|
||||
handler () {
|
||||
this.resetRecordState();
|
||||
this.loadChatRecords();
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
this.loadChatRecords();
|
||||
},
|
||||
methods: {
|
||||
parseTime,
|
||||
sendTime: formatTime,
|
||||
@@ -496,27 +492,49 @@ export default {
|
||||
|
||||
|
||||
|
||||
resetRecordState () {
|
||||
this.loadRecord.minRecord = 0;
|
||||
this.loadRecord.pageNumber = 0;
|
||||
this.tipsBoard = false;
|
||||
this.multiSelect = {
|
||||
isOpen: false,
|
||||
items: [],
|
||||
mode: 0,
|
||||
};
|
||||
},
|
||||
|
||||
// 加载用户聊天详情信息
|
||||
loadChatRecords () {
|
||||
if (this.loadRecord.pageNumber === 0 || this.params.clickFlag) {
|
||||
this.loadRecord.pageNumber = 1
|
||||
this.params.clickFlag = false
|
||||
} else {
|
||||
this.loadRecord.pageNumber = this.loadRecord.pageNumber + 1
|
||||
if (!this.params.talkId) {
|
||||
this.loadRecord.status = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
const isFirstPage = this.loadRecord.pageNumber === 0;
|
||||
if (isFirstPage) {
|
||||
this.loadRecord.pageNumber = 1;
|
||||
} else {
|
||||
this.loadRecord.pageNumber = this.loadRecord.pageNumber + 1;
|
||||
}
|
||||
|
||||
const user_id = this.id;
|
||||
const data = {
|
||||
pageNumber: this.loadRecord.pageNumber,
|
||||
pageSize: this.loadChatRecords.pageSize,
|
||||
pageSize: this.loadRecord.pageSize,
|
||||
talkId: this.params.talkId,
|
||||
};
|
||||
this.loadRecord.status = 0;
|
||||
|
||||
let el = document.getElementById('lumenChatPanel')
|
||||
let scrollHeight = el.scrollHeight
|
||||
const requestId = ++this.recordsRequestId;
|
||||
let el = document.getElementById('lumenChatPanel');
|
||||
let scrollHeight = el ? el.scrollHeight : 0;
|
||||
|
||||
ServeTalkRecords(data).then((res) => {
|
||||
// 防止点击切换过快消息返回延迟,导致信息错误
|
||||
// console.log("读取历史数据", res);
|
||||
if (requestId !== this.recordsRequestId) return;
|
||||
if (res.code !== 200 || !Array.isArray(res.result)) {
|
||||
this.loadRecord.status = 2;
|
||||
return;
|
||||
}
|
||||
const records = res.result.map((item) => {
|
||||
let key = new Date().getTime();
|
||||
item.float = "center";
|
||||
@@ -524,28 +542,26 @@ export default {
|
||||
item.float = item.fromUser == user_id ? "right" : "left";
|
||||
}
|
||||
if (item.messageType == 'GOODS') {
|
||||
item.text = JSON.parse(item.text)
|
||||
item.text = JSON.parse(item.text);
|
||||
}
|
||||
// if (item.messageType == 'MESSAGE"') {
|
||||
// item.text = this.textReplaceEmoji(item.text)
|
||||
// }
|
||||
if (item.messageType == 'ORDER') {
|
||||
item.text = JSON.parse(item.text)
|
||||
item.text = JSON.parse(item.text);
|
||||
}
|
||||
return { ...item, [key]: key };
|
||||
});
|
||||
this.$store.commit("UNSHIFT_DIALOGUE", records);
|
||||
records.length
|
||||
? (this.loadRecord.status = 1)
|
||||
: (this.loadRecord.status = 2);
|
||||
this.loadRecord.status = records.length ? 1 : 2;
|
||||
this.$nextTick(() => {
|
||||
// if (data.record_id == 0 || !data.record_id) {
|
||||
if (data.record_id == 0 || data.pageNumber == 1) {
|
||||
el.scrollTop = el.scrollHeight
|
||||
if (!el) return;
|
||||
if (isFirstPage) {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
} else {
|
||||
el.scrollTop = el.scrollHeight - scrollHeight
|
||||
el.scrollTop = el.scrollHeight - scrollHeight;
|
||||
}
|
||||
})
|
||||
});
|
||||
}).catch(() => {
|
||||
if (requestId !== this.recordsRequestId) return;
|
||||
this.loadRecord.status = 2;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user