From cda005d5d6e433cffcba8403a5f944305239dff7 Mon Sep 17 00:00:00 2001 From: printempw Date: Sun, 24 Jul 2016 12:33:11 +0800 Subject: [PATCH] enhance performance of ajax sign responce --- app/Controllers/UserController.php | 7 ++++--- assets/src/js/user.js | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index cfa758a1..6a571e31 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -28,9 +28,10 @@ class UserController extends BaseController { if ($aquired_score = $this->user->sign()) { View::json([ - 'errno' => 0, - 'msg' => '签到成功,获得了 '.$aquired_score.' 积分~', - 'score' => $this->user->getScore() + 'errno' => 0, + 'msg' => '签到成功,获得了 '.$aquired_score.' 积分~', + 'score' => $this->user->getScore(), + 'remaining_time' => $this->user->canSign(true) ]); } else { View::json($this->user->canSign(true).' 小时后才能再次签到哦~', 1); diff --git a/assets/src/js/user.js b/assets/src/js/user.js index 2addad7b..8751daae 100644 --- a/assets/src/js/user.js +++ b/assets/src/js/user.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-16 10:02:24 * @Last Modified by: printempw - * @Last Modified time: 2016-07-23 15:23:31 + * @Last Modified time: 2016-07-24 12:28:52 */ 'use strict'; @@ -497,7 +497,8 @@ function sign() { if (json.errno == 0) { toastr.success(json.msg); $('#score').html(json.score); - $('#sign-button').attr('disabled', 'disabled').html('  24 小时后可签到'); + var dom = '  '+json.remaining_time+' 小时后可签到'; + $('#sign-button').attr('disabled', 'disabled').html(dom); } else { toastr.warning(json.msg); }