From bc6fa7fd27d0cd5eb3e123fc6e80bde4a58caf01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9F=A6=E8=8D=A3=E8=B6=85?= <302645122@qq.com>
Date: Tue, 8 Mar 2022 09:06:38 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B6=88=E6=81=AF=E5=8F=B3=E9=94=AE?=
=?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=A0=87=E8=AE=B0?=
=?UTF-8?q?=E5=B7=B2=E8=AF=BB=E3=80=81=E6=A0=87=E8=AE=B0=E6=9C=AA=E8=AF=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Http/Controllers/Api/DialogController.php | 42 +++++++++++++++++++
.../assets/js/pages/manage/messenger.vue | 22 ++++++++++
2 files changed, 64 insertions(+)
diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php
index 4d85b2014..a76822a3c 100755
--- a/app/Http/Controllers/Api/DialogController.php
+++ b/app/Http/Controllers/Api/DialogController.php
@@ -487,4 +487,46 @@ class DialogController extends AbstractController
$dialogUser->save();
return Base::retSuccess("success", $dialogId);
}
+
+
+ /**
+ * @api {get} api/dialog/msg/mark 13. 消息标记操作
+ *
+ * @apiDescription 需要token身份
+ * @apiVersion 1.0.0
+ * @apiGroup dialog
+ * @apiName msg__mark
+ *
+ * @apiParam {Number} dialog_id 消息ID
+ * @apiParam {String} type 类型
+ * - read
+ * - unread
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function msg__mark()
+ {
+ $user = User::auth();
+ $dialogId = intval(Request::input('dialog_id'));
+ $type = Request::input('type');
+ if ($type == 'read') {
+ WebSocketDialogMsgRead::whereUserid($user->userid)
+ ->whereReadAt(null)
+ ->whereDialogId($dialogId)
+ ->update(
+ [
+ 'read_at' => Carbon::now()
+ ]);
+ } elseif ($type == 'unread') {
+ $msgRead = WebSocketDialogMsgRead::whereUserid(User::userid())->whereDialogId($dialogId)->orderByDesc('id')->first();
+ if (!$msgRead) {
+ return Base::retError("对方未发任何消息,没法设置未读");
+ }
+ $msgRead->read_at = null;
+ $msgRead->save();
+ }
+ return Base::retSuccess("success");
+ }
}
diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue
index 622442f6a..eafe452d0 100644
--- a/resources/assets/js/pages/manage/messenger.vue
+++ b/resources/assets/js/pages/manage/messenger.vue
@@ -85,6 +85,12 @@
{{ $L(topOperateItem.top_at ? '取消置顶' : '置顶该聊天') }}
+
+ {{ $L('标记已读') }}
+
+
+ {{ $L('标记未读') }}
+
@@ -480,6 +486,22 @@ export default {
$A.modalError(msg, 301);
this.$Modal.remove();
});
+ },
+
+ updateRead(type) {
+ this.$store.dispatch("call", {
+ url: 'dialog/msg/mark',
+ data: {
+ dialog_id: this.topOperateItem.id,
+ type: type
+ },
+ }).then(() => {
+ this.$store.dispatch("getDialogs");
+ this.$Modal.remove();
+ }).catch(({msg}) => {
+ $A.modalError(msg, 301);
+ this.$Modal.remove();
+ });
}
}
}