no message
This commit is contained in:
parent
7dfacd93a6
commit
72970eab2d
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\ProjectTask;
|
||||||
|
use App\Models\ProjectTaskFile;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\WebSocketDialog;
|
use App\Models\WebSocketDialog;
|
||||||
use App\Models\WebSocketDialogMsg;
|
use App\Models\WebSocketDialogMsg;
|
||||||
@ -247,11 +249,36 @@ class DialogController extends AbstractController
|
|||||||
if (Base::isError($data)) {
|
if (Base::isError($data)) {
|
||||||
return Base::retError($data['msg']);
|
return Base::retError($data['msg']);
|
||||||
} else {
|
} else {
|
||||||
$msg = $data['data'];
|
$fileData = $data['data'];
|
||||||
$msg['thumb'] = Base::unFillUrl($msg['thumb']);
|
$fileData['thumb'] = Base::unFillUrl($fileData['thumb']);
|
||||||
$msg['size'] *= 1024;
|
$fileData['size'] *= 1024;
|
||||||
//
|
//
|
||||||
return WebSocketDialogMsg::sendMsg($dialog_id, 'file', $msg, $user->userid, $extra_int, $extra_str);
|
if ($dialog->type === 'group') {
|
||||||
|
if ($dialog->group_type === 'task') {
|
||||||
|
$task = ProjectTask::whereDialogId($dialog->id)->first();
|
||||||
|
if ($task) {
|
||||||
|
$file = ProjectTaskFile::createInstance([
|
||||||
|
'project_id' => $task->project_id,
|
||||||
|
'task_id' => $task->id,
|
||||||
|
'name' => $fileData['name'],
|
||||||
|
'size' => $fileData['size'],
|
||||||
|
'ext' => $fileData['ext'],
|
||||||
|
'path' => $fileData['path'],
|
||||||
|
'thumb' => $fileData['thumb'],
|
||||||
|
'userid' => $user->userid,
|
||||||
|
]);
|
||||||
|
$file->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$result = WebSocketDialogMsg::sendMsg($dialog_id, 'file', $fileData, $user->userid, $extra_int, $extra_str);
|
||||||
|
if (Base::isSuccess($result)) {
|
||||||
|
if (isset($task)) {
|
||||||
|
$result['data']['task_id'] = $task->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$task = new WebSocketDialogMsgTask($userids, $dialogMsg->toArray());
|
$task = new WebSocketDialogMsgTask($userids, $dialogMsg->toArray());
|
||||||
Task::deliver($task);
|
Task::deliver($task);
|
||||||
//
|
//
|
||||||
return Base::retSuccess('发送成功', $dialogMsg);
|
return Base::retSuccess('发送成功', $dialogMsg->toArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,9 @@ export default {
|
|||||||
if (res.ret === 1) {
|
if (res.ret === 1) {
|
||||||
file.data = res.data;
|
file.data = res.data;
|
||||||
this.$emit('on-success', file);
|
this.$emit('on-success', file);
|
||||||
|
if (res.data.task_id) {
|
||||||
|
this.$store.dispatch("getTaskFiles", res.data.task_id)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$A.modalWarning({
|
$A.modalWarning({
|
||||||
title: '发送失败',
|
title: '发送失败',
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
:rows="1"
|
:rows="1"
|
||||||
:autosize="{ minRows: 1, maxRows: 3 }"
|
:autosize="{ minRows: 1, maxRows: 3 }"
|
||||||
:maxlength="255"
|
:maxlength="255"
|
||||||
|
@on-focus="onEventFocus"
|
||||||
|
@on-blur="onEventblur"
|
||||||
@on-keydown="chatKeydown"
|
@on-keydown="chatKeydown"
|
||||||
@on-input-paste="pasteDrag"
|
@on-input-paste="pasteDrag"
|
||||||
:placeholder="$L('输入消息...')" />
|
:placeholder="$L('输入消息...')" />
|
||||||
@ -141,13 +143,10 @@ export default {
|
|||||||
text: this.msgText,
|
text: this.msgText,
|
||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.$store.dispatch("dialogMsgSplice", {id: tempId, data});
|
this.$store.dispatch("dialogMsgUpdate", {id: tempId, data});
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalWarning({
|
$A.modalError(msg);
|
||||||
title: '发送失败',
|
this.$store.dispatch("dialogMsgUpdate", {id: tempId});
|
||||||
content: msg
|
|
||||||
});
|
|
||||||
this.$store.dispatch("dialogMsgSplice", {id: tempId});
|
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
this.msgText = '';
|
this.msgText = '';
|
||||||
@ -214,11 +213,11 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'error':
|
case 'error':
|
||||||
this.$store.dispatch("dialogMsgSplice", {id: file.tempId});
|
this.$store.dispatch("dialogMsgUpdate", {id: file.tempId});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'success':
|
case 'success':
|
||||||
this.$store.dispatch("dialogMsgSplice", {id: file.tempId, data: file.data});
|
this.$store.dispatch("dialogMsgUpdate", {id: file.tempId, data: file.data});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -248,6 +247,14 @@ export default {
|
|||||||
this.goBottom();
|
this.goBottom();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onEventFocus(e) {
|
||||||
|
this.$emit("on-focus", e)
|
||||||
|
},
|
||||||
|
|
||||||
|
onEventblur(e) {
|
||||||
|
this.$emit("on-blur", e)
|
||||||
|
},
|
||||||
|
|
||||||
formatTime(date) {
|
formatTime(date) {
|
||||||
let time = Math.round(new Date(date).getTime() / 1000),
|
let time = Math.round(new Date(date).getTime() / 1000),
|
||||||
string = '';
|
string = '';
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<Input prefix="ios-search" v-model="dialogKey" :placeholder="$L('搜索...')" clearable />
|
<Input prefix="ios-search" v-model="dialogKey" :placeholder="$L('搜索...')" clearable />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="messenger-list overlay-y">
|
<div ref="list" class="messenger-list overlay-y">
|
||||||
<ul v-if="tabActive==='dialog'" class="dialog">
|
<ul v-if="tabActive==='dialog'" class="dialog">
|
||||||
<li
|
<li
|
||||||
v-for="(dialog, key) in dialogLists"
|
v-for="(dialog, key) in dialogLists"
|
||||||
@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="messenger-msg">
|
<div class="messenger-msg">
|
||||||
<DialogWrapper v-if="dialogId > 0"/>
|
<DialogWrapper v-if="dialogId > 0" @on-focus="scrollIntoActive"/>
|
||||||
<div v-else class="dialog-no">
|
<div v-else class="dialog-no">
|
||||||
<div class="dialog-no-icon"><Icon type="ios-chatbubbles" /></div>
|
<div class="dialog-no-icon"><Icon type="ios-chatbubbles" /></div>
|
||||||
<div class="dialog-no-text">{{$L('选择一个会话开始聊天')}}</div>
|
<div class="dialog-no-text">{{$L('选择一个会话开始聊天')}}</div>
|
||||||
@ -126,6 +126,7 @@ export default {
|
|||||||
openDialog(dialog) {
|
openDialog(dialog) {
|
||||||
this.$store.state.method.setStorage("messengerDialogId", dialog.id)
|
this.$store.state.method.setStorage("messengerDialogId", dialog.id)
|
||||||
this.$store.dispatch("getDialogMsgList", dialog.id);
|
this.$store.dispatch("getDialogMsgList", dialog.id);
|
||||||
|
this.scrollIntoActive();
|
||||||
},
|
},
|
||||||
|
|
||||||
openDialogStorage() {
|
openDialogStorage() {
|
||||||
@ -211,6 +212,20 @@ export default {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
scrollIntoActive() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.list) {
|
||||||
|
let active = this.$refs.list.querySelector(".active")
|
||||||
|
if (active) {
|
||||||
|
scrollIntoView(active, {
|
||||||
|
behavior: 'smooth',
|
||||||
|
scrollMode: 'if-needed',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
24
resources/assets/js/store/actions.js
vendored
24
resources/assets/js/store/actions.js
vendored
@ -740,7 +740,7 @@ export default {
|
|||||||
dialog_id,
|
dialog_id,
|
||||||
},
|
},
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
dispatch("dialogUpdate", result.data);
|
dispatch("saveDialog", result.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -864,12 +864,16 @@ export default {
|
|||||||
* @param state
|
* @param state
|
||||||
* @param params {id, data}
|
* @param params {id, data}
|
||||||
*/
|
*/
|
||||||
dialogMsgSplice({state}, params) {
|
dialogMsgUpdate({state}, params) {
|
||||||
let {id, data} = params;
|
let {id, data} = params;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.method.isJson(data)) {
|
if (state.method.isJson(data)) {
|
||||||
|
state.projectDetail.project_column.some(({project_task}) => {
|
||||||
|
const task = project_task.find(({dialog_id}) => dialog_id === data.dialog_id);
|
||||||
|
if (task) task.msg_num++;
|
||||||
|
});
|
||||||
if (data.id && state.dialogMsgList.find(m => m.id == data.id)) {
|
if (data.id && state.dialogMsgList.find(m => m.id == data.id)) {
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
@ -998,10 +1002,11 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (type === "dialog") {
|
if (type === "dialog") {
|
||||||
// 更新消息
|
// 更新会话
|
||||||
(function (msg) {
|
(function (msg) {
|
||||||
const {data} = msg;
|
const {mode, data} = msg;
|
||||||
const {dialog_id} = data;
|
const {dialog_id} = data;
|
||||||
|
// 更新消息列表
|
||||||
if (dialog_id == state.dialogId) {
|
if (dialog_id == state.dialogId) {
|
||||||
let index = state.dialogMsgList.findIndex(({id}) => id == data.id);
|
let index = state.dialogMsgList.findIndex(({id}) => id == data.id);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@ -1010,11 +1015,6 @@ export default {
|
|||||||
state.dialogMsgList.splice(index, 1, data);
|
state.dialogMsgList.splice(index, 1, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(msgDetail);
|
|
||||||
// 更新会话
|
|
||||||
(function (msg) {
|
|
||||||
const {mode, data} = msg;
|
|
||||||
const {dialog_id} = data;
|
|
||||||
// 更新最后消息
|
// 更新最后消息
|
||||||
let dialog = state.dialogList.find(({id}) => id == dialog_id);
|
let dialog = state.dialogList.find(({id}) => id == dialog_id);
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
@ -1023,6 +1023,7 @@ export default {
|
|||||||
dispatch("getDialogOne", dialog_id);
|
dispatch("getDialogOne", dialog_id);
|
||||||
}
|
}
|
||||||
if (mode === "add") {
|
if (mode === "add") {
|
||||||
|
// 更新对话列表
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
// 新增未读数
|
// 新增未读数
|
||||||
if (data.userid !== state.userId) dialog.unread++;
|
if (data.userid !== state.userId) dialog.unread++;
|
||||||
@ -1034,6 +1035,11 @@ export default {
|
|||||||
state.dialogList.unshift(tmp);
|
state.dialogList.unshift(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 新增任务消息数量
|
||||||
|
state.projectDetail.project_column.some(({project_task}) => {
|
||||||
|
const task = project_task.find(({dialog_id}) => dialog_id === data.dialog_id);
|
||||||
|
if (task) task.msg_num++;
|
||||||
|
});
|
||||||
// 新增总未读数
|
// 新增总未读数
|
||||||
if (data.userid !== state.userId) state.dialogMsgUnread++;
|
if (data.userid !== state.userId) state.dialogMsgUnread++;
|
||||||
}
|
}
|
||||||
|
17
resources/assets/js/store/state.js
vendored
17
resources/assets/js/store/state.js
vendored
@ -32,6 +32,23 @@ const method = {
|
|||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
zeroFill(str, length, after) {
|
||||||
|
str+= "";
|
||||||
|
if (str.length >= length) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
let _str = '', _ret = '';
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
_str += '0';
|
||||||
|
}
|
||||||
|
if (after || typeof after === 'undefined') {
|
||||||
|
_ret = (_str + "" + str).substr(length * -1);
|
||||||
|
} else {
|
||||||
|
_ret = (str + "" + _str).substr(0, length);
|
||||||
|
}
|
||||||
|
return _ret;
|
||||||
|
},
|
||||||
|
|
||||||
formatDate(format, v) {
|
formatDate(format, v) {
|
||||||
if (typeof format === 'undefined' || format === '') {
|
if (typeof format === 'undefined' || format === '') {
|
||||||
format = 'Y-m-d H:i:s';
|
format = 'Y-m-d H:i:s';
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="{{ asset_main('css/iview.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ asset_main('css/iview.css') }}">
|
||||||
<script src="{{ asset_main('js/jquery.min.js') }}"></script>
|
<script src="{{ asset_main('js/jquery.min.js') }}"></script>
|
||||||
<script src="{{ asset_main('js/bootstrap.min.js') }}"></script>
|
<script src="{{ asset_main('js/bootstrap.min.js') }}"></script>
|
||||||
|
<script src="{{ asset_main('js/scroll-into-view.min.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
window.csrfToken = { csrfToken : "{{ csrf_token() }}" };
|
window.csrfToken = { csrfToken : "{{ csrf_token() }}" };
|
||||||
window.webSocketConfig = { URL: "{{ env('LARAVELS_PROXY_URL') }}", DEBUG: {{ env('APP_DEBUG') ? "true" : "false" }}, LISTENER: {} };
|
window.webSocketConfig = { URL: "{{ env('LARAVELS_PROXY_URL') }}", DEBUG: {{ env('APP_DEBUG') ? "true" : "false" }}, LISTENER: {} };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user