From 1761d8d325e1a2fc802ada68483b53e0e00ddc45 Mon Sep 17 00:00:00 2001 From: tiansf Date: Wed, 12 Mar 2025 18:03:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=A8=E6=88=BF=E7=A7=A4=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KitchenScale/controller/app/Base.php | 47 +--- .../KitchenScale/controller/app/Cookbook.php | 223 ++++++++++-------- .../KitchenScale/controller/app/Countfood.php | 109 ++++++--- .../KitchenScale/controller/app/Index.php | 132 ++++++----- .../KitchenScale/controller/app/Login.php | 67 ------ .../KitchenScale/controller/app/Product.php | 75 ++++++ .../controller/app/Usercenter.php | 185 +++++++++++++++ application/app/controller/Login.php | 7 +- application/route.php | 23 ++ public/kitchenscale_all/upload.html | 3 +- public/tsf/ceshi_xuanxiang.html | 130 ++++++++++ 11 files changed, 690 insertions(+), 311 deletions(-) delete mode 100644 application/KitchenScale/controller/app/Login.php create mode 100644 application/KitchenScale/controller/app/Product.php create mode 100644 application/KitchenScale/controller/app/Usercenter.php create mode 100644 public/tsf/ceshi_xuanxiang.html diff --git a/application/KitchenScale/controller/app/Base.php b/application/KitchenScale/controller/app/Base.php index bc1e197..34b96eb 100644 --- a/application/KitchenScale/controller/app/Base.php +++ b/application/KitchenScale/controller/app/Base.php @@ -150,6 +150,7 @@ class Base extends Controller{ ####################################################图片选择上传start############################################################## public function pic_chose_list($page = 1) { $data = input(); + $page_num = 20; if(!array_key_exists('token',$data)){ return $this->msg(10001,'token is miss'); } @@ -164,8 +165,8 @@ class Base extends Controller{ $cfc = Db::connect('cfc_db'); $num = $cfc->table('app_user_upload_img')->where($parameter_data)->count(); - $result = $cfc->table('app_user_upload_img')->where($parameter_data)->order('id desc')->page($page,20)->field('id,pic_name,pic_url')->select(); - $return_result['total_num'] = $num; + $result = $cfc->table('app_user_upload_img')->where($parameter_data)->order('id desc')->page($page,$page_num)->field('id,pic_name,pic_url')->select(); + $return_result['page_total'] = $page_total = ceil($num/$page_num); $return_result['page_now'] = $page; $return_result['result'] = $result; return $this->msg($return_result); @@ -180,6 +181,9 @@ class Base extends Controller{ if(!$token){ return $this->msg(10001,'token is miss'); } + if(count($files)>5){ + return $this->msg(10001,'单次最多上传5张图片'); + } if($files){ foreach($files as $file){ $name = $file->getInfo()['name']; @@ -200,7 +204,6 @@ class Base extends Controller{ 'user_token'=>$token, 'pic_name'=>$new_filename, 'pic_url'=>"https://tc.pcxbc.com/kitchenscale_all/user_upload/".$new_filename, - // 'pic_url'=>"http://wm.tcxbc.com/kitchenscale_all/user_upload/".$new_filename, 'create_time'=>date('Y-m-d H:i:s'), ]; $pic_id = $cfc->table('app_user_upload_img')->insertGetId($temporary_data); @@ -217,47 +220,11 @@ class Base extends Controller{ } } - return $this->msg(['error_data'=>$miss_data,'insert_data'=>$insert_data]); + return $this->msg(['error_num'=>$miss_data,'insert_data'=>$insert_data]); }else{ return $this->msg(10001,'未选择图片'); } - - - - // dump($file); - // die; - - // if($file){ - // $name = $file->getInfo()['name']; - // // 使用 pathinfo() 函数获取文件名的扩展名 - // $pathinfo = pathinfo($name); - // $extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较 - // $file_name = $pathinfo['filename']; - // // 判断扩展名是否不是 .png 或 .gif - // if ($extension !== 'png' && $extension !== 'gif') { - // // 修改文件名,将扩展名改为 .jpg - // $new_filename = date('YmdHis').$file_name . '.jpg'; - // } else { - // $new_filename = date('YmdHis').$name; - // } - // $info = $file->validate(['size'=>$this->file_size,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'upload_pic',$new_filename); - // if($info){ - // $insert_data = [ - // 'url_data'=>"https://tc.pcxbc.com/upload_pic/".$new_filename, - // 'name'=>$new_filename, - // 'create_time'=>date('Y-m-d H:i:s'), - // ]; - // $pic_result = Db::table('admin_pic_manage')->insertGetId($insert_data); - // if($pic_result){ - // return $this->msg(['url'=>$insert_data['url_data'],'id'=>$pic_result]); - // }else{ - // return $this->msg(10002,'图片数据保存失败'); - // } - // }else{ - // return $this->msg(10002,'图片上传失败'); - // } - // } } diff --git a/application/KitchenScale/controller/app/Cookbook.php b/application/KitchenScale/controller/app/Cookbook.php index 2209023..7fcd393 100644 --- a/application/KitchenScale/controller/app/Cookbook.php +++ b/application/KitchenScale/controller/app/Cookbook.php @@ -18,7 +18,11 @@ class Cookbook extends Base{ 'uploadimg'=>'app_user_upload_img',//素材表 'followlist'=>'app_user_follow_list',//关注列表 'collect_list'=>'app_user_collect_list',//收藏列表 + 'foodlist1'=>'app_food_type_one',//食材列表3 + 'foodlist2'=>'app_food_type_two',//食材列表3 'foodlist3'=>'app_food_type_three',//食材列表3 + 'user_kcal_log'=>'app_user_kcal_log',//食材列表3 + ]; // 加 bcadd(,,20) @@ -64,6 +68,9 @@ class Cookbook extends Base{ if(!$this->verify_data_is_ok($data['description'],'str')){ return $this->msg(10005,'description type is error'); } + if(!$this->verify_data_is_ok($data['cook_label'],'intnum')){ + return $this->msg(10005,'cook_label type is error'); + } if (!is_array($data['food_list'])) { return $this->msg(10005,'food_list type is error'); } @@ -90,7 +97,7 @@ class Cookbook extends Base{ // } } // 根据菜谱标签查询列表(首页用)(OK) - public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>'家常菜谱','page'=>'1']){ + public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>2,'page'=>'1']){ // 尝试捕获异常 // try { if(count(input('post.')) > 0){ @@ -108,7 +115,7 @@ class Cookbook extends Base{ if(!$this->verify_data_is_ok($data['token'],'str')){ return $this->msg(10005,'token type is error'); } - if(!$this->verify_data_is_ok($data['cook_label'],'str')){ + if(!$this->verify_data_is_ok($data['cook_label'],'intnum')){ return $this->msg(10005,'cook_label type is error'); } if(!$this->verify_data_is_ok($data['page'],'intnum')){ @@ -174,7 +181,7 @@ class Cookbook extends Base{ // } } // 查询食谱的详情(OK) - public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'17']){ + public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'21']){ // 尝试捕获异常 // try { if(count(input('post.')) > 0){ @@ -324,8 +331,8 @@ class Cookbook extends Base{ // return json(['status' => 'error', 'message' => '系统错误']); // } } - // 保存每日餐食食物信息 - public function save_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_list'=>[['name'=>'鸡肉','weight'=>456.37,'kcal'=>761.52]]]){ + // 食材列表查询接口(OK) + public function find_food($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_name'=>'鸡肉']){ // 尝试捕获异常 // try { if(count(input('post.')) > 0){ @@ -334,15 +341,17 @@ class Cookbook extends Base{ if(!array_key_exists('token', $data)){ return $this->msg(10001,'token is miss'); } - if(!array_key_exists('food_list', $data)){ - return $this->msg(10001,'food_list is miss'); + if(!array_key_exists('food_name', $data)){ + return $this->msg(10001,'food_name is miss'); } if(!$this->verify_data_is_ok($data['token'],'str')){ return $this->msg(10005,'token type is error'); } + if(!$this->verify_data_is_ok($data['food_name'],'str')){ + return $this->msg(10005,'food_name type is error'); + } - - $return_data = $this->save_food_list_action($data); + $return_data = $this->find_food_action($data); return $return_data; // } catch (\Exception $e) { // // 捕获异常 @@ -359,11 +368,20 @@ class Cookbook extends Base{ // return json(['status' => 'error', 'message' => '系统错误']); // } } + + #######################################################################action####################################################################### #######################################################################action####################################################################### #######################################################################action####################################################################### public function add_cookbook_action($data){ + + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(10005,'账号信息错误'); + } + if(count($data['food_list']) < 1){ return $this->msg(10005,'至少添加一个食物'); } @@ -382,7 +400,9 @@ class Cookbook extends Base{ if(!$this->verify_data_is_ok($value['weight'],'intnum')){ return $this->msg(10005,'食材重量格式错误,需整数数字'); } - array_push($food_type, $value['name']); + if(!in_array($value['name'], $food_type)){ + array_push($food_type, $value['name']); + } } // 检验一下step_list是否合规(步骤列表) foreach ($data['step_list'] as $key => $value) { @@ -392,24 +412,22 @@ class Cookbook extends Base{ if(!$this->verify_data_is_ok($value['description'],'str')){ return $this->msg(10005,'步骤描述格式错误,需要正常字符'); } - foreach ($value['pic_list'] as $k => $v) { if(!$this->verify_data_is_ok($v,'intnum')){ return $this->msg(10005,'步骤中图片ID错误,需整数数字'); } } } - $cfc = Db::connect('cfc_db'); // 获取账号下信息以及用户信息 $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); // 处理食材卡路里start $kcal_data = $this->count_calorie($data['food_list'],$data['step_list']); - $data['food_list'] =$kcal_data[0]; - $data['step_list'] = $kcal_data[1]; + $data['food_list'] =$kcal_data; // 处理食材卡路里end + $insert_data = [ 'title'=>$data['title'], 'cover'=>$data['cover'], @@ -423,6 +441,8 @@ class Cookbook extends Base{ 'cook_label'=>$data['cook_label'], 'create_time'=>date('Y-m-d H:i:s') ]; + // dump($insert_data); + // die; $cook_book_result = $cfc->table($this->kitchenscale_db_msg['cookbook'])->insert($insert_data); if($cook_book_result){ @@ -447,7 +467,7 @@ class Cookbook extends Base{ ->alias('cookbook') ->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT') ->where(['cookbook.cook_label'=>$cook_label]) - ->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num') + ->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num') ->page("$page_now,$page_num") ->select(); @@ -460,9 +480,9 @@ class Cookbook extends Base{ foreach ($content_list as $key => $value) { // if(in_array($value['id'],$my_collect_list)){ if(array_key_exists($value['id'],$my_collect_list)){ - $content_list[$key]['is_me_like_it'] = 1; + $content_list[$key]['is_me_like_it'] = 'yes'; }else{ - $content_list[$key]['is_me_like_it'] = 0; + $content_list[$key]['is_me_like_it'] = 'no'; } if($value['cover'] == null){ $content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; @@ -490,7 +510,7 @@ class Cookbook extends Base{ ->alias('cookbook') ->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT') ->where("cookbook.food_type like '%$food_name%'") - ->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num') + ->field('cookbook.id,cookbook.title,uploadimg.pic_url as cover,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num') ->page("$page_now,$page_num") ->select(); @@ -503,9 +523,9 @@ class Cookbook extends Base{ foreach ($content_list as $key => $value) { // if(in_array($value['id'],$my_collect_list)){ if(array_key_exists($value['id'],$my_collect_list)){ - $content_list[$key]['is_me_like_it'] = 1; + $content_list[$key]['is_me_like_it'] = 'yes'; }else{ - $content_list[$key]['is_me_like_it'] = 0; + $content_list[$key]['is_me_like_it'] = 'no'; } if($value['cover'] == null){ $content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; @@ -568,30 +588,30 @@ class Cookbook extends Base{ }else{ $cookbook_data['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; } - // 处理关注跟收藏信息 - if($data['token'] == $cookbook_data['create_user_token']){ - // 如果查询跟作者一致 - $cookbook_data['follow_status'] = 'myself'; - $cookbook_data['collect_status'] = 'myself'; - }else{ - $follow_data = $cfc->table($this->kitchenscale_db_msg['followlist']) - ->where([ - 'follow_user_token'=>$data['token'], - 'being_follow_user_token'=>$cookbook_data['create_user_token'], - ]) - ->find(); - if($follow_data){ - if($follow_data['is_del'] == 0){ - // 如果有结果并且没被删过 - $cookbook_data['follow_status'] = 'yes'; - }else{ - // 如果有结果被删过 - $cookbook_data['follow_status'] = 'no'; - } - }else{ - // 如果没结果 - $cookbook_data['follow_status'] = 'no'; - } + // // 处理关注跟收藏信息 + // if($data['token'] == $cookbook_data['create_user_token']){ + // // 如果查询跟作者一致 + // $cookbook_data['follow_status'] = 'myself'; + // $cookbook_data['collect_status'] = 'myself'; + // }else{ + // $follow_data = $cfc->table($this->kitchenscale_db_msg['followlist']) + // ->where([ + // 'follow_user_token'=>$data['token'], + // 'being_follow_user_token'=>$cookbook_data['create_user_token'], + // ]) + // ->find(); + // if($follow_data){ + // if($follow_data['is_del'] == 0){ + // // 如果有结果并且没被删过 + // $cookbook_data['follow_status'] = 'yes'; + // }else{ + // // 如果有结果被删过 + // $cookbook_data['follow_status'] = 'no'; + // } + // }else{ + // // 如果没结果 + // $cookbook_data['follow_status'] = 'no'; + // } $collect_data = $cfc->table($this->kitchenscale_db_msg['collect_list']) ->where([ @@ -611,12 +631,12 @@ class Cookbook extends Base{ // 如果没结果 $cookbook_data['collect_status'] = 'no'; } - } + // } // 添加阅读量 - $read_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('read_it'); - if($read_num){ - $cookbook_data['read_it'] = $cookbook_data['read_it']+1; - } + // $read_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('read_it'); + // if($read_num){ + // $cookbook_data['read_it'] = $cookbook_data['read_it']+1; + // } // unset($cookbook_data['create_user_token']); unset($cookbook_data['create_time']); unset($cookbook_data['cook_label']); @@ -667,21 +687,24 @@ class Cookbook extends Base{ } } public function cookbook_like_action($data){ + + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic')->find(); + if(!$user_data){ + return $this->msg(10005,'账号信息错误'); + } + $cfc = Db::connect('cfc_db'); - $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->field('id,create_user_token')->find(); + $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->field('id,create_user_token,likes_num')->find(); if(!$cookbook_data){ return $this->msg(10002,'未找到菜谱'); } + // return $this->msg(10002,'是这里'); // if($data['token'] == $cookbook_data['create_user_token']){ // // 如果查询跟作者一致 // return $this->msg(10002,'不能收藏自己'); // } - $like_data = $cfc->table($this->kitchenscale_db_msg['collect_list']) - ->where([ - 'token'=>$data['token'], - 'cookbook_id'=>$data['cookbook_id'], - ]) - ->find(); + $like_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token'],'cookbook_id'=>$data['cookbook_id']])->find(); $like_data_state = 0; if($like_data){ @@ -698,17 +721,28 @@ class Cookbook extends Base{ ->where(['id'=>$like_data['id']]) ->update(['is_del'=>$like_data_state]); if($like_data_state == 0){ - $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('like_it'); + $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('likes_num'); }else{ - $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setDec('like_it'); + $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setDec('likes_num'); } // 提交事务 Db::commit(); - return $this->msg([]); + if($like_data_state==0){ + $likes_num = $cookbook_data['likes_num']+1; + }else{ + $likes_num = $cookbook_data['likes_num']-1; + if($likes_num <= 0){ + $likes_num = 0; + } + } + return $this->msg([ + 'collect_status'=>$like_data_state==0?'yes':'no', + 'likes_num'=>$likes_num + ]); } catch (\Exception $e) { // 回滚事务 Db::rollback(); - return $this->msg(10001,'操作失败'); + return $this->msg(10001,'操作失败.'); } }else{ // 启动事务 @@ -720,10 +754,13 @@ class Cookbook extends Base{ 'cookbook_id'=>$data['cookbook_id'], 'create_time'=>date('Y-m-d H:i:s') ]); - $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('like_it'); + $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setInc('likes_num'); // 提交事务 Db::commit(); - return $this->msg([]); + return $this->msg([ + 'collect_status'=>"yes", + 'likes_num'=>$cookbook_data['likes_num']+1 + ]); } catch (\Exception $e) { // 回滚事务 Db::rollback(); @@ -741,38 +778,26 @@ class Cookbook extends Base{ $kcal = bcmul($weight,$food_data['kcal'],2); return $this->msg(['value'=>$kcal,'unit'=>'kcal']); } - public function save_food_list_action($data){ + public function find_food_action($data){ $cfc = Db::connect('cfc_db'); - foreach ($data['food_list'] as $key => $value) { - if(!array_key_exists('name', $value) || !array_key_exists('weight', $value) || !array_key_exists('kcal', $value)){ - return $this->msg(10001,'food_list content lost'); - } - if(!$this->verify_data_is_ok($value['name'],'str')){ - return $this->msg(10005,'name type is error'); - } - if(!$this->verify_data_is_ok($value['weight'],'num')){ - return $this->msg(10005,'weight type is error'); - } - if(!$this->verify_data_is_ok($value['kcal'],'num')){ - return $this->msg(10005,'kcal type is error'); - } - } - if(!array_key_exists('eat_time', $data)){ - $data['eat_time'] = date('Y-m-d H:i:s'); + $food_data = $cfc->query("select f3.id,f3.name,f3.kcal,f2.id as up_one_level_id,f1.id as up_two_level_id + from ".$this->kitchenscale_db_msg['foodlist3']." as f3 + LEFT JOIN ".$this->kitchenscale_db_msg['foodlist2']." as f2 + on f3.two_id = f2.id + LEFT JOIN ".$this->kitchenscale_db_msg['foodlist1']." as f1 + on f2.one_id = f1.id + where f3.is_del=0 AND f3.name like '%".$data['food_name']."%' + "); + + if(count($food_data)>0){ + return $this->msg($food_data); }else{ - if(!$this->verify_data_is_ok($value['kcal'],'datetime')){ - return $this->msg(10005,'kcal type is error'); - } + return $this->msg(10002,'未找到该食材'); } - - $result = $cfc->table($this->kitchenscale_db_msg['foodlist3']) - ->insert([ - - ]); - } + #######################################################################小工具####################################################################### #######################################################################小工具####################################################################### @@ -799,19 +824,19 @@ class Cookbook extends Base{ $data[$key]['weight'] = $data[$key]['weight'].'g'; } - foreach ($step as $key => $value) { - foreach ($value['foot_list'] as $k => $v) { + // foreach ($step as $key => $value) { + // foreach ($value['foot_list'] as $k => $v) { - if(array_key_exists($v['name'], $foot_kcal2)){ - $step[$key]['foot_list'][$k]['kcal'] = $this->count_calorie_action($v['weight'],$foot_kcal2[$v['name']]).'kcal'; - }else{ - $step[$key]['foot_list'][$k]['kcal'] = '0kcal'; - } - $step[$key]['foot_list'][$k]['weight'] = $step[$key]['foot_list'][$k]['weight'].'g'; - } + // if(array_key_exists($v['name'], $foot_kcal2)){ + // $step[$key]['foot_list'][$k]['kcal'] = $this->count_calorie_action($v['weight'],$foot_kcal2[$v['name']]).'kcal'; + // }else{ + // $step[$key]['foot_list'][$k]['kcal'] = '0kcal'; + // } + // $step[$key]['foot_list'][$k]['weight'] = $step[$key]['foot_list'][$k]['weight'].'g'; + // } - } - return [$data,$step]; + // } + return [$data]; } diff --git a/application/KitchenScale/controller/app/Countfood.php b/application/KitchenScale/controller/app/Countfood.php index 4aff619..0eb2d78 100644 --- a/application/KitchenScale/controller/app/Countfood.php +++ b/application/KitchenScale/controller/app/Countfood.php @@ -6,11 +6,19 @@ use think\Db; class Login extends Base{ - protected $code_time = 50; - // protected $token_time = 2592000;//30天的秒数 protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png'; - protected $login_use_db_name = [ - '1'=>'app_account_number', + protected $reedaw_db_msg = [ + 'zhanghao'=>'app_account_number',//账号表 + 'juese'=>'app_user_data',//角色表 + ]; + protected $kitchenscale_db_msg = [ + 'cookbook'=>'app_user_cookbook',//菜谱表 + 'uploadimg'=>'app_user_upload_img',//素材表 + 'followlist'=>'app_user_follow_list',//关注列表 + 'collect_list'=>'app_user_collect_list',//收藏列表 + 'foodlist3'=>'app_food_type_three',//食材列表3 + 'user_kcal_log'=>'app_user_kcal_log',//食材列表3 + ]; // 加 bcadd(,,20) @@ -21,47 +29,74 @@ class Login extends Base{ ################################################################接口################################################################ ################################################################接口################################################################ - // 注册 - - public function login_api($data = ['account'=>123,'password'=>456]){ - try { - // 你的业务逻辑 + // 保存每日餐食食物信息 + public function save_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','food_list'=>[['name'=>'鸡肉','weight'=>456.37,'kcal'=>761.52]]]){ + // 尝试捕获异常 + // try { if(count(input('post.')) > 0){ $data = input('post.'); } - if(!array_key_exists('account', $data) && !array_key_exists('password', $data)){ - return $this->msg(10001); + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); } - $return_data = $this->login_action($data); - // 成功 - $this->record_api_log($data, null, $return_data); + if(!array_key_exists('food_list', $data)){ + return $this->msg(10001,'food_list is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + + + $return_data = $this->save_food_list_action($data); return $return_data; - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["file"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // // 记录日志 + // // $this->record_api_log($data, $logContent, null); + // return json(['status' => 'error', 'message' => '系统错误']); + // } } #######################################################################action####################################################################### - public function login_action($data){ - // dump($data); - $user = Db::table('admin_user_account_number')->where(["account_num"=>$data['account'],'password'=>$data['password']])->find(); - // dump($user); - // die; - if($user){ - return $this->msg(['token'=>$user['token']]); - }else{ - return $this->msg(10004); + #######################################################################action####################################################################### + #######################################################################action####################################################################### + + public function save_food_list_action($data){ + $cfc = Db::connect('cfc_db'); + foreach ($data['food_list'] as $key => $value) { + if(!array_key_exists('name', $value) || !array_key_exists('weight', $value) || !array_key_exists('kcal', $value)){ + return $this->msg(10001,'food_list content lost'); + } + if(!$this->verify_data_is_ok($value['name'],'str')){ + return $this->msg(10005,'name type is error'); + } + if(!$this->verify_data_is_ok($value['weight'],'num')){ + return $this->msg(10005,'weight type is error'); + } + if(!$this->verify_data_is_ok($value['kcal'],'num')){ + return $this->msg(10005,'kcal type is error'); + } } - + if(!array_key_exists('eat_time', $data)){ + $data['eat_time'] = date('Y-m-d H:i:s'); + }else{ + if(!$this->verify_data_is_ok($data['eat_time'],'datetime')){ + return $this->msg(10005,'eat_time type is error'); + } + } + + $result = $cfc->table($this->kitchenscale_db_msg['user_kcal_log']) + ->insert([ + 'food_name'=> + ]); + } } \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Index.php b/application/KitchenScale/controller/app/Index.php index 837733a..202d906 100644 --- a/application/KitchenScale/controller/app/Index.php +++ b/application/KitchenScale/controller/app/Index.php @@ -12,15 +12,16 @@ class Index extends Base{ protected $reedaw_db_msg = [ 'zhanghao'=>'app_account_number',//账号表 'juese'=>'app_user_data',//角色表 - 'banner'=>'admin_notice_banner',//banner ]; protected $kitchenscale_db_msg = [ 'cookbook'=>'app_user_cookbook',//菜谱表 + 'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表 'uploadimg'=>'app_user_upload_img',//图片素材表 'foodlist1'=>'app_food_type_one',//食材列表1 'foodlist2'=>'app_food_type_two',//食材列表2 'foodlist3'=>'app_food_type_three',//食材列表3 - 'collect_list'=>'app_user_collect_list',//素材表 + 'collect_list'=>'app_user_collect_list',//点赞表 + 'banner'=>'app_banner_data',//banner ]; @@ -64,7 +65,7 @@ class Index extends Base{ // 获取首页信息(banner,金刚区,label_list)(OK) public function get_homepage_information($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){ - try { + // try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -79,25 +80,25 @@ class Index extends Base{ // 成功 $this->record_api_log($data, null, $return_data); return $return_data; - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "接口: (get_homepage_information)\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "接口: (get_homepage_information)\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // $this->record_api_log($data, $logContent, null); + // return $this->msg(99999); + // } } // 首页搜索接口(OK) public function search_column($data = ['search_data'=>'鱼','token'=>'caadd1be045a65f30b92aa805f1de54a']){ - try { + // try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -113,20 +114,20 @@ class Index extends Base{ } $return_data = $this->search_column_action($data); return $return_data; - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "接口: (search_column)\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "接口: (search_column)\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // $this->record_api_log($data, $logContent, null); + // return $this->msg(99999); + // } } #######################################################################action####################################################################### @@ -136,8 +137,11 @@ class Index extends Base{ public function get_default_config_action($data){ $return_data = [ 'food_list'=>[], + 'cook_label'=>[], 'account'=>[], ]; + + $cfc = Db::connect('cfc_db'); // 获取食材分类列表start $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); @@ -152,6 +156,7 @@ class Index extends Base{ foreach ($foodlist3 as $k3 => $v3) { if($v3['two_id'] == $v['id']){ unset($foodlist3[$k3]['ROW_NUMBER']); + $foodlist3[$k3]['one_id'] = $v['one_id']; array_push($foodlist2[$k]['list'],$foodlist3[$k3]); // unset($foodlist3[$k3]); } @@ -165,6 +170,16 @@ class Index extends Base{ } $return_data['food_list'] = $foodlist1; // 获取食材分类列表end + // 获取菜谱分类标签start + $cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label']) + ->where("is_del = 0") + ->field('id,name') + ->select(); + foreach ($cook_label as $key => $value) { + unset($cook_label[$key]['ROW_NUMBER']); + } + $return_data['cook_label'] = $cook_label; + // 获取菜谱分类标签end // 获取账号下信息以及用户信息start $user_account = Db::table($this->reedaw_db_msg['zhanghao']) ->alias('zhanghao') @@ -187,51 +202,38 @@ class Index extends Base{ ['name'=>'热量计算','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'], ['name'=>'健康食谱','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'], ], - 'label_list'=>[], ]; $cfc = Db::connect('cfc_db'); // 获取banner - $banner_list = Db::table($this->reedaw_db_msg['banner']) - ->where("is_del = 0 AND scene_data IN (21)") - ->order('sort_num desc,id desc') - ->field('id,title,pic,type,jump_url,create_time,scene_data,sort_num,parameter_data') - ->select(); + $banner_list = $cfc->query("select b.id,b.title,b.cover,b.create_user_head_pic,b.create_user_nickname + from ".$this->kitchenscale_db_msg['banner']." as a + LEFT JOIN ".$this->kitchenscale_db_msg['cookbook']." as b + on a.cookbook_id = b.id + where a.is_del=0 + ORDER BY a.sort_num desc,a.id desc + "); + $collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token']])->column('cookbook_id'); + + foreach ($banner_list as $key => $value) { - if($value['type'] == '1'){ - $banner_list[$key]['type'] = 'h5'; - $banner_list[$key]['id'] = $value['parameter_data']; + if(array_key_exists($value['id'],$collect_list)){ + $banner_list[$key]['is_me_like_it'] = 1; }else{ - $banner_list[$key]['type'] = 'wechat'; - // 提取查询字符串部分(?后面的部分) - $queryString = substr($banner_list[$key]['jump_url'], strpos($banner_list[$key]['jump_url'], '?') + 1); - // 使用parse_str解析查询字符串 - $params = []; - parse_str($queryString, $params); - // 提取appid和path的值 - $appid = isset($params['appid']) ? $params['appid'] : null; - $path = isset($params['path']) ? $params['path'] : null; - $banner_list[$key]['appid'] = $appid; - $banner_list[$key]['path'] = $path; - // 重新定义跳转链接为中间页 - $banner_list[$key]['jump_url'] = "https://tc.pcxbc.com/open_wechat_content"; + $banner_list[$key]['is_me_like_it'] = 0; } - unset($banner_list[$key]['scene_data']); - unset($banner_list[$key]['sort_num']); unset($banner_list[$key]['ROW_NUMBER']); - unset($banner_list[$key]['parameter_data']); } $return_data['banner'] = $banner_list; // 获取菜谱列表 - $label_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])->group('cook_label')->field('cook_label,count(*) as num')->select(); - // dump($label_list); - if(count($label_list) <= 0){ - $return_data['label_list'] = []; - return $this->msg($return_data); - } - $return_data['label_list'] = $label_list; + // $label_list = $cfc->query("select id,name from ".$this->kitchenscale_db_msg['cookbook_label']." where is_del=0 ORDER BY id"); + // if(count($label_list) <= 0){ + // $return_data['label_list'] = []; + // return $this->msg($return_data); + // } + // $return_data['label_list'] = $label_list; return $this->msg($return_data); @@ -245,7 +247,7 @@ class Index extends Base{ ->alias('cookbook') ->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','cookbook.cover = uploadimg.id','LEFT') ->where("cookbook.title LIKE '%".$data['search_data']."%' OR cookbook.describe_data LIKE '%".$data['search_data']."%'") - ->field("cookbook.id,cookbook.title,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.like_it as like_num,uploadimg.pic_url as cover") + ->field("cookbook.id,cookbook.title,cookbook.create_user_head_pic,cookbook.create_user_nickname,cookbook.likes_num,uploadimg.pic_url as cover") ->select(); if(count($content_list)<=0){ return $this->msg([]); diff --git a/application/KitchenScale/controller/app/Login.php b/application/KitchenScale/controller/app/Login.php deleted file mode 100644 index 4aff619..0000000 --- a/application/KitchenScale/controller/app/Login.php +++ /dev/null @@ -1,67 +0,0 @@ -'app_account_number', - ]; - - // 加 bcadd(,,20) - // 减 bcsub(,,20) - // 乘 bcmul(,,20) - // 除 bcdiv(,,20) - ################################################################接口################################################################ - ################################################################接口################################################################ - ################################################################接口################################################################ - - // 注册 - - public function login_api($data = ['account'=>123,'password'=>456]){ - try { - // 你的业务逻辑 - if(count(input('post.')) > 0){ - $data = input('post.'); - } - if(!array_key_exists('account', $data) && !array_key_exists('password', $data)){ - return $this->msg(10001); - } - $return_data = $this->login_action($data); - // 成功 - $this->record_api_log($data, null, $return_data); - return $return_data; - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } - } - #######################################################################action####################################################################### - public function login_action($data){ - // dump($data); - $user = Db::table('admin_user_account_number')->where(["account_num"=>$data['account'],'password'=>$data['password']])->find(); - // dump($user); - // die; - if($user){ - return $this->msg(['token'=>$user['token']]); - }else{ - return $this->msg(10004); - } - - } - -} \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Product.php b/application/KitchenScale/controller/app/Product.php new file mode 100644 index 0000000..429f30b --- /dev/null +++ b/application/KitchenScale/controller/app/Product.php @@ -0,0 +1,75 @@ +table("ceshi3_option") + ->alias('xuanxiang') + ->join('ceshi2_configuration peizhi','xuanxiang.parent_id = peizhi.id','LEFT') + ->where(['peizhi.is_default'=>$this->is_default]) + ->field("xuanxiang.*,peizhi.name") + ->select(); + $temporary = []; + foreach ($content_num as $key => $value) { + $temporary[$value['name']]['id'] = $value['parent_id']; + $temporary[$value['name']]['name'] = $value['name']; + $temporary[$value['name']]['type'] = "configuration"; + $temporary[$value['name']]['list'][$value['value']] = []; + $temporary[$value['name']]['list'][$value['value']]['id'] = $value['id']; + $temporary[$value['name']]['list'][$value['value']]['name'] = $value['value']; + $temporary[$value['name']]['list'][$value['value']]['type'] = "parameter"; + $temporary[$value['name']]['list'][$value['value']]['list'] = []; + } + // dump($temporary); + // die; + return $this->msg($temporary); + } + + // 获取所点击选项的所有直属上级配置项 + private function getAncestorConfigurations($cfc, $optionId) + { + $ancestors = []; + + // 获取当前选项的配置项 + $currentConfig = $cfc->query(" + SELECT c.id, c.name, c.parent_id + FROM configurations c + JOIN options o ON c.id = o.config_id + WHERE o.id = ? + ", [$optionId]); + + if (!empty($currentConfig)) { + $currentConfig = $currentConfig[0]; + + // 获取直属上级配置项 + if ($currentConfig['parent_id']) { + $parentConfig = $cfc->query(" + SELECT c.id, c.name + FROM configurations c + WHERE c.id = ? + ", [$currentConfig['parent_id']]); + + if (!empty($parentConfig)) { + $parentConfig = $parentConfig[0]; + $ancestors[] = $parentConfig; + } + } + } + + return $ancestors; + } +} \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Usercenter.php b/application/KitchenScale/controller/app/Usercenter.php new file mode 100644 index 0000000..dc211ca --- /dev/null +++ b/application/KitchenScale/controller/app/Usercenter.php @@ -0,0 +1,185 @@ +'app_account_number',//账号表 + 'juese'=>'app_user_data',//角色表 + ]; + protected $kitchenscale_db_msg = [ + 'cookbook'=>'app_user_cookbook',//菜谱表 + 'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表 + 'uploadimg'=>'app_user_upload_img',//图片素材表 + 'foodlist1'=>'app_food_type_one',//食材列表1 + 'foodlist2'=>'app_food_type_two',//食材列表2 + 'foodlist3'=>'app_food_type_three',//食材列表3 + 'collect_list'=>'app_user_collect_list',//点赞表 + 'banner'=>'app_banner_data',//banner + ]; + + + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + + // 获取用户收藏点赞列表(OK) + public function get_user_collect_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1,'search_data'=>'']){ + // try { + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); + } + if(!array_key_exists('page', $data)){ + return $this->msg(10001,'page is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + if(!$this->verify_data_is_ok($data['page'],'intnum')){ + return $this->msg(10005,'page type is error'); + } + $return_data = $this->get_user_collect_list_action($data); + return $return_data; + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "接口: (get_default_config)\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // $this->record_api_log($data, $logContent, null); + // return $this->msg(99999); + // } + } + + // 我的菜谱 + public function get_my_cookbook($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1]){ + // try { + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); + } + if(!array_key_exists('page', $data)){ + return $this->msg(10001,'page is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + if(!$this->verify_data_is_ok($data['page'],'intnum')){ + return $this->msg(10005,'page type is error'); + } + $return_data = $this->get_my_cookbook_action($data); + return $return_data; + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "接口: (get_default_config)\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // $this->record_api_log($data, $logContent, null); + // return $this->msg(99999); + // } + } + + + #######################################################################action####################################################################### + #######################################################################action####################################################################### + #######################################################################action####################################################################### + public function get_user_collect_list_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count(); + if($user_data<=0){ + return $this->msg(10005,'账号信息错误'); + } + $search_sql_str = "a.token = '".$data['token']."' AND a.is_del = 0"; + if(!array_key_exists('search_data', $data)){ + $data['search_data'] = ""; + }else{ + if($data['search_data'] === ""){ + $data['search_data'] = ""; + }else{ + $data['search_data'] = " AND (b.title LIKE '%".$data['search_data']."%' OR b.describe_data LIKE '%".$data['search_data']."%')"; + } + } + $search_sql_str = $search_sql_str.$data['search_data']; + // "a.token = 'asdasdasdasda' AND a.is_del = 0 AND b.title LIKE '%鱼%' OR b.describe_data LIKE '%鱼%'"; + + $cfc = Db::connect('cfc_db'); + + $content_num = $cfc->table($this->kitchenscale_db_msg['collect_list']) + ->alias('a') + ->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT') + ->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT') + ->where($search_sql_str) + ->count(); + $page_total = ceil($content_num/$this->page_num);; + $collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list']) + ->alias('a') + ->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT') + ->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT') + ->where($search_sql_str) + ->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname") + ->page($data['page'],$this->page_num) + ->select(); + + return $this->msg([ + 'page_now'=>$data['page'], + 'page_total'=>$page_total, + 'content_list'=>$collect_list + ]); + } + + public function get_my_cookbook_action($data){ + // 获取账号下信息以及用户信息 + $user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count(); + if($user_data<=0){ + return $this->msg(10005,'账号信息错误'); + } + $cfc = Db::connect('cfc_db'); + $content_num = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->alias('b') + ->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT') + ->where(['b.create_user_token'=>$data['token'],'b.is_del'=>0]) + ->count(); + $page_total = ceil($content_num/$this->page_num);; + $collect_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->alias('b') + ->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT') + ->where(['b.create_user_token'=>$data['token'],'b.is_del'=>0]) + ->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname") + ->page($data['page'],$this->page_num) + ->select(); + + return $this->msg([ + 'page_now'=>$data['page'], + 'page_total'=>$page_total, + 'content_list'=>$collect_list + ]); + } + +} \ No newline at end of file diff --git a/application/app/controller/Login.php b/application/app/controller/Login.php index 36e4cff..417008d 100644 --- a/application/app/controller/Login.php +++ b/application/app/controller/Login.php @@ -20,7 +20,7 @@ class Login extends Base{ ################################################################接口################################################################ // 注册 - public function register_action($data = ['data'=>18530934717,'password'=>'ceshi','code'=>'746119']){ + public function register_action($data = ['data'=>13408173311,'password'=>'123','code'=>'746119']){ try { // 你的业务逻辑 // 验证是否前段发送过来的数据 @@ -46,11 +46,14 @@ class Login extends Base{ if($montage_data == false){ return $this->msg(10005); } + // 查询账号是否已经注册 $inspect_repeat = Db::table($this->login_use_db_name['1'])->where([$montage_data=>$data['data'],'is_del'=>0])->count(); - if($inspect_repeat >= 0){ + + if($inspect_repeat > 0){ return $this->msg(10002,'注册失败,账号已存在'); } + // 检查验证码 $code_result = $this->check_code($data['data'],$data['code']); if($code_result !== true){ diff --git a/application/route.php b/application/route.php index 9686583..cd96bfb 100644 --- a/application/route.php +++ b/application/route.php @@ -450,6 +450,29 @@ Route::any('/testedition/kitchenscale/cookbook_like', 'app/kitchenscale/testapp. // 获取当前食材重量卡路里 Route::any('/kitchenscale/food_count_kcal', 'app/kitchenscale/app.cookbook/food_count_kcal'); Route::any('/testedition/kitchenscale/food_count_kcal', 'app/kitchenscale/testapp.cookbook/food_count_kcal'); +// 获取当前食材重量卡路里 +Route::any('/kitchenscale/find_food', 'app/kitchenscale/app.cookbook/find_food'); +Route::any('/testedition/kitchenscale/find_food', 'app/kitchenscale/testapp.cookbook/find_food'); + + +// 计食器################################################################ +// 保存每日餐食食物信息 +Route::any('/kitchenscale/save_food_list', 'app/kitchenscale/app.cookbook/save_food_list'); +Route::any('/testedition/kitchenscale/save_food_list', 'app/kitchenscale/testapp.cookbook/save_food_list'); + +// 我的################################################################ +// 账号收藏点赞列表 +Route::any('/kitchenscale/get_user_collect_list', 'app/kitchenscale/app.usercenter/get_user_collect_list'); +Route::any('/testedition/kitchenscale/get_user_collect_list', 'app/kitchenscale/testapp.usercenter/get_user_collect_list'); +// 我的菜谱 +Route::any('/kitchenscale/get_my_cookbook', 'app/kitchenscale/app.usercenter/get_my_cookbook'); +Route::any('/testedition/kitchenscale/get_my_cookbook', 'app/kitchenscale/testapp.usercenter/get_my_cookbook'); + + +// 测试用内容################################################################ +Route::any('/kitchenscale/get_default_configuration', 'app/kitchenscale/app.product/get_default_configuration'); +// Route::any('/kitchenscale/getRelatedConfigurations', 'app/kitchenscale/app.product/getRelatedConfigurations'); +// Route::any('/kitchenscale/getOptionConfigurations', 'app/kitchenscale/app.product/getOptionConfigurations'); diff --git a/public/kitchenscale_all/upload.html b/public/kitchenscale_all/upload.html index fc057ef..f6147b1 100644 --- a/public/kitchenscale_all/upload.html +++ b/public/kitchenscale_all/upload.html @@ -100,7 +100,7 @@ + + +
+
+ + +
+
+ + +
+
+ + + + \ No newline at end of file