获取可聊天的技师数据
This commit is contained in:
@@ -97,6 +97,21 @@ export class GirlChatData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
/** 是否可聊天 */
|
||||
public isCanChat(): boolean {
|
||||
// 剩余聊天次数
|
||||
let remainCount = this.chatRemainCount;
|
||||
if (remainCount < 0) {
|
||||
// 会员
|
||||
return true;
|
||||
} else if (remainCount === 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析聊天记录数据,一个
|
||||
private parseOneChatRecord(data: proto.cs.IChatMsg): proto.cs.IChatMsg | null {
|
||||
if (!data) return null;
|
||||
@@ -143,7 +158,6 @@ export class GirlChatData extends BaseData {
|
||||
|
||||
// 排序:根据 msgId 从大到小排序
|
||||
this.chatRecordIds.sort((a, b) => b - a);
|
||||
|
||||
logger.log("当前技师 ", this.id, " ,聊天记录:", this.chatRecord);
|
||||
}
|
||||
|
||||
@@ -152,6 +166,19 @@ export class GirlChatData extends BaseData {
|
||||
return this.chatRecordIds;
|
||||
}
|
||||
|
||||
/** 获取最新的聊天记录的id */
|
||||
public getLatestChatRecordId(): number | null {
|
||||
if (this.chatRecordIds.length === 0) return null;
|
||||
return this.chatRecordIds[0];
|
||||
}
|
||||
|
||||
/** 获取最新的聊天记录的时间戳(毫秒) */
|
||||
public getLatestChatRecordTimestamp(): number | null {
|
||||
if (this.chatRecordIds.length === 0) return null;
|
||||
// 最新一条的 msgId 本身就是时间戳(毫秒)
|
||||
return this.chatRecordIds[0];
|
||||
}
|
||||
|
||||
/** 获取聊天记录,根据 id */
|
||||
private getChatRecordById(id: number): proto.cs.IChatMsg | null {
|
||||
return this.chatRecord.get(id.toString()) ?? null;
|
||||
|
||||
Reference in New Issue
Block a user