diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php index 352bb911..1129aee4 100755 --- a/app/Http/Controllers/Api/DialogController.php +++ b/app/Http/Controllers/Api/DialogController.php @@ -44,9 +44,6 @@ class DialogController extends AbstractController } // $list = WebSocketDialogMsg::whereDialogId($dialog_id)->orderByDesc('id')->paginate(Base::getPaginate(100, 50)); - $list->transform(function (WebSocketDialogMsg $item) { - return $item->sendSuccess(); - }); // return Base::retSuccess('success', $list); } diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index b4923d6b..a107eead 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -15,7 +15,7 @@ use Carbon\Carbon; * @property int|null $userid 发送会员ID * @property string|null $type 消息类型 * @property array|mixed $msg 详细消息 - * @property int|null $send 是否已送达 + * @property int|null $read 是否已读 * @property int|null $extra_int 额外数字参数 * @property string|null $extra_str 额外字符参数 * @property \Illuminate\Support\Carbon|null $created_at @@ -29,7 +29,7 @@ use Carbon\Carbon; * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereExtraStr($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMsg($value) - * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSend($value) + * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereType($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereUserid($value) @@ -58,10 +58,10 @@ class WebSocketDialogMsg extends AbstractModel * 标记已送达 同时 告诉发送人已送达 * @return $this */ - public function sendSuccess() + public function readSuccess() { - if (empty($this->send)) { - $this->send = 1; + if (empty($this->read)) { + $this->read = 1; $this->save(); PushTask::push([ 'userid' => $this->userid, diff --git a/app/Services/WebSocketService.php b/app/Services/WebSocketService.php index d247125d..b6861b92 100644 --- a/app/Services/WebSocketService.php +++ b/app/Services/WebSocketService.php @@ -114,8 +114,14 @@ class WebSocketService implements WebSocketHandlerInterface * 收到回执 */ case 'receipt': - $dialogMsg = WebSocketDialogMsg::whereId(intval($msgId))->first(); - $dialogMsg && $dialogMsg->sendSuccess(); + return; + + /** + * 已阅消息 + */ + case 'readMsg': + $dialogMsg = WebSocketDialogMsg::whereId(intval($data['id']))->first(); + $dialogMsg && $dialogMsg->readSuccess(); return; } // diff --git a/resources/assets/js/pages/manage/components/message-view.vue b/resources/assets/js/pages/manage/components/message-view.vue index 88c3fec7..f37213fb 100644 --- a/resources/assets/js/pages/manage/components/message-view.vue +++ b/resources/assets/js/pages/manage/components/message-view.vue @@ -6,7 +6,7 @@
@@ -15,6 +15,8 @@