测试终版

This commit is contained in:
tiansf 2025-04-03 18:19:04 +08:00
parent 96a7b42933
commit c9296ecb2a
36 changed files with 6903 additions and 423 deletions

View File

@ -247,6 +247,45 @@ class Base extends Controller{
$return_result['result'] = $result;
return $this->msg($return_result);
}
public function pic_upload_one_action(){
$temporary_data = [];
$cfc = Db::connect('cfc_db');
$file = request()->file('image');
$token = request()->param('token');
if(!$token){
return $this->msg(10001,'token is miss');
}
if($file){
$name = $file->getInfo()['name'];
// 使用 pathinfo() 函数获取文件名的扩展名
$pathinfo = pathinfo($name);
$extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较
$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,
'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']);
return $this->msg($temporary_data);
}else{
return $this->msg(10002);
}
}else{
// 上传失败获取错误信息
return $this->msg(10010,$file->getError());
}
}else{
return $this->msg(10001,'未选择图片');
}
}
public function pic_upload_action(){
$insert_data = [];
$temporary_data = [];
@ -257,10 +296,10 @@ class Base extends Controller{
if(!$token){
return $this->msg(10001,'token is miss');
}
if($files){
if(count($files)>5){
return $this->msg(10001,'单次最多上传5张图片');
}
if($files){
foreach($files as $file){
$name = $file->getInfo()['name'];
// 使用 pathinfo() 函数获取文件名的扩展名
@ -302,7 +341,7 @@ class Base extends Controller{
return $this->msg(10001,'未选择图片');
}
}
####################################################图片选择上传end##############################################################
public function msg($data,$str='',$result = []){
if(is_array($data)){
@ -329,6 +368,7 @@ class Base extends Controller{
return $randomString;
}
public function ceshi(){
echo 'hello';
}

View File

@ -9,6 +9,7 @@ class Cookbook extends Base{
// protected $token_time = 2592000;//30天的秒数
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
protected $page_num = 10;
protected $reedaw_db_msg = [
'zhanghao'=>'app_account_number',//账号表
'juese'=>'app_user_data',//角色表
@ -23,7 +24,7 @@ class Cookbook extends Base{
'foodlist2'=>'app_food_type_two',//食材列表3
'foodlist3'=>'app_food_type_three',//食材列表3
'user_kcal_log'=>'app_user_kcal_log',//食材列表3
'user'=>'app_user_data',//banner
];
// 加 bcadd(,,20)
@ -97,8 +98,8 @@ class Cookbook extends Base{
// return json(['status' => 'error', 'message' => '系统错误']);
// }
}
// 根据菜谱标签查询列表(首页用)(OK)
public function find_by_cook_label($data=['token'=>'caadd1be045a65f3','cook_label'=>2,'page'=>'1']){
// 修改菜谱(OK)
public function update_cookbook(){
// 尝试捕获异常
// try {
if(count(input('post.')) > 0){
@ -107,15 +108,81 @@ class Cookbook extends Base{
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(!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['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(!$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');
}
if (!is_array($data['step_list'])) {
return $this->msg(10005,'step_list 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->update_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' => '系统错误']);
// }
}
// 根据菜谱标签查询列表(首页用)(OK)
public function find_by_cook_label($data=['token'=>'','cook_label'=>4,'page'=>'1']){
// 尝试捕获异常
// try {
if(count(input('post.')) > 0){
$data = input('post.');
}
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'],'intnum')){
return $this->msg(10005,'cook_label type is error');
}
@ -182,21 +249,15 @@ class Cookbook extends Base{
// }
}
// 查询食谱的详情(OK)
public function cookbook_details($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','cookbook_id'=>'21']){
public function cookbook_details($data=['token'=>'','cookbook_id'=>'21']){
// 尝试捕获异常
// 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');
}
@ -358,17 +419,23 @@ class Cookbook extends Base{
// }
}
// 获取所有食材列表
public function get_food_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_food_list($data=['food_level2_id'=>'4','search_data'=>'','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_level2_id', $data)){
return $this->msg(10001,'food_level2_id is miss');
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005,'token type is error');
if(!array_key_exists('page', $data)){
return $this->msg(10001,'page is miss');
}
if(!$this->verify_data_is_ok($data['food_level2_id'],'intnum')){
return $this->msg(10005,'food_level2_id type is error');
}
if(!$this->verify_data_is_ok($data['page'],'intnum')){
return $this->msg(10005,'page type is error');
}
$return_data = $this->get_food_list_action($data);
@ -476,7 +543,8 @@ class Cookbook extends Base{
$data['food_list'] =$kcal_data;
// 处理食材卡路里end
// dump($data['food_list']);
// die;
$insert_data = [
'title'=>$data['title'],
'cover'=>$data['cover'],
@ -500,12 +568,89 @@ class Cookbook extends Base{
return $this->msg(10002);
}
}
public function find_by_cook_label_action($data){
public function update_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(20001,'账号信息错误');
}
if(count($data['food_list']) < 1){
return $this->msg(10001,'至少添加一个食物');
}
if(count($data['step_list']) < 1){
return $this->msg(10001,'至少添加一个步骤');
}
$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(10001,'食材缺少名称或者重量');
}
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,'食材重量格式错误,需整数数字');
}
if(!in_array($value['name'], $food_type)){
array_push($food_type, $value['name']);
}
}
// 检验一下step_list是否合规步骤列表
foreach ($data['step_list'] as $key => $value) {
if (!array_key_exists('description', $value) || !array_key_exists('pic_list', $value)) {
return $this->msg(10001,'步骤缺少描述或者图片');
}
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();
// if(!$user_data){
// }
// 处理食材卡路里start
$kcal_data = $this->count_calorie($data['food_list'],$data['step_list']);
$data['food_list'] =$kcal_data;
// 处理食材卡路里end
// dump($data['food_list']);
// die;
$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'],
];
$cook_book_result = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->update($insert_data);
// dump($cook_book_result);
// die;
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;
@ -513,21 +658,29 @@ class Cookbook extends Base{
$cfc = Db::connect('cfc_db');
$content_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])
->where(['cook_label'=>$cook_label])
->where(['cook_label'=>$cook_label,'is_del'=>0])
->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.likes_num')
->alias('a')
->join($this->kitchenscale_db_msg['uploadimg'].' b','a.cover = b.id','LEFT')
->where(['a.cook_label'=>$cook_label,'a.is_del'=>0])
->field('a.id,a.title,b.pic_url as cover,a.create_user_head_pic,a.create_user_nickname,a.likes_num')
->order('id DESC')
->page("$page_now,$page_num")
->select();
if(array_key_exists('token',$data)){
if($data['token'] != ''){
// 获取账号下信息以及用户信息
$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(20001,'账号信息错误');
}
// 获取用户收藏列表
$my_collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
->where(['token'=>$data['token']])
->where(['token'=>$data['token'],'is_del'=>0])
->column('cookbook_id');
// dump($my_collect_list);
// 处理菜谱收藏信息
@ -543,6 +696,26 @@ class Cookbook extends Base{
}
unset($content_list[$key]['ROW_NUMBER']);
}
}else{
foreach ($content_list as $key => $value) {
$content_list[$key]['is_me_like_it'] = 'no';
if($value['cover'] == null){
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
}
unset($content_list[$key]['ROW_NUMBER']);
}
}
}else{
foreach ($content_list as $key => $value) {
$content_list[$key]['is_me_like_it'] = 'no';
if($value['cover'] == null){
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
}
unset($content_list[$key]['ROW_NUMBER']);
}
}
// dump($content_list);
// die;
return $this->msg([
'page_now'=>$page_now,
'page_total'=>$page_total,
@ -599,11 +772,7 @@ class Cookbook extends Base{
]);
}
public function cookbook_details_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(20001,'账号信息错误');
}
$cfc = Db::connect('cfc_db');
$img_arr = [];
// 查询菜谱详情
@ -613,9 +782,11 @@ class Cookbook extends Base{
}
$cookbook_data['food_data'] = json_decode($cookbook_data['food_data'],true);
$cookbook_data['step_data'] = json_decode($cookbook_data['step_data'],true);
// $cookbook_data['food_type'] = explode(',',$cookbook_data['food_type']);
$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) {
@ -625,6 +796,8 @@ class Cookbook extends Base{
}
}
}
// dump($cookbook_data);
// die;
$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();
@ -633,50 +806,36 @@ class Cookbook extends Base{
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'] = [];
$cookbook_data['step_data'][$key]['step_num'] = "步骤".($key+1).'/'.$cookbook_data_step_data_count;
$cookbook_data['step_data'][$key]['pic_url_list'] = [];
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]);
array_push($cookbook_data['step_data'][$key]['pic_url_list'],$cookbook_img_data[$v]);
}else{
array_push($cookbook_data['step_data'][$key]['pic_list_ls'],'https://tc.pcxbc.com/kitchenscale_all/diule.jpg');
array_push($cookbook_data['step_data'][$key]['pic_url_list'],'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'] = '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';
// }
// $cookbook_data['cover_id'] = $cookbook_data['cover'];
if(array_key_exists($cookbook_data['cover'], $cookbook_img_data)){
$cookbook_data['cover_pic_url'] = $cookbook_img_data[$cookbook_data['cover']];
}else{
$cookbook_data['cover_pic_url'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
}
if(array_key_exists($cookbook_data['cover'], $cookbook_img_data)){
if($data['token'] != ''){
// 获取账号下信息以及用户信息
$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(20001,'账号信息错误');
}
$collect_data = $cfc->table($this->kitchenscale_db_msg['collect_list'])
->where([
'token'=>$data['token'],
@ -695,17 +854,27 @@ 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;
// }
// unset($cookbook_data['create_user_token']);
}else{
$cookbook_data['collect_status'] = 'no';
}
}else{
$cookbook_data['collect_status'] = 'no';
}
$cookbook_data['token'] = $cookbook_data['create_user_token'];
$cookbook_data['description'] = $cookbook_data['describe_data'];
$cookbook_data['food_list'] = $cookbook_data['food_data'];
$cookbook_data['step_list'] = $cookbook_data['step_data'];
unset($cookbook_data['create_user_token']);
unset($cookbook_data['describe_data']);
unset($cookbook_data['food_data']);
unset($cookbook_data['step_data']);
unset($cookbook_data['create_time']);
unset($cookbook_data['cook_label']);
unset($cookbook_data['food_type']);
unset($cookbook_data['ROW_NUMBER']);
unset($cookbook_data['is_del']);
return $this->msg($cookbook_data);
}
public function cookbook_follow_action($data){
@ -866,33 +1035,65 @@ class Cookbook extends Base{
}
}
public function get_food_list_action($data){
$cp_page_num = 100;
$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,unit')->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']);
$foodlist3[$k3]['one_id'] = $v['one_id'];
array_push($foodlist2[$k]['list'],$foodlist3[$k3]);
// unset($foodlist3[$k3]);
// $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,unit')->select();
$search_sql_str = "is_del = 0 AND two_id = ".$data['food_level2_id'];
if(!array_key_exists('search_data', $data)){
$data['search_data'] = "";
}else{
if($data['search_data'] === ""){
$data['search_data'] = "";
}else{
$data['search_data'] = " AND name LIKE '%".$data['search_data']."%'";
}
}
if($v['one_id'] == $value['id']){
unset($foodlist2[$k]['ROW_NUMBER']);
array_push($foodlist1[$key]['list'],$foodlist2[$k]);
// unset($foodlist2[$k]);
}
}
}
return $this->msg($foodlist1);
$search_sql_str = $search_sql_str.$data['search_data'];
// dump($data);
// dump($search_sql_str);
$content_num = $cfc->table($this->kitchenscale_db_msg['foodlist3'])
// ->alias('a')
// ->join($this->kitchenscale_db_msg['foodlist2'].' b','a.two_id = b.id','LEFT')
// ->join($this->kitchenscale_db_msg['foodlist1'].' c','b.one_id = c.id','LEFT')
->where($search_sql_str)
->count();
$page_total = ceil($content_num/$cp_page_num);;
$collect_list = $cfc->table($this->kitchenscale_db_msg['foodlist3'])
// ->alias('a')
// ->join($this->kitchenscale_db_msg['foodlist2'].' b','a.two_id = b.id','LEFT')
// ->join($this->kitchenscale_db_msg['foodlist1'].' c','b.one_id = c.id','LEFT')
->where($search_sql_str)
->field('id,name,kcal,unit')
->page($data['page'],$cp_page_num)
->select();
// $return_data = [];
// $temporary_arr = [];
// foreach ($collect_list as $key => $value) {
// unset($collect_list[$key]['ROW_NUMBER']);
// if(!array_key_exists($value['two_id'], $temporary_arr)){
// $temporary_arr[$value['two_id']] = [
// 'id'=>$value['two_id'],
// 'name'=>$value['two_name'],
// 'list'=>[['id'=>$value['id'],'name'=>$value['name'],'kcal'=>$value['kcal'],'unit'=>$value['unit']]],
// ];
// }else{
// array_push($temporary_arr[$value['two_id']]['list'],['id'=>$value['id'],'name'=>$value['name'],'kcal'=>$value['kcal'],'unit'=>$value['unit']]);
// }
// }
// foreach ($temporary_arr as $key => $value) {
// array_push($return_data,$value);
// }
return $this->msg([
'page_now'=>$data['page'],
'page_total'=>$page_total,
'content_list'=>$collect_list
]);
}
public function get_cookbook_label_list_action(){
$cfc = Db::connect('cfc_db');
@ -934,34 +1135,40 @@ class Cookbook extends Base{
$foot_name = array_column($data, 'name');
$foot_name = array_unique($foot_name);
$cfc = Db::connect('cfc_db');
$foot_kcal = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("name in ('".implode("','", $foot_name)."')")->field("name,kcal")->select();
$foot_kcal = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("name in ('".implode("','", $foot_name)."')")->field("id,name,kcal")->select();
$foot_kcal2 = [];
foreach ($foot_kcal as $key => $value) {
$foot_kcal2[$value['name']] = $value['kcal'];
$foot_kcal2[$value['name']] = [$value['id'],$value['kcal']];
}
// dump($data);
// dump($foot_kcal2);
// die;
foreach ($data as $key => $value) {
if(array_key_exists($value['name'], $foot_kcal2)){
$data[$key]['kcal'] = $this->count_calorie_action($value['weight'],$foot_kcal2[$value['name']]).'kcal';
$data[$key]['id'] = $foot_kcal2[$value['name']][0];
$data[$key]['kcal'] = $foot_kcal2[$value['name']][1];
}else{
$data[$key]['kcal'] = '0kcal';
$data[$key]['kcal'] = '0';
$data[$key]['id'] = 0;
}
$data[$key]['weight'] = $data[$key]['weight'].'g';
$data[$key]['unit'] = 'g';
}
// 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';
// foreach ($data as $key => $value) {
// if(array_key_exists($value['name'], $foot_kcal2)){
// // $data[$key]['kcal'] = $this->count_calorie_action($value['weight'],$foot_kcal2[$value['name']]).'kcal';
// $data[$key]['kcal'] = $this->count_calorie_action($value['weight'],$foot_kcal2[$value['name']]);
// }else{
// $step[$key]['foot_list'][$k]['kcal'] = '0kcal';
// // $data[$key]['kcal'] = '0kcal';
// $data[$key]['kcal'] = '0';
// }
// $step[$key]['foot_list'][$k]['weight'] = $step[$key]['foot_list'][$k]['weight'].'g';
// // $data[$key]['weight'] = $data[$key]['weight'].'g';
// $data[$key]['unit'] = 'g';
// $data[$key]['id'] = 'g';
// }
// }
return [$data];
return $data;
}
@ -976,4 +1183,58 @@ class Cookbook extends Base{
}
public function chuli_shuju(){
$cfc = Db::connect('cfc_db');
$foot_kcal = $cfc->table('app_user_cookbook')->field("food_data,id")->select();
$foot_name = [];
// dump($foot_kcal);
foreach ($foot_kcal as $key => $value) {
unset($foot_kcal[$key]['ROW_NUMBER']);
$foot_kcal[$key]['food_data'] = json_decode($foot_kcal[$key]['food_data'],true);
foreach ($foot_kcal[$key]['food_data'] as $k => $v) {
$linshi_data = $v;
// dump($linshi_data);
$foot_kcal[$key]['food_data'][$k] = [];
$foot_kcal[$key]['food_data'][$k]['name'] = $linshi_data['name'];
$foot_kcal[$key]['food_data'][$k]['weight'] = $linshi_data['weight'];
$foot_kcal[$key]['food_data'][$k]['unit'] = 'g';
$foot_kcal[$key]['food_data'][$k]['kcal'] = rtrim($linshi_data['kcal'], "kcal");
if(!in_array($linshi_data['name'], $foot_name)){
array_push($foot_name,$linshi_data['name']);
}
}
// $foot_kcal[$key]['food_data'] = $foot_kcal[$key]['food_data'][0];
// $foot_kcal[$key]['food_data'] = json_encode($foot_kcal[$key]['food_data']);
}
$shicai = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("name in ('".implode("','", $foot_name)."')")->field("id,name,kcal")->select();
$shicai2 = [];
foreach ($shicai as $key => $value) {
$shicai2[$value['name']] = [$value['id'],$value['kcal']];
}
// dump($shicai2);
foreach ($foot_kcal as $key => $value) {
foreach ($foot_kcal[$key]['food_data'] as $k => $v) {
$foot_kcal[$key]['food_data'][$k]['kcal'] = $shicai2[$v['name']][1];
$foot_kcal[$key]['food_data'][$k]['id'] = $shicai2[$v['name']][0];
}
// $foot_kcal[$key]['food_data'] = $foot_kcal[$key]['food_data'][0];
$foot_kcal[$key]['food_data'] = json_encode($foot_kcal[$key]['food_data']);
}
// dump($foot_kcal);
// die;
foreach ($foot_kcal as $key => $value) {
$cfc->table('app_user_cookbook')->where(['id'=>$value['id']])->update(['food_data'=>$value['food_data']]);
}
dump($foot_kcal);
die;
}
}

View File

