no message
This commit is contained in:
parent
6aff8eeb3f
commit
e306a17023
@ -87,6 +87,9 @@ class DialogController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$userid = intval(Request::input('userid'));
|
$userid = intval(Request::input('userid'));
|
||||||
|
if ($userid == $user->userid) {
|
||||||
|
return Base::retError('不能对话自己');
|
||||||
|
}
|
||||||
//
|
//
|
||||||
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
||||||
if (empty($dialog)) {
|
if (empty($dialog)) {
|
||||||
|
@ -244,6 +244,7 @@ class UsersController extends AbstractController
|
|||||||
//
|
//
|
||||||
$user->save();
|
$user->save();
|
||||||
User::token($user);
|
User::token($user);
|
||||||
|
User::AZUpdate($user->userid);
|
||||||
return Base::retSuccess('修改成功', $user);
|
return Base::retSuccess('修改成功', $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +341,7 @@ class UsersController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function search()
|
public function search()
|
||||||
{
|
{
|
||||||
$builder = User::select(['userid', 'email', 'nickname', 'userimg']);
|
$builder = User::select(['userid', 'email', 'nickname', 'profession', 'userimg', 'az']);
|
||||||
//
|
//
|
||||||
$keys = Request::input('where');
|
$keys = Request::input('where');
|
||||||
if (is_array($keys)) {
|
if (is_array($keys)) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="messenger-list overlay-y">
|
<div class="messenger-list overlay-y">
|
||||||
<ul>
|
<ul v-if="tabActive==='dialog'" class="dialog">
|
||||||
<li
|
<li
|
||||||
v-for="(dialog, key) in dialogLists"
|
v-for="(dialog, key) in dialogLists"
|
||||||
:key="key"
|
:key="key"
|
||||||
@ -29,11 +29,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<Badge class="dialog-num" :count="dialog.unread"/>
|
<Badge class="dialog-num" :count="dialog.unread"/>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="dialogLoad > 0" class="loading"><Loading/></li>
|
||||||
|
</ul>
|
||||||
|
<ul v-else class="contacts">
|
||||||
|
<li v-for="(users, label) in contactsLists">
|
||||||
|
<div class="label">{{label}}</div>
|
||||||
|
<ul>
|
||||||
|
<li v-for="(user, index) in users" :key="index" @click="openContacts(user)">
|
||||||
|
<div class="avatar"><UserAvatar :userid="user.userid" :size="30" hide-icon-menu/></div>
|
||||||
|
<div class="nickname">{{user.nickname}}</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li v-if="contactsLoad > 0" class="loading"><Loading/></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="messenger-menu">
|
<div class="messenger-menu">
|
||||||
<Icon class="active" type="ios-chatbubbles" />
|
<Icon @click="tabActive='dialog'" :class="{active:tabActive==='dialog'}" type="ios-chatbubbles" />
|
||||||
<Icon type="md-person" />
|
<Icon @click="tabActive='contacts'" :class="{active:tabActive==='contacts'}" type="md-person" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -65,8 +78,13 @@ export default {
|
|||||||
components: {DialogWrapper},
|
components: {DialogWrapper},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dialogKey: '',
|
tabActive: 'dialog',
|
||||||
|
|
||||||
dialogLoad: 0,
|
dialogLoad: 0,
|
||||||
|
dialogKey: '',
|
||||||
|
|
||||||
|
contactsLoad: 0,
|
||||||
|
contactsLists: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -102,6 +120,14 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
tabActive(val) {
|
||||||
|
if (val && this.contactsLists === null) {
|
||||||
|
this.getContactsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
openDialog(dialog) {
|
openDialog(dialog) {
|
||||||
this.$store.state.method.setStorage('messengerDialogId', dialog.id)
|
this.$store.state.method.setStorage('messengerDialogId', dialog.id)
|
||||||
@ -116,6 +142,45 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openContacts(user) {
|
||||||
|
this.$store.commit("openDialogUser", user.userid);
|
||||||
|
this.tabActive = 'dialog';
|
||||||
|
},
|
||||||
|
|
||||||
|
getContactsList() {
|
||||||
|
if (this.contactsLists === null) {
|
||||||
|
this.contactsLists = {};
|
||||||
|
}
|
||||||
|
this.contactsLoad++;
|
||||||
|
$A.apiAjax({
|
||||||
|
url: 'users/search',
|
||||||
|
data: {
|
||||||
|
take: 50
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.contactsLoad--;
|
||||||
|
},
|
||||||
|
success: ({ret, data, msg}) => {
|
||||||
|
if (ret === 1) {
|
||||||
|
data.some((user) => {
|
||||||
|
if (user.userid === this.userId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let az = user.az ? user.az.toUpperCase() : "#";
|
||||||
|
if (typeof this.contactsLists[az] === "undefined") this.contactsLists[az] = [];
|
||||||
|
//
|
||||||
|
let index = this.contactsLists[az].findIndex(({userid}) => userid === user.userid);
|
||||||
|
if (index > -1) {
|
||||||
|
this.contactsLists[az].splice(index, 1, user);
|
||||||
|
} else {
|
||||||
|
this.contactsLists[az].push(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
formatTime(date) {
|
formatTime(date) {
|
||||||
let time = Math.round(new Date(date).getTime() / 1000),
|
let time = Math.round(new Date(date).getTime() / 1000),
|
||||||
string = '';
|
string = '';
|
||||||
@ -154,7 +219,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
3
resources/assets/js/store/mutations.js
vendored
3
resources/assets/js/store/mutations.js
vendored
@ -274,6 +274,9 @@ export default {
|
|||||||
* @param userid
|
* @param userid
|
||||||
*/
|
*/
|
||||||
openDialogUser(state, userid) {
|
openDialogUser(state, userid) {
|
||||||
|
if (userid === state.userId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$A.apiAjax({
|
$A.apiAjax({
|
||||||
url: 'dialog/open/user',
|
url: 'dialog/open/user',
|
||||||
data: {
|
data: {
|
||||||
|
191
resources/assets/sass/messenger-wrapper.scss
vendored
191
resources/assets/sass/messenger-wrapper.scss
vendored
@ -51,80 +51,145 @@
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
> ul {
|
> ul {
|
||||||
> li {
|
&.dialog {
|
||||||
display: flex;
|
> li {
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
height: 80px;
|
|
||||||
padding: 0 12px;
|
|
||||||
position: relative;
|
|
||||||
cursor: pointer;
|
|
||||||
&.active {
|
|
||||||
background-color: #F4F5F7;
|
|
||||||
}
|
|
||||||
.user-avatar,
|
|
||||||
.icon-avatar {
|
|
||||||
width: 46px;
|
|
||||||
height: 46px;
|
|
||||||
flex-grow: 0;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.icon-avatar {
|
|
||||||
line-height: 46px;
|
|
||||||
border-radius: 50%;
|
|
||||||
font-size: 26px;
|
|
||||||
background-color: #61B2F9;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
.dialog-box {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: row;
|
||||||
padding-left: 12px;
|
align-items: center;
|
||||||
.dialog-title {
|
height: 80px;
|
||||||
|
padding: 0 12px;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
list-style: none;
|
||||||
|
&.active {
|
||||||
|
background-color: #F4F5F7;
|
||||||
|
}
|
||||||
|
&.loading {
|
||||||
|
margin: 0;
|
||||||
|
height: 52px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
line-height: 24px;
|
.common-loading {
|
||||||
> span {
|
width: 20px;
|
||||||
flex: 1;
|
height: 20px;
|
||||||
max-width: 130px;
|
margin: 0;
|
||||||
color: #333333;
|
}
|
||||||
font-size: 14px;
|
}
|
||||||
|
.user-avatar,
|
||||||
|
.icon-avatar {
|
||||||
|
width: 46px;
|
||||||
|
height: 46px;
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.icon-avatar {
|
||||||
|
line-height: 46px;
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: 26px;
|
||||||
|
background-color: #61B2F9;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.dialog-box {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-left: 12px;
|
||||||
|
.dialog-title {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
line-height: 24px;
|
||||||
|
> span {
|
||||||
|
flex: 1;
|
||||||
|
max-width: 130px;
|
||||||
|
color: #333333;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
> i {
|
||||||
|
margin-left: 8px;
|
||||||
|
transform: scale(0.9);
|
||||||
|
font-size: 12px;
|
||||||
|
color: #87d068;
|
||||||
|
}
|
||||||
|
> em {
|
||||||
|
margin-left: 8px;
|
||||||
|
font-style: normal;
|
||||||
|
color: #999999;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.dialog-text {
|
||||||
|
max-width: 170px;
|
||||||
|
color: #999999;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 24px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
> i {
|
|
||||||
margin-left: 8px;
|
|
||||||
transform: scale(0.9);
|
|
||||||
font-size: 12px;
|
|
||||||
color: #87d068;
|
|
||||||
}
|
|
||||||
> em {
|
|
||||||
margin-left: 8px;
|
|
||||||
font-style: normal;
|
|
||||||
color: #999999;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.dialog-text {
|
.dialog-num {
|
||||||
max-width: 170px;
|
position: absolute;
|
||||||
color: #999999;
|
top: 10px;
|
||||||
|
left: 42px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 24px;
|
transform: scale(0.8);
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.dialog-num {
|
}
|
||||||
position: absolute;
|
&.contacts {
|
||||||
top: 10px;
|
> li {
|
||||||
left: 42px;
|
list-style: none;
|
||||||
font-size: 12px;
|
margin-left: 24px;
|
||||||
transform: scale(0.8);
|
position: relative;
|
||||||
|
.label {
|
||||||
|
padding-left: 4px;
|
||||||
|
margin-top: 6px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
height: 34px;
|
||||||
|
line-height: 34px;
|
||||||
|
border-bottom: 1px solid #efefef;
|
||||||
|
}
|
||||||
|
&.loading {
|
||||||
|
margin: 0;
|
||||||
|
height: 52px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
.common-loading {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
> ul {
|
||||||
|
> li {
|
||||||
|
list-style: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
height: 52px;
|
||||||
|
cursor: pointer;
|
||||||
|
.avatar {
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
.nickname {
|
||||||
|
padding: 0 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user