From b3b0606d95cecc044d4b8cd019d1ffc268e97a3a Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Fri, 16 Jun 2017 23:25:13 +0800 Subject: [PATCH 1/2] bugfix --- app/Http/Controllers/ContentController.php | 2 +- app/Http/Controllers/MessageController.php | 2 + app/User.php | 2 + ...17_145134_alter_users_table_add_locker.php | 39 +++++++++++++++++++ public/js/good/good_list.js | 3 +- public/js/message.js | 8 +++- 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2017_06_17_145134_alter_users_table_add_locker.php diff --git a/app/Http/Controllers/ContentController.php b/app/Http/Controllers/ContentController.php index b646999..0201240 100644 --- a/app/Http/Controllers/ContentController.php +++ b/app/Http/Controllers/ContentController.php @@ -22,7 +22,7 @@ class ContentController extends Controller $data['populargoods'] = GoodInfo::where('baned', false)->where('count', '>', 0)->where('fav_num', '>', 0)->orderby('fav_num', 'desc')->limit(8)->get(); $data['cats'] = GoodCat::orderby('cat_index', 'asc')->get(); foreach($data['cats'] as $cat){ - $data['catgoods'][$cat->cat_name] = GoodInfo::where('cat_id', $cat->id)->where('baned', false)->inRandomOrder()->limit(4)->get(); + $data['catgoods'][$cat->cat_name] = GoodInfo::where('cat_id', $cat->id)->where('baned', false)->where('count', '>', 0)->inRandomOrder()->limit(4)->get(); } $data['announces'] = Announcement::orderby('id', 'dsc')->limit(3)->get(); return View::make('welcome')->with($data); diff --git a/app/Http/Controllers/MessageController.php b/app/Http/Controllers/MessageController.php index f42ef1a..61884ab 100644 --- a/app/Http/Controllers/MessageController.php +++ b/app/Http/Controllers/MessageController.php @@ -65,6 +65,8 @@ class MessageController extends Controller MessageContact::where('user_id', $user_id) ->where('contact_id', $contact_id) ->update(['unread_count' => 0]); + User::where('id', $user_id) + ->update(['last_get_new_message_time' => time()]); return json_encode($messages); } diff --git a/app/User.php b/app/User.php index 870749b..24db95b 100644 --- a/app/User.php +++ b/app/User.php @@ -9,6 +9,8 @@ class User extends Model { protected $table = 'users'; + protected $fillable = ['last_get_new_message_time', 'last_send_email_time']; + public function user_infos() { return $this->hasMany('App\UserInfo'); diff --git a/database/migrations/2017_06_17_145134_alter_users_table_add_locker.php b/database/migrations/2017_06_17_145134_alter_users_table_add_locker.php new file mode 100644 index 0000000..25b7762 --- /dev/null +++ b/database/migrations/2017_06_17_145134_alter_users_table_add_locker.php @@ -0,0 +1,39 @@ +integer('last_get_new_message_time')->nullable()->default(0); + $table->integer('last_send_email_time')->nullable()->default(0); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + if (Schema::hasTable('users') && Schema::hasColumn('users', 'last_get_new_message_time') + && Schema::hasColumn('users', 'last_send_email_time')) { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['last_get_new_message_time', 'last_send_email_time']); + }); + } + } +} diff --git a/public/js/good/good_list.js b/public/js/good/good_list.js index 6b2371a..bb40e45 100644 --- a/public/js/good/good_list.js +++ b/public/js/good/good_list.js @@ -40,7 +40,7 @@ function setprice(){ location.href=hr; } function setc(ha){ - var hr="/good/?"; + var hr="/good?"; if($("#priceSet1").val()!=""){ hr=hr+"&start_price="+$("#priceSet1").val(); } @@ -61,6 +61,7 @@ function setc(ha){ } if(getUrlParam('cat_id')) hr = hr + '&cat_id=' + getUrlParam('cat_id'); + //alert(hr); location.href=hr; } diff --git a/public/js/message.js b/public/js/message.js index 93d8080..fd2515b 100644 --- a/public/js/message.js +++ b/public/js/message.js @@ -157,8 +157,12 @@ Vue.component('message-dialog', { mounted: function () { this.$nextTick(function () { this.$on('loadDialogHandler', function (id) { - this.clearMessage(id); - this.getHistoryMessage(id); + var vm = this; + if (vm.contact_id != id) + { + this.clearMessage(id); + this.getHistoryMessage(id); + } }); this.$on('refreshMessageEvent', function () { this.getNewMessage(); From c39cbe1bfb89a086826d2799fd35d4f46f8854f9 Mon Sep 17 00:00:00 2001 From: Harry Zhou Date: Sat, 17 Jun 2017 23:58:09 +0800 Subject: [PATCH 2/2] Fix Message time bug. --- resources/views/message/message.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/message/message.blade.php b/resources/views/message/message.blade.php index 9d892d8..95326e3 100644 --- a/resources/views/message/message.blade.php +++ b/resources/views/message/message.blade.php @@ -70,7 +70,7 @@

@{{ message.content }}



- @{{ message.updated_at }} + @{{ message.created_at }} 以上是历史消息