@ -4,9 +4,11 @@ namespace app\KitchenScale\controller\app;
use think\Db;
class Login extends Base{
class Countfood extends Base{
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
protected $page_num = 10;
protected $reedaw_db_msg = [
'zhanghao'=>'app_account_number',//账号表
'juese'=>'app_user_data',//角色表
@ -17,8 +19,8 @@ class Login extends Base{
'followlist'=>'app_user_follow_list',//关注列表
'collect_list'=>'app_user_collect_list',//收藏列表
'foodlist3'=>'app_food_type_three',//食材列表3
'eat_log'=>'',//食材列表3
'eat_log'=>'app_user_kcal_log',//食材列表3
'user'=>'app_user_data',//banner
];
// 加 bcadd(,,20)
@ -30,7 +32,7 @@ class Login extends Base{
################################################################接口################################################################
// 添加每日摄入记录
public function add_intake_food($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'meals_type'=>'餐','food_list'=>[['food_id'=>1,'weight'=>'500'],['food_id'=>1,'weight'=>'500']]]){
public function add_intake_food($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'meals_type'=>'午加餐','food_list'=>[['id'=>1,'weight'=>'150','unit'=>'g'],['id'=>2,'weight'=>'100','unit'=>'g']]]){
// 尝试捕获异常
// try {
if(count(input('post.')) > 0){
@ -42,6 +44,9 @@ class Login extends Base{
if(!array_key_exists('aud_id', $data)){
return $this->msg(10001,'aud_id is miss');
}
if(!array_key_exists('meals_type', $data)){
return $this->msg(10001,'meals_type is miss');
}
if(!array_key_exists('food_list', $data)){
return $this->msg(10001,'food_list is miss');
}
@ -69,7 +74,7 @@ class Login extends Base{
// }
}
// 获取记食器板块内容
public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'time'=>'2025-03-17']){
public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>61,'time'=>'2025-03-17']){
// 尝试捕获异常
// try {
if(count(input('post.')) > 0){
@ -112,7 +117,7 @@ class Login extends Base{
// }
}
// 获取记食器记录
public function get_log_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'page'=>1]){
public function get_log_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'s_time'=>'2025-03-15','e_time'=>'2025-03-16']){
// 尝试捕获异常
// try {
if(count(input('post.')) > 0){
@ -124,8 +129,11 @@ class Login extends Base{
if(!array_key_exists('aud_id', $data)){
return $this->msg(10001,'aud_id is miss');
}
if(!array_key_exists('page', $data)){
return $this->msg(10001,'page is miss');
if(!array_key_exists('s_time', $data)){
return $this->msg(10001,'s_time is miss');
}
if(!array_key_exists('e_time', $data)){
return $this->msg(10001,'e_time is miss');
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005,'token type is error');
@ -133,8 +141,11 @@ class Login extends Base{
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005,'aud_id type is error');
}
if(!$this->verify_data_is_ok($data['page'],'intnum')){
return $this->msg(10005,'page type is error');
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
return $this->msg(10005,'s_time type is error');
}
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
return $this->msg(10005,'e_time type is error');
}
$return_data = $this->get_log_list_action($data);
@ -154,7 +165,86 @@ class Login extends Base{
// return json(['status' => 'error', 'message' => '系统错误']);
// }
}
// 计食器板块-设置内容
public function set_up_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>61]){
// 尝试捕获异常
// 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('aud_id', $data)){
return $this->msg(10001,'aud_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['aud_id'],'intnum')){
return $this->msg(10005,'aud_id type is error');
}
$return_data = $this->set_up_content_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 set_user_kcal($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>61,'set_kcal'=>2000]){
// 尝试捕获异常
// 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('aud_id', $data)){
return $this->msg(10001,'aud_id is miss');
}
if(!array_key_exists('set_kcal', $data)){
return $this->msg(10001,'set_kcal 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['aud_id'],'intnum')){
return $this->msg(10005,'aud_id type is error');
}
if(!$this->verify_data_is_ok($data['set_kcal'],'num')){
return $this->msg(10005,'set_kcal type is error');
}
$return_data = $this->set_user_kcal_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#######################################################################
#######################################################################action#######################################################################
#######################################################################action#######################################################################
@ -165,28 +255,42 @@ class Login extends Base{
public function add_intake_food_action($data){
$cfc = Db::connect('cfc_db');
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
->find();
if(!$user_data){
return $this->msg(10003);
}
// 统计食物的id
$food_id_arr = [];
foreach ($data['food_list'] as $key => $value) {
if(!array_key_exists('food_id', $value)){
return $this->msg(10001,'food_id is miss');
if(!array_key_exists('id', $value)){
return $this->msg(10001,'id is miss');
}
if(!array_key_exists('weight', $value)){
return $this->msg(10001,'weight is miss');
}
if(!$this->verify_data_is_ok($value['food_id'],'intnum')){
return $this->msg(10005,'food_id type is error');
if(!$this->verify_data_is_ok($value['id'],'intnum')){
return $this->msg(10005,'id type is error');
}
if(!$this->verify_data_is_ok($value['weight'],'num')){
return $this->msg(10005,'weight type is error');
}
foreach ($data['food_list'][$key] as $k => $v) {
// dump($k);
if(!in_array($k,['id','weight','unit'])){
unset($data['food_list'][$key][$k]);
}
}
array_push($food_id_arr,$value['id']);
}
$food_content = $cfc->table($this->kitchenscale_db_msg['foodlist3'])
->where("id in (".implode(',',$food_id_arr).")")
->field('id,name,kcal,carbohydrate,protein,fat')
->select();
// 整理食物信息
$food_content_arr = [];
foreach ($food_content as $key => $value) {
@ -201,22 +305,27 @@ class Login extends Base{
$data['food_list'][$key]['carbohydrate_val'] = bcmul($food_content_arr[$value['id']]['carbohydrate'],$proportion_num,2);
$data['food_list'][$key]['protein_val'] = bcmul($food_content_arr[$value['id']]['protein'],$proportion_num,2);
$data['food_list'][$key]['fat_val'] = bcmul($food_content_arr[$value['id']]['fat'],$proportion_num,2);
$data['food_list'][$key]['food_name'] = $food_content_arr[$value['id']]['name'];
$data['food_list'][$key]['aud_id'] = $data['aud_id'];
$data['food_list'][$key]['meals_type'] = $data['meals_type'];
$data['food_list'][$key]['food_name'] = $data['meals_type'];
$data['food_list'][$key]['create_time'] = $create_time;
$data['food_list'][$key]['food_id'] = $value['id'];
unset($data['food_list'][$key]['id']);
}else{
unset($data['food_list'][$key]);
}
}
// dump($data['food_list']);
// die;
// 数据库数据字段id,aud_id,meals_type,food_id,food_name,weight,kcal_val,carbohydrate_val,protein_val,fat_val,create_time
// 启动事务
Db::startTrans();
try{
$result = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->insertAll($data['food_list']);
if ($result !== count($data)) {
$result = $cfc->table($this->kitchenscale_db_msg['eat_log'])->insertAll($data['food_list']);
if ($result !== count($data['food_list'])) {
Db::rollback();
return $this->msg(10002);
return $this->msg(10001);
} else {
Db::commit();
return $this->msg([]);
@ -230,31 +339,34 @@ class Login extends Base{
public function get_countfoot_content_action($data){
$cfc = Db::connect('cfc_db');
$user_data = Db::table($this->reedaw_db_msg['juese'])
->where(["id"=>$data['aud_id'],'token'=>$data['token']])
->field('weight,height,gender,birthday')
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
->find();
if(!$user_data){
return $this->msg(10003);
}
$user_data['age_num'] = $this->calculate_age($user_data['birthday']);
$user_data['age_num'] = $user_data['age'];
$nutrition_data = $this->count_user_nutrition_all($user_data);
if($user_data['is_use_set_kcal'] == 1){
$nutrition_data['kcal'] = $user_data['set_kcal'];
}
// 查询用户今日摄入食物
$food_content = $cfc->table($this->kitchenscale_db_msg['eat_log'])
// ->where(["aud_id"=>$data['aud_id'],'create_time'=>['=']])
->where("aud_id = ".$data['aud_id']." AND CAST(create_time AS DATE) = ".$data['time']."")
->where("aud_id = " . $data['aud_id'] . " AND CAST(create_time AS DATE) = CAST('" . $data['time'] . "' AS DATE)")
->field('meals_type,food_name,weight,kcal_val,carbohydrate_val,protein_val,fat_val')
->select();
$date = date('Y-m-d H:i:s');
$return_data = [
'suggestion'=>[
'kcal'=>$nutrition_data['tdee'],
'carbohydrate'=>$nutrition_data['carbohydrate'].'克',
'protein'=>$nutrition_data['protein'].'克',
'fat'=>$nutrition_data['fat'].'克',
'kcal'=>$nutrition_data['kcal'],
'carbohydrate'=>$nutrition_data['carbohydrate'],
'protein'=>$nutrition_data['protein'],
'fat'=>$nutrition_data['fat'],
],
'today_intake'=>[
'kcal'=>0,
@ -262,7 +374,7 @@ class Login extends Base{
'protein'=>0,
'fat'=>0,
],
'remaining_kcal'=>$nutrition_data['tdee'],//剩下可摄入卡路里
'remaining_kcal'=>$nutrition_data['kcal'],//剩下可摄入卡路里
'list'=>[
[
'name'=>'早餐',
@ -283,13 +395,19 @@ class Login extends Base{
'list'=>[],
],
[
'name'=>'加餐',
'name'=>'加餐',
'val'=>0,
'unit'=>'kcal',
'list'=>[],
],
[
'name'=>'其他',
'name'=>'午加餐',
'val'=>0,
'unit'=>'kcal',
'list'=>[],
],
[
'name'=>'晚加餐',
'val'=>0,
'unit'=>'kcal',
'list'=>[],
@ -298,79 +416,261 @@ class Login extends Base{
'date'=>date('Y-m-d'),
];
if(count($food_content) <= 0){
$return_data['list'] = [];
return $this->msg($return_data);
}
foreach ($food_content as $key => $value) {
$return_data['today_intake']['kcal'] += $value['kcal_val'];
$return_data['today_intake']['carbohydrate'] += $value['carbohydrate_val'];
$return_data['today_intake']['protein'] += $value['protein_val'];
$return_data['today_intake']['fat'] += $value['fat_val'];
$return_data['today_intake']['kcal'] = bcadd($return_data['today_intake']['kcal'],$value['kcal_val'],2);
$return_data['today_intake']['carbohydrate'] = bcadd($return_data['today_intake']['carbohydrate'],$value['carbohydrate_val'],2);
$return_data['today_intake']['protein'] = bcadd($return_data['today_intake']['protein'],$value['protein_val'],2);
$return_data['today_intake']['fat'] = bcadd($return_data['today_intake']['fat'],$value['fat_val'],2);
if($value['meals_type'] == '早餐'){
$return_data['list'][0]['val'] += $value['kcal_val'];
$return_data['list'][0]['val'] = bcadd($return_data['list'][0]['val'],$value['kcal_val'],2);
array_push($return_data['list'][0]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else if($value['meals_type'] == '午餐'){
$return_data['list'][1]['val'] += $value['kcal_val'];
$return_data['list'][1]['val'] = bcadd($return_data['list'][1]['val'],$value['kcal_val'],2);
array_push($return_data['list'][1]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else if($value['meals_type'] == '晚餐'){
$return_data['list'][2]['val'] += $value['kcal_val'];
$return_data['list'][2]['val'] = bcadd($return_data['list'][2]['val'],$value['kcal_val'],2);
array_push($return_data['list'][2]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else if($value['meals_type'] == '加餐'){
$return_data['list'][3]['val'] += $value['kcal_val'];
}else if($value['meals_type'] == '加餐'){
$return_data['list'][3]['val'] = bcadd($return_data['list'][3]['val'],$value['kcal_val'],2);
array_push($return_data['list'][3]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else{
$return_data['list'][4]['val'] += $value['kcal_val'];
}else if($value['meals_type'] == '午加餐'){
$return_data['list'][4]['val'] = bcadd($return_data['list'][4]['val'],$value['kcal_val'],2);
array_push($return_data['list'][4]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else if($value['meals_type'] == '晚加餐'){
$return_data['list'][5]['val'] = bcadd($return_data['list'][5]['val'],$value['kcal_val'],2);
array_push($return_data['list'][5]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']);
}else{
}
}
$return_data['today_intake'] = $return_data['suggestion']['kcal']-$return_data['today_intake']['kcal']>=0?$return_data['suggestion']['kcal']-$return_data['today_intake']['kcal']:0;
return $this->msg($return_data);
}
foreach ($return_data['list'] as $key => $value) {
if(count($value['list']) <= 0){
unset($return_data['list'][$key]);
}
}
$return_data['list'] = array_values($return_data['list']);
$return_data['remaining_kcal'] = bcsub($return_data['suggestion']['kcal'],$return_data['today_intake']['kcal'],2)>=0?bcsub($return_data['suggestion']['kcal'],$return_data['today_intake']['kcal'],2):0;
return $this->msg($return_data);
}
public function get_log_list_action($data){
$cfc = Db::connect('cfc_db');
$user_data = Db::table($this->reedaw_db_msg['juese'])
->where(["id"=>$data['aud_id'],'token'=>$data['token']])
->field('weight,height,gender,birthday')
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
->find();
if(!$user_data){
return $this->msg(10003);
}
// dump($user_data);
// 计算年龄
$user_data['age_num'] = $user_data['age'];
// 计算推荐营养
$nutrition_data = $this->count_user_nutrition_all($user_data);
if($user_data['is_use_set_kcal'] == 1){
$nutrition_data['kcal'] = $user_data['set_kcal'];
}
// 计算取值范围
// $time_arr = $this->calculateDateRange($data['page']);
// $content_num = $cfc->query("SELECT COUNT(DISTINCT CONVERT(varchar, create_time, 23)) as total
// FROM ".$this->kitchenscale_db_msg['eat_log']."
// WHERE aud_id = ".$data['aud_id']."");
// $page_total = ceil($content_num[0]['total']/$this->page_num);
$food_content = $cfc->table($this->kitchenscale_db_msg['eat_log'])
->field("CONVERT(varchar, create_time, 23) as create_time, SUM(kcal_val) as kcal_val")
->where(['aud_id'=>$data['aud_id'],'create_time'=>['>=',$data['s_time'].' 00:00:00'],'create_time'=>['<=',$data['e_time'].' 23:59:59']])
->group('CONVERT(varchar, create_time, 23)')
// ->page($data['page'],$this->page_num)
->order('create_time DESC')
->select();
// dump($food_content);
// die;
$user_log = [];
foreach ($food_content as $key => $value) {
$time_data = substr($value['create_time'], 0, 10);
if(array_key_exists($time_data, $user_log)){
$user_log[$time_data] += $value['kcal_val'];
}else{
$user_log[$time_data] = $value['kcal_val'];
}
}
$return_data = [];
foreach ($user_log as $key => $value) {
if(bcdiv($value,$nutrition_data['kcal'],2) < 0.9){
$bz['text'] = '不达标';
$bz['color'] = '#F0AD4E';
}else if(bcdiv($value,$nutrition_data['kcal'],2) >= 0.9 && bcdiv($value,$nutrition_data['kcal'],2) < 1.1){
$bz['text'] = '达标';
$bz['color'] = '#4CD964';
}else{
$bz['text'] = '超标';
$bz['color'] = '#FF0000';
}
array_push($return_data,['time'=>$key,'val'=>$value,'unit'=>'kcal','describe'=>$bz['text'],'color'=>$bz['color']]);
}
// dump($return_data);
return $this->msg([
// 'page_now'=>$data['page'],
// 'page_total'=>$page_total,
'content_list'=>$return_data
]);
}
public function set_up_content_action($data){
$cfc = Db::connect('cfc_db');
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
->find();
if(!$user_data){
return $this->msg(10003);
}
// 计算年龄
$user_data['age_num'] = $this->calculate_age($user_data['birthday']);
$user_data['age_num'] = $user_data['age'];
// 计算推荐营养
$nutrition_data = $this->count_user_nutrition_all($user_data);
// 计算取值范围
$time_arr = $this->calculateDateRange($data['page']);
if($user_data['is_use_set_kcal'] == 1){
$nutrition_data['kcal'] = $user_data['set_kcal'];
}
$nutrition_describe = [
[
'对于一个孩子2-18岁没有特殊健康问题身体处于快速生长发育阶段需要充足的营养支持尤其是蛋白质和健康脂肪。通常建议的三大营养素比例为',
'1、碳水化合物45%-65% 的总热量',
'提供能量,支持孩子的日常活动和生长发育。',
'优先选择复合碳水化合物(如全谷物、蔬菜、水果),避免精制糖和高糖零食。',
'2、蛋白质10%-30% 的总热量',
'支持肌肉、骨骼和器官的发育。',
'建议摄入优质蛋白质来源,如瘦肉、鱼类、鸡蛋、豆类和乳制品。',
'蛋白质需求较高,尤其是青春期孩子。',
'3、脂肪25%-35% 的总热量',
'提供能量并支持大脑发育尤其是Omega-3脂肪酸。',
'优先选择健康脂肪,如鱼类、坚果、种子、橄榄油和牛油果。',
'避免反式脂肪和过多的饱和脂肪。',
'注意事项',
'如果你有特定的健康目标(如增高,减重),可以进一步调整比例,并咨询营养师或医生以获得个性化建议。',
],
[
'对于一个正常成年人(没有特殊健康问题或特定健身目标),通常建议的三大营养素比例为:',
'1、碳水化合物45%-65% 的总热量',
'主要功能是提供能量',
'建议选择复合碳水化合物(如全谷物、蔬菜、豆类),而不是精制糖。',
'对于普通人,碳水化合物占总热量的 50%-55% 是一个常见的推荐值。',
'2、蛋白质10%-35% 的总热量',
'用于维持肌肉、修复组织和支持免疫功能。',
'普通人每日蛋白质摄入量建议为 0.8-1.2克/公斤体重。',
'对于活动量较大或健身人群,蛋白质比例可以提高到 20%-30%。',
'3、脂肪20%-35% 的总热量',
'提供能量、支持细胞功能并帮助吸收脂溶性维生素。',
'建议以 不饱和脂肪(如橄榄油、坚果、鱼类)为主,减少饱和脂肪和反式脂肪的摄入。',
'脂肪占总热量的 20%-30% 是常见的推荐值。',
'以上是根据世界卫生组织WHO和其他健康机构的建议制定的。具体比例可以根据个人的活动水平、健康状况和目标进行微调。',
'注意事项',
'活动水平:活动量大的人可能需要更多的碳水化合物来提供能量,而健身人群可能需要更多的蛋白质。',
'健康状况:例如,糖尿病患者可能需要控制碳水化合物比例,而心血管疾病患者可能需要减少脂肪摄入。',
'个体差异:每个人的代谢和需求不同,建议根据个人情况调整。',
'如果你有特定的健康目标(如减脂、增肌或控制慢性病),可以进一步调整比例,并咨询营养师或医生以获得个性化建议。',
],
[
'对于一个老人65岁以上没有特殊健康问题身体的代谢率下降肌肉量减少可能面临营养不良或慢性病风险因此需要调整营养比例。通常建议的三大营养素比例为',
'1、碳水化合物45%-65% 的总热量',
'提供能量但应选择低血糖指数GI的食物如全谷物、蔬菜和豆类以控制血糖水平。',
'避免精制糖和高糖食物,尤其是糖尿病患者。',
'帮助维持肌肉质量,预防肌肉流失(少肌症)。',
'建议摄入优质蛋白质,如鱼类、瘦肉、鸡蛋、豆类和乳制品。',
'蛋白质需求较高,尤其是活动量较大的老人。',
'3、脂肪20%-35% 的总热量',
'提供能量,并支持细胞功能和脂溶性维生素的吸收。',
'优先选择不饱和脂肪,如橄榄油、坚果、种子和鱼类。',
'减少饱和脂肪和反式脂肪的摄入,以降低心血管疾病风险。',
'注意事项',
'如果你有特定的健康目标(控制慢性病),可以进一步调整比例,并咨询营养师或医生以获得个性化建议。',
]
];
$return_data = [
'kcal'=>[
'title'=>"建议摄入卡路里",
'suggestion_kcal_val'=>$nutrition_data['kcal'],
'suggestion_kcal_unit'=>"千卡",
'suggestion_kcal_range_val'=>"建议您在:".bcmul($nutrition_data['bmr'],1.2,2)."~".bcmul($nutrition_data['bmr'],1.9,2)."千卡范围内调整,修改时请以医生建议为准!",
'describe'=>[
'基础代谢率(BMR):是指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率。',
'每日总能量消耗TDEE',
'TDEE是BMR乘以活动系数活动系数根据日常活动水平确定',
'久坐很少或没有运动BMR × 1.2',
'轻度活动每周1-3天轻度运动BMR × 1.375',
'中度活动每周3-5天中度运动BMR × 1.55',
'高度活动每周6-7天高强度运动BMR × 1.725',
'极高活动体力劳动或每天高强度训练BMR × 1.9',
'您的BMR为'.$nutrition_data['bmr'].',建议根据您的日常生活水平调整合适的TDEE',
],
],
'nutrition'=>[
'title'=>"建议三大营养比例",
'list'=>[
[
'name'=>'碳水化合物',
'icon'=>'icon-tanshuihuahewu',
'proportion'=>'50%',
'val'=>$nutrition_data['carbohydrate'],
'unit'=>'克'
],
[
'name'=>'蛋白质',
'icon'=>'icon-Sm-danbaizhi',
'proportion'=>'20%',
'val'=>$nutrition_data['protein'],
'unit'=>'克'
],
[
'name'=>'脂肪',
'icon'=>'icon-w_fat_normal',
'proportion'=>'30%',
'val'=>$nutrition_data['fat'],
'unit'=>'克'
]
],
'describe'=>[]
]
];
if($user_data['age_num'] >= 2 && $user_data['age_num'] <= 18){
$return_data['nutrition']['describe'] = $nutrition_describe[0];
}else if($user_data['age_num'] > 18 && $user_data['age_num'] < 65){
$return_data['nutrition']['describe'] = $nutrition_describe[1];
}else if($user_data['age_num'] >= 65){
$return_data['nutrition']['describe'] = $nutrition_describe[2];
}else{
$food_content = $cfc->table($this->kitchenscale_db_msg['eat_log'])
->where(['aud_id'=>$data['aud_id']])
->whereTime('create_time', 'between', [$time_arr['s_time'], $time_arr['e_time']])
->field('kcal_val,create_time')
->order('create_time desc')
->select();
$user_log = [];
foreach ($food_content as $key => $value) {
if(array_key_exists($value['create_time'], $user_log)){
$user_log[$value['create_time']] += $value['kcal_val'];
}else{
$user_log[$value['create_time']] = $value['kcal_val'];
}
}
$return_data = [];
foreach ($variable as $key => $value) {
if(bcdiv($value,$nutrition_data['kcal'],2) < 0.9){
$bz['text'] = '不达标';
$bz['color'] = '#F1D452';
}else if(bcdiv($value,$nutrition_data['kcal'],2) >= 0.9 && bcdiv($value,$nutrition_data['kcal'],2) < 1.1){
$bz['text'] = '达标';
$bz['color'] = '#66AE00';
}else{
$bz['text'] = '超标';
$bz['color'] = '#D7001A';
}
array_push($return_data,['time'=>$key,'val'=>$value,'unit'=>'kcal','describe'=>$bz['text'],'color'=>$bz['color']]);
}
return $this->msg($return_data);
}
public function set_user_kcal_action($data){
$cfc = Db::connect('cfc_db');
$user_data = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->field('weight,height,gender,age,is_use_set_kcal,set_kcal')
->find();
if(!$user_data){
return $this->msg(10003);
}
$result = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["id"=>$data['aud_id']])
->update([
'is_use_set_kcal'=>1,
'set_kcal'=>$data['set_kcal']
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
#######################################################################工具#######################################################################
@ -384,13 +684,13 @@ class Login extends Base{
$bmr = bcmul(10,$data['weight'],20);
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
$bmr = bcadd($bmr,5,20);
$bmr = bcadd($bmr,5,2);
}else if($data['gender'] == 2){
// 女性BMR = 10 × 体重kg + 6.25 × 身高cm - 5 × 年龄(岁) - 161
$bmr = bcmul(10,$data['weight'],20);
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
$bmr = bcsub($bmr,161,20);
$bmr = bcsub($bmr,161,2);
}else{
return $this->msg(10003,'性别未知');
}
@ -420,19 +720,19 @@ class Login extends Base{
$protein = bcdiv(bcmul($tdee,0.25,20),4,2);
$fat =bcdiv(bcmul($tdee,0.25,20),9,2);
}
return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat];
return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat,'bmr'=>$bmr];
}
public function calculateDateRange($n) {
// 获取当前日期和时间
$today = new DateTime();
$today = new \DateTime();
// 计算结束时间:往前推 (10 * (n - 1)) 天,时间设为 23:59:59
$endInterval = new DateInterval('P' . (10 * ($n - 1)) . 'D');
$endInterval = new \DateInterval('P' . (10 * ($n - 1)) . 'D');
$endTime = clone $today;
$endTime->sub($endInterval)->setTime(23, 59, 59);
// 计算开始时间:往前推 (10 * n) 天,时间设为 00:00:00
$startInterval = new DateInterval('P' . (10 * $n) . 'D');
$startInterval = new \DateInterval('P' . (10 * $n) . 'D');
$startTime = clone $today;
$startTime->sub($startInterval)->setTime(0, 0, 0);

View File

@ -3,6 +3,7 @@
namespace app\KitchenScale\controller\app;
use think\Db;
// use app\KitchenScale\controller\app\Wechat;// 引入Wechat服务类
class Index extends Base{
@ -23,6 +24,7 @@ class Index extends Base{
'collect_list'=>'app_user_collect_list',//点赞表
'banner'=>'app_banner_data',//banner
'version'=>'app_version_log',//版本表
'user'=>'app_user_data',//banner
];
@ -75,18 +77,96 @@ class Index extends Base{
}
}
// 微信手机号快捷登录
public function wechat_quick_login($data = ['code'=>'asdasdasd','encryptedData'=>'adsadasdasd','iv'=>'asdasdasdasd']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('code', $data)){
// return $this->msg(10001,'');
return $this->msg(10001,'code is miss');
}
if(!array_key_exists('encryptedData', $data)){
return $this->msg(10001,'encryptedData is miss');
}
if(!array_key_exists('iv', $data)){
return $this->msg(10001,'iv is miss');
}
// 校验参数
if (empty($data['code'])) {
return $this->msg(10001,'code is miss.');
}
if (empty($data['encryptedData'])) {
return $this->msg(10001,'encryptedData is miss.');
}
if (empty($data['iv'])) {
return $this->msg(10001,'iv is miss.');
}
// 调用Wechat服务类处理微信登录逻辑
$wechatService = new Wechat();
// die;
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
// dump($result);
// die;
if($result['code'] == 0){
// return $this->msg($result['code'],$result['msg']);
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['tel'=>$result['data']['phoneNumber'],'is_del'=>0])->find();
if($user_data){
Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
$return_data = $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
}else{
$set_data['password'] = '';
$set_data['tel'] = $result['data']['phoneNumber'];
$set_data['head_pic'] = $this->default_head_pic;
$set_data['nickname'] = '用户'.$result['data']['phoneNumber'];
$set_data['create_time'] = date('Y-m-d H:i:s');
$set_data['login_time'] = date('Y-m-d H:i:s');
$set_data['token'] = md5($result['data']['phoneNumber'].$this->create_random_string(12).time());
$set_user_result = Db::table($this->reedaw_db_msg['zhanghao'])->insertGetId($set_data);
if($set_user_result){
$return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$set_user_result],'登录成功');
}else{
$return_data = $this->msg(10002);
}
}
return $return_data;
}else{
return $this->msg($result['code'],$result['msg']);
}
} 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'] .= "方法: (wechat_quick_login)" . "\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 get_default_config($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_default_config($data = ['token'=>'']){
// try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
// if(!array_key_exists('token', $data)){
// return $this->msg(10001);
// }
// if(!$this->verify_data_is_ok($data['token'],'str')){
// return $this->msg(10005);
// }
$return_data = $this->get_default_config_action($data);
return $return_data;
// } catch (\Exception $e) {
@ -105,55 +185,19 @@ class Index extends Base{
// }
}
// 获取首页信息banner金刚区label_list(OK)
public function get_homepage_information($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
// try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->get_homepage_information_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'] .= "接口: (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']){
public function search_column($data = ['search_data'=>'鱼','token'=>'']){
// try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('search_data', $data) || !array_key_exists('token', $data)){
if(!array_key_exists('search_data', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['search_data'],'str')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->search_column_action($data);
return $return_data;
// } catch (\Exception $e) {
@ -177,45 +221,36 @@ class Index extends Base{
#######################################################################action#######################################################################
public function get_default_config_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(20001,'账号信息错误');
}
$return_data = [
// 'food_list'=>[],
// 'cook_label'=>[],
'account'=>[],
'cook_label'=>[],
// 'account'=>[],
'food_list'=>[],
'banner'=>[],
'jingang_region'=>[
['name'=>'菜谱分类','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra1.png'],
['name'=>'我的收藏','jump_url'=>'/pageTwo/me/mymenu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra2.png'],
['name'=>'热量计算','jump_url'=>'/pages/count/count','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra3.png'],
['name'=>'健康食谱','jump_url'=>'/pages/menu/menu','icon'=>'https://tc.pcxbc.com/kitchenscale_all/vajra4.png'],
],
];
$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']);
// $foodlist3[$k3]['one_id'] = $v['one_id'];
// 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;
$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();
// dump($foodlist3);
foreach ($foodlist1 as $key => $value) {
unset($foodlist1[$key]['ROW_NUMBER']);
$foodlist1[$key]['list'] = [];
foreach ($foodlist2 as $k => $v) {
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
// 获取菜谱分类标签start
$cook_label = $cfc->table($this->kitchenscale_db_msg['cookbook_label'])
@ -227,76 +262,56 @@ class Index extends Base{
}
$return_data['cook_label'] = $cook_label;
// 获取菜谱分类标签end
// 获取账号下信息以及用户信息start
$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.grade,juese.head_pic')
->select();
$return_data['account'] = $user_account;
// 获取账号下信息以及用户信息end
return $this->msg($return_data);
// 获取首页信息start
// 获取banner
$banner_list = $cfc->query("select b.id,b.title,b.cover,b.create_user_head_pic,b.create_user_nickname,c.pic_url
from ".$this->kitchenscale_db_msg['banner']." as a
LEFT JOIN ".$this->kitchenscale_db_msg['cookbook']." as b on a.cookbook_id = b.id
LEFT JOIN ".$this->kitchenscale_db_msg['uploadimg']." as c on b.cover = c.id
where a.is_del=0 AND b.is_del=0
ORDER BY a.sort_num desc,a.id desc
");
// dump($banner_list);
// die;
if($data['token'] != ''){
// 获取账号下信息以及用户信息
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
if(!$user_data){
return $this->msg(20001,'账号信息错误');
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
public function get_homepage_information_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(20001,'账号信息错误');
}
$return_data = [
'banner'=>[],
'jingang_region'=>[
['name'=>'菜谱分类','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
['name'=>'我的收藏','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
['name'=>'热量计算','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
['name'=>'健康食谱','jump_url'=>'/xxx/xxx/xxx','icon'=>'/xxx/xxx/xxx'],
],
];
$cfc = Db::connect('cfc_db');
// 获取banner
$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');
$collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])->where(['token'=>$data['token'],'is_del'=>0])->column('cookbook_id');
foreach ($banner_list as $key => $value) {
if(array_key_exists($value['id'],$collect_list)){
$banner_list[$key]['is_me_like_it'] = 1;
$banner_list[$key]['is_me_like_it'] = 'yes';
}else{
$banner_list[$key]['is_me_like_it'] = 0;
$banner_list[$key]['is_me_like_it'] = 'no';
}
unset($banner_list[$key]['ROW_NUMBER']);
}
$return_data['banner'] = $banner_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);
}else{
foreach ($banner_list as $key => $value) {
$banner_list[$key]['is_me_like_it'] = 'no';
unset($banner_list[$key]['ROW_NUMBER']);
}
}
$return_data['banner'] = $banner_list;
// return $this->msg($return_data);
// 获取首页信息end
return $this->msg($return_data);
}
public function search_column_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(20001,'账号信息错误');
}
// $cookbook = new Cookbook();
$cfc = Db::connect('cfc_db');
// 获取菜谱信息
@ -309,6 +324,13 @@ class Index extends Base{
if(count($content_list)<=0){
return $this->msg([]);
}
if(array_key_exists('token',$data)){
if($data['token'] != ''){
// 获取账号下信息以及用户信息
$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(20001,'账号信息错误');
}
// 获取用户收藏列表
$my_collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
->where(['token'=>$data['token']])
@ -317,17 +339,55 @@ class Index extends Base{
// 处理菜谱收藏信息
foreach ($content_list as $key => $value) {
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';
}
unset($content_list[$key]['ROW_NUMBER']);
}
}else{
foreach ($content_list as $key => $value) {
$content_list[$key]['is_me_like_it'] = 'no';
if($value['cover'] == null){
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
}
unset($content_list[$key]['ROW_NUMBER']);
}
}
}else{
foreach ($content_list as $key => $value) {
$content_list[$key]['is_me_like_it'] = 'no';
if($value['cover'] == null){
$content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
}
unset($content_list[$key]['ROW_NUMBER']);
}
}
return $this->msg($content_list);
}
########################################################################################################################################################################
########################################################################################################################################################################
########################################################################################################################################################################
public function create_random_string($length = 12)
{
//创建随机字符
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$str = "";
for ($i = 0; $i < $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
}

View File

@ -23,6 +23,7 @@ class Usercenter extends Base{
'foodlist3'=>'app_food_type_three',//食材列表3
'collect_list'=>'app_user_collect_list',//点赞表
'banner'=>'app_banner_data',//banner
'user'=>'app_user_data',//banner
];
@ -34,6 +35,95 @@ class Usercenter extends Base{
################################################################接口################################################################
################################################################接口################################################################
// 获取角色信息
public function get_user_msg($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
// try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->get_user_msg_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 update_user_msg($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','nickname'=>'测试人员001','gender'=>'1','age'=>'18','height'=>'165.34','weight'=>'55.55']){
// 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('nickname', $data)){
return $this->msg(10001,'nickname is miss');
}
if(!array_key_exists('gender', $data)){
return $this->msg(10001,'gender is miss');
}
if(!array_key_exists('age', $data)){
return $this->msg(10001,'age is miss');
}
if(!array_key_exists('height', $data)){
return $this->msg(10001,'height is miss');
}
if(!array_key_exists('weight', $data)){
return $this->msg(10001,'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['nickname'],'str')){
return $this->msg(10005,'nickname type is error');
}
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005,'gender type is error');
}
if(!$this->verify_data_is_ok($data['age'],'intnum')){
return $this->msg(10005,'age type is error');
}
if(!$this->verify_data_is_ok($data['height'],'num')){
return $this->msg(10005,'height type is error');
}
if(!$this->verify_data_is_ok($data['weight'],'num')){
return $this->msg(10005,'weight type is error');
}
$return_data = $this->update_user_msg_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);
// }
}
// 获取用户收藏点赞列表(OK)
public function get_user_collect_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1,'search_data'=>'']){
// try {
@ -71,7 +161,7 @@ class Usercenter extends Base{
}
// 我的菜谱
public function get_my_cookbook($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1]){
public function get_my_cookbook($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','page'=>1,'search_data'=>'']){
// try {
if(count(input('post.')) > 0){
$data = input('post.');
@ -106,17 +196,171 @@ class Usercenter extends Base{
// }
}
// 菜谱删除
public function del_my_cookbook($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'cookbook_id'=>'33']){
// 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('aud_id', $data)){
return $this->msg(10001,'aud_id 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['aud_id'],'intnum')){
return $this->msg(10005,'aud_id 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->del_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_msg_action($data){
// 获取账号下信息以及用户信息
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
if(!$user_data){
return $this->msg(10003);
}
// $return_data = [];
// 获取账号下信息以及用户信息start
$user_all_data['aud_id'] = '';
$user_all_data['token'] = $user_data['token'];
$user_all_data['nickname'] = $user_data['nickname'];
$user_all_data['head_pic'] = $user_data['head_pic'];
$user_all_data['gender'] = '';
$user_all_data['age'] = '';
$user_all_data['height'] = '';
$user_all_data['weight'] = '';
$user_all_data['set_kcal'] = '';
$user_all_data['is_use_set_kcal'] = '';
$user_all_data['tel'] = $user_data['tel'];
$user_all_data['email'] = $user_data['email'];
$cfc = Db::connect('cfc_db');
$user_account = $cfc->table($this->kitchenscale_db_msg['user'])
->where(["token"=>$data['token']])
->field('id as aud_id,token,nickname,head_pic,gender,age,height,weight,set_kcal,is_use_set_kcal')
->find();
if($user_account){
if($user_account['set_kcal'] == '.00'){
$user_account['set_kcal'] = 0;
}
$user_all_data['aud_id'] = $user_account['aud_id'];
$user_all_data['gender'] = $user_account['gender'];
$user_all_data['age'] = $user_account['age'];
$user_all_data['height'] = $user_account['height'];
$user_all_data['weight'] = $user_account['weight'];
$user_all_data['set_kcal'] = $user_account['set_kcal'];
$user_all_data['is_use_set_kcal'] = $user_account['is_use_set_kcal'];
}else{
return $this->msg(10004);
}
// $return_data = $user_all_data;
return $this->msg($user_all_data);
// 获取账号下信息以及用户信息end
}
public function update_user_msg_action($data){
if($data['gender'] == 0){
return $this->msg(10005,'性别信息错误');
}
// 获取账号下信息以及用户信息
$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');
$is_user_true = $cfc->table($this->kitchenscale_db_msg['user'])->where(['token'=>$data['token']])->count();
$user_msg['nickname'] = $data['nickname'];
$user_msg['head_pic'] = $data['gender'] == 1?'https://tc.pcxbc.com/tsf/1.png':'https://tc.pcxbc.com/tsf/2.png';
$user_msg['gender'] = $data['gender'];
$user_msg['age'] = $data['age'];
$user_msg['height'] = $data['height'];
$user_msg['weight'] = $data['weight'];
// $cfc->startTrans();
// Db::startTrans();
// try {
// if($is_user_true>0){
// $user_msg['update_time'] = date('Y-m-d H:i:s');
// $result = $cfc->table($this->kitchenscale_db_msg['user'])
// ->where(['token'=>$data['token']])
// ->update($user_msg);
// }else{
// $user_msg['token'] = $data['token'];
// $result = $cfc->table($this->kitchenscale_db_msg['user'])
// ->insert($user_msg);
// }
// Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->update(['nickname'=>$user_msg['nickname']]);
// // 提交事务
// $cfc->commit();
// Db::commit();
// return $this->msg([]);
// } catch (\Exception $e) {
// // 回滚事务
// $cfc->rollback();
// Db::rollback();
// return $this->msg(10002);
// }
if($is_user_true>0){
$user_msg['update_time'] = date('Y-m-d H:i:s');
$result = $cfc->table($this->kitchenscale_db_msg['user'])
->where(['token'=>$data['token']])
->update($user_msg);
}else{
$user_msg['token'] = $data['token'];
$result = $cfc->table($this->kitchenscale_db_msg['user'])
->insert($user_msg);
}
Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->update(['nickname'=>$user_msg['nickname']]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
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";
$search_sql_str = "a.token = '".$data['token']."' AND a.is_del = 0 AND b.is_del = 0";
if(!array_key_exists('search_data', $data)){
$data['search_data'] = "";
}else{
@ -147,6 +391,11 @@ class Usercenter extends Base{
->page($data['page'],$this->page_num)
->select();
foreach ($collect_list as $key => $value) {
$collect_list[$key]['is_me_like_it'] = 'yes';
}
return $this->msg([
'page_now'=>$data['page'],
'page_total'=>$page_total,
@ -160,26 +409,99 @@ class Usercenter extends Base{
if($user_data<=0){
return $this->msg(10005,'账号信息错误');
}
$search_sql_str = "b.create_user_token = '".$data['token']."' AND b.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'];
$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])
->where($search_sql_str)
->count();
$page_total = ceil($content_num/$this->page_num);;
$collect_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])
$content_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])
->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();
// 获取用户收藏列表
$my_collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
->where(['token'=>$data['token'],'is_del'=>0])
->column('cookbook_id');
// dump($my_collect_list);
// 处理菜谱收藏信息
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'] = 'yes';
}else{
$content_list[$key]['is_me_like_it'] = 'no';
}
// if($value['cover'] == null){
// $content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
// }
unset($content_list[$key]['ROW_NUMBER']);
}
// foreach ($collect_list as $key => $value) {
// $collect_list[$key]['is_me_like_it'] = 'yes';
// }
return $this->msg([
'page_now'=>$data['page'],
'page_total'=>$page_total,
'content_list'=>$collect_list
'content_list'=>$content_list
]);
}
public function del_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');
$cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id'],'create_user_token'=>$data['token']])->find();
if($cookbook_data){
// 启动事务
$cfc->startTrans();
try{
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->update(['is_del'=>1]);
$result_banner = $cfc->table($this->kitchenscale_db_msg['banner'])->where(['cookbook_id'=>$cookbook_data['id']])->count();
if($result_banner > 0){
$cfc->table($this->kitchenscale_db_msg['banner'])->where(['cookbook_id'=>$cookbook_data['id']])->update(['is_del'=>1]);
}
// 提交事务
$cfc->commit();
return $this->msg([]);
} catch (\Exception $e) {
// 回滚事务
$cfc->rollback();
return $this->msg(10002);
}
}else{
return $this->msg(10003);
}
}
}

View File

@ -0,0 +1,123 @@
<?php
namespace app\KitchenScale\controller\app;
use think\Db;
class Wechat extends Base{
// reedaw的小程序信息
private $app_id = 'wx1f32af4f93c913f6'; // 微信小程序的AppID
private $app_secret = '21c6660d94d635cea4831253c60fc6e2'; // 微信小程序的AppSecret
// ed7cda5874f0eef3360e782a3db73c80
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
/**
* 处理微信登录
*
* @param string $code 微信登录凭证
* @param string $encryptedData 加密的用户信息
* @param string $iv 解密算法的初始向量
* @return array
*/
public function handleWechatLogin($code, $encryptedData, $iv)
{
// try {
// 1. 通过code获取openid和session_key
$sessionData = $this->getSessionKey($code);
if (empty($sessionData['openid']) || empty($sessionData['session_key'])) {
// throw new Exception('获取openid或session_key失败');
// return false;
// return $this->msg(10001);
return ['code'=>10002,'msg'=>'获取openid或session_key失败'];
}
// 2. 解密用户信息
$userInfo = $this->decryptData($encryptedData, $iv, $sessionData['session_key']);
if(array_key_exists('phoneNumber',$userInfo)){
return ['code'=>0,'msg'=>'seccess','data'=>$userInfo];
}else{
return ['code'=>10002,'msg'=>'解密用户信息失败'];
}
// if (empty($userInfo['phoneNumber'])) {
// // throw new Exception('获取手机号失败');
// }else{
// }
// // 3. 保存或更新用户信息
// $user = User::where('openid', $sessionData['openid'])->find();
// if (!$user) {
// $user = new User();
// $user->openid = $sessionData['openid'];
// }
// $user->phone = $userInfo['phoneNumber'];
// $user->save();
// 返回成功信息
// return ['code' => 0, 'msg' => '登录成功', 'data' => $user];
// } catch (Exception $e) {
// // 返回错误信息
// return ['code' => 500, 'msg' => $e->getMessage()];
// }
}
/**
* 通过code获取openid和session_key
*
* @param string $code
* @return array
* @throws Exception
*/
private function getSessionKey($code)
{
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->app_id}&secret={$this->app_secret}&js_code={$code}&grant_type=authorization_code";
$result = file_get_contents($url);
$data = json_decode($result, true);
if (isset($data['openid']) && isset($data['session_key'])) {
return $data;
} else {
return ['code'=>10002,'msg'=>'获取openid或session_key失败'];
}
}
/**
* 解密用户信息
*
* @param string $encryptedData
* @param string $iv
* @param string $sessionKey
* @return array
* @throws Exception
*/
private function decryptData($encryptedData, $iv, $sessionKey)
{
// require_once 'wx_crypt/WXBizDataCrypt.php'; // 引入微信解密类
// require_once env('root_path') . 'extend/wx_crypt/WXBizDataCrypt.php';
// dump(ROOT_PATH . 'extend\wx_crypt\wxBizDataCrypt.php');
require_once ROOT_PATH . 'extend\wx_crypt\wxBizDataCrypt.php';
$pc = new \WXBizDataCrypt($this->app_id, $sessionKey);
$errCode = $pc->decryptData($encryptedData, $iv, $data);
if ($errCode == 0) {
return json_decode($data, true);
} else {
return ['code'=>10002,'msg'=>'解密用户信息失败('.$errCode.')'];
// throw new Exception('解密失败: ' . $errCode);
}
}
// 注册
}

View File

@ -40,7 +40,7 @@ class Appversion extends Base{
// }
}
$num = Db::table('app_version_log')->where($parameter)->count();
$result = Db::table('app_version_log')->where($parameter)->order('is_del,id desc')->page($page,$this->page_num)->select();
$result = Db::table('app_version_log')->where($parameter)->order('id desc')->page($page,$this->page_num)->select();
if(!$pd){
$return_data['num'] = $num;
$return_data['data'] = $result;

View File

@ -0,0 +1,62 @@
<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use app\bj\controller\Common;
use think\Log;
use \think\Validate;
class Kitchenscale extends Base{
protected $page_num = 10;
protected $kitchenscale_db_msg = [
'cookbook'=>'app_user_cookbook',//菜谱表
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
'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
'user'=>'app_user_data',//banner
];
################################################################食材管理################################################################
################################################################食材管理################################################################
################################################################食材管理################################################################
public function food_ingredients_index_1($page = 1){
$data = input();
$pd = true;
$parameter = [];
if(array_key_exists('tt', $data)){
$page = $data['page_num'];
unset($data['page_num']);
unset($data['tt']);
$pd = false;
}
$cfc = Db::connect('cfc_db');
$num = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->count();
$result = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->order('is_del,id')->select();
if(!$pd){
$result['num'] = $num;
$result['data'] = $result;
return $this->msg(0,'success',$result);
}
$this->assign([
'result' => $result,
'num' => $num,
]);
return $this->fetch();
}
################################################################other################################################################
################################################################other################################################################
################################################################other################################################################
}

View File

@ -159,6 +159,42 @@
</li>
</ul>
</li>
<li>
<a href="javascript:;">
<i class="iconfont left-nav-li" lay-tips="厨房秤"></i>
<cite>厨房秤</cite>
<i class="iconfont nav_right">&#xe697;</i></a>
<ul class="sub-menu">
<li>
<a href="javascript:;">
<i class="iconfont"></i>
<cite>食材管理</cite>
<i class="iconfont nav_right">&#xe697;</i></a>
<ul class="sub-menu">
<li>
<a onclick="xadmin.add_tab('食材列表','/kitchenscale/food_ingredients_index_1')">
<i class="iconfont">&#xe6a7;</i>
<cite>食材列表</cite></a>
</li>
</ul>
</li>
</ul>
<ul class="sub-menu">
<li>
<a href="javascript:;">
<i class="iconfont">&#xe70b;</i>
<cite>菜谱管理</cite>
<i class="iconfont nav_right">&#xe697;</i></a>
<ul class="sub-menu">
<li>
<a onclick="xadmin.add_tab('菜谱列表','member-del.html')">
<i class="iconfont">&#xe6a7;</i>
<cite>菜谱列表</cite></a>
</li>
</ul>
</li>
</ul>
</li>
<!-- <li>
<a href="javascript:;">
<i class="iconfont left-nav-li" lay-tips="技术支持管理">&#xe723;</i>

View File

@ -0,0 +1,218 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>app版本管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="layui-fluid">
<div class="layui-row">
<form class="layui-form">
<div class="layui-form-item">
<label for="L_email" class="layui-form-label">
<span class="x-red"></span>卡片图标</label>
</label>
<div class="layui-input-inline">
<!-- <input type="text" id="L_email" name="email" required="" lay-verify="email" autocomplete="off" class="layui-input"> -->
<input type="file" id="upload_file_app" lay-verify="upload_file_app" name="file_data">
</div>
<!-- <div class="layui-form-mid layui-word-aux">
<span class="x-red">*</span>将会成为您唯一的登入名
</div> -->
</div>
<div class="layui-form-item">
<label for="card_name" class="layui-form-label">
<span class="x-red"></span>卡片名称</label>
<div class="layui-input-inline">
<input type="text" id="card_name" name="card_name" required="" lay-verify="card_name" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="page_url_record" class="layui-form-label">
<span class="x-red">*</span>手动记录路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_record" name="page_url_record" required="" lay-verify="page_url_record" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="page_url_report" class="layui-form-label">
<span class="x-red">*</span>报告页路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_report" name="page_url_report" required="" lay-verify="page_url_report" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="page_url_bluetooth" class="layui-form-label">
<span class="x-red">*</span>蓝牙路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_bluetooth" name="page_url_bluetooth" required="" lay-verify="page_url_bluetooth" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="content" class="layui-form-label">
<span class="x-red">*</span>描述</label>
<div class="layui-input-inline">
<input type="text" id="content" name="content" required="" lay-verify="content" autocomplete="off" class="layui-input"></div>
</div>
<div class="layui-form-item">
<label for="L_repass" class="layui-form-label"></label>
<!-- <div class="layui-btn" id="add" lay-filter="add" lay-submit="">增加</div>
<input value="登录" lay-submit lay-filter="add" type="submit" class="layui-btn"> -->
<button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
</div>
</form>
</div>
</div>
<script>
$(document).ready(function(){
var file_name_all = ''
var file_name = ''
var file_extension = ''
var pd = true
$('#upload_file_app').on('change', function() {
// 获取被选择的文件
var fileInput = $(this)[0];
var file = fileInput.files[0];
// 检查是否有文件被选择
if (file) {
// 获取文件的名称
file_name_all = file.name;
// 使用lastIndexOf和substring来获取文件名不包括后缀
var lastIndex = file_name_all.lastIndexOf('.');
file_name = lastIndex !== -1 ? file_name_all.substring(0, lastIndex) : file_name_all;
// 获取文件后缀
file_extension = lastIndex !== -1 ? file_name_all.substring(lastIndex + 1) : '';
$('#file_name').val(file_name)
console.log(file_name)
console.log(file_extension)
// formdata.append('apk',$('#upload_file_app')[0].files[0])
}
});
function add_data(){
if(pd === false){
return
}
var formdata = new FormData();
formdata.append('upload_file_app',$('#upload_file_app')[0].files[0])
formdata.append('card_name',$('#card_name').val())
formdata.append('page_url_record',$('#page_url_record').val())
formdata.append('page_url_report',$('#page_url_report').val())
formdata.append('page_url_bluetooth',$('#page_url_bluetooth').val())
formdata.append('content',$('#content').val())
formdata.append('file_extension',file_extension)
load()
pd = false
console.log('进来了')
$.ajax({
url:"/card/card_add_action", //请求的url地址
contentType:false,
processData:false,
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:formdata, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
pd = true
if(req.code == 0){
layer.alert("增加成功", {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}else{
layer.alert("增加失败"+req.msg, {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}
//请求成功时处理
console.log(req)
},
error:function(){
//请求出错处理
pd = true
}
});
}
layui.use(['form', 'layer','jquery'],function() {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//自定义验证规则
form.verify({
upload_file_app: function(value) {
if (value == '') {
return '请先选择文件';
}
},
card_name: function(value) {
if (value == '') {
return '必须填写文件名';
}
},
// version_num: [/[\d.]{0,9}$/, '版本号必须以大写V开头最多10个字符由数字跟英文"."组成)'],
content: function(value) {
if (value == '') {
return '必须填写描述';
}
},
});
//监听提交
form.on('submit(add)',function(data) {
//发异步把数据提交给php
add_data()
return false;
});
});
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
});
// });
</script>
</body>
</html>

View File

@ -0,0 +1,232 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>app版本管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="layui-fluid">
<div class="layui-row">
<form class="layui-form">
<div class="layui-form-item">
<label for="L_email" class="layui-form-label">
<span class="x-red"></span>卡片图标</label>
</label>
<div class="layui-input-inline">
<!-- <input type="text" id="L_email" name="email" required="" lay-verify="email" autocomplete="off" class="layui-input"> -->
<input type="file" id="upload_file_app" lay-verify="upload_file_app" name="file_data">
</div>
<!-- <div class="layui-form-mid layui-word-aux">
<span class="x-red">*</span>将会成为您唯一的登入名
</div> -->
</div>
<div class="layui-form-item">
<label for="card_name" class="layui-form-label">
<span class="x-red"></span>卡片名称</label>
<div class="layui-input-inline">
<input type="text" id="card_name" name="card_name" required="" lay-verify="card_name" autocomplete="off" class="layui-input" value="{$result.name}">
</div>
</div>
<div class="layui-form-item">
<label for="page_url_record" class="layui-form-label">
<span class="x-red">*</span>手动记录路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_record" name="page_url_record" required="" lay-verify="page_url_record" autocomplete="off" class="layui-input" value="{$result.page_url_record}"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="page_url_report" class="layui-form-label">
<span class="x-red">*</span>报告页路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_report" name="page_url_report" required="" lay-verify="page_url_report" autocomplete="off" class="layui-input" value="{$result.page_url_report}"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="page_url_bluetooth" class="layui-form-label">
<span class="x-red">*</span>蓝牙路径</label>
<div class="layui-input-inline">
<input type="text" id="page_url_bluetooth" name="page_url_bluetooth" required="" lay-verify="page_url_bluetooth" autocomplete="off" class="layui-input" value="{$result.page_url_bluetooth}"></div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label for="content" class="layui-form-label">
<span class="x-red">*</span>描述</label>
<div class="layui-input-inline">
<input type="text" id="content" name="content" required="" lay-verify="content" autocomplete="off" class="layui-input" value="{$result.content}"></div>
</div>
<div class="layui-form-item">
<label for="L_repass" class="layui-form-label"></label>
<!-- <div class="layui-btn" id="add" lay-filter="add" lay-submit="">增加</div>
<input value="登录" lay-submit lay-filter="add" type="submit" class="layui-btn"> -->
<button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
</div>
</form>
</div>
</div>
<!-- <div class="layui-fluid">
<div id="official_1" class="layui-row">
<div style="margin-left: 8%;margin-top: 5%;font-size: 25px;">请先下载模板文件,信息填写完成并上传该文件后点击生成</div>
<img style="width: 90%;margin-left: 3%;"src="/uploads/code_demo.png?v=1.0" alt="">
<div class="layui-form-item" style="width: 30%;margin-left: 33%;margin-top: 5%;">
<span>步骤1</span><a href="/uploads/code_demo.xlsx" class="layui-btn" lay-filter="add">下载模板文件</a>
</div>
<div class="layui-form-item" style="width: 50%;margin-left: 33%;margin-top: 5%;">
<span>步骤2</span><input type="file" id="data_excel" name="data_excel">
</div>
<div class="layui-form-item" style="width: 30%;margin-left: 33%;margin-top: 5%;">
<span>步骤3</span><button class="layui-btn" lay-filter="add" lay-submit="" onclick="add_data()">生成</button>
</div>
</div>
</div> -->
<script>
$(document).ready(function(){
var id = "{$result.id}"
var file_name_all = ''
var file_name = ''
var file_extension = ''
var pd = true
$('#upload_file_app').on('change', function() {
// 获取被选择的文件
var fileInput = $(this)[0];
var file = fileInput.files[0];
// 检查是否有文件被选择
if (file) {
// 获取文件的名称
file_name_all = file.name;
// 使用lastIndexOf和substring来获取文件名不包括后缀
var lastIndex = file_name_all.lastIndexOf('.');
file_name = lastIndex !== -1 ? file_name_all.substring(0, lastIndex) : file_name_all;
// 获取文件后缀
file_extension = lastIndex !== -1 ? file_name_all.substring(lastIndex + 1) : '';
$('#file_name').val(file_name)
// console.log($('#upload_file_app')[0].files[0])
// formdata.append('apk',$('#upload_file_app')[0].files[0])
}
});
function edit_data(){
if(pd === false){
return
}
var formdata = new FormData();
formdata.append('upload_file_app',$('#upload_file_app')[0].files[0])
formdata.append('card_name',$('#card_name').val())
formdata.append('page_url_record',$('#page_url_record').val())
formdata.append('page_url_report',$('#page_url_report').val())
formdata.append('page_url_bluetooth',$('#page_url_bluetooth').val())
formdata.append('content',$('#content').val())
formdata.append('file_extension',file_extension)
formdata.append('id',id)
load()
pd = false
console.log('进来了')
$.ajax({
url:"/card/card_edit_action", //请求的url地址
contentType:false,
processData:false,
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:formdata, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
pd = true
if(req.code == 0){
layer.alert("修改成功", {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}else{
layer.alert("修改失败"+req.msg, {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}
//请求成功时处理
console.log(req)
},
error:function(){
//请求出错处理
pd = true
}
});
}
layui.use(['form', 'layer','jquery'],function() {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//自定义验证规则
form.verify({
// upload_file_app: function(value) {
// if (value == '') {
// return '请先选择文件';
// }
// },
file_name: function(value) {
if (value == '') {
return '必须填写文件名';
}
},
// version_num: [/[\d.]{0,9}$/, '版本号必须以大写V开头最多10个字符由数字跟英文"."组成)'],
content: function(value) {
if (value == '') {
return '必须填写描述';
}
},
});
//监听提交
form.on('submit(add)',function(data) {
//发异步把数据提交给php
edit_data()
return false;
});
});
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
});
// });
</script>
</body>
</html>

View File

@ -0,0 +1,251 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>所有卡片管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<style>
/* th{
min-width:30px;
} */
</style>
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">演示</a>
<a>
<cite>导航元素</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
<button class="layui-btn" onclick="xadmin.open('添加版本','/card/card_add','80%','60%')"><i class="layui-icon"></i>添加</button>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
<table class="layui-table layui-form">
<thead>
<tr>
<th>ID</th>
<th>类别</th>
<th>类目名称</th>
<th>创建时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody id='content'>
{volist name="result" id="vo"}
<tr>
<td>{$vo.id}</td>
<td>一级</td>
<td>{$vo.name}</td>
<td>{$vo.create_time}</td>
<td class="td-status">
{if condition="$vo.is_del == 1"}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
{else /}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>
{/if}
</td>
<td>
<button class="layui-btn" onclick="xadmin.open('修改','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
<button class="layui-btn" onclick="xadmin.open('查看下级','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
<div class="layui-card-body ">
<div id="page" style="text-align: center;">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var form
layui.use(['laydate','form'], function(){
var laydate = layui.laydate;
form = layui.form;
});
var page_num;
var laypage;
var all_page = "{$num}";
layui.use('laypage', function () {
laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page',
count: all_page, //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
find("n")
}
}
});
});
/*用户-停用*/
function stop_it(obj,id){
// return
var title = '',is_del,num
if($(obj).attr('title')=='启用'){
title = '停用'
is_del = 1
num = 5
}else{
title = '启用'
is_del = 0
num = 6
}
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
layer.confirm('确认要'+ title +'吗?',function(index){
load()
$.ajax({
url:"/card/card_del", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id,'is_del':is_del}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
//请求成功时处理
if(req['code'] == 0){
//发异步把用户状态进行更改
$(obj).attr('title',title)
if(is_del == 1){
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
}else{
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
}
layer.msg('已'+ title,{icon: num});
}else{
layer.msg('操作失败!',{icon: 5});
}
},
error:function(){
//请求出错处理
}});
});
}
function find(pd) {
if(!page_num || pd == 'y'){
page_num = 1;
}
page({
"status_num":$('#status_num').val(),
"tel":$('#tel').val(),
"email":$('#email').val(),
"s_time":$('#s_time').val(),
"e_time":$('#e_time').val(),
"page_num":page_num,
"tt":1},pd);
}
function page(data,pd) {
console.log(data)
load()
$.ajax({
url: "member_list", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success: function (req) {
console.log(req)
c_load();
if (req['code'] == 0) {
var str,str_s,str_c,str_all="";
for (let i = 0; i < req['data']['data'].length; i++) {
if(req['data']['data'][i]['is_del'] == 1){
str = '<span onclick="member_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
}else{
str = '<span onclick="member_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
}
str_c = "<tr>"+
'<td><input type="checkbox" name="id" value="'+req['data']['data'][i]['id']+'" lay-skin="primary"></td>'+
'<td>'+req['data']['data'][i]['id']+'</td>'+
'<td>'+req['data']['data'][i]['token']+'</td>'+
'<td>'+req['data']['data'][i]['tel']+'</td>'+
'<td>'+req['data']['data'][i]['email']+'</td>'+
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
'<td class="td-status">'+
str+
'</td>'
'</tr>'
str_all = str_all+str_c;
}
$('#content').html(str_all);
form.render();
if(pd == 'y'){
$("#page").html("")
laypage.render({
elem: 'page',
count: req['data']['num'], //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
// page({"page":page_num,"tt":1});
find("n")
}
}
});
}
} else {
layer.msg(req['msg'])
}
},
error: function () {
//请求出错处理
}
});
}
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
</script>
</html>

View File

@ -0,0 +1,251 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>所有卡片管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<style>
/* th{
min-width:30px;
} */
</style>
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">演示</a>
<a>
<cite>导航元素</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
<button class="layui-btn" onclick="xadmin.open('添加版本','/card/card_add','80%','60%')"><i class="layui-icon"></i>添加</button>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
<table class="layui-table layui-form">
<thead>
<tr>
<th>ID</th>
<th>类别</th>
<th>类目名称</th>
<th>创建时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody id='content'>
{volist name="result" id="vo"}
<tr>
<td>{$vo.id}</td>
<td>一级</td>
<td>{$vo.name}</td>
<td>{$vo.create_time}</td>
<td class="td-status">
{if condition="$vo.is_del == 1"}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
{else /}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>
{/if}
</td>
<td>
<button class="layui-btn" onclick="xadmin.open('修改','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
<button class="layui-btn" onclick="xadmin.open('查看下级','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
<div class="layui-card-body ">
<div id="page" style="text-align: center;">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var form
layui.use(['laydate','form'], function(){
var laydate = layui.laydate;
form = layui.form;
});
var page_num;
var laypage;
var all_page = "{$num}";
layui.use('laypage', function () {
laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page',
count: all_page, //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
find("n")
}
}
});
});
/*用户-停用*/
function stop_it(obj,id){
// return
var title = '',is_del,num
if($(obj).attr('title')=='启用'){
title = '停用'
is_del = 1
num = 5
}else{
title = '启用'
is_del = 0
num = 6
}
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
layer.confirm('确认要'+ title +'吗?',function(index){
load()
$.ajax({
url:"/card/card_del", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id,'is_del':is_del}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
//请求成功时处理
if(req['code'] == 0){
//发异步把用户状态进行更改
$(obj).attr('title',title)
if(is_del == 1){
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
}else{
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
}
layer.msg('已'+ title,{icon: num});
}else{
layer.msg('操作失败!',{icon: 5});
}
},
error:function(){
//请求出错处理
}});
});
}
function find(pd) {
if(!page_num || pd == 'y'){
page_num = 1;
}
page({
"status_num":$('#status_num').val(),
"tel":$('#tel').val(),
"email":$('#email').val(),
"s_time":$('#s_time').val(),
"e_time":$('#e_time').val(),
"page_num":page_num,
"tt":1},pd);
}
function page(data,pd) {
console.log(data)
load()
$.ajax({
url: "member_list", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success: function (req) {
console.log(req)
c_load();
if (req['code'] == 0) {
var str,str_s,str_c,str_all="";
for (let i = 0; i < req['data']['data'].length; i++) {
if(req['data']['data'][i]['is_del'] == 1){
str = '<span onclick="member_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
}else{
str = '<span onclick="member_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
}
str_c = "<tr>"+
'<td><input type="checkbox" name="id" value="'+req['data']['data'][i]['id']+'" lay-skin="primary"></td>'+
'<td>'+req['data']['data'][i]['id']+'</td>'+
'<td>'+req['data']['data'][i]['token']+'</td>'+
'<td>'+req['data']['data'][i]['tel']+'</td>'+
'<td>'+req['data']['data'][i]['email']+'</td>'+
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
'<td class="td-status">'+
str+
'</td>'
'</tr>'
str_all = str_all+str_c;
}
$('#content').html(str_all);
form.render();
if(pd == 'y'){
$("#page").html("")
laypage.render({
elem: 'page',
count: req['data']['num'], //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
// page({"page":page_num,"tt":1});
find("n")
}
}
});
}
} else {
layer.msg(req['msg'])
}
},
error: function () {
//请求出错处理
}
});
}
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
</script>
</html>

View File

@ -0,0 +1,251 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>所有卡片管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<style>
/* th{
min-width:30px;
} */
</style>
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">演示</a>
<a>
<cite>导航元素</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
<button class="layui-btn" onclick="xadmin.open('添加版本','/card/card_add','80%','60%')"><i class="layui-icon"></i>添加</button>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
<table class="layui-table layui-form">
<thead>
<tr>
<th>ID</th>
<th>类别</th>
<th>类目名称</th>
<th>创建时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody id='content'>
{volist name="result" id="vo"}
<tr>
<td>{$vo.id}</td>
<td>一级</td>
<td>{$vo.name}</td>
<td>{$vo.create_time}</td>
<td class="td-status">
{if condition="$vo.is_del == 1"}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
{else /}
<span onclick="stop_it(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>
{/if}
</td>
<td>
<button class="layui-btn" onclick="xadmin.open('修改','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
<button class="layui-btn" onclick="xadmin.open('查看下级','/card/card_edit?id={$vo.id}','80%','60%')">修改</button>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
<div class="layui-card-body ">
<div id="page" style="text-align: center;">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var form
layui.use(['laydate','form'], function(){
var laydate = layui.laydate;
form = layui.form;
});
var page_num;
var laypage;
var all_page = "{$num}";
layui.use('laypage', function () {
laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page',
count: all_page, //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
find("n")
}
}
});
});
/*用户-停用*/
function stop_it(obj,id){
// return
var title = '',is_del,num
if($(obj).attr('title')=='启用'){
title = '停用'
is_del = 1
num = 5
}else{
title = '启用'
is_del = 0
num = 6
}
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
layer.confirm('确认要'+ title +'吗?',function(index){
load()
$.ajax({
url:"/card/card_del", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id,'is_del':is_del}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
//请求成功时处理
if(req['code'] == 0){
//发异步把用户状态进行更改
$(obj).attr('title',title)
if(is_del == 1){
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
}else{
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
}
layer.msg('已'+ title,{icon: num});
}else{
layer.msg('操作失败!',{icon: 5});
}
},
error:function(){
//请求出错处理
}});
});
}
function find(pd) {
if(!page_num || pd == 'y'){
page_num = 1;
}
page({
"status_num":$('#status_num').val(),
"tel":$('#tel').val(),
"email":$('#email').val(),
"s_time":$('#s_time').val(),
"e_time":$('#e_time').val(),
"page_num":page_num,
"tt":1},pd);
}
function page(data,pd) {
console.log(data)
load()
$.ajax({
url: "member_list", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success: function (req) {
console.log(req)
c_load();
if (req['code'] == 0) {
var str,str_s,str_c,str_all="";
for (let i = 0; i < req['data']['data'].length; i++) {
if(req['data']['data'][i]['is_del'] == 1){
str = '<span onclick="member_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
}else{
str = '<span onclick="member_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
}
str_c = "<tr>"+
'<td><input type="checkbox" name="id" value="'+req['data']['data'][i]['id']+'" lay-skin="primary"></td>'+
'<td>'+req['data']['data'][i]['id']+'</td>'+
'<td>'+req['data']['data'][i]['token']+'</td>'+
'<td>'+req['data']['data'][i]['tel']+'</td>'+
'<td>'+req['data']['data'][i]['email']+'</td>'+
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
'<td class="td-status">'+
str+
'</td>'
'</tr>'
str_all = str_all+str_c;
}
$('#content').html(str_all);
form.render();
if(pd == 'y'){
$("#page").html("")
laypage.render({
elem: 'page',
count: req['data']['num'], //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
// page({"page":page_num,"tt":1});
find("n")
}
}
});
}
} else {
layer.msg(req['msg'])
}
},
error: function () {
//请求出错处理
}
});
}
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
</script>
</html>

View File

@ -5,6 +5,7 @@ namespace app\app\controller;
use think\Db;
use PHPMailer\PHPMailer\PHPMailer;
use app\app\controller\Wechat;// 引入Wechat服务类
class Login extends Base{
@ -90,6 +91,7 @@ class Login extends Base{
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: (register_action)" . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
@ -154,6 +156,7 @@ class Login extends Base{
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: (reset_password)" . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
@ -161,7 +164,6 @@ class Login extends Base{
}
}
// 登录
public function login_action($data = ['data'=>'18530934717','validate_data'=>'0932','type'=>'login','validate_type'=>'password']){
try {
@ -238,6 +240,7 @@ class Login extends Base{
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: (login_action)" . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
@ -245,6 +248,82 @@ class Login extends Base{
}
}
// 微信手机号快捷登录
public function wechat_quick_login(){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('code', $data)){
// return $this->msg(10001,'');
return $this->msg(10001,'code is miss');
}
if(!array_key_exists('encryptedData', $data)){
return $this->msg(10001,'encryptedData is miss');
}
if(!array_key_exists('iv', $data)){
return $this->msg(10001,'iv is miss');
}
// 校验参数
if (empty($data['code'])) {
return $this->msg(10001,'code is miss.');
}
if (empty($data['encryptedData'])) {
return $this->msg(10001,'encryptedData is miss.');
}
if (empty($data['iv'])) {
return $this->msg(10001,'iv is miss.');
}
// 调用Wechat服务类处理微信登录逻辑
$wechatService = new Wechat();
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
// die;
if($result['code'] == 0){
// return $this->msg($result['code'],$result['msg']);
$user_data = Db::table($this->login_use_db_name['1'])->where(['tel'=>$result['data']['phoneNumber'],'is_del'=>0])->find();
if($user_data){
Db::table($this->login_use_db_name['1'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
$return_data = $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
}else{
$set_data['password'] = '';
$set_data['tel'] = $result['data']['phoneNumber'];
$set_data['head_pic'] = $this->default_head_pic;
$set_data['nickname'] = '用户'.$result['data']['phoneNumber'];
$set_data['create_time'] = date('Y-m-d H:i:s');
$set_data['login_time'] = date('Y-m-d H:i:s');
$set_data['token'] = md5($result['data']['phoneNumber'].$this->create_random_string(12).time());
$set_user_result = Db::table($this->login_use_db_name['1'])->insertGetId($set_data);
if($set_user_result){
$return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$set_user_result],'登录成功');
}else{
$return_data = $this->msg(10002);
}
}
return $return_data;
}else{
return $this->msg($result['code'],$result['msg']);
}
} 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'] .= "方法: (wechat_quick_login)" . "\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 user_quit_account($data=['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
@ -266,8 +345,6 @@ class Login extends Base{
}else{
$return_data = $this->msg(10002);
}
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
@ -279,6 +356,7 @@ class Login extends Base{
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: (user_quit_account)" . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
@ -286,8 +364,6 @@ class Login extends Base{
}
}
// 删除账号
public function delete_account($data=['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
@ -316,6 +392,7 @@ class Login extends Base{
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: (delete_account)" . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
@ -336,7 +413,7 @@ class Login extends Base{
* $type验证类型是注册用还是其他用途 字符串 默认register注册register、login、reset_password
* $road是手机还是邮箱还是其他 字符串 默认tel或email
*/
public function send_phone_email_code($data = ['data'=>'18530934717']){
public function send_phone_email_code($data = ['data'=>'18736019909']){
if(count(input('post.')) > 0){
$data = input('post.');
@ -352,6 +429,7 @@ class Login extends Base{
$num = mt_rand(100000,999999);
if (preg_match('/^\d{11}$/', $data['data'])) {
$result = $this->send_tel_code($data['data'],$num);
// return $this->msg($result);
$road = 'tel';
}else{
$result = $this->send_email_code([$data['data']],['title'=>'体测APP验证码','from_user_name'=>'体测APP','content'=>$num]);
@ -390,7 +468,12 @@ class Login extends Base{
$postData = array(
'phone' => $tel,
// 'content' => '您好欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码三分钟内有效,若非本人操作,请忽略!'
'content' => '【Reedaw】您好欢迎使用Reedaw您的验证码是'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信'
// 'content' => '【Reedaw】您好欢迎使用Reedaw您的验证码是'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信'
'content' => '【巨天】您好欢迎使用Reedaw您的手机验证码是'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信'
// 'content' => '【小白秤】您好欢迎使用Reedaw您的手机验证码是'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信'
// 'content' => '【品传科技】您好欢迎使用Reedaw您的手机验证码是'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信'
// 'content' => '【巨天】您好,欢迎使用巨天,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略!'
);
$postData = json_encode($postData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

View File

@ -7,6 +7,9 @@ use think\Db;
class Msginformation extends Base{
protected $judge_wechat_release = false;
protected $msginformation_use_db_name = [
'1'=>'admin_editor_text_content',
'2'=>'admin_editor_text_like_up_log',
@ -251,6 +254,9 @@ class Msginformation extends Base{
################################################################业务################################################################
################################################################get_sector_label_msg
public function get_sector_label_msg_action($data){
$Template_arr = [
1=>[
'id'=>'1',
@ -266,6 +272,17 @@ class Msginformation extends Base{
]
],
];
if($this->judge_wechat_release === true){
$Template_arr = [
1=>[
'id'=>'1',
'name'=>'推荐',
'loop_data'=>[],
'list'=>[
]
],
];
}
// 获取需要版块id start
$sector = Db::query("
SELECT
@ -316,7 +333,9 @@ class Msginformation extends Base{
'page_num'=>$this->page_num,
'content_data'=>[]
];
// return $this->msg($return_result);
if($this->judge_wechat_release === true){
return $this->msg($return_result);
}
if($data['type'] != 0){
$type_str = " AND type LIKE '%".$data['type']."%'";
}else{
@ -499,5 +518,16 @@ class Msginformation extends Base{
}
################################################################小工具################################################################
################################################################小工具################################################################
################################################################小工具################################################################
################################################################小工具################################################################
################################################################小工具################################################################
// 判断微信发版工具
public function judge_wechat_release(){
}
}

View File

@ -20,7 +20,7 @@ class Myinformation extends Base{
################################################################接口################################################################
// 获取账号下信息
public function get_my_account_msg($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_my_account_msg($data = ['token'=>'e0966788d02cc93290d9d674921d9715']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){

View File

@ -0,0 +1,124 @@
<?php
namespace app\app\controller;
use think\Db;
use PHPMailer\PHPMailer\PHPMailer;
class Wechat extends Base{
// reedaw的小程序信息
private $app_id = 'wx9c0b7a436ada6d1e'; // 微信小程序的AppID
private $app_secret = 'ed7cda5874f0eef3360e782a3db73c80'; // 微信小程序的AppSecret
// ed7cda5874f0eef3360e782a3db73c80
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
/**
* 处理微信登录
*
* @param string $code 微信登录凭证
* @param string $encryptedData 加密的用户信息
* @param string $iv 解密算法的初始向量
* @return array
*/
public function handleWechatLogin($code, $encryptedData, $iv)
{
// try {
// 1. 通过code获取openid和session_key
$sessionData = $this->getSessionKey($code);
if (empty($sessionData['openid']) || empty($sessionData['session_key'])) {
// throw new Exception('获取openid或session_key失败');
// return false;
// return $this->msg(10001);
return ['code'=>10002,'msg'=>'获取openid或session_key失败'];
}
// 2. 解密用户信息
$userInfo = $this->decryptData($encryptedData, $iv, $sessionData['session_key']);
if(array_key_exists('phoneNumber',$userInfo)){
return ['code'=>0,'msg'=>'seccess','data'=>$userInfo];
}else{
return ['code'=>10002,'msg'=>'解密用户信息失败'];
}
// if (empty($userInfo['phoneNumber'])) {
// // throw new Exception('获取手机号失败');
// }else{
// }
// // 3. 保存或更新用户信息
// $user = User::where('openid', $sessionData['openid'])->find();
// if (!$user) {
// $user = new User();
// $user->openid = $sessionData['openid'];
// }
// $user->phone = $userInfo['phoneNumber'];
// $user->save();
// 返回成功信息
// return ['code' => 0, 'msg' => '登录成功', 'data' => $user];
// } catch (Exception $e) {
// // 返回错误信息
// return ['code' => 500, 'msg' => $e->getMessage()];
// }
}
/**
* 通过code获取openid和session_key
*
* @param string $code
* @return array
* @throws Exception
*/
private function getSessionKey($code)
{
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->app_id}&secret={$this->app_secret}&js_code={$code}&grant_type=authorization_code";
$result = file_get_contents($url);
$data = json_decode($result, true);
if (isset($data['openid']) && isset($data['session_key'])) {
return $data;
} else {
return ['code'=>10002,'msg'=>'获取openid或session_key失败'];
}
}
/**
* 解密用户信息
*
* @param string $encryptedData
* @param string $iv
* @param string $sessionKey
* @return array
* @throws Exception
*/
private function decryptData($encryptedData, $iv, $sessionKey)
{
// require_once 'wx_crypt/WXBizDataCrypt.php'; // 引入微信解密类
// require_once env('root_path') . 'extend/wx_crypt/WXBizDataCrypt.php';
// dump(ROOT_PATH . 'extend\wx_crypt\wxBizDataCrypt.php');
require_once ROOT_PATH . 'extend\wx_crypt\wxBizDataCrypt.php';
$pc = new \WXBizDataCrypt($this->app_id, $sessionKey);
$errCode = $pc->decryptData($encryptedData, $iv, $data);
if ($errCode == 0) {
return json_decode($data, true);
} else {
return ['code'=>10002,'msg'=>'解密用户信息失败('.$errCode.')'];
// throw new Exception('解密失败: ' . $errCode);
}
}
// 注册
}

View File

@ -33,4 +33,356 @@ class Qrcode extends Base{
return $this->fetch();
}
##################################################################小贴士视频部分start##################################################################
##################################################################小贴士视频部分start##################################################################
##################################################################小贴士视频部分start##################################################################
// 小贴士的前端二维码页面
public function little_tips_project(){
$qrcode_db = Db::connect('qrcode_db');
// $temporary_data = $qrcode_db->table('little_tips_data')->where(['is_del'=>0])->order('id desc')->select();
// $temporary_data = $qrcode_db->table('little_tips_data')->where(['is_del'=>0])->order('id desc')->select();
$temporary_data2 = $qrcode_db->table('little_tips_label')->where(['type'=>1])->order('is_del,id')->select();
$title = $qrcode_db->table('little_tips_label')->where(['id'=>3])->find();
// dump($temporary_data);
// dump($temporary_data2);
// dump($title);
// die;
$this->assign([
'label' => $temporary_data2,
'title' => $title,
'default_id' => $temporary_data2[0]['id'],
]);
return $this->fetch();
}
// 小贴士前端页面获取数据
public function little_tips_get_video_list(){
$data = input();
$qrcode_db = Db::connect('qrcode_db');
$temporary_data = $qrcode_db->table('little_tips_data')->where(['device_category'=>$data['id'],'is_del'=>0])->order('id desc')->select();
return $this->msg($temporary_data);
}
// 小贴士视频上传管理页面
public function little_tips_project_set_page(){
$qrcode_db = Db::connect('qrcode_db');
$temporary_data = $qrcode_db->table('little_tips_data')
->alias('a')
->join('little_tips_label b','a.device_category = b.id','LEFT')
->field('a.*,b.type_name')
->order('is_del,id desc')
->select();
$temporary_data2 = $qrcode_db->table('little_tips_label')->where(['type'=>1])->order('is_del,id desc')->select();
$title = $qrcode_db->table('little_tips_label')->where(['id'=>3])->find();
$this->assign([
'data' => $temporary_data,
'label' => $temporary_data2,
'title' => $title,
]);
return $this->fetch();
}
public function little_tips_project_upload_action(){
// return $this->msg([]);
$temporary_data = [];
$qrcode_db = Db::connect('qrcode_db');
$device_model = request()->param('device_model_name');
$device_model_type = request()->param('device_model_type');
$device_describe = request()->param('device_describe');
$device_category = request()->param('device_category');
$image_type = request()->param('image_type');
$video_type = request()->param('video_type');
if(!$device_model){
return $this->msg(10001,'设备名称不能为空');
}
$temporary_data = [];
$temporary_data['device_model'] = $device_model;
if($device_describe){
$temporary_data['device_describe'] = $device_describe;
}
if($device_model_type){
$temporary_data['device_type'] = $device_model_type;
}
if($device_category){
$temporary_data['device_category'] = $device_category;
}
// dump($image_type);
// dump($video_type);
if($image_type == 'yes'){
$pic = request()->file('image');
$name_pic = $pic->getInfo()['name'];
$pathinfo_pic = pathinfo($name_pic);
$extension_pic = strtolower($pathinfo_pic['extension']); // 转换为小写以进行不区分大小写的比较
$new_filename_pic = 'pic_'.time().$this->generateRandomString(). '.' . $extension_pic;
$info_pic = $pic->validate(['size'=>10*1024*1024,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_pic);
if(!$info_pic){
// 上传失败获取错误信息
return $this->msg(10010,$pic->getError());
}
$temporary_data['pic_url'] = "https://tc.pcxbc.com/teaching_video/".$new_filename_pic;
$temporary_data['pic_name'] = $new_filename_pic;
}
if($video_type == 'yes'){
$video = request()->file('video');
$name_video = $video->getInfo()['name'];
$pathinfo_video = pathinfo($name_video);
$extension_video = strtolower($pathinfo_video['extension']); // 转换为小写以进行不区分大小写的比较
$new_filename_video = 'pic_'.time().$this->generateRandomString(). '.' . $extension_video;
$info_video = $video->validate(['size'=>90*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
if(!$info_video){
// 上传失败获取错误信息
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $new_filename_pic);
return $this->msg(10011,$video->getError());
}
$temporary_data['video_url'] = "https://tc.pcxbc.com/teaching_video/".$new_filename_video;
$temporary_data['video_name'] = $new_filename_video;
}
// dump($temporary_data);
// die;
// 判断是修改还是新建
$device_data = $qrcode_db->table('little_tips_data')->where(['device_model'=>$temporary_data['device_model']])->find();
if($device_data){
// 修改
// unset($temporary_data['create_time']);
$result = $qrcode_db->table('little_tips_data')
->where(['device_model'=>$temporary_data['device_model']])
->update($temporary_data);
// 删除刚才存储的图片和视频文件
if($image_type == 'yes'){
if($device_data['pic_name']){
if (file_exists(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['pic_name'])) {
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['pic_name']);
}
}
}
if($video_type == 'yes'){
if($device_data['video_name']){
if (file_exists(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['video_name'])) {
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['video_name']);
}
}
}
}else{
$temporary_data['create_time'] = date('Y-m-d H:i:s');
$result = $qrcode_db->table('little_tips_data')->insertGetId($temporary_data);
}
if($result){
return $this->msg([]);
}else{
return $this->msg(10002,'操作失败');
}
// // dump($device_model);
// // dump($device_model_type);
// // dump($device_describe);
// // dump($device_category);
// // die;
// if(!$device_model){
// return $this->msg(10001,'设备名称不能为空');
// }
// dump($device_model);
// dump($devicdevice_model_typee_model);
// dump($device_category);
// dump($device_describe);
// dump($pic);
// dump($video);
// die;
// // if(!$device_model_type){
// // return $this->msg(10001,'设备类型不能为空');
// // }
// // if(!$device_category){
// // return $this->msg(10001,'设备设备分类不能为空');
// // }
// if(!$pic || !$video){
// return $this->msg(10001,'未选择图片或者视频');
// }else{
// // $name_pic = $pic->getInfo()['name'];
// // $pathinfo_pic = pathinfo($name_pic);
// // $extension_pic = strtolower($pathinfo_pic['extension']); // 转换为小写以进行不区分大小写的比较
// // $new_filename_pic = 'pic_'.time().$this->generateRandomString(). '.' . $extension_pic;
// // $name_video = $video->getInfo()['name'];
// // $pathinfo_video = pathinfo($name_video);
// // $extension_video = strtolower($pathinfo_video['extension']); // 转换为小写以进行不区分大小写的比较
// // $new_filename_video = 'pic_'.time().$this->generateRandomString(). '.' . $extension_video;
// // $info_pic = $pic->validate(['size'=>10*1024*1024,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_pic);
// // if(!$info_pic){
// // // 上传失败获取错误信息
// // return $this->msg(10010,$pic->getError());
// // }
// // $info_video = $video->validate(['size'=>90*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
// // if(!$info_video){
// // // 上传失败获取错误信息
// // unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $new_filename_pic);
// // return $this->msg(10011,$video->getError());
// // }
// $temporary_data = [
// 'device_model'=>$device_model,
// 'device_describe'=>$device_describe,
// 'device_type'=>$device_model_type,
// 'device_category'=>$device_category,
// 'pic_url'=>"https://tc.pcxbc.com/teaching_video/".$new_filename_pic,
// 'video_url'=>"https://tc.pcxbc.com/teaching_video/".$new_filename_video,
// 'pic_name'=>$new_filename_pic,
// 'video_name'=>$new_filename_video,
// 'create_time'=>date('Y-m-d H:i:s'),
// ];
// if($device_data){
// unset($temporary_data['create_time']);
// $result = $qrcode_db->table('little_tips_data')
// ->where(['device_model'=>$temporary_data['device_model']])
// ->update($temporary_data);
// // 删除刚才存储的图片和视频文件
// if (file_exists(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['pic_name'])) {
// unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['pic_name']);
// }
// if (file_exists(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['video_name'])) {
// unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['video_name']);
// }
// return $this->msg([]);
// }else{
// $result = $qrcode_db->table('little_tips_data')->insertGetId($temporary_data);
// }
// if($result){
// return $this->msg([]);
// }else{
// return $this->msg(10002,'添加失败');
// }
// }
}
// 小贴士下架操作
public function little_tips_is_del_update(){
$data = input();
$qrcode_db = Db::connect('qrcode_db');
if(!array_key_exists('id', $data)){
return $this->msg(10001,'id缺失');
}
if(!array_key_exists('type', $data)){
return $this->msg(10001,'type缺失');
}
$device_data = $qrcode_db->table('little_tips_data')->where(['id'=>$data['id']])->field('pic_name,video_name')->find();
if($device_data){
$temporary_data = $qrcode_db->table('little_tips_data')->where(['id'=>$data['id']])->update(['is_del'=>$data['type']]);
if($temporary_data){
return $this->msg([]);
}else{
return $this->msg(10002,'操作失败');
}
}else{
return $this->msg(10002,'未找到对应设备信息');
}
}
// 小贴士删除操作
public function little_tips_del_action(){
$data = input();
$qrcode_db = Db::connect('qrcode_db');
if(!array_key_exists('id', $data)){
return $this->msg(10001,'id缺失');
}
$device_data = $qrcode_db->table('little_tips_data')->where(['id'=>$data['id']])->field('pic_name,video_name')->find();
$temporary_data = $qrcode_db->table('little_tips_data')->where(['id'=>$data['id']])->delete();
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['pic_name']);
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $device_data['video_name']);
if($temporary_data){
return $this->msg([]);
}else{
return $this->msg(10002,'操作失败');
}
}
##################################################################小贴士视频部分end##################################################################
##################################################################小贴士视频部分end##################################################################
##################################################################小贴士视频部分end##################################################################
public function add_label_action(){
$data = input();
$qrcode_db = Db::connect('qrcode_db');
if(!array_key_exists('label', $data)){
return $this->msg(10001,'label缺失');
}
$device_data = $qrcode_db->table('little_tips_label')->insert([
'type_name'=>$data['label'],
'create_time'=>date('Y-m-d H:i:s'),
'type'=>1,
]);
if($device_data){
return $this->msg([]);
}else{
return $this->msg(10002,'操作失败');
}
}
public function update_title_action(){
$data = input();
$qrcode_db = Db::connect('qrcode_db');
if(!array_key_exists('title', $data)){
return $this->msg(10001,'title缺失');
}
$device_data = $qrcode_db->table('little_tips_label')->where(['id'=>3])->update([
'type_name'=>$data['title'],
]);
if($device_data){
return $this->msg([]);
}else{
return $this->msg(10002,'操作失败');
}
}
##################################################################以下是工具部分##################################################################
##################################################################以下是工具部分##################################################################
##################################################################以下是工具部分##################################################################
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;
}
}

View File

@ -0,0 +1,382 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="full-screen" content="true">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>小贴士</title>
<script src="/x_admin/js/jq.js"></script>
<style>
*{
padding: 0 0;
margin: 0 0;
}
.yc{
display: none;
}
.big_box{
width: 100vw;
height: 100vh;
padding-bottom: 6vw;
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
background: linear-gradient(to top right, #00679C, #00BAA0);
display: flex;
overflow: auto;
flex-direction: column;
flex-wrap: nowrap;
align-items: center;
}
.title_data{
width: 100vw;
height: 12vw;
line-height: 12vw;
text-align: center;
font-size: 5vw;
background-color: #BEE0DF;
}
.label{
width: 100vw;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-top: 3vw;
}
.label_c{
margin: 1vw;
border-radius: 5vw;
padding: 1vw 3vw;
box-sizing: border-box;
}
.label_c_color1{
background-color: #E9FDFE;
color: black;
}
.label_c_color2{
background-color: #333333;
color: white;
}
.content{
width: 100vw;
height: 75vh;
display: flex;
flex-wrap: wrap;
overflow: auto;
justify-content: flex-start;
flex-direction: row;
}
.c_c{
width: 45vw;
height: 75vw;
border-radius: 2.5vw;
background-color: #BFDEE0;
position: relative;
margin-bottom: 3vw;
margin-left: 3vw;
}
.c_c_c{
width: 94%;
height: 88%;
border-radius: 2.5vw;
background-color: white;
position: absolute;
top: 6%;
left: 0;
right: 0;
margin: 0 auto;
}
.c_c_c_name{
position: absolute;
top: 58%;
left: 0%;
width: 100%;
font-size: 4vw;
font-weight: bold;
text-align: center;
}
.c_c_c_type{
position: absolute;
top: 66.5%;
left: 4%;
width: 92%;
font-size: 3.2vw;
font-weight: bold;
text-align: center;
}
.c_c_c_describe{
position: absolute;
top: 75%;
left: 4%;
width: 92%;
height: 14%;
font-size: 3vw;
color: #B4B4B4;
text-align: center;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.c_c_c_pic{
position: absolute;
top: 2%;
right: 4%;
width: 92%;
height: 55%;
}
.c_c_c_play{
position: absolute;
top: 40%;
left: 70%;
width: 12vw;
height: 12vw;
background: url(/tsf/play.png) no-repeat;
background-position: center;
background-size: cover;
}
.c_c_c_copy{
position: absolute;
top: 92%;
right: 0;
left: 0;
margin: 0 auto;
width: 26vw;
height: 6vw;
background-color: #37CC92;
line-height: 6vw;
text-align: center;
font-weight: bold;
color: white;
border-radius: 5vw;
box-shadow: 1px 1px 1px 1px black;
font-size: 3.6vw;
}
.play_page{
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
}
.play_page_title{
width: 20vw;
height: 20vw;
position: absolute;
top: 1vw;
right: 1vw;
font-size: 7vw;
color: white;
text-align: center;
line-height: 20vw;
z-index: 99;
}
.play_page_content{
width: 90vw;
position: absolute;
top: 12vw;
left: 5vw;
}
.zg{
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
/* background-color: rgba(0, 0, 0, 0.4); */
z-index: 9999;
}
.zg_content{
min-width: 20vw;
max-width: 40vw;
height: auto;
word-break: break-word; /* 更激进地在任意字符间换行 */
overflow-wrap: break-word; /* 优先在单词间换行 */
white-space: pre-wrap; /* 保留空白符序列,但正常换行 */
background-color: rgba(0, 0, 0, 0.8);
color: white;
position: absolute;
top: 40%;
left: 0;
right: 0;
margin: 0 auto;
padding: 2vw;
box-sizing: border-box;
text-align: center;
}
.zg_content2{
min-width: 20vw;
max-width: 40vw;
height: auto;
word-break: break-word; /* 更激进地在任意字符间换行 */
overflow-wrap: break-word; /* 优先在单词间换行 */
white-space: pre-wrap; /* 保留空白符序列,但正常换行 */
background-color: rgba(0, 0, 0, 0.8);
color: white;
position: absolute;
top: 40%;
left: 0;
right: 0;
margin: 0 auto;
padding: 2vw;
box-sizing: border-box;
text-align: center;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="title_data">{$title.type_name}</div>
<div class="label">
{volist name="label" id="vo"}
<span id="label_id_{$vo.id}" class="label_c label_c_color1" onclick="get_video('{$vo.id}')">{$vo.type_name}</span>
{/volist}
</div>
<div style="height: 5vw;width: 80vw;border-top: 1px dashed #72C9D2;margin-top: 3vw;"></div>
<div class="content">
</div>
<div class="play_page">
<div class="play_page_title">关闭</div>
<div class="play_page_content"></div>
</div>
<div class="zg yc">
<div class="zg_content">加载中...</div>
</div>
<div class="zg_content2 yc"></div>
</div>
</body>
</html>
<script>
var default_id = "{$default_id}"
$('.play_page').hide();
function play(str){
// 如果已经存在 video 元素,先移除
const existingVideo = document.querySelector('video');
if (existingVideo) {
existingVideo.remove();
}
// 获取对应的视频链接
const videoUrl = str;
if (!videoUrl) {
alert('未找到对应的视频链接!');
return;
}
// 动态创建 video 元素
const video = document.createElement('video');
video.src = videoUrl;
video.controls = true; // 显示控制条
video.autoplay = true; // 自动播放
video.style.width = '100%'; // 设置视频宽度
video.style.marginTop = '20px'; // 设置视频上边距
// 将 video 元素添加到页面中
document.querySelector('.play_page_content').appendChild(video);
$('.play_page').show();
}
$('.play_page_title').on('click',function(){
$('.play_page').hide();
const existingVideo = document.querySelector('video');
if (existingVideo) {
existingVideo.remove();
}
})
get_video(default_id)
function get_video(id){
$('.zg').removeClass('yc')
$('.label_c').removeClass('label_c_color2')
$('.label_c').addClass('label_c_color1')
$('#label_id_'+id).removeClass('label_c_color1')
$('#label_id_'+id).addClass('label_c_color2')
$.ajax({
url:"https://tc.pcxbc.com/little_tips_get_video_list", //请求的url地址
// url:"http://wm.tcxbc.com/little_tips_get_video_list", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{'id':id}, //参数值
type:"POST", //请求方式
success:function(req){
$('.zg').addClass('yc')
if(req.code === 0){
var str='',ls_str=''
for (let index = 0; index < req.data.length; index++) {
ls_str = '<div class="c_c">'
+'<div class="c_c_c">'
+'<div class="c_c_c_name">'+ req.data[index]['device_model'] +'</div>'
+'<div class="c_c_c_type">'+ req.data[index]['device_type'] +'</div>'
+'<div class="c_c_c_describe">'+ req.data[index]['device_describe'] +'</div>'
+'<img class="c_c_c_pic" src="'+ req.data[index]['pic_url'] +'" alt="" onclick="play(\''+ req.data[index]['video_url'] +'\')">'
+'<div class="c_c_c_play" onclick="play(\''+ req.data[index]['video_url'] +'\')"></div>'
+'<div class="c_c_c_copy" data-link="'+ req.data[index]['video_url'] +'" onclick="copy_url(this)" style="cursor: pointer;">复制链接</div>'
+'</div>'
+'</div>'
str = str + ls_str
}
$('.content').html(str)
}else{
}
},
error:function(){
//请求出错处理
}
});
}
function copy_url(td) {
console.log(td)
var link = td.getAttribute('data-link');
console.log(link)
if (navigator.clipboard) {
console.log(1)
navigator.clipboard.writeText(link).then(function() {
// alert('链接已复制到粘贴板');
$('.zg_content2').html('链接已复制到粘贴板')
$('.zg_content2').removeClass('yc')
setTimeout(() => {
$('.zg_content2').addClass('yc')
}, 1000);
}).catch(function(err) {
console.log(3)
// console.error('复制失败: ', err);
// alert('复制链接时出错');
$('.zg_content2').html('复制链接时出错')
$('.zg_content2').removeClass('yc')
setTimeout(() => {
$('.zg_content').addClass('yc')
}, 1000);
});
} else {
console.log(2)
$('.zg_content2').html('你的浏览器不支持剪贴板API,请粘贴后手动提取链接('+link+')')
$('.zg_content2').removeClass('yc')
setTimeout(() => {
$('.zg_content2').addClass('yc')
}, 1000);
// alert('你的浏览器不支持剪贴板API,请手动复制链接('+link+')并在手机浏览器内打开');
}
}
</script>

View File

@ -0,0 +1,608 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="full-screen" content="true">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>小贴士</title>
<script src="/x_admin/js/jq.js"></script>
<style>
*{
padding: 0 0;
margin: 0 0;
}
.yc{
display: none;
}
.big_box{
width: 100vw;
height: 100vh;
padding-bottom: 6vw;
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
display: flex;
background-color: white;
overflow: auto;
flex-direction: column;
}
.title_data{
width: 100vw;
height: 7vw;
font-size: 3vw;
line-height: 7vw;
text-align: center;
background-color: bisque;
}
#fileInput{
display: none;
}
#fileInput2{
display: none;
}
#show_pic{
max-width: 70%;
}
#show_pic2{
max-width: 70%;
}
.content{
width: 100vw;
display: flex;
}
.left_add{
width: 30vw;
}
.add_device{
background-color: beige;
padding: 3vw 0;
padding-left: 3vw;
box-sizing: border-box;
}
.add_label{
background-color: rgb(151, 187, 162);
padding: 3vw 0;
padding-left: 3vw;
box-sizing: border-box;
}
.update_title{
background-color: rgb(144, 189, 231);
padding: 3vw 0;
padding-left: 3vw;
box-sizing: border-box;
}
.right_list{
width: 70vw;
}
button{
padding: 3px 10px;
box-sizing: border-box;
border-radius: 5px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
.up_shelf{
background-color: green;
color: white;
font-weight: bold;
}
.down_shelf{
background-color: red;
color: white;
font-weight: bold;
}
.video_type{
height: 10vw;
}
.img_type{
height: 5vw;
}
.play_page{
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
flex-direction: column;
align-items: center;
}
.play_page_title{
width: 80vw;
height: 10vh;
font-size: 7vw;
color: white;
line-height: 10vh;
text-align: right;
}
.play_page_content{
width: 90vw;
height: 90vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
}
.fuceng{
width: 100vw;
height: 100vh;
line-height: 100vh;
text-align: center;
background-color: rgba(0, 0, 0, 0.8);
color: white;
font-size: 3vw;
font-weight: bold;
position: fixed;
z-index: 9999999;
}
.fuceng2{
width: 100vw;
height: 100vh;
line-height: 100vh;
text-align: center;
background-color: rgba(0, 0, 0, 0.8);
color: white;
font-size: 3vw;
font-weight: bold;
position: fixed;
z-index: 9999999;
}
#progressBar{
width: 50%;
height: 28px;
background: #ccc;
position: absolute;
top: 56%;
left: 0;
right: 0;
margin: 0 auto;
}
#progress{
width: 0%; height: 100%; background: green;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="title_data">小贴士管理页面</div>
<div class="content">
<div class="left_add">
<div class="add_device">
<div><span>设备型号:</span><input id="device_model_name" type="text"><span style="font-size: 12px;color: red;">必填</span></div></br>
<div><span>设备类型:</span><input id="device_model_type" type="text"></div></br>
<div><span>设备描述:</span><input id="device_describe" type="text"></div></br>
<div><span>设备图片:</span><button onclick="change_action_pic()">选择图片</button><span style="font-size: 12px;color: red;">请不要上传超过10M的图片</span></div></br>
<div><span>图片预览:</span><img id="show_pic" src="" alt=""></div></br>
<div><span>设备视频:</span><button onclick="change_action_video()">选择视频</button><span style="font-size: 12px;color: red;">请不要上传超过90M的视频大于90M的视频概率会导致提交失败</span></div></br>
<div><span>视频名称:</span><span id="show_video"></span></div></br>
<div>
<span>设备分类:</span>
<select name="" id="device_category">
{volist name="label" id="vo"}
<option value="{$vo.id}">{$vo.type_name}</option>
{/volist}
</select>
<span style="font-size: 12px;color: red;">必选</span>
</div>
</br>
<button onclick="upload_action()">提交</button>
</br>
<span style="font-size: 12px;color: red;">如果提交后,查询到已经有该设备型号,那么将更新该设备信息,没有则新建</span>
</div>
<div class="add_label">
<div><span>添加设备分类:</span><input id="device_label_name" type="text"><span style="font-size: 12px;color: red;">必填(添加后将出现在上面黄色板块内的设备分类当中)</span></div></br>
<button onclick="upload_label_action()">添加</button>
</div>
<div class="update_title">
<div><span>页面标题:</span><input id="page_title_name" type="text"><span style="font-size: 12px;color: red;">必填(修改后,前端展示页面的标题将更改)</span></div></br>
<span style="font-size: 12px;color: red;">当前标题为“{$title.type_name}”</span></br>
<button onclick="upload_title_action()">修改</button>
</div>
</div>
<div class="right_list">
注:</br>
1、下架代表该设备及视频暂时下架将不在列表内展示后续如果恢复可以点击上架重新展示</br>
2、删除则代表该设备及相关视频永久删除。不存在信息恢复可能。</br>
3、如信息编辑错误则需要删除后重新编辑添加</br>
4、左侧的三个编辑板块之间并不关联每个板块仅处理自己板块内的内容</br>
<table>
<tr>
<!-- <th>序号</th> -->
<th>设备名称</th>
<th>设备类型</th>
<th>设备描述</th>
<th>所属分类</th>
<th>设备图</th>
<th>视频</th>
<th>操作</th>
</tr>
{volist name="data" id="vo"}
<tr>
<!-- <td>{$vo.id}</td> -->
<td>{$vo.device_model}</td>
<td>{$vo.device_type}</td>
<td>{$vo.device_describe}</td>
<td>{$vo.type_name}</td>
<td><img class="img_type" src="{$vo.pic_url}" alt=""></td>
<td><button onclick="play('{$vo.video_url}')">点击查看</button><button data-link="{$vo.video_url}" onclick="copy_url(this)">复制链接</button></td>
{if condition="$vo.is_del == 0"}
<td>
<button class="down_shelf" onclick="del_action('{$vo.id}',1)">下架</button>
<button onclick="del_device_data('{$vo.id}')">删除</button>
</td>
{else /}
<td>
<button class="up_shelf" onclick="del_action('{$vo.id}',0)">上架</button>
<button onclick="del_device_data('{$vo.id}')">删除</button>
</td>
{/if}
</tr>
{/volist}
</table>
</div>
</div>
</div>
<div class="play_page">
<div class="play_page_title">关闭</div>
<div class="play_page_content"></div>
</div>
<input type="file" id="fileInput" accept="image/*" name="img_list" multiple>
<input type="file" id="fileInput2" accept="video/*" name="img_list" multiple>
<div class="fuceng yc">请求发送中...请不要关闭页面或者刷新页面,等待上传完成</div>
<div class="fuceng2 yc">
上传中...
<div id="progressBar">
<div id="progress"></div>
</div>
</div>
</body>
</html>
<script>
// 设置参数
$('.play_page').hide();
var formdata = new FormData();
var files,videoFile
// ####################################################################################左侧功能####################################################################################
// ####################################################################################左侧功能####################################################################################
// ####################################################################################左侧功能####################################################################################
// #######################################################设备创建或者修改#######################################################
// ####################################图片跟视频选择器####################################
function change_action_pic(){
document.getElementById('fileInput').click();
}
function change_action_video(){
document.getElementById('fileInput2').click();
}
$('#fileInput').on('change', function() {
// 获取被选择的文件
files = event.target.files;
if (files.length > 1) {
alert('最多只能选择1张图片,您选择了' + files.length + ' 张图片');
// 清空文件输入,取消选择的文件
$(this).val('');
return
}
console.log('当前选择了' + files.length + ' 张图片');
// 检查是否有文件被选择
if (files.length > 0) {
// var formdata = new FormData();
formdata.append('image', files[0]);
var reader = new FileReader();
reader.onload = function(e) {
// 将图片预览显示在show_pic元素中
$('#show_pic').attr('src', e.target.result);
};
// 读取文件内容
reader.readAsDataURL(files[0]);
}
});
$('#fileInput2').on('change', function() {
videoFile = event.target.files;
// var videoFile = files_video[0];
if (videoFile.length > 1) {
alert('最多只能选择1部视频,您选择了' + videoFile.length + ' 部视');
// 清空文件输入,取消选择的文件
$(this).val('');
return
}
if (videoFile.length > 0) {
// 将视频文件添加到formdata
formdata.append('video', videoFile[0]);
// 将视频名称显示在show_video元素中
$('#show_video').text(videoFile[0].name);
}
});
// ####################################提交动作####################################
function upload_action() {
if (!$('#device_model_name').val()) {
alert('请填写设备型号');
return;
}
// if (!$('#device_model_type').val()) {
// alert('请填写设备类型');
// return;
// }
// if (!$('#device_category').val()) {
// alert('请选择设备分类');
// return;
// }
if (!files || files.length === 0) {
// alert('请选择设备图片');
// return;
console.log('12')
formdata.append('image', 'no');
formdata.append('image_type', 'no');
}else{
formdata.append('image_type', 'yes');
}
if (!videoFile || videoFile.length === 0) {
// alert('请选择设备视频');
// return;
console.log('34')
formdata.append('video', 'no');
formdata.append('video_type', 'no');
}else{
formdata.append('video_type', 'yes');
}
// 添加表单数据
formdata.append('device_model_name', $('#device_model_name').val());
formdata.append('device_model_type', $('#device_model_type').val());
formdata.append('device_describe', $('#device_describe').val());
formdata.append('device_category', $('#device_category').val());
// 显示上传进度条
$('.fuceng2').removeClass('yc');
// 发起AJAX请求
$.ajax({
url: "https://tc.pcxbc.com/little_tips_project_upload_action", // 请求的URL地址
// url: "http://wm.tcxbc.com/little_tips_project_upload_action", // 请求的URL地址
contentType: false,
processData: false,
async: true, // 请求是否异步,默认为异步
data: formdata, // 表单数据
type: "POST", // 请求方式
xhr: function () {
// 创建XMLHttpRequest对象
var xhr = new XMLHttpRequest();
// 监听上传进度
xhr.upload.addEventListener("progress", function (event) {
if (event.lengthComputable) {
var percentComplete = (event.loaded / event.total) * 100;
$('#progress').css('width', percentComplete + '%'); // 更新进度条
}
}, false);
return xhr;
},
success: function (req) {
$('.fuceng').addClass('yc');
if (req.code === 0) {
// 清空表单内容
$('#device_model_name').val('');
$('#device_model_type').val('');
$('#device_describe').val('');
$('#device_category').val('');
$('#show_pic').attr('src', '');
$('#show_video').text('');
files = null;
videoFile = null;
formdata = new FormData(); // 重置表单数据
alert('操作成功');
// console.log('添加成功')
window.location.reload();
} else {
if (req.code == 10010) {
alert('图片添加失败,' + req.msg);
window.location.reload();
// console.log('图片添加失败,' + req.msg)
} else if (req.code == 10011) {
alert('视频添加失败,' + req.msg);
window.location.reload();
// console.log('视频添加失败,' + req.msg)
} else {
// console.log(req.msg)
alert(req.msg);
window.location.reload();
}
}
},
error: function () {
// console.log('请求出错:', textStatus, errorThrown);
// console.log('响应内容:', jqXHR.responseText);
// // alert('请求出错,请重试。错误信息:' + textStatus + ' - ' + errorThrown);
alert('请求出错,请重试');
window.location.reload();
}
});
}
// #######################################################设备分类创建或者修改#######################################################
function upload_label_action(){
if(!$('#device_label_name').val()){
alert('填写设页面标题')
return
}
$('.fuceng').removeClass('yc')
$.ajax({
url:"https://tc.pcxbc.com/add_label_action", //请求的url地址
// url:"http://wm.tcxbc.com/add_label_action", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{'label':$('#device_label_name').val()}, //参数值
type:"POST", //请求方式
success:function(req){
$('.fuceng').addClass('yc')
if(req.code === 0){
alert('添加成功')
window.location.reload();
}else{
alert('添加失败')
}
},
error:function(){
//请求出错处理
}
});
}
// ####################################页面标题修改####################################
function upload_title_action(){
if(!$('#page_title_name').val()){
alert('填写设备分类名称')
return
}
$('.fuceng').removeClass('yc')
$.ajax({
url:"https://tc.pcxbc.com/update_title_action", //请求的url地址
// url:"http://wm.tcxbc.com/update_title_action", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{'title':$('#page_title_name').val()}, //参数值
type:"POST", //请求方式
success:function(req){
$('.fuceng').addClass('yc')
if(req.code === 0){
alert('修改成功')
window.location.reload();
}else{
alert('修改失败')
}
},
error:function(){
//请求出错处理
}
});
}
// ####################################################################################右侧功能####################################################################################
// ####################################################################################右侧功能####################################################################################
// ####################################################################################右侧功能####################################################################################
function del_action(str,num){
$('.fuceng').removeClass('yc')
$.ajax({
url:"https://tc.pcxbc.com/little_tips_is_del_update", //请求的url地址
// url:"http://wm.tcxbc.com/little_tips_is_del_update", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":str,'type':num}, //参数值
type:"POST", //请求方式
success:function(req){
$('.fuceng').addClass('yc')
if(req.code === 0){
alert('修改成功')
window.location.reload();
}else{
alert('修改失败')
}
},
error:function(){
//请求出错处理
}
});
}
function play(str){
// 如果已经存在 video 元素,先移除
const existingVideo = document.querySelector('video');
if (existingVideo) {
existingVideo.remove();
}
// 获取对应的视频链接
const videoUrl = str;
if (!videoUrl) {
alert('未找到对应的视频链接!');
return;
}
// 动态创建 video 元素
const video = document.createElement('video');
video.src = videoUrl;
video.controls = true; // 显示控制条
video.autoplay = true; // 自动播放
video.style.weight = 'auto'; // 设置视频高度
video.style.height = '70%'; // 设置视频高度
video.style.marginTop = '20px'; // 设置视频上边距
// 将 video 元素添加到页面中
document.querySelector('.play_page_content').appendChild(video);
$('.play_page').show();
}
$('.play_page_title').on('click',function(){
$('.play_page').hide();
const existingVideo = document.querySelector('video');
if (existingVideo) {
existingVideo.remove();
}
})
function del_device_data(id){
$('.fuceng').removeClass('yc')
$.ajax({
url:"https://tc.pcxbc.com/little_tips_del_action", //请求的url地址
// url:"http://wm.tcxbc.com/little_tips_del_action", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id}, //参数值
type:"POST", //请求方式
success:function(req){
$('.fuceng').addClass('yc')
if(req.code === 0){
alert('修改成功')
window.location.reload();
}else{
alert('修改失败')
}
},
error:function(){
//请求出错处理
}
});
}
function copy_url(td) {
var link = td.getAttribute('data-link');
if (navigator.clipboard) {
navigator.clipboard.writeText(link).then(function() {
alert('链接已复制到粘贴板');
}).catch(function(err) {
console.error('复制失败: ', err);
alert('复制链接时出错');
});
} else {
alert('你的浏览器不支持剪贴板API,请手动复制链接('+link+')并在手机浏览器内打开');
}
}
</script>

View File

@ -242,7 +242,7 @@ return [
],
// 第个数据库配置(厨房秤)
// 第2个数据库配置(厨房秤)
'cfc_db' => [
// 数据库类型
'type' => 'sqlsrv',
@ -266,4 +266,28 @@ return [
// 数据库调试模式
'debug' => true,
],
// 第3个数据库配置(二维码)
'qrcode_db' => [
// 数据库类型
'type' => 'sqlsrv',
// 服务器地址
'hostname' => '121.36.67.254',
// 'hostname' => '127.0.0.1',
// 数据库名
'database' => 'all_qrcode_data',
// 用户名
'username' => 'jt_user',
// 密码
'password' => 'jtuser1qaz@WSX',
// 端口
'hostport' => '4331',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => '',
// 数据库调试模式
'debug' => true,
],
];

View File

@ -34,6 +34,22 @@ Route::any('/business_cooperation_action', 'app/download/business_cooperation_ac
Route::any('/ordinary_code', 'code/qrcode/ordinary_code');
// 配合reedaw&宠物小白使用
Route::any('/bluetooth_code', 'code/qrcode/bluetooth_code');
// 配合小贴士使用
Route::any('/little_tips_project', 'code/qrcode/little_tips_project');
Route::any('/little_tips_get_video_list', 'code/qrcode/little_tips_get_video_list');
Route::any('/little_tips_project_set_page', 'code/qrcode/little_tips_project_set_page');
Route::any('/little_tips_project_upload_action', 'code/qrcode/little_tips_project_upload_action');
Route::any('/little_tips_is_del_update', 'code/qrcode/little_tips_is_del_update');
Route::any('/little_tips_del_action', 'code/qrcode/little_tips_del_action');
Route::any('/add_label_action', 'code/qrcode/add_label_action');
Route::any('/update_title_action', 'code/qrcode/update_title_action');
// // ################################################################设备请求入口################################################################
// // ################################################################设备请求入口################################################################
@ -64,6 +80,7 @@ Route::any('/admin/pic', 'admin/base/pic_index');
Route::any('/admin/pic_upload_action', 'admin/base/pic_upload_action');
// 登录页
Route::any('/admin/login', 'admin/login/login');
// 登录动作
@ -156,6 +173,20 @@ Route::any('/technology/set_user_opinion', 'admin/technology/set_user_opinion');
// // Route::get('/admin/member_list', 'admin/member/member_list');
// // Route::get('/admin/user_list', 'admin/member/user_list');
// ################################################################厨房秤部分###################################
// #################################食材管理
// 一级食材页面
Route::any('/kitchenscale/food_ingredients_index_1', 'admin/kitchenscale/food_ingredients_index_1');
// 二级食材页面
Route::any('/kitchenscale/food_ingredients_index_2', 'admin/kitchenscale/food_ingredients_index_2');
// 三级食材页面
Route::any('/kitchenscale/food_ingredients_index_3', 'admin/kitchenscale/food_ingredients_index_3');
// 菜谱管理
Route::any('/technology/index', 'admin/technology/index');
Route::any('/technology/web_index', 'admin/technology/web_index');
Route::any('/technology/privacy_index', 'admin/technology/privacy_index');
Route::any('/technology/set_user_opinion', 'admin/technology/set_user_opinion');
// // ################################################################APP接口################################################################
@ -191,6 +222,9 @@ Route::any('/testedition/reset_password', 'testapp/login/reset_password');
// 登录接口
Route::any('/login_action', 'app/login/login_action');
Route::any('/testedition/login_action', 'testapp/login/login_action');
// 微信小程序快捷登录接口
Route::any('/wechat_quick_login', 'app/login/wechat_quick_login');
Route::any('/testedition/wechat_quick_login', 'testapp/login/wechat_quick_login');
// 手机或者邮箱验证码接口接口
Route::any('/send_phone_email_code', 'app/login/send_phone_email_code');
Route::any('/testedition/send_phone_email_code', 'testapp/login/send_phone_email_code');
@ -406,11 +440,18 @@ Route::any('/open_wechat_content', 'app/Msginformation/open_wechat_content');
################################################################下面是厨房秤################################################################
###########################################################################################################################################
// 微信小程序快捷登录接口
Route::any('/kitchenscale/wechat_quick_login', 'app/kitchenscale/app.index/wechat_quick_login');
Route::any('/testedition/kitchenscale/wechat_quick_login', 'app/kitchenscale/app.index/wechat_quick_login');
// 公共内容################################################################
// 获取用户上传图片列表
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_one_action', 'app/kitchenscale/app.base/pic_upload_one_action');
Route::any('/testedition/kitchenscale/pic_upload_one_action', 'app/kitchenscale/testapp.base/pic_upload_one_action');
// 用户多图上传接口
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');
@ -436,6 +477,10 @@ Route::any('/testedition/kitchenscale/search_column', 'app/kitchenscale/testapp.
// 添加菜谱
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/update_cookbook', 'app/kitchenscale/app.cookbook/update_cookbook');
Route::any('/testedition/kitchenscale/update_cookbook', 'app/kitchenscale/testapp.cookbook/update_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');
@ -468,17 +513,42 @@ Route::any('/testedition/kitchenscale/get_cookbook_label_list', 'app/kitchenscal
// 计食器################################################################
// 保存每日餐食食物信息
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/add_intake_food', 'app/kitchenscale/app.countfood/add_intake_food');
Route::any('/testedition/kitchenscale/add_intake_food', 'app/kitchenscale/testapp.countfood/add_intake_food');
// 获取记食器板块内容
Route::any('/kitchenscale/get_countfoot_content', 'app/kitchenscale/app.countfood/get_countfoot_content');
Route::any('/testedition/kitchenscale/get_countfoot_content', 'app/kitchenscale/testapp.countfood/get_countfoot_content');
// 获取记食器记录
Route::any('/kitchenscale/get_log_list', 'app/kitchenscale/app.countfood/get_log_list');
Route::any('/testedition/kitchenscale/get_log_list', 'app/kitchenscale/testapp.countfood/get_log_list');
// 计食器板块-设置内容
Route::any('/kitchenscale/set_up_content', 'app/kitchenscale/app.countfood/set_up_content');
Route::any('/testedition/kitchenscale/set_up_content', 'app/kitchenscale/testapp.countfood/set_up_content');
// 设置用户的卡路里
Route::any('/kitchenscale/set_user_kcal', 'app/kitchenscale/app.countfood/set_user_kcal');
Route::any('/testedition/kitchenscale/set_user_kcal', 'app/kitchenscale/testapp.countfood/set_user_kcal');
// 我的################################################################
// 获取角色信息
Route::any('/kitchenscale/get_user_msg', 'app/kitchenscale/app.usercenter/get_user_msg');
Route::any('/testedition/kitchenscale/get_user_msg', 'app/kitchenscale/testapp.usercenter/get_user_msg');
// 修改角色信息
Route::any('/kitchenscale/update_user_msg', 'app/kitchenscale/app.usercenter/update_user_msg');
Route::any('/testedition/kitchenscale/update_user_msg', 'app/kitchenscale/testapp.usercenter/update_user_msg');
// 账号收藏点赞列表
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/del_my_cookbook', 'app/kitchenscale/app.usercenter/del_my_cookbook');
Route::any('/testedition/kitchenscale/del_my_cookbook', 'app/kitchenscale/testapp.usercenter/del_my_cookbook');
// 测试用内容################################################################
@ -504,6 +574,9 @@ Route::any('/testedition/del_all_read_log', 'testapp/Msginformation/del_all_read
Route::any('/ceshiyong', 'app/base/ceshiyong');
Route::any('/testedition/ceshiyong', 'testapp/base/ceshiyong');
Route::any('/kitchenscale/chuli_shuju', 'app/kitchenscale/app.cookbook/chuli_shuju');
// Route::any('/app_update_file/*', 'app/sportstesting/aaaaaaaaaaaaaaa');
// 处理404错误 z

View File

@ -19,7 +19,8 @@
"php": ">=5.4.0",
"topthink/framework": "5.0.*",
"phpmailer/phpmailer": "^6.9",
"phpoffice/phpspreadsheet": "^1.25"
"phpoffice/phpspreadsheet": "^1.25",
"overtrue/wechat": "~4.0"
},
"autoload": {
"psr-4": {
@ -32,7 +33,11 @@
"config": {
"preferred-install": "dist",
"allow-plugins": {
"topthink/think-installer": true
"topthink/think-installer": true,
"easywechat-composer/easywechat-composer": true
},
"audit": {
"enabled": false
}
}
}

View File

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="full-screen" content="true">
<meta name="screen-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<title>隐私协议</title>
<style>
*{
padding: 0 0;
margin: 0 0;
}
.big_box{
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
overflow: auto;
padding: 10vw;
box-sizing: border-box;
}
.title{
width: 100%;
height: 10vw;
text-align: center;
font-size: 7vw;
font-weight: bold;
margin-bottom: 6vw;
}
.content{
width: 100%;
}
.font_1{
font-size: 4.5vw;
font-weight: bold;
}
.font_2{
font-size: 3.5vw;
margin: 3vw 0;
}
.fint_w{
font-weight: bold;
margin-left: 5vw;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="title">轻厨记隐私协议</div>
<div class="content">
<div class="font_1">一、前言</div>
<div class="font_2">感谢您选择使用我们的智能厨房秤APP以下简称“本应用”。我们深知您的个人信息安全至关重要在您使用本应用时我们郑重承诺将严格遵守相关法律法规采取合理有效的措施保护您的个人隐私。本隐私协议旨在明确我们在采集、使用、存储、共享及保护您的个人信息方面的责任和义务。请您在使用本应用前仔细阅读并理解本协议内容。一旦您开始使用本应用即视为您同意我们按照本协议的规定处理您的个人信息。</div>
<div class="font_1">二、信息收集</div>
<div class="font_2"><span class="fint_w">1.必要信息:</span>为了提供基本服务,我们可能会收集您的手机号码、电子邮箱等联系方式,以便验证身份、保障账号安全及提供必要的服务支持。</div>
<div class="font_2"><span class="fint_w">2.健康数据:</span>在使用本应用时您可以选择提供身高、体重、BMI等健康数据以便我们为您计算营养摄入建议或生成健康报告。</div>
<div class="font_2"><span class="fint_w">3.饮食记录:</span>本应用会记录您通过厨房秤测量的食材重量、饮食内容及时间等信息,用于分析您的饮食习惯并提供个性化建议。</div>
<div class="font_2"><span class="fint_w">4.设备信息:</span>为了优化服务体验我们可能会采集您的设备型号、操作系统版本、IP地址等必要的技术信息。这些信息将帮助我们了解用户的使用环境以便进行技术调试和服务改进。</div>
<div class="font_1">三、信息使用</div>
<div class="font_2"><span class="fint_w">1.服务提供:</span>我们将根据您提供的信息,为您提供食材称重、营养分析、饮食记录及健康建议等服务。</div>
<div class="font_2"><span class="fint_w">2.个性化推荐:</span>基于您的饮食记录、健康数据和使用习惯,我们可能会向您推荐适合的食谱、营养计划或健康管理方案。</div>
<div class="font_2"><span class="fint_w">3.数据分析:</span>我们会对收集到的数据进行匿名化处理,用于统计分析、产品优化及服务改进。这些统计数据将不包含任何可以识别您个人身份的信息。</div>
<div class="font_1">四、信息共享与披露</div>
<div class="font_2"><span class="fint_w">1.内部共享:</span>我们可能会将您的信息共享给公司内部负责处理您个人信息的部门或人员,以确保为您提供更好的服务。</div>
<div class="font_2"><span class="fint_w">2.第三方合作:</span>在必要且合法的情况下,我们可能会与第三方服务提供商(如云服务提供商、数据分析公司等)共享您的个人信息,以便他们为我们提供技术支持或数据分析服务。我们将与这些第三方签订严格的保密协议,并要求其遵守相关法律法规和本协议的规定。</div>
<div class="font_2"><span class="fint_w">3.法律要求:</span>在法律法规要求或政府部门、司法机关依法要求的情况下,我们可能会披露您的个人信息。</div>
<div class="font_1">五、信息安全</div>
<div class="font_2"><span class="fint_w">1.技术保障:</span>我们将采取合理的技术手段和管理措施,确保您的个人信息在采集、存储、使用及共享过程中的安全。</div>
<div class="font_2"><span class="fint_w">2.数据加密:</span>对于敏感信息(如健康数据、饮食记录等),我们将采用加密技术进行处理,防止数据在传输和存储过程中被非法访问或泄露。</div>
<div class="font_2"><span class="fint_w">3.访问控制:</span>我们将对访问个人信息的员工进行严格的权限管理,确保只有授权人员才能接触相关信息。</div>
<div class="font_1">六、用户权利</div>
<div class="font_2"><span class="fint_w">1.知情权:</span>您有权了解我们采集、使用、共享及保护您个人信息的详细情况。</div>
<div class="font_2"><span class="fint_w">2.选择权:</span>您有权选择是否向我们提供个人信息的具体内容,以及是否接受个性化推荐服务。</div>
<div class="font_2"><span class="fint_w">3.更正权:</span>如果您发现我们采集的个人信息有误,您有权要求我们及时更正。</div>
<div class="font_2"><span class="fint_w">4.删除权:</span>在符合法律法规要求的情况下,您有权要求删除您的个人信息。</div>
<div class="font_1">七、协议变更</div>
<div class="font_2">我们有权根据法律法规的变化或业务发展的需要,对本隐私协议进行修订。修订后的协议将通过本应用内通知或其他适当方式告知您。请您定期查阅本协议,以便及时了解最新政策。</div>
<div class="font_1">八、争议解决</div>
<div class="font_2">如因本协议产生任何争议,双方应首先通过友好协商解决;协商不成的,任何一方均有权向本应用运营方所在地的人民法院提起诉讼。</div>
<div class="font_1">九、生效与终止</div>
<div class="font_2">本协议自您同意并接受之日起生效,并持续有效至您注销账号或本应用终止服务时止。</div>
</div>
</div>
</body>
</html>

View File

@ -6,6 +6,11 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
'Stringable' => $vendorDir . '/myclabs/php-enum/stubs/Stringable.php',
'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
);

View File

@ -6,6 +6,13 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'f0e7e63bbb278a92db02393536748c5f' => $vendorDir . '/overtrue/wechat/src/Kernel/Support/Helpers.php',
'6747f579ad6817f318cc3a7e7a0abb93' => $vendorDir . '/overtrue/wechat/src/Kernel/Helpers.php',
);

View File

@ -6,5 +6,6 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Pimple' => array($vendorDir . '/pimple/pimple/src'),
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
);

View File

@ -10,13 +10,34 @@ return array(
'think\\' => array($baseDir . '/thinkphp/library/think'),
'app\\' => array($baseDir . '/application'),
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'),
'Symfony\\Contracts\\Cache\\' => array($vendorDir . '/symfony/cache-contracts'),
'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'),
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\Cache\\' => array($vendorDir . '/symfony/cache'),
'Symfony\\Bridge\\PsrHttpMessage\\' => array($vendorDir . '/symfony/psr-http-message-bridge'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'),
'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'),
'EasyWeChatComposer\\' => array($vendorDir . '/easywechat-composer/easywechat-composer/src'),
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
);

View File

@ -7,8 +7,15 @@ namespace Composer\Autoload;
class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
{
public static $files = array (
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'f0e7e63bbb278a92db02393536748c5f' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Support/Helpers.php',
'6747f579ad6817f318cc3a7e7a0abb93' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Helpers.php',
);
public static $prefixLengthsPsr4 = array (
@ -27,21 +34,51 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
),
'S' =>
array (
'Symfony\\Polyfill\\Php80\\' => 23,
'Symfony\\Polyfill\\Php73\\' => 23,
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Contracts\\Service\\' => 26,
'Symfony\\Contracts\\EventDispatcher\\' => 34,
'Symfony\\Contracts\\Cache\\' => 24,
'Symfony\\Component\\VarExporter\\' => 30,
'Symfony\\Component\\HttpFoundation\\' => 33,
'Symfony\\Component\\EventDispatcher\\' => 34,
'Symfony\\Component\\Cache\\' => 24,
'Symfony\\Bridge\\PsrHttpMessage\\' => 30,
),
'P' =>
array (
'Psr\\SimpleCache\\' => 16,
'Psr\\Log\\' => 8,
'Psr\\Http\\Message\\' => 17,
'Psr\\Http\\Client\\' => 16,
'Psr\\EventDispatcher\\' => 20,
'Psr\\Container\\' => 14,
'Psr\\Cache\\' => 10,
'PhpOffice\\PhpSpreadsheet\\' => 25,
'PHPMailer\\PHPMailer\\' => 20,
),
'O' =>
array (
'Overtrue\\Socialite\\' => 19,
),
'M' =>
array (
'MyCLabs\\Enum\\' => 13,
'Monolog\\' => 8,
'Matrix\\' => 7,
),
'G' =>
array (
'GuzzleHttp\\Psr7\\' => 16,
'GuzzleHttp\\Promise\\' => 19,
'GuzzleHttp\\' => 11,
),
'E' =>
array (
'EasyWeChat\\' => 11,
'EasyWeChatComposer\\' => 19,
),
'C' =>
array (
'Complex\\' => 8,
@ -65,14 +102,58 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
array (
0 => __DIR__ . '/..' . '/maennchen/zipstream-php/src',
),
'Symfony\\Polyfill\\Php80\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
),
'Symfony\\Polyfill\\Php73\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php73',
),
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Contracts\\Service\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/service-contracts',
),
'Symfony\\Contracts\\EventDispatcher\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/event-dispatcher-contracts',
),
'Symfony\\Contracts\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/cache-contracts',
),
'Symfony\\Component\\VarExporter\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/var-exporter',
),
'Symfony\\Component\\HttpFoundation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/http-foundation',
),
'Symfony\\Component\\EventDispatcher\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
),
'Symfony\\Component\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/cache',
),
'Symfony\\Bridge\\PsrHttpMessage\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/psr-http-message-bridge',
),
'Psr\\SimpleCache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
),
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-factory/src',
@ -82,6 +163,18 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
array (
0 => __DIR__ . '/..' . '/psr/http-client/src',
),
'Psr\\EventDispatcher\\' =>
array (
0 => __DIR__ . '/..' . '/psr/event-dispatcher/src',
),
'Psr\\Container\\' =>
array (
0 => __DIR__ . '/..' . '/psr/container/src',
),
'Psr\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/cache/src',
),
'PhpOffice\\PhpSpreadsheet\\' =>
array (
0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet',
@ -90,14 +183,42 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
array (
0 => __DIR__ . '/..' . '/phpmailer/phpmailer/src',
),
'Overtrue\\Socialite\\' =>
array (
0 => __DIR__ . '/..' . '/overtrue/socialite/src',
),
'MyCLabs\\Enum\\' =>
array (
0 => __DIR__ . '/..' . '/myclabs/php-enum/src',
),
'Monolog\\' =>
array (
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
),
'Matrix\\' =>
array (
0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src',
),
'GuzzleHttp\\Psr7\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
),
'GuzzleHttp\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
),
'GuzzleHttp\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
),
'EasyWeChat\\' =>
array (
0 => __DIR__ . '/..' . '/overtrue/wechat/src',
),
'EasyWeChatComposer\\' =>
array (
0 => __DIR__ . '/..' . '/easywechat-composer/easywechat-composer/src',
),
'Complex\\' =>
array (
0 => __DIR__ . '/..' . '/markbaker/complex/classes/src',
@ -105,6 +226,13 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
);
public static $prefixesPsr0 = array (
'P' =>
array (
'Pimple' =>
array (
0 => __DIR__ . '/..' . '/pimple/pimple/src',
),
),
'H' =>
array (
'HTMLPurifier' =>
@ -115,8 +243,13 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd
);
public static $classMap = array (
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
'Stringable' => __DIR__ . '/..' . '/myclabs/php-enum/stubs/Stringable.php',
'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
);
public static function getInitializer(ClassLoader $loader)

File diff suppressed because it is too large Load Diff

View File

@ -3,13 +3,22 @@
'name' => 'topthink/think',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'fcd7859cf4ed7d92ea7f2b5250e35e824d6b0d57',
'reference' => '96a7b429339e68a8dfd3eaa4457d6f8cfdf0e6d5',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'easywechat-composer/easywechat-composer' => array(
'pretty_version' => '1.4.1',
'version' => '1.4.1.0',
'reference' => '3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd',
'type' => 'composer-plugin',
'install_path' => __DIR__ . '/../easywechat-composer/easywechat-composer',
'aliases' => array(),
'dev_requirement' => false,
),
'ezyang/htmlpurifier' => array(
'pretty_version' => 'v4.18.0',
'version' => '4.18.0.0',
@ -19,6 +28,33 @@
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/guzzle' => array(
'pretty_version' => '7.9.2',
'version' => '7.9.2.0',
'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/promises' => array(
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'reference' => 'f9c436286ab2892c7db7be8c8da4ef61ccf7b455',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/promises',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/psr7' => array(
'pretty_version' => '2.7.0',
'version' => '2.7.0.0',
'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
'aliases' => array(),
'dev_requirement' => false,
),
'maennchen/zipstream-php' => array(
'pretty_version' => '2.1.0',
'version' => '2.1.0.0',
@ -46,15 +82,42 @@
'aliases' => array(),
'dev_requirement' => false,
),
'monolog/monolog' => array(
'pretty_version' => '2.10.0',
'version' => '2.10.0.0',
'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7',
'type' => 'library',
'install_path' => __DIR__ . '/../monolog/monolog',
'aliases' => array(),
'dev_requirement' => false,
),
'myclabs/php-enum' => array(
'pretty_version' => '1.8.4',
'version' => '1.8.4.0',
'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
'pretty_version' => '1.8.5',
'version' => '1.8.5.0',
'reference' => 'e7be26966b7398204a234f8673fdad5ac6277802',
'type' => 'library',
'install_path' => __DIR__ . '/../myclabs/php-enum',
'aliases' => array(),
'dev_requirement' => false,
),
'overtrue/socialite' => array(
'pretty_version' => '2.0.24',
'version' => '2.0.24.0',
'reference' => 'ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec',
'type' => 'library',
'install_path' => __DIR__ . '/../overtrue/socialite',
'aliases' => array(),
'dev_requirement' => false,
),
'overtrue/wechat' => array(
'pretty_version' => '4.9.0',
'version' => '4.9.0.0',
'reference' => '92791f5d957269c633b9aa175f842f6006f945b1',
'type' => 'library',
'install_path' => __DIR__ . '/../overtrue/wechat',
'aliases' => array(),
'dev_requirement' => false,
),
'phpmailer/phpmailer' => array(
'pretty_version' => 'v6.9.3',
'version' => '6.9.3.0',
@ -73,6 +136,54 @@
'aliases' => array(),
'dev_requirement' => false,
),
'pimple/pimple' => array(
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => 'a94b3a4db7fb774b3d78dad2315ddc07629e1bed',
'type' => 'library',
'install_path' => __DIR__ . '/../pimple/pimple',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/cache' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/cache',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/cache-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0|2.0',
),
),
'psr/container' => array(
'pretty_version' => '2.0.1',
'version' => '2.0.1.0',
'reference' => '2ae37329ee82f91efadc282cc2d527fd6065a5ef',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/container',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/event-dispatcher' => array(
'pretty_version' => '1.0.0',
'version' => '1.0.0.0',
'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/event-dispatcher',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/event-dispatcher-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
@ -82,6 +193,12 @@
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-client-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-factory' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
@ -91,6 +208,12 @@
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-factory-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-message' => array(
'pretty_version' => '1.1',
'version' => '1.1.0.0',
@ -100,6 +223,27 @@
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-message-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/log' => array(
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/log',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/log-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0.0 || 2.0.0 || 3.0.0',
),
),
'psr/simple-cache' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
@ -109,6 +253,87 @@
'aliases' => array(),
'dev_requirement' => false,
),
'psr/simple-cache-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0|2.0',
),
),
'ralouphie/getallheaders' => array(
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
'type' => 'library',
'install_path' => __DIR__ . '/../ralouphie/getallheaders',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/cache' => array(
'pretty_version' => 'v5.4.46',
'version' => '5.4.46.0',
'reference' => '0fe08ee32cec2748fbfea10c52d3ee02049e0f6b',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/cache',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/cache-contracts' => array(
'pretty_version' => 'v2.5.4',
'version' => '2.5.4.0',
'reference' => '517c3a3619dadfa6952c4651767fcadffb4df65e',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/cache-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/cache-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0|2.0',
),
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v2.5.4',
'version' => '2.5.4.0',
'reference' => '605389f2a7e5625f273b53960dc46aeaf9c62918',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/event-dispatcher' => array(
'pretty_version' => 'v5.4.45',
'version' => '5.4.45.0',
'reference' => '72982eb416f61003e9bb6e91f8b3213600dcf9e9',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/event-dispatcher',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/event-dispatcher-contracts' => array(
'pretty_version' => 'v2.5.4',
'version' => '2.5.4.0',
'reference' => 'e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/event-dispatcher-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/event-dispatcher-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '2.0',
),
),
'symfony/http-foundation' => array(
'pretty_version' => 'v5.4.48',
'version' => '5.4.48.0',
'reference' => '3f38b8af283b830e1363acd79e5bc3412d055341',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/http-foundation',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
@ -118,6 +343,51 @@
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-php73' => array(
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
'reference' => '0f68c03565dcaaf25a890667542e8bd75fe7e5bb',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php73',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-php80' => array(
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php80',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/psr-http-message-bridge' => array(
'pretty_version' => 'v2.3.1',
'version' => '2.3.1.0',
'reference' => '581ca6067eb62640de5ff08ee1ba6850a0ee472e',
'type' => 'symfony-bridge',
'install_path' => __DIR__ . '/../symfony/psr-http-message-bridge',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/service-contracts' => array(
'pretty_version' => 'v1.1.2',
'version' => '1.1.2.0',
'reference' => '191afdcb5804db960d26d8566b7e9a2843cab3a0',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/service-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/var-exporter' => array(
'pretty_version' => 'v5.4.45',
'version' => '5.4.45.0',
'reference' => '862700068db0ddfd8c5b850671e029a90246ec75',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/var-exporter',
'aliases' => array(),
'dev_requirement' => false,
),
'topthink/framework' => array(
'pretty_version' => 'v5.0.25',
'version' => '5.0.25.0',
@ -130,7 +400,7 @@
'topthink/think' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'fcd7859cf4ed7d92ea7f2b5250e35e824d6b0d57',
'reference' => '96a7b429339e68a8dfd3eaa4457d6f8cfdf0e6d5',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),

View File

@ -34,6 +34,8 @@ use MyCLabs\Enum\Enum;
/**
* Action enum
*
* @extends Enum<Action::*>
*/
final class Action extends Enum
{

View File

@ -3,7 +3,7 @@
"type": "library",
"description": "PHP Enum implementation",
"keywords": ["enum"],
"homepage": "http://github.com/myclabs/php-enum",
"homepage": "https://github.com/myclabs/php-enum",
"license": "MIT",
"authors": [
{
@ -31,6 +31,6 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "1.*",
"vimeo/psalm": "^4.6.2"
"vimeo/psalm": "^4.6.2 || ^5.2"
}
}

View File

@ -176,6 +176,7 @@ abstract class Enum implements \JsonSerializable, \Stringable
/** @psalm-var T $value */
foreach (static::toArray() as $key => $value) {
/** @psalm-suppress UnsafeGenericInstantiation */
$values[$key] = new static($value);
}
@ -297,6 +298,7 @@ abstract class Enum implements \JsonSerializable, \Stringable
$message = "No static method or enum constant '$name' in class " . static::class;
throw new \BadMethodCallException($message);
}
/** @psalm-suppress UnsafeGenericInstantiation */
return self::$instances[$class][$name] = new static($array[$name]);
}
return clone self::$instances[$class][$name];
@ -308,7 +310,6 @@ abstract class Enum implements \JsonSerializable, \Stringable
*
* @return mixed
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @psalm-pure
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()

View File

@ -43,7 +43,7 @@ final class Comparator extends \SebastianBergmann\Comparator\Comparator
);
}
private function formatEnum(Enum $enum = null)
private function formatEnum(?Enum $enum = null)
{
if ($enum === null) {
return "null";