Show precision time when sign remaining time is less than 1 hour

This commit is contained in:
printempw 2017-08-05 23:43:35 +08:00
parent cb2ce86aae
commit a2edc469ac
3 changed files with 15 additions and 4 deletions

View File

@ -74,13 +74,22 @@ class UserController extends Controller
'msg' => trans('user.sign-success', ['score' => $acuiredScore]),
'score' => $this->user->getScore(),
'storage' => $this->calculatePercentageUsed($this->user->getStorageUsed(), option('score_per_storage')),
'remaining_time' => round($this->user->getSignRemainingTime() / 3600)
'remaining_time' => $this->getUserSignRemainingTimeWithPrecision()
]);
} else {
return json(trans('user.cant-sign-until', ['time' => round($this->user->getSignRemainingTime() / 3600)]), 1);
return json(trans('user.cant-sign-until', [
'time' => $this->getUserSignRemainingTimeWithPrecision()
]), 1);
}
}
public function getUserSignRemainingTimeWithPrecision()
{
$hours = $this->user->getSignRemainingTime() / 3600;
return round($hours) ?: round($hours, 1);
}
public function profile()
{
return view('user.profile')->with('user', $this->user);

@ -1 +1 @@
Subproject commit b4eeec21d9ae5b36d2978b389830ae0f9f4dddcf
Subproject commit 56e0b405985bdc843ec42be80f82a213e2d21198

View File

@ -75,7 +75,9 @@
</button>
@else
<button class="btn btn-primary pull-left" title="{{ trans('user.last-sign', ['time' => $user->getLastSignTime()]) }}" disabled="disabled">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ trans('user.sign-remain-time', ['time' => round($user->getSignRemainingTime() / 3600)]) }}
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;
<?php $hours = $user->getSignRemainingTime() / 3600; ?>
{{ trans('user.sign-remain-time', ['time' => round($hours) ?: round($hours, 1)]) }}
</button>
@endif
</div><!-- /.box-footer -->