From 8d3b39a59c00c0db4139b8c8f78448f09a12b93e Mon Sep 17 00:00:00 2001 From: tiansf Date: Wed, 22 Jan 2025 12:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E7=BA=BF=E4=B8=8A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KitchenScale/controller/app/Base.php | 124 +++ .../KitchenScale/controller/app/Cookbook.php | 787 ++++++++++++++++++ .../KitchenScale/controller/app/Countfood.php | 67 ++ .../KitchenScale/controller/app/Index.php | 102 ++- application/admin/controller/Device.php | 38 +- application/app/controller/Skip.php | 6 +- application/code/controller/Qrcode.php | 19 +- application/code/view/ordinary/card_add.html | 218 ----- application/code/view/ordinary/card_edit.html | 232 ------ application/code/view/ordinary/index.html | 360 -------- .../code/view/qrcode/bluetooth_code.html | 234 ++++++ .../code/view/qrcode/ordinary_code.html | 182 ++++ application/config.php | 1 + application/route.php | 39 +- public/kitchenscale_all/ceshi.html | 256 ++++++ public/kitchenscale_all/upload.html | 427 ++++++++++ 16 files changed, 2234 insertions(+), 858 deletions(-) create mode 100644 application/KitchenScale/controller/app/Cookbook.php create mode 100644 application/KitchenScale/controller/app/Countfood.php delete mode 100644 application/code/view/ordinary/card_add.html delete mode 100644 application/code/view/ordinary/card_edit.html delete mode 100644 application/code/view/ordinary/index.html create mode 100644 application/code/view/qrcode/bluetooth_code.html create mode 100644 application/code/view/qrcode/ordinary_code.html create mode 100644 public/kitchenscale_all/ceshi.html create mode 100644 public/kitchenscale_all/upload.html diff --git a/application/KitchenScale/controller/app/Base.php b/application/KitchenScale/controller/app/Base.php index 85f7f60..2d374fc 100644 --- a/application/KitchenScale/controller/app/Base.php +++ b/application/KitchenScale/controller/app/Base.php @@ -13,6 +13,7 @@ class Base extends Controller{ protected $base_use_db_name = [ '1'=>'test_app_data_log', ]; + protected $file_size = 5*1024*1024; protected $return_data_all = [ '10001'=>'关键参数缺失', '10002'=>'操作失败', @@ -122,6 +123,7 @@ class Base extends Controller{ } }else if($type == 'intnum'){ $pattern = '/^\d+$/'; + // dump($data); if (preg_match($pattern, $data)) { return true; // 匹配成功,返回 true } else { @@ -145,6 +147,118 @@ class Base extends Controller{ } } + ####################################################图片选择上传start############################################################## + public function pic_chose_list($page = 1) { + $data = input(); + if(!array_key_exists('token',$data)){ + return $this->msg(10001,'token is miss'); + } + if(array_key_exists('page',$data)){ + $page = $data['page']; + } + $parameter_data = [ + 'user_token'=>$data['token'], + 'is_del'=>0 + ]; + + $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; + $return_result['page_now'] = $page; + $return_result['result'] = $result; + return $this->msg($return_result); + } + public function pic_upload_action(){ + $insert_data = []; + $temporary_data = []; + $miss_data = 0; + $cfc = Db::connect('cfc_db'); + $files = request()->file('images'); + $token = request()->param('token'); + if(!$token){ + return $this->msg(10001,'token is miss'); + } + if($files){ + foreach($files as $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 = time().$this->generateRandomString(). '.jpg'; + } else { + $new_filename = time().$this->generateRandomString(). '.' . $extension; + } + $info = $file->validate(['size'=>$this->file_size,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'kitchenscale_all' . DS . 'user_upload',$new_filename); + if($info){ + $temporary_data = [ + '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); + if($pic_id){ + $temporary_data['id'] = $pic_id; + unset($temporary_data['create_time']); + unset($temporary_data['user_token']); + array_push($insert_data,$temporary_data); + }else{ + $miss_data = $miss_data+1; + } + }else{ + $miss_data = $miss_data+1; + } + } + + return $this->msg(['error_data'=>$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,'图片上传失败'); + } + } + } public function msg($data,$str='',$result = []){ @@ -162,6 +276,16 @@ class Base extends Controller{ } } + public function generateRandomString($length = 10) { + $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + public function ceshi(){ echo 'hello'; } diff --git a/application/KitchenScale/controller/app/Cookbook.php b/application/KitchenScale/controller/app/Cookbook.php new file mode 100644 index 0000000..a5a27a4 --- /dev/null +++ b/application/KitchenScale/controller/app/Cookbook.php @@ -0,0 +1,787 @@ +'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',//关注列表 + 'collectlist'=>'app_user_collect_list',//收藏列表 + ]; + + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + + // 添加菜谱 + public function add_cookbook(){ + // 尝试捕获异常 + // 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('cover', $data)){ + return $this->msg(10001,'cover is miss'); + } + if(!array_key_exists('description', $data)){ + return $this->msg(10001,'description is miss'); + } + if(!array_key_exists('cook_label', $data)){ + return $this->msg(10001,'cook_label is miss'); + } + if(!array_key_exists('food_list', $data)){ + $data['food_list'] = []; + } + if(!array_key_exists('step_list', $data)){ + $data['step_list'] = []; + } + + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + if(!$this->verify_data_is_ok($data['cover'],'intnum')){ + return $this->msg(10005,'cover type is error'); + } + if(!$this->verify_data_is_ok($data['description'],'str')){ + return $this->msg(10005,'description type is error'); + } + if (!is_array($data['food_list'])) { + return $this->msg(10005,'food_list type is error'); + } + if (!is_array($data['step_list'])) { + return $this->msg(10005,'step_list type is error'); + } + + + $return_data = $this->add_cookbook_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + // 根据菜谱标签查询列表(首页用) + public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>'早餐','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('cook_label', $data)){ + return $this->msg(10001,'cook_label 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['cook_label'],'str')){ + return $this->msg(10005,'cook_label type is error'); + } + if(!$this->verify_data_is_ok($data['page'],'intnum')){ + return $this->msg(10005,'page type is error'); + } + $return_data = $this->find_by_cook_label_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + + // 根据食材详细查找列表 + public function find_by_food($data=['token'=>'caadd1be045a65f3','food_name'=>'猪肉','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('food_name', $data)){ + return $this->msg(10001,'food_name 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['food_name'],'str')){ + return $this->msg(10005,'food_name type is error'); + } + if(!$this->verify_data_is_ok($data['page'],'intnum')){ + return $this->msg(10005,'page type is error'); + } + $return_data = $this->find_by_food_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + + // 查询食谱的详情 + public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'12']){ + // 尝试捕获异常 + // 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('cookbook_id', $data)){ + return $this->msg(10001,'cookbook_id 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['cookbook_id'],'intnum')){ + return $this->msg(10005,'cookbook_id type is error'); + } + $return_data = $this->cookbook_details_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + + // 关注菜谱 + public function cookbook_follow($data=['token'=>'caadd1be045a65f3','cookbook_id'=>'12']){ + // 尝试捕获异常 + // 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('cookbook_id', $data)){ + return $this->msg(10001,'cookbook_id 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['cookbook_id'],'intnum')){ + return $this->msg(10005,'cookbook_id type is error'); + } + $return_data = $this->cookbook_follow_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + // 收藏菜谱 + public function cookbook_like($data=['token'=>'caadd1be045a65f3','cookbook_id'=>'12']){ + // 尝试捕获异常 + // 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('cookbook_id', $data)){ + return $this->msg(10001,'cookbook_id 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['cookbook_id'],'intnum')){ + return $this->msg(10005,'cookbook_id type is error'); + } + $return_data = $this->cookbook_like_action($data); + return $return_data; + // } 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' => '系统错误']); + // } + } + + // 计算根据菜谱称重 + public function cookbook_count_weight($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'12','food_weight'=>[]]){ + // 尝试捕获异常 + // 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('cookbook_id', $data)){ + return $this->msg(10001,'cookbook_id is miss'); + } + if(!array_key_exists('food_weight', $data)){ + return $this->msg(10001,'food_weight 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['cookbook_id'],'intnum')){ + return $this->msg(10005,'cook_label type is error'); + } + + $return_data = $this->cookbook_count_weight_action($data); + return $return_data; + // } 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 add_cookbook_action($data){ + if(count($data['food_list']) < 1){ + return $this->msg(10005,'至少添加一个食物'); + } + if(count($data['step_list']) < 1){ + return $this->msg(10005,'至少添加一个步骤'); + } + $food_type = []; + // 检验一下food_list是否合规(食材列表) + foreach ($data['food_list'] as $key => $value) { + if (!array_key_exists('name', $value) || !array_key_exists('weight', $value)) { + return $this->msg(10005,'食材缺少名称或者重量'); + } + if(!$this->verify_data_is_ok($value['name'],'str')){ + return $this->msg(10005,'食材名称格式错误,需字符串'); + } + if(!$this->verify_data_is_ok($value['weight'],'intnum')){ + return $this->msg(10005,'食材重量格式错误,需整数数字'); + } + array_push($food_type, $value['name']); + } + // 检验一下step_list是否合规(步骤列表) + foreach ($data['step_list'] as $key => $value) { + // if (!array_key_exists('description', $value) || !array_key_exists('foot_list', $value) || !array_key_exists('pic_list', $value)) { + if (!array_key_exists('description', $value) || !array_key_exists('pic_list', $value)) { + return $this->msg(10005,'步骤缺少描述或者图片'); + } + 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错误,需整数数字'); + } + } + // foreach ($value['foot_list'] as $k => $v) { + // if (!array_key_exists('name', $v) || !array_key_exists('weight', $v)) { + // return $this->msg(10005,'步骤食材缺少名称或者重量'); + // } + // if(!$this->verify_data_is_ok($v['name'],'str')){ + // return $this->msg(10005,'步骤食材名称格式错误,需字符串'); + // } + // if(!$this->verify_data_is_ok($v['weight'],'intnum')){ + // return $this->msg(10005,'步骤食材重量格式错误,需整数数字'); + // } + // } + } + + $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 + foreach ($data['food_list'] as $key => $value) { + $data['food_list'][$key]['kcal'] = '0kcal'; + } + // foreach ($data['step_list'] as $key => $value) { + // foreach ($value['foot_list'] as $k => $v) { + // $data['step_list'][$key]['foot_list'][$k]['kcal'] = '0kcal'; + // } + // } + // 处理食材卡路里end + + $insert_data = [ + 'title'=>$data['title'], + 'cover'=>$data['cover'], + 'create_user_token'=>$user_data['token'], + 'create_user_head_pic'=>$user_data['head_pic'], + 'create_user_nickname'=>$user_data['nickname'], + 'describe_data'=>$data['description'], + 'food_data'=>json_encode($data['food_list']), + 'step_data'=>json_encode($data['step_list']), + 'food_type'=>implode(',', $food_type), + 'cook_label'=>$data['cook_label'], + 'create_time'=>date('Y-m-d H:i:s') + ]; + $cook_book_result = $cfc->table($this->kitchenscale_db_msg['cookbook'])->insert($insert_data); + + if($cook_book_result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } + + public function find_by_cook_label_action($data){ + $page_now = $data['page']; + $page_total = $data['page']; + $page_num = 20; + $cook_label = $data['cook_label']; + + $cfc = Db::connect('cfc_db'); + $content_num = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->where(['cook_label'=>$cook_label]) + ->count(); + $page_total = ceil($content_num/$page_num); + $content_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->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') + ->page("$page_now,$page_num") + ->select(); + + // 处理本人是否关注 start + $like_it_arr = []; + foreach ($content_list as $key => $value) { + array_push($like_it_arr, $value['id']); + } + + $like_it_data = $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->where("token = '".$data['token']."' AND cookbook_id in (".implode(',',$like_it_arr).") AND is_del = 0") + ->select(); + $like_it_arr2 = []; + foreach ($like_it_data as $key => $value) { + array_push($like_it_arr2, $value['cookbook_id']); + } + + foreach ($content_list as $key => $value) { + if(in_array($value['id'],$like_it_arr2)){ + $content_list[$key]['is_like'] = 1; + }else{ + $content_list[$key]['is_like'] = 0; + } + } + // 处理本人是否关注 end + for ($i=0; $i < count($content_list); $i++) { + if($content_list[$i]['cover'] == null){ + $content_list[$i]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; + } + } + + return $this->msg([ + 'page_now'=>$page_now, + 'page_total'=>$page_total, + 'content_list'=>$content_list + ]); + } + + public function find_by_food_action($data){ + $page_now = $data['page']; + $page_total = $data['page']; + $page_num = 20; + $food_name = $data['food_name']; + + $cfc = Db::connect('cfc_db'); + $content_num = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->where("food_type like '%$food_name%'") + ->count(); + $page_total = ceil($content_num/$page_num); + $content_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->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') + ->page("$page_now,$page_num") + ->select(); + + // 处理本人是否关注 start + $like_it_arr = []; + foreach ($content_list as $key => $value) { + array_push($like_it_arr, $value['id']); + } + + $like_it_data = $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->where("token = '".$data['token']."' AND cookbook_id in (".implode(',',$like_it_arr).") AND is_del = 0") + ->select(); + $like_it_arr2 = []; + foreach ($like_it_data as $key => $value) { + array_push($like_it_arr2, $value['cookbook_id']); + } + + foreach ($content_list as $key => $value) { + if(in_array($value['id'],$like_it_arr2)){ + $content_list[$key]['is_like'] = 1; + }else{ + $content_list[$key]['is_like'] = 0; + } + } + // 处理本人是否关注 end + + for ($i=0; $i < count($content_list); $i++) { + if($content_list[$i]['cover'] == null){ + $content_list[$i]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; + } + } + + return $this->msg([ + 'page_now'=>$page_now, + 'page_total'=>$page_total, + 'content_list'=>$content_list + ]); + } + + public function cookbook_details_action($data){ + $cfc = Db::connect('cfc_db'); + + $img_arr = []; + + // 查询菜谱详情 + $cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->find(); + if(!$cookbook_data){ + return $this->msg(10002,'菜谱不存在'); + } + $cookbook_data['food_data'] = json_decode($cookbook_data['food_data'],true); + $cookbook_data['step_data'] = json_decode($cookbook_data['step_data'],true); + $cookbook_data_step_data_count = count($cookbook_data['step_data']); + + // 设置需要的图片id + array_push($img_arr, $cookbook_data['cover']); + foreach ($cookbook_data['step_data'] as $key => $value) { + if(count($value['pic_list']) > 0){ + foreach ($value['pic_list'] as $k => $v) { + if(!in_array($v, $img_arr)){ + array_push($img_arr, $v); + } + } + } + } + $img_arr = implode(',',$img_arr); + + // 查找需要的图片 + $img_arr_data = $cfc->table($this->kitchenscale_db_msg['uploadimg'])->where("id in ($img_arr) AND is_del = 0")->field('id,pic_name,pic_url')->select(); + $cookbook_img_data = []; + // 处理菜谱图片 + foreach ($img_arr_data as $key => $value) { + $cookbook_img_data[$value['id']] = $value['pic_url']; + } + + // 设置菜谱图片 + foreach ($cookbook_data['step_data'] as $key => $value) { + $cookbook_data['step_data'][$key]['pic_list_ls'] = []; + foreach ($value['pic_list'] as $k => $v) { + if(array_key_exists($v, $cookbook_img_data)){ + array_push($cookbook_data['step_data'][$key]['pic_list_ls'],$cookbook_img_data[$v]); + }else{ + array_push($cookbook_data['step_data'][$key]['pic_list_ls'],'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'); + } + } + $cookbook_data['step_data'][$key]['pic_list'] = $cookbook_data['step_data'][$key]['pic_list_ls']; + unset($cookbook_data['step_data'][$key]['pic_list_ls']); + $cookbook_data['step_data'][$key]['step_num'] = "步骤".($key+1).'/'.$cookbook_data_step_data_count; + } + if(array_key_exists($cookbook_data['cover'], $cookbook_img_data)){ + $cookbook_data['cover'] = $cookbook_img_data[$cookbook_data['cover']]; + }else{ + $cookbook_data['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; + } + + + // 处理关注跟收藏信息 + if($data['token'] == $cookbook_data['create_user_token']){ + // 如果查询跟作者一致 + $cookbook_data['follow_status'] = 3; + $cookbook_data['collect_status'] = 3; + }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'] = 1; + }else{ + // 如果有结果被删过 + $cookbook_data['follow_status'] = 0; + } + }else{ + // 如果没结果 + $cookbook_data['follow_status'] = 0; + } + + $collect_data = $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->where([ + 'token'=>$data['token'], + 'cookbook_id'=>$data['cookbook_id'], + ]) + ->find(); + if($collect_data){ + if($collect_data['is_del'] == 0){ + // 如果有结果并且没被删过 + $cookbook_data['collect_status'] = 1; + }else{ + // 如果有结果被删过 + $cookbook_data['collect_status'] = 0; + } + }else{ + // 如果没结果 + $cookbook_data['collect_status'] = 0; + } + } + + // 添加阅读量 + $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']); + unset($cookbook_data['food_type']); + unset($cookbook_data['ROW_NUMBER']); + + + + return $this->msg($cookbook_data); + // dump($cookbook_data); + + } + + + public function cookbook_follow_action($data){ + // dump($data); + $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(); + if(!$cookbook_data){ + return $this->msg(10002,'未找到菜谱'); + } + if($data['token'] == $cookbook_data['create_user_token']){ + // 如果查询跟作者一致 + return $this->msg(10002,'不能关注自己'); + } + $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(); + $follow_data_state = 0; + if($follow_data){ + if($follow_data['is_del'] == 0){ + // 如果当前是关注状态 + $follow_data_state = 1; + }else{ + $follow_data_state = 0; + } + + $follow_result= $cfc->table($this->kitchenscale_db_msg['followlist']) + ->where([ + 'follow_user_token'=>$data['token'], + 'being_follow_user_token'=>$cookbook_data['create_user_token'], + ]) + ->update(['is_del'=>$follow_data_state]); + }else{ + $follow_result = $cfc->table($this->kitchenscale_db_msg['followlist']) + ->insert([ + 'follow_user_token'=>$data['token'], + 'being_follow_user_token'=>$cookbook_data['create_user_token'], + 'create_time'=>date('Y-m-d H:i:s') + ]); + } + + if($follow_result){ + return $this->msg([]); + }else{ + return $this->msg(10001,'操作失败'); + } + } + + public function cookbook_like_action($data){ + $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(); + if(!$cookbook_data){ + return $this->msg(10002,'未找到菜谱'); + } + if($data['token'] == $cookbook_data['create_user_token']){ + // 如果查询跟作者一致 + return $this->msg(10002,'不能收藏自己'); + } + $like_data = $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->where([ + 'token'=>$data['token'], + 'cookbook_id'=>$data['cookbook_id'], + ]) + ->find(); + + $like_data_state = 0; + if($like_data){ + if($like_data['is_del'] == 0){ + // 如果当前是关注状态 + $like_data_state = 1; + }else{ + $like_data_state = 0; + } + + // 启动事务 + Db::startTrans(); + try{ + $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->where([ + 'token'=>$data['token'], + 'cookbook_id'=>$data['cookbook_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'); + }else{ + $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->setDec('like_it'); + } + // 提交事务 + Db::commit(); + return $this->msg([]); + } catch (\Exception $e) { + // 回滚事务 + Db::rollback(); + return $this->msg(10001,'操作失败'); + } + }else{ + // 启动事务 + Db::startTrans(); + try{ + $cfc->table($this->kitchenscale_db_msg['collectlist']) + ->insert([ + 'token'=>$data['token'], + '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'); + // 提交事务 + Db::commit(); + return $this->msg([]); + } catch (\Exception $e) { + // 回滚事务 + Db::rollback(); + return $this->msg(10001,'操作失败'); + } + } + } + + public function cookbook_count_weight_action($data){ + $data['food_weight'] = [ + [ + 'food_name'=>'牛肉', + 'food_weight'=>'100', + 'food_kcal'=>'190', + ], + [ + 'food_name'=>'狗肉', + 'food_weight'=>'100', + 'food_kcal'=>'116', + ], + ]; + foreach ($variable as $key => $value) { + if(!array_key_exists('food_name', $data['food_weight']) || !array_key_exists('food_weight', $data['food_weight']) || !array_key_exists('food_kcal', $data['food_weight'])){ + return $this->msg(10001,'食材称重参数错误'); + } + } + } + + + + +} \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Countfood.php b/application/KitchenScale/controller/app/Countfood.php new file mode 100644 index 0000000..4aff619 --- /dev/null +++ b/application/KitchenScale/controller/app/Countfood.php @@ -0,0 +1,67 @@ +'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/Index.php b/application/KitchenScale/controller/app/Index.php index ebad67d..e6e9a9c 100644 --- a/application/KitchenScale/controller/app/Index.php +++ b/application/KitchenScale/controller/app/Index.php @@ -10,12 +10,19 @@ class Index extends Base{ // protected $token_time = 2592000;//30天的秒数 protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png'; protected $reedaw_db_msg = [ - 'zhanghao'=>'test_app_account_number',//账号表 - 'juese'=>'test_app_user_data',//角色表 - 'banner'=>'admin_notice_banner',//角色表 - 'read_log'=>'admin_editor_text_like_up_log',//角色表 - - + 'zhanghao'=>'app_account_number',//账号表 + 'juese'=>'app_user_data',//角色表 + 'banner'=>'admin_notice_banner',//banner + 'read_log'=>'admin_editor_text_like_up_log',//阅读记录 + 'cookbook'=>'app_user_cookbook',//菜谱表 + 'upload_img'=>'app_user_upload_img',//素材表 + ]; + protected $kitchenscale_db_msg = [ + 'cookbook'=>'app_user_cookbook',//菜谱表 + 'uploadimg'=>'app_user_upload_img',//素材表 + 'foodlist1'=>'app_food_type_one',//素材表 + 'foodlist2'=>'app_food_type_two',//素材表 + 'foodlist3'=>'app_food_type_three',//素材表 ]; @@ -27,12 +34,12 @@ class Index extends Base{ ################################################################接口################################################################ ################################################################接口################################################################ - // 获取默认配置信息 + // 获取默认配置信息(包含:食材的分类列表) public function get_default_config(){ // try { - $return_data = $this->get_default_config_action($data); + $return_data = $this->get_default_config_action(); // 成功 - $this->record_api_log($data, null, $return_data); + // $this->record_api_log($data, null, $return_data); return $return_data; // } catch (\Exception $e) { // // 捕获异常 @@ -51,7 +58,7 @@ class Index extends Base{ } // 获取首页信息 - public function get_homepage_information($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){ + public function get_homepage_information($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){ // try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -81,10 +88,41 @@ class Index extends Base{ // return $this->msg(99999); // } } + #######################################################################action####################################################################### public function get_default_config_action(){ - + $return_data = [ + 'food_list'=>[], + ]; + $cfc = Db::connect('cfc_db'); + // 获取食材分类列表start + $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); + $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select(); + $foodlist3 = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("is_del = 0")->field('id,name,two_id,kcal')->select(); + // dump($foodlist3); + foreach ($foodlist1 as $key => $value) { + unset($foodlist1[$key]['ROW_NUMBER']); + $foodlist1[$key]['list'] = []; + foreach ($foodlist2 as $k => $v) { + $foodlist2[$k]['list'] = []; + foreach ($foodlist3 as $k3 => $v3) { + if($v3['two_id'] == $v['id']){ + unset($foodlist3[$k3]['ROW_NUMBER']); + array_push($foodlist2[$k]['list'],$foodlist3[$k3]); + // unset($foodlist3[$k3]); + } + } + if($v['one_id'] == $value['id']){ + unset($foodlist2[$k]['ROW_NUMBER']); + array_push($foodlist1[$key]['list'],$foodlist2[$k]); + // unset($foodlist2[$k]); + } + } + } + $return_data['food_list'] = $foodlist1; + // 获取食材分类列表end + return $this->msg($return_data); } public function get_homepage_information_action($data){ @@ -92,19 +130,22 @@ class Index extends Base{ $return_data = [ 'account'=>[], 'banner'=>[], - 'content'=>[], + 'content'=>[ + 'label_list'=>[], + 'content_list'=>[], + ], ]; - $cfc = Db::connect('cfc_db'); + // 获取账号下信息以及用户信息 $user_account = Db::table($this->reedaw_db_msg['zhanghao']) ->alias('zhanghao') ->join($this->reedaw_db_msg['juese'].' juese','zhanghao.id = juese.aan_id','LEFT') ->where(["zhanghao.token"=>$data['token'],'juese.is_del'=>0]) - ->field('juese.id as aud_id,juese.nickname,juese.birthday,juese.gender,juese.last_update_time,juese.grade,juese.head_pic,juese.weight,juese.height,juese.identity_name,juese.address,juese.identity_id,juese.weight') + // ->field('juese.id as aud_id,juese.nickname,juese.birthday,juese.gender,juese.last_update_time,juese.grade,juese.head_pic,juese.weight,juese.height,juese.identity_name,juese.address,juese.identity_id,juese.weight') + ->field('juese.id as aud_id,juese.nickname,juese.birthday,juese.gender,juese.grade,juese.head_pic') ->select(); $return_data['account'] = $user_account; - // 获取banner $banner_list = Db::table($this->reedaw_db_msg['banner']) ->where("is_del = 0 AND scene_data IN (21)") @@ -138,16 +179,31 @@ class Index extends Base{ $return_data['banner'] = $banner_list; // 获取菜谱列表 - - dump($return_data); - die; - - if($user){ - return $this->msg(['token'=>$user['token']]); - }else{ - return $this->msg(10004); + $label_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])->group('cook_label')->field('cook_label,count(*) as num')->select(); + if(count($label_list) <= 0){ + $return_data['content']['label_list'] = []; + $return_data['content']['content_list'] = []; + return $this->msg($return_data); } + $content_list = $cfc->table($this->kitchenscale_db_msg['cookbook']) + ->alias('zhanghao') + ->join($this->kitchenscale_db_msg['uploadimg'].' uploadimg','zhanghao.cover = uploadimg.id','LEFT') + ->where(['zhanghao.cook_label'=>$label_list[0]['cook_label']]) + ->field('zhanghao.title,uploadimg.pic_url as cover,zhanghao.create_user_head_pic,zhanghao.create_user_nickname,zhanghao.like_it') + ->page("1,20") + ->select(); + + $return_data['content']['label_list'] = $label_list; + for ($i=0; $i < count($content_list); $i++) { + if($content_list[$i]['cover'] == null){ + $content_list[$i]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg'; + } + } + $return_data['content']['content_list'] = $content_list; + + return $this->msg($return_data); + } } \ No newline at end of file diff --git a/application/admin/controller/Device.php b/application/admin/controller/Device.php index 3e1d349..fef5cb3 100644 --- a/application/admin/controller/Device.php +++ b/application/admin/controller/Device.php @@ -212,9 +212,22 @@ class Device extends Base{ public function device_request_api(){ - $data = input(); + // $data = input(); + $rawData = file_get_contents('php://input'); // 获取原始请求体 - $result = Db::table('app_device_log_test')->insert(['content'=>json_encode($data),'create_time'=>date('Y-m-d H:i:s)')]); + // $params = explode(',', trim($rawData, '{}')); // 假设参数是用逗号分隔的,并且被大括号包裹 + + // // 现在$params是一个数组,包含了['03', '180.0', '65.1'] + // $param1 = $params[0]; // 获取第一个参数 + // $param2 = $params[1]; // 获取第二个参数,注意转换为浮点数或保持字符串形式 + // $param3 = $params[2]; // 获取第三个参数 + // dump($data); + // dump(json_encode($data)); + // dump($rawData); + $content = json_encode($rawData); + // dump($content); + // die; + $result = Db::table('app_device_log_test')->insert(['content'=>$content,'create_time'=>date('Y-m-d H:i:s')]); if($result){ return $this->msg(0,'success'); @@ -235,16 +248,17 @@ class Device extends Base{ $neirong = ''; foreach ($result as $key => $value) { - $temporary_arr1 = json_decode($value['content'],true); - if(count($temporary_arr1) == 0){ - $temporary_arr2 = '请求参数为:
'."本次未发送请求参数
"; - }else{ - $temporary_arr2 = '请求参数为:
'; - } - foreach ($temporary_arr1 as $k => $v) { - $temporary_arr2 = $temporary_arr2.$k."(参数名):".$v."(参数值)
"; - } - $neirong = $neirong.$temporary_arr2.'请求时间为:'.$value['create_time']."


"; + $neirong = $neirong.'第'.($key+1).'次请求
本次请求参数为:'.$value['content'].'
'.'请求时间为:'.$value['create_time']."


"; + // $temporary_arr1 = json_decode($value['content'],true); + // if(count($temporary_arr1) == 0){ + // $temporary_arr2 = '请求参数为:
'."本次未发送请求参数
"; + // }else{ + // $temporary_arr2 = '请求参数为:
'; + // } + // foreach ($temporary_arr1 as $k => $v) { + // $temporary_arr2 = $temporary_arr2.$k."(参数名):".$v."(参数值)
"; + // } + // $neirong = $neirong.$temporary_arr2.'请求时间为:'.$value['create_time']."


"; } diff --git a/application/app/controller/Skip.php b/application/app/controller/Skip.php index b5985b7..0dbc8fe 100644 --- a/application/app/controller/Skip.php +++ b/application/app/controller/Skip.php @@ -47,7 +47,11 @@ class Skip extends Base{ if(!$this->verify_data_is_ok($data['type'],'str')){ return $this->msg(10005); } - if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){ + // {"aud_id":"331","num":"100","r_time":"2025-01-15","time_m":"","time_s":"","type":"free","token":"2581d40766e7cfd25ca140f3514072bd","aan_id":"254"} + // if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){ + // $return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); + // } + if(!$this->verify_data_is_ok($data['num'],'intnum') || !$this->verify_data_is_ok($data['time_m'],'intnum') || !$this->verify_data_is_ok($data['time_s'],'intnum')){ $return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); } if($data['num'] <= 0){ diff --git a/application/code/controller/Qrcode.php b/application/code/controller/Qrcode.php index 68e8352..33d2bca 100644 --- a/application/code/controller/Qrcode.php +++ b/application/code/controller/Qrcode.php @@ -11,27 +11,26 @@ class Qrcode extends Base{ public function ordinary_code(){ // $num = Db::table('app_version_log')->order('id desc')->find(); - echo '你好,这里仅仅是个展示页面-配合小白快乐成长&宠物小白使用'; + // echo '你好,这里仅仅是个展示页面-配合小白快乐成长&宠物小白使用'; // echo '
点击下载'; // $url = Db::table('app_version_log')->order('id desc')->find(); // $this->assign([ // 'url' => $url['download_url'], // ]); - // return $this->fetch(); + return $this->fetch(); } public function bluetooth_code(){ - // $num = Db::table('app_version_log')->order('id desc')->find(); - echo '你好,这里仅仅是个展示页面-配合reedaw&宠物小白使用'; - // echo '
点击下载'; - // $url = Db::table('app_version_log')->order('id desc')->find(); - // $this->assign([ + $url = Db::table('app_version_log')->order('id desc')->find(); + + + $this->assign([ - // 'url' => $url['download_url'], - // ]); - // return $this->fetch(); + 'url' => $url['download_url'], + ]); + return $this->fetch(); } } \ No newline at end of file diff --git a/application/code/view/ordinary/card_add.html b/application/code/view/ordinary/card_add.html deleted file mode 100644 index 7de2f3d..0000000 --- a/application/code/view/ordinary/card_add.html +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - app版本管理 - - - - - - - - - - - - -
-
-
-
- - -
- - -
- -
-
- -
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/application/code/view/ordinary/card_edit.html b/application/code/view/ordinary/card_edit.html deleted file mode 100644 index d448a5c..0000000 --- a/application/code/view/ordinary/card_edit.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - app版本管理 - - - - - - - - - - - - -
-
-
-
- - -
- - -
- -
-
- -
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- - - -
-
-
-
- - - - - - \ No newline at end of file diff --git a/application/code/view/ordinary/index.html b/application/code/view/ordinary/index.html deleted file mode 100644 index a50c68b..0000000 --- a/application/code/view/ordinary/index.html +++ /dev/null @@ -1,360 +0,0 @@ - - - - - 所有卡片管理 - - - - - - - - - - -
- - 首页 - 演示 - - 导航元素 - - - -
-
-
-
-
- -
- - - -
-
- - - - - - - - - - - - - - - {volist name="result" id="vo"} - - - - - - - - - - - {/volist} - -
ID卡片名称卡片图标卡片描述创建时间状态操作
{$vo.id}{$vo.name}{$vo.content}{$vo.create_time} - {if condition="$vo.is_del == 1"} - 已停用 - {else /} - 已启用 - {/if} - - - -
-
-
-
-
-
- -
-
-
-
- - - \ No newline at end of file diff --git a/application/code/view/qrcode/bluetooth_code.html b/application/code/view/qrcode/bluetooth_code.html new file mode 100644 index 0000000..ebd4cd8 --- /dev/null +++ b/application/code/view/qrcode/bluetooth_code.html @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + 跳转页 + + + + + +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/application/code/view/qrcode/ordinary_code.html b/application/code/view/qrcode/ordinary_code.html new file mode 100644 index 0000000..042b4e0 --- /dev/null +++ b/application/code/view/qrcode/ordinary_code.html @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + 跳转页 + + + + + +
+
+
+
+
+
+
+
+ + + + + diff --git a/application/config.php b/application/config.php index 64121e7..62019bb 100644 --- a/application/config.php +++ b/application/config.php @@ -248,6 +248,7 @@ return [ 'type' => 'sqlsrv', // 服务器地址 'hostname' => '121.36.67.254', + // 'hostname' => '127.0.0.1', // 数据库名 'database' => 'kitchen_scale', // 用户名 diff --git a/application/route.php b/application/route.php index 3339923..0e73196 100644 --- a/application/route.php +++ b/application/route.php @@ -395,10 +395,45 @@ Route::any('/open_wechat_content', 'app/Msginformation/open_wechat_content'); ################################################################下面是厨房秤################################################################ ########################################################################################################################################### +// 公共内容################################################################ +// 获取用户上传图片列表 +Route::any('/kitchenscale/pic_chose_list', 'app/kitchenscale/app.base/pic_chose_list'); +Route::any('/testedition/kitchenscale/pic_chose_list', 'app/kitchenscale/testapp.base/pic_chose_list'); +// 用户多图上传接口 +Route::any('/kitchenscale/pic_upload_action', 'app/kitchenscale/app.base/pic_upload_action'); +Route::any('/testedition/kitchenscale/pic_upload_action', 'app/kitchenscale/testapp.base/pic_upload_action'); + + + +// 首页内容################################################################ +// 获取配置类信息 +Route::any('/kitchenscale/get_default_config', 'app/kitchenscale/app.index/get_default_config'); +Route::any('/testedition/kitchenscale/get_default_config', 'app/kitchenscale/testapp.index/get_default_config'); +// 获取首页页面展示数据 +Route::any('/kitchenscale/get_homepage_information', 'app/kitchenscale/app.index/get_homepage_information'); +Route::any('/testedition/kitchenscale/get_homepage_information', 'app/kitchenscale/testapp.index/get_homepage_information'); + +// 菜谱内容################################################################ +// 添加菜谱 +Route::any('/kitchenscale/add_cookbook', 'app/kitchenscale/app.cookbook/add_cookbook'); +Route::any('/testedition/kitchenscale/add_cookbook', 'app/kitchenscale/testapp.cookbook/add_cookbook'); +// 根据菜谱标签查询列表(首页用) +Route::any('/kitchenscale/find_by_cook_label', 'app/kitchenscale/app.cookbook/find_by_cook_label'); +Route::any('/testedition/kitchenscale/find_by_cook_label', 'app/kitchenscale/testapp.cookbook/find_by_cook_label'); +// 根据食材详细查找列表 +Route::any('/kitchenscale/find_by_food', 'app/kitchenscale/app.cookbook/find_by_food'); +Route::any('/testedition/kitchenscale/find_by_food', 'app/kitchenscale/testapp.cookbook/find_by_food'); +// 查询食谱的详情 +Route::any('/kitchenscale/cookbook_details', 'app/kitchenscale/app.cookbook/cookbook_details'); +Route::any('/testedition/kitchenscale/cookbook_details', 'app/kitchenscale/testapp.cookbook/cookbook_details'); +// 关注菜谱 +Route::any('/kitchenscale/cookbook_follow', 'app/kitchenscale/app.cookbook/cookbook_follow'); +Route::any('/testedition/kitchenscale/cookbook_follow', 'app/kitchenscale/testapp.cookbook/cookbook_follow'); +// 收藏菜谱 +Route::any('/kitchenscale/cookbook_like', 'app/kitchenscale/app.cookbook/cookbook_like'); +Route::any('/testedition/kitchenscale/cookbook_like', 'app/kitchenscale/testapp.cookbook/cookbook_like'); -Route::any('/get_homepage_information', 'app/KitchenScale/app.index/get_homepage_information'); -Route::any('/testedition/get_homepage_information', 'testapp/KitchenScale/app.get_homepage_information'); diff --git a/public/kitchenscale_all/ceshi.html b/public/kitchenscale_all/ceshi.html new file mode 100644 index 0000000..721b45f --- /dev/null +++ b/public/kitchenscale_all/ceshi.html @@ -0,0 +1,256 @@ + + + + + + 测试菜谱提交 + + + + +

菜谱信息

+
+ + +
+ + +
+ + +
+
+

添加食材

+
+
+
+
+
清空
+
添加食材
+
+
+

编辑步骤

+
+
+
+ +
+
+
保存
+ + + \ No newline at end of file diff --git a/public/kitchenscale_all/upload.html b/public/kitchenscale_all/upload.html new file mode 100644 index 0000000..0d909bb --- /dev/null +++ b/public/kitchenscale_all/upload.html @@ -0,0 +1,427 @@ + + + + + + 测试菜谱提交 + + + + +

菜谱信息~

+
+ + +
+
+
+
+ + +
+
+ + +
+
+

添加食材

+
+
+
+
+
清空
+
添加食材
+
+
+

编辑步骤

+
+
+
+ +
+
+
保存
+ + + +
+
+ +
+ + + + + \ No newline at end of file