mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
feat: 消息右键对话新增:标记已读、标记未读
This commit is contained in:
parent
e5901f28e3
commit
bc6fa7fd27
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,6 +85,12 @@
|
||||
<DropdownItem @click.native="handleTopClick">
|
||||
{{ $L(topOperateItem.top_at ? '取消置顶' : '置顶该聊天') }}
|
||||
</DropdownItem>
|
||||
<DropdownItem @click.native="updateRead('read')" v-if="topOperateItem.unread > 0">
|
||||
{{ $L('标记已读') }}
|
||||
</DropdownItem>
|
||||
<DropdownItem @click.native="updateRead('unread')" v-else>
|
||||
{{ $L('标记未读') }}
|
||||
</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
</div>
|
||||
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user