Merge branch 'master' into foundation
This commit is contained in:
@@ -156,4 +156,13 @@ class MessageController extends Controller
|
||||
return Redirect::to('/message');
|
||||
}
|
||||
|
||||
public function closeConversation(Request $request, $receiver)
|
||||
{
|
||||
$user_id = $request->session()->get('user_id');
|
||||
MessageContact::where('user_id', $user_id)
|
||||
->where('contact_id', $receiver)
|
||||
->delete();
|
||||
return json_encode(['result' => true, 'msg' => 'success']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,6 +71,7 @@ Route::group(['middleware' => ['web']],function () {
|
||||
Route::get('/message/getHistoryMessage', "MessageController@getHistoryMessage");
|
||||
Route::get('/message/getNewMessage', "MessageController@getNewMessage");
|
||||
Route::get('/message/startConversation/{receiver}', "MessageController@startConversation");
|
||||
Route::get('/message/closeConversation/{receiver}', "MessageController@closeConversation");
|
||||
});
|
||||
|
||||
Route::get('/user/{user_id}/banpage', "UserController@banPage")->middleware('admin');
|
||||
|
||||
Vendored
+15
@@ -76,6 +76,11 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
word-break:break-all;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.contact-list-item {
|
||||
transition: all 1s;
|
||||
}
|
||||
@@ -128,4 +133,14 @@
|
||||
|
||||
#message-container::-webkit-scrollbar-resizer {
|
||||
background: #efefff;
|
||||
}
|
||||
|
||||
#contact-closer {
|
||||
position: relative;
|
||||
top: -4.6em;
|
||||
float: right;
|
||||
}
|
||||
|
||||
#contact-closer:hover {
|
||||
background-color: #b42600;
|
||||
}
|
||||
+60
-3
@@ -11,7 +11,8 @@ Vue.component('contact-list', {
|
||||
errorMessage: '',
|
||||
current_page: 0,
|
||||
last_page: null,
|
||||
current_contact_id: null
|
||||
current_contact_id: null,
|
||||
current_index: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -40,6 +41,7 @@ Vue.component('contact-list', {
|
||||
this.last_page = null;
|
||||
this.contacts = [];
|
||||
this.current_contact_id = null;
|
||||
this.current_index = null;
|
||||
},
|
||||
getHistoryContact: function (initialize) {
|
||||
var vm = this;
|
||||
@@ -85,11 +87,58 @@ Vue.component('contact-list', {
|
||||
c.unread_count = 0;
|
||||
Vue.set(vm.contacts, index, c);
|
||||
vm.current_contact_id = vm.contacts[index].contact_id;
|
||||
vm.current_index = index;
|
||||
},
|
||||
closeContact: function (index) {
|
||||
var vm = this;
|
||||
//console.log(contact_id);
|
||||
//console.log(index);
|
||||
axios.get('/message/closeConversation/' + vm.contacts[index].contact_id)
|
||||
.then(function (response) {
|
||||
if (vm.contacts.length === 1) //Hide dialog
|
||||
{
|
||||
vm.clearContact();
|
||||
vm.$emit('load-dialog', -2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index === vm.current_index) //Need autoload
|
||||
{
|
||||
var len = vm.contacts.length;
|
||||
if (parseInt(vm.current_index) + 1 < len) //Load next contact
|
||||
{
|
||||
vm.contacts.splice(index, 1);
|
||||
vm.current_contact_id = vm.contacts[vm.current_index].contact_id;
|
||||
vm.$emit('load-dialog', vm.current_contact_id);
|
||||
}
|
||||
else //Load last contact
|
||||
{
|
||||
vm.contacts.splice(index, 1);
|
||||
vm.current_index = parseInt(vm.current_index) - 1;
|
||||
vm.current_contact_id = vm.contacts[vm.current_index].contact_id;
|
||||
vm.$emit('load-dialog', vm.current_contact_id);
|
||||
}
|
||||
}
|
||||
else //Just close it
|
||||
vm.contacts.splice(index, 1);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
vm.errorMessage = "服务器连接失败,请检查网络QAQ";
|
||||
vm.$emit('network-error');
|
||||
})
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 对话窗格
|
||||
/*
|
||||
contact_id = -1 : 初始化对话窗格
|
||||
contact_id = -2 : 隐藏对话窗格
|
||||
其他 : 加载历史消息
|
||||
*/
|
||||
Vue.component('message-dialog', {
|
||||
template: '#message_dialog',
|
||||
data: function () {
|
||||
@@ -108,7 +157,7 @@ Vue.component('message-dialog', {
|
||||
mounted: function () {
|
||||
this.$nextTick(function () {
|
||||
this.$on('loadDialogHandler', function (id) {
|
||||
this.clearMessage();
|
||||
this.clearMessage(id);
|
||||
this.getHistoryMessage(id);
|
||||
});
|
||||
this.$on('refreshMessageEvent', function () {
|
||||
@@ -134,6 +183,8 @@ Vue.component('message-dialog', {
|
||||
},
|
||||
methods: {
|
||||
getHistoryMessage: function (contact_id) {
|
||||
if (contact_id === -2)
|
||||
return;
|
||||
var vm = this;
|
||||
if (contact_id === -1 || this.contact_id === contact_id) {
|
||||
contact_id = this.contact_id;
|
||||
@@ -184,11 +235,16 @@ Vue.component('message-dialog', {
|
||||
this.contact_id = contact_id;
|
||||
}
|
||||
},
|
||||
clearMessage: function() {
|
||||
clearMessage: function(id) {
|
||||
this.current_page = 0;
|
||||
this.last_page = null;
|
||||
this.messages = [];
|
||||
this.isLockScroll = false;
|
||||
if (id === -2)
|
||||
{
|
||||
this.contact_id = null;
|
||||
this.isHidden = true;
|
||||
}
|
||||
},
|
||||
sendMessage: function () {
|
||||
var vm = this;
|
||||
@@ -216,6 +272,7 @@ Vue.component('message-dialog', {
|
||||
{
|
||||
vm.messages.push(response.data[i]);
|
||||
}
|
||||
vm.isHidden = false;
|
||||
})
|
||||
.catch(function (error) {
|
||||
vm.errorMessage = "服务器连接失败,请检查网络QAQ";
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
contact.contact.nickname + '【已封禁】') }}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<span id="contact-closer" class="badge secondary"
|
||||
v-on:click="closeContact(index)">X</span>
|
||||
</li>
|
||||
</transition-group>
|
||||
</table>
|
||||
@@ -51,30 +53,34 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-template" id="message_dialog">
|
||||
<div :class="{ hide: isHidden }">
|
||||
<a v-if="hasMore" v-on:click="getHistoryMessage(-1)">加载更多</a>
|
||||
<p v-else>没有更多了</p>
|
||||
<ul id="message-container" class="message-container">
|
||||
<transition-group name="message-list" tag="ul">
|
||||
<li :class="{ box: message.type !== 'history-info' }" class="msg message-list-item"
|
||||
v-for="message in messages" v-bind:key="message.id">
|
||||
<div>
|
||||
<p v-if="messages.length == 0" style="text-align: center">暂无消息</p>
|
||||
<div :class="{ hide: isHidden }">
|
||||
<a v-if="hasMore" v-on:click="getHistoryMessage(-1)">加载更多</a>
|
||||
<p v-else>没有更多了</p>
|
||||
<ul id="message-container" class="message-container">
|
||||
<transition-group name="message-list" tag="ul">
|
||||
<li :class="{ box: message.type !== 'history-info' }" class="msg message-list-item"
|
||||
v-for="message in messages" v-bind:key="message.id">
|
||||
<span v-if="message.type !== 'history-info'">
|
||||
<img class="mavatar" :src="'/avatar/' + message.sender_id + '/64/64'"/>
|
||||
@{{ message.content }}<br/><br/>
|
||||
<p v-if="contact_id == 0" class="message-content" v-html="message.content"></p>
|
||||
<p v-else class="message-content">@{{ message.content }}</p>
|
||||
<br/><br/>
|
||||
<i class="time-tag">@{{ message.updated_at }}</i>
|
||||
</span>
|
||||
<span v-else>
|
||||
<span v-else>
|
||||
<i class="history-text">以上是历史消息</i>
|
||||
<hr/>
|
||||
</span>
|
||||
</li>
|
||||
</transition-group>
|
||||
</ul>
|
||||
<p class="err-msg" v-if="errorMessage">@{{ errorMessage }}</p>
|
||||
<textarea placeholder="键入要发送的内容:" v-model="inputMessage"></textarea>
|
||||
<input type="button" class="button" value="发送" v-on:click="sendMessage"/>
|
||||
<input id="token" type="hidden" value="{{ csrf_token() }}"/>
|
||||
{{--<a v-on:click="getNewMessage">!!!</a>--}}
|
||||
</li>
|
||||
</transition-group>
|
||||
</ul>
|
||||
<p class="err-msg" v-if="errorMessage">@{{ errorMessage }}</p>
|
||||
<textarea placeholder="键入要发送的内容:" v-model="inputMessage"></textarea>
|
||||
<input type="button" class="button" value="发送" v-on:click="sendMessage"/>
|
||||
<input id="token" type="hidden" value="{{ csrf_token() }}"/>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user