enhance performance of ajax sign responce

This commit is contained in:
printempw 2016-07-24 12:33:11 +08:00
parent ef227b1045
commit cda005d5d6
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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('<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;24 小时后可签到');
var dom = '<i class="fa fa-calendar-check-o"></i> &nbsp;'+json.remaining_time+' 小时后可签到';
$('#sign-button').attr('disabled', 'disabled').html(dom);
} else {
toastr.warning(json.msg);
}