Example #1
0
 public function actionGetMonthStep()
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $session = yii::$app->session;
     $healthStates = HealthState::getMonthHealth($session['user']->id);
     $steps = array();
     for ($i = 0; $i < count($healthStates); $i++) {
         $steps[$i] = $healthStates[$i]->step;
     }
     return $steps;
 }
 public function actionSetNowHealth()
 {
     $request = yii::$app->request;
     $session = yii::$app->session;
     $oldHealth = HealthState::getUserLatestHealth($session['user']->id);
     $isNewDay = 0;
     if (!($oldHealth['date'] == date("Y-m-d"))) {
         $isNewDay = 1;
         $oldHealth = new HealthState();
         $oldHealth['date'] = date('Y-m-d');
         $oldHealth['userId'] = $session['user']->id;
     }
     //是新的一天
     $oldHealth['height'] = floatval($request->post('heightInput'));
     $oldHealth['weight'] = floatval($request->post('weightInput'));
     $oldHealth['sleep'] = floatval($request->post('sleepInput'));
     $oldHealth['highblood'] = intval($request->post('highbloodInput'));
     $oldHealth['lowblood'] = intval($request->post('lowbloodInput'));
     $oldHealth['heartbeat'] = intval($request->post('heartbeatInput'));
     $oldHealth['step'] = intval($request->post('stepInput'));
     if ($isNewDay) {
         $oldHealth->save();
     } else {
         $oldHealth->update();
     }
     return $this->render("index");
     //渲染模板
 }
Example #3
0
<?php

use app\models\HealthState;
use app\models\Activity;
use app\models\User;
$this->registerCssFile('@web/css/account/mypage.css');
$this->registerCssFile('@web/css/activity/activity.css');
$session = yii::$app->session;
$thisuser = $session['user'];
//用户
$nowHealth = HealthState::getUserLatestHealth($thisuser['id']);
//当前健康状态
$attendActivities = Activity::getUserActivities($thisuser['id']);
$releaseActivities = Activity::getUserReleaseActivity($thisuser['id']);
?>
<div class="container">
	<div class="row">
		<div class="col-sm-3">
			<div class="my_info">
					<div class="portrait">
						<img alt="头像" src="image/mypage/portrait.png">
					</div>
					<h3 id="username"><?php 
echo $thisuser['username'];
?>
</h3>
			</div>
			<div class="sidenav list-group">
				<button type="button" id="health_manage_bar" class="list-group-item active" onclick="clickBar(this)">
					健康管理
				</button>