作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

个人中心接口

... ... @@ -2,6 +2,7 @@
namespace api\portal\controller;
use cmf\controller\RestBaseController;
use Think\Db;
use api\portal\service\ParamService;
/**
* @title 签到
* @description 签到相关接口
... ... @@ -98,7 +99,6 @@ class SignController extends RestBaseController
* @url /portal/Sign/daySign
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param
*/
public function daySign(){
//用户信息
... ... @@ -219,7 +219,6 @@ class SignController extends RestBaseController
* @url /portal/Sign/share
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param
*/
public function share()
{
... ... @@ -230,4 +229,37 @@ class SignController extends RestBaseController
Db::name('user_score_log')->insert(['user_id'=>$this->getUserId(),'score'=>$config['share_score'],'now_score'=>$user['score']]);
$this->success('分享成功');
}
/**
* @title 周打卡页面
* @description 麦夫子周打卡页面页面渲染
* @author panhaowen
* @url /portal/Sign/weekSign
* @method POST
* @header name:XX-Token require:1 default: desc:token
*/
public function weekSign(){
//用户信息
$user=Db::name('user')->where('id',$this->getUserId())->find();
//判断是否是第一次周打卡
$re=Db::name('user_week_sign')->where('user_id',$user['id'])->find();
if (!$re){
$param['pregnant_week']=$user['pregnant_week'];
$param['day']=ceil((time()-$user['register_time'])/(60*60*21));
$param['weight']=$user['before_weight'];
$paramService=new ParamService();
}
//返回
$this->success('日打卡信息',array(
'all'=>$user['all_sign_day'],
'last'=>$user['stay_sign_day'],
'longest'=>$user['longest_sign_day'],
'morning'=>$daySign['morning'],
'noon'=>$daySign['noon'],
'night'=>$daySign['night'],
'sleep'=>$daySign['sleep'],
));
}
}
... ...
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
namespace api\portal\service;
use Think\Db;
class ParamService
{
public function BMI($weight=0,$height=0){
$bmi=$weight/pow(($height/100),2);
return $bmi;
}
public function status($weight=0,$height=0){
$bmi=$weight/pow(($height/100),2);
if($bmi<=18.5){
$status='消瘦';
}elseif (18.5<$bmi&&$bmi<=23.9){
$status='正常';
}elseif (24<$bmi&&$bmi<=27.9){
$status='超重';
}elseif ($bmi>=28){
$status='肥胖';
}
return $status;
}
}
... ...