|
|
@@ -67,7 +67,7 @@
|
|
|
<button class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="message-time align-right">{{ message.time }}</view>
|
|
|
+ <view class="message-time">{{ message.time }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -201,6 +201,7 @@ export default {
|
|
|
},
|
|
|
// 聊天消息列表
|
|
|
messageList: [],
|
|
|
+ today: new Date().toLocaleDateString(),
|
|
|
// WebSocket相关
|
|
|
socket: null,
|
|
|
isConnected: true,
|
|
|
@@ -281,16 +282,16 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- const paramsUserId = this._parseAndValidateId(params.userId, "登录用户数据异常,请稍后再试", false);
|
|
|
+ const paramsUserId = this._parseAndValidateId(params.userId, "登录用户数据异常1,请稍后再试", false);
|
|
|
// if (paramsUserId === null) return;
|
|
|
|
|
|
if (this.loginInfo.id) {
|
|
|
- this.currentUser.userId = this._parseAndValidateId(this.loginInfo.id, "登录用户数据异常,请稍后再试");
|
|
|
+ this.currentUser.userId = this._parseAndValidateId(this.loginInfo.id, "登录用户数据异常2,请稍后再试");
|
|
|
if (this.currentUser.userId === null) return;
|
|
|
|
|
|
if (paramsUserId != null && this.currentUser.userId !== paramsUserId) {
|
|
|
console.error("登录用户数据异常 ---- :", this.currentUser.userId, paramsUserId)
|
|
|
- this.$msg("登录用户数据异常,请稍后再试");
|
|
|
+ this.$msg("登录用户数据异常3,请稍后再试");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -342,8 +343,8 @@ export default {
|
|
|
_parseAndValidateId(id, errorMsg, showMsg=true) {
|
|
|
const parsedId = parseInt(id);
|
|
|
if (isNaN(parsedId) || parsedId <= 0) {
|
|
|
- console.error(errorMsg + ' ---------- id: ', id);
|
|
|
if (showMsg) {
|
|
|
+ console.error(errorMsg + ' ---------- id: ', id);
|
|
|
this.$msg(errorMsg);
|
|
|
}
|
|
|
return null;
|
|
|
@@ -389,7 +390,10 @@ export default {
|
|
|
newItem.goodsInfo = this.parseGoodsMessage(newItem.message, newItem.timestamp);
|
|
|
}
|
|
|
newItem.isMine = isMine;
|
|
|
-
|
|
|
+ // 每6条消息显示一次时间
|
|
|
+ if (index % 6 === 0) {
|
|
|
+ newItem.time = this.getCurrentTime(newItem.timestamp);
|
|
|
+ }
|
|
|
return newItem;
|
|
|
});
|
|
|
|
|
|
@@ -1002,9 +1006,16 @@ export default {
|
|
|
} else {
|
|
|
now = new Date();
|
|
|
}
|
|
|
+ // 判断是不是今天,如果是今天,则只显示时间,否则显示日期和时间
|
|
|
const hours = String(now.getHours()).padStart(2, "0");
|
|
|
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
|
- return `${hours}:${minutes}`;
|
|
|
+
|
|
|
+ if (this.today == now.toLocaleDateString()) {
|
|
|
+ return `${hours}:${minutes}`;
|
|
|
+ } else {
|
|
|
+ // return now.toLocaleDateString() + ' ' + `${hours}:${minutes}`;
|
|
|
+ return `${now.getMonth() + 1}/${now.getDate()} ${hours}:${minutes}`;
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 输入框聚焦事件
|