Add System Message whose contact_id is 0.
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Message;
|
||||
use App\Transaction;
|
||||
use App\TransactionLog;
|
||||
use App\User;
|
||||
use App\MessageContact;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
@@ -110,6 +111,15 @@ class TransactionController extends Controller
|
||||
$message->receiver_id = $good->user_id;
|
||||
$message->content = '您好!' . $buyer->not_null_nickname . '购买了你的' . $good->good_name . ',请及时前往确认。';
|
||||
$message->save();
|
||||
|
||||
//Create or Update MessageContact
|
||||
$contact = MessageContact::firstOrNew([
|
||||
'user_id' => $message->receiver_id,
|
||||
'contact_id' => 0
|
||||
]);
|
||||
$contact->unread_count += 1;
|
||||
$contact->last_contact_time = time();
|
||||
$contact->save();
|
||||
return json_encode(['result' => true, 'msg' => 'success']);
|
||||
}
|
||||
|
||||
@@ -134,6 +144,14 @@ class TransactionController extends Controller
|
||||
$message->receiver_id = $good->user_id;
|
||||
$message->content = '您好!您的' . $good->good_name . '的一个订单被买家取消,你可以前往查看。';
|
||||
$message->save();
|
||||
//Create or Update MessageContact
|
||||
$contact = MessageContact::firstOrNew([
|
||||
'user_id' => $message->receiver_id,
|
||||
'contact_id' => 0
|
||||
]);
|
||||
$contact->unread_count += 1;
|
||||
$contact->last_contact_time = time();
|
||||
$contact->save();
|
||||
return json_encode(['result' => true, 'character' => 'buyer', 'msg' => 'success']);
|
||||
break;
|
||||
case $trans->seller_id:
|
||||
@@ -154,6 +172,14 @@ class TransactionController extends Controller
|
||||
$message->receiver_id = $trans->buyer_id;
|
||||
$message->content = '您好!您购买的' . $good->good_name . '的一个订单被卖家驳回,你可以前往查看。';
|
||||
$message->save();
|
||||
//Create or Update MessageContact
|
||||
$contact = MessageContact::firstOrNew([
|
||||
'user_id' => $message->receiver_id,
|
||||
'contact_id' => 0
|
||||
]);
|
||||
$contact->unread_count += 1;
|
||||
$contact->last_contact_time = time();
|
||||
$contact->save();
|
||||
return json_encode(['result' => true, 'character' => 'seller', 'msg' => 'success']);
|
||||
break;
|
||||
default:
|
||||
@@ -185,6 +211,14 @@ class TransactionController extends Controller
|
||||
$message->receiver_id = $trans->buyer_id;
|
||||
$message->content = '您好!你订购的' . $good->good_name . '已被卖家确认,你们现在可以去看对方的联系方式并且交♂易啦。';
|
||||
$message->save();
|
||||
//Create or Update MessageContact
|
||||
$contact = MessageContact::firstOrNew([
|
||||
'user_id' => $message->receiver_id,
|
||||
'contact_id' => 0
|
||||
]);
|
||||
$contact->unread_count += 1;
|
||||
$contact->last_contact_time = time();
|
||||
$contact->save();
|
||||
return json_encode(['result' => true, 'msg' => 'success']);
|
||||
}
|
||||
|
||||
@@ -242,6 +276,14 @@ class TransactionController extends Controller
|
||||
else
|
||||
$message->content = '您好!你订购的' . $good->good_name . '的订单已被卖家标记为交易失败。';
|
||||
$message->save();
|
||||
//Create or Update MessageContact
|
||||
$contact = MessageContact::firstOrNew([
|
||||
'user_id' => $message->receiver_id,
|
||||
'contact_id' => 0
|
||||
]);
|
||||
$contact->unread_count += 1;
|
||||
$contact->last_contact_time = time();
|
||||
$contact->save();
|
||||
return json_encode(['result' => true, 'msg' => 'success']);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ Vue.component('message-dialog', {
|
||||
methods: {
|
||||
getHistoryMessage: function (contact_id) {
|
||||
var vm = this;
|
||||
if (contact_id === 0 || this.contact_id === contact_id) {
|
||||
if (contact_id === -1 || this.contact_id === contact_id) {
|
||||
contact_id = this.contact_id;
|
||||
axios.get('/message/getHistoryMessage?contact_id=' + contact_id.toString() + '&page=' + (this.current_page + 1).toString())
|
||||
.then(function (response) {
|
||||
|
||||
@@ -15,27 +15,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{--<div class="page-content">
|
||||
@foreach($informations as $information)
|
||||
<form action="/message/{{$information->id}}" method="POST">
|
||||
{!! csrf_field() !!}
|
||||
{!! method_field('delete') !!}
|
||||
{{$information->id}}<br/>
|
||||
{{$information->title}}<br/>
|
||||
{{$information->content}}<br/>
|
||||
{{$information->created_at}}<br/>
|
||||
{{$information->is_read}}<br/>
|
||||
@if($information->sender_id != 0)
|
||||
{{$information->receiver->nickname}}<br/>
|
||||
@else
|
||||
系统通知<br/>
|
||||
@endif
|
||||
<input type="submit" value="Delete"><br/>
|
||||
<br/>
|
||||
</form>
|
||||
@endforeach
|
||||
{{ $informations->links() }}
|
||||
</div>--}}
|
||||
|
||||
<script type="text/x-template" id="contact_list">
|
||||
<div>
|
||||
@@ -53,7 +32,7 @@
|
||||
<i v-if="contact.unread_count > 0" class="balloon-tip">@{{ contact.unread_count }}</i>
|
||||
</span>
|
||||
</td>
|
||||
<td><p class="con-name">@{{ contact.contact.nickname }}</p></td>
|
||||
<td><p class="con-name">@{{ contact.contact_id === 0 ? "系统消息" : contact.contact.nickname }}</p></td>
|
||||
</tr>
|
||||
</li>
|
||||
</transition-group>
|
||||
@@ -65,7 +44,7 @@
|
||||
|
||||
<script type="text/x-template" id="message_dialog">
|
||||
<div :class="{ hide: isHidden }">
|
||||
<a v-if="hasMore" v-on:click="getHistoryMessage(0)">加载更多</a>
|
||||
<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">
|
||||
|
||||
Reference in New Issue
Block a user