no message
This commit is contained in:
parent
6aff8eeb3f
commit
e306a17023
@ -87,6 +87,9 @@ class DialogController extends AbstractController
|
||||
}
|
||||
//
|
||||
$userid = intval(Request::input('userid'));
|
||||
if ($userid == $user->userid) {
|
||||
return Base::retError('不能对话自己');
|
||||
}
|
||||
//
|
||||
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
||||
if (empty($dialog)) {
|
||||
|
@ -244,6 +244,7 @@ class UsersController extends AbstractController
|
||||
//
|
||||
$user->save();
|
||||
User::token($user);
|
||||
User::AZUpdate($user->userid);
|
||||
return Base::retSuccess('修改成功', $user);
|
||||
}
|
||||
|
||||
@ -340,7 +341,7 @@ class UsersController extends AbstractController
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$builder = User::select(['userid', 'email', 'nickname', 'userimg']);
|
||||
$builder = User::select(['userid', 'email', 'nickname', 'profession', 'userimg', 'az']);
|
||||
//
|
||||
$keys = Request::input('where');
|
||||
if (is_array($keys)) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="messenger-list overlay-y">
|
||||
<ul>
|
||||
<ul v-if="tabActive==='dialog'" class="dialog">
|
||||
<li
|
||||
v-for="(dialog, key) in dialogLists"
|
||||
:key="key"
|
||||
@ -29,11 +29,24 @@
|
||||
</div>
|
||||
<Badge class="dialog-num" :count="dialog.unread"/>
|
||||
</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>
|
||||
</div>
|
||||
<div class="messenger-menu">
|
||||
<Icon class="active" type="ios-chatbubbles" />
|
||||
<Icon type="md-person" />
|
||||
<Icon @click="tabActive='dialog'" :class="{active:tabActive==='dialog'}" type="ios-chatbubbles" />
|
||||
<Icon @click="tabActive='contacts'" :class="{active:tabActive==='contacts'}" type="md-person" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -65,8 +78,13 @@ export default {
|
||||
components: {DialogWrapper},
|
||||
data() {
|
||||
return {
|
||||
dialogKey: '',
|
||||
tabActive: 'dialog',
|
||||
|
||||
dialogLoad: 0,
|
||||
dialogKey: '',
|
||||
|
||||
contactsLoad: 0,
|
||||
contactsLists: null,
|
||||
}
|
||||
},
|
||||
|
||||
@ -102,6 +120,14 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
tabActive(val) {
|
||||
if (val && this.contactsLists === null) {
|
||||
this.getContactsList();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
openDialog(dialog) {
|
||||
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) {
|
||||
let time = Math.round(new Date(date).getTime() / 1000),
|
||||
string = '';
|
||||
@ -154,7 +219,7 @@ export default {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</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
|
||||
*/
|
||||
openDialogUser(state, userid) {
|
||||
if (userid === state.userId) {
|
||||
return;
|
||||
}
|
||||
$A.apiAjax({
|
||||
url: 'dialog/open/user',
|
||||
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-y: auto;
|
||||
> ul {
|
||||
> li {
|
||||
display: flex;
|
||||
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;
|
||||
&.dialog {
|
||||
> li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-left: 12px;
|
||||
.dialog-title {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 80px;
|
||||
padding: 0 12px;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
&.active {
|
||||
background-color: #F4F5F7;
|
||||
}
|
||||
&.loading {
|
||||
margin: 0;
|
||||
height: 52px;
|
||||
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;
|
||||
justify-content: center;
|
||||
.common-loading {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
.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;
|
||||
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;
|
||||
.dialog-num {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 42px;
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
}
|
||||
.dialog-num {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 42px;
|
||||
font-size: 12px;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
&.contacts {
|
||||
> li {
|
||||
list-style: none;
|
||||
margin-left: 24px;
|
||||
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