From e531bb7aa1b9fd4a7705b8a53682ce009ab84d9c Mon Sep 17 00:00:00 2001 From: tiansf Date: Wed, 22 May 2024 19:50:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + application/app/controller/Base.php | 34 ++++++++++++---------------- application/app/controller/Index.php | 6 +++-- public/.htaccess | 9 -------- 4 files changed, 19 insertions(+), 31 deletions(-) delete mode 100644 public/.htaccess diff --git a/.gitignore b/.gitignore index be1a531..8c63f2c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock *.log +/public/*.htaccess diff --git a/application/app/controller/Base.php b/application/app/controller/Base.php index ca2dcb6..e73c121 100644 --- a/application/app/controller/Base.php +++ b/application/app/controller/Base.php @@ -162,28 +162,22 @@ class Base extends Controller{ // 曲线页面-底部统计动作 - public function base_target_initial_cumulative_weight($id,$weight = '',$target_weight,$initial_weight,$initial_date){ - if($weight != ''){ - $user_data = Db::table('app_user_data')->where(['id'=>$id])->field('target_weight,initial_weight,initial_date')->find(); + public function base_target_initial_cumulative_weight($data = []){ + // 第一种:用户详情(所有数据都有) + // 第二种:手动记录(只有最新体重) + // 第三种:修改原始体重(只有原始体重) + if(count($data) > 0){ + $result_data['target_weight'] = $data['target_weight']; + $result_data['initial_weight'] = $data['initial_weight']; + $result_data['cumulative_weight'] = $data['weight'] - $data['initial_weight']; + $result_data['cumulative_day'] = $this->daysSince($user_data['initial_date']); }else{ - $user_data = Db::table('app_user_data')->where(['id'=>$id])->field('target_weight,initial_weight,initial_date')->find(); + $result_data['target_weight'] = 0; + $result_data['initial_weight'] = 0; + $result_data['cumulative_weight'] = 0; + $result_data['cumulative_day'] = 0; } - if($user_data){ - if($user_data['initial_date']){ - $result_data['target_weight'] = $user_data['target_weight']; - $result_data['initial_weight'] = $user_data['initial_weight']; - $result_data['cumulative_weight'] = 0; - $result_data['cumulative_day'] = $this->daysSince($user_data['initial_date']).'天'; - }else{ - $result_data['target_weight'] = 0; - $result_data['initial_weight'] = 0; - $result_data['cumulative_weight'] = 0; - $result_data['cumulative_day'] = 0; - } - }else{ - return $this->msg(10003); - } - dump($result_data); + return $result_data; } diff --git a/application/app/controller/Index.php b/application/app/controller/Index.php index 168f380..a443a1a 100644 --- a/application/app/controller/Index.php +++ b/application/app/controller/Index.php @@ -84,7 +84,7 @@ class Index extends Base{ if(count(input()) > 0){ $data = input(); } - if(!array_key_exists('token', $data)){ + if(!array_key_exists('token', $data) || !array_key_exists('aan_id', $data) || !array_key_exists('type', $data)){ return $this->msg(10001); } @@ -110,7 +110,7 @@ class Index extends Base{ if(count(input()) > 0){ $data = input(); } - if(!array_key_exists('token', $data)){ + if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){ return $this->msg(10001); } @@ -119,6 +119,7 @@ class Index extends Base{ } unset($data['token']); $result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order')->find(); + if(!$result){ return $this->msg(10003); } @@ -131,6 +132,7 @@ class Index extends Base{ $result['card_order'] = explode(',',$result['card_order']); $result['card_data_list'] = $this->get_user_card_data_list($result['card_order'],$result['id']); } + // base_target_initial_cumulative_weight // dump($result); // die; $result['birthday'] = str_replace('-', '/', $result['birthday']); diff --git a/public/.htaccess b/public/.htaccess deleted file mode 100644 index deb409e..0000000 --- a/public/.htaccess +++ /dev/null @@ -1,9 +0,0 @@ - - Options +FollowSymlinks -Multiviews - RewriteEngine On - - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - ## RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] - RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] - \ No newline at end of file