diff --git a/application/app/controller/Base.php b/application/app/controller/Base.php index d41356b..7138526 100644 --- a/application/app/controller/Base.php +++ b/application/app/controller/Base.php @@ -141,17 +141,17 @@ class Base extends Controller{ $length = strlen($token); if ($length < 10 ) { Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,字符串长度小于10', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } }else{ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,不是字符串', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } - $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time')->find(); + $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time,language')->find(); if(!$user_login){ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,未找到用户token', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } // 创建 DateTime 对象来表示指定的日期和时间 @@ -174,16 +174,16 @@ class Base extends Controller{ if ($daysDifference > $this->token_time) { // echo "超过 {$specifiedDays} 天"; Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token,或该token已经超过30天', 'token_log'); - return false; + return ['state'=>false,'language'=>$user_login['language']]; } else { // echo "未超过 {$specifiedDays} 天"; $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]); if($user_login){ Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.date('Y-m-d H:i:s'), 'token_log'); - return true; + return ['state'=>true,'language'=>$user_login['language']]; }else{ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,数据库更新时间未成功', 'token_log'); - return true; + return ['state'=>true,'language'=>$user_login['language']]; } } @@ -709,6 +709,8 @@ class Base extends Controller{ + + public function ceshiyong($aa = 4,$gd = 0.2){ $token = 'cd3f27cf4c4002170ea7bceeb723ac91'; diff --git a/application/app/controller/Card.php b/application/app/controller/Card.php index 16570e3..e9a0ef2 100644 --- a/application/app/controller/Card.php +++ b/application/app/controller/Card.php @@ -88,7 +88,7 @@ class Card extends Base{ // 详细卡片信息 // $data = ['id'=>'2'] - public function card_data_detailed($data=['aud_id'=>'38']){ + public function card_data_detailed($data=['aud_id'=>'144']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -100,9 +100,10 @@ class Card extends Base{ if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); } + // $return_data; $return_data = $this->get_user_body_data($data); - // 成功 - $this->record_api_log($data, null, $return_data); + // $language_data = new Language(); + // $return_data = $language_data->handling_languages_from_multiple_countries('en', $return_data->getData()); return $return_data; } catch (\Exception $e) { // 捕获异常 @@ -591,9 +592,11 @@ class Card extends Base{ // 处理返回数据 $result_end = $this->processing_return_data_new($result[0]); + $cardparts = new Cardparts; $result_end['gender'] = $result[0]['gender']; $result_end['record_time'] = $result[0]['record_time']; + $result_end['score'] = $result_end['score']; $result_end['body_type'] = $result_end['body_type']; $result_end = $cardparts->conversion_interval($result_end); @@ -605,6 +608,7 @@ class Card extends Base{ 'bmi'=>$result[0]['bmi'] ], ]); + // 只有含有阻抗的记录才有数据参考 if($result[0]['record_type'] == 'by_device_adc'){ if(count($result_end['cplist']['nutritionlist']) <= 0){ @@ -628,7 +632,7 @@ class Card extends Base{ 'initial_weight'=>$result[0]['initial_weight']>0?$result[0]['initial_weight']:0, 'initial_date'=>$result[0]['initial_date']!=null?$result[0]['initial_date']:0, ]); - + // dump($result_end); if(count($result_end['top_list'][2]['list']) <= 0){ // 这是16岁以上人群 $data = [ @@ -639,15 +643,20 @@ class Card extends Base{ ]; $temporary_arr_bmi_list = $this->card_bmi_evaluation($data,true); + // dump($temporary_arr_bmi_list); $temporary_arr_bmi_list = $temporary_arr_bmi_list->getData(); - + // dump($temporary_arr_bmi_list); + // die; if($temporary_arr_bmi_list['code'] == 0){ $result_end['top_list'][2]['standard'] = $temporary_arr_bmi_list['data']['bmilevel']; $result_end['top_list'][2]['color'] = $temporary_arr_bmi_list['data']['bmilevelcolor']; $result_end['top_list'][2]['list'] = $temporary_arr_bmi_list['data']['bmilevellist']; $result_end['top_list'][2]['offset'] = $temporary_arr_bmi_list['data']['offset']; } + // dump($result_end); + // die; } + // 加入曲线板块底部的减肥计划数据end // 添加头围数据(如果有的话)start if($head_circumference !== false && $this->calculate_age($result[0]['birthday']) < 3){ @@ -664,7 +673,7 @@ class Card extends Base{ 'color'=>'', 'list'=>$head_circumference['list2'], 'key_name'=>'head_circumference', - 'desc'=>'头围是指绕头部一周的最大长度,头围的大小与闹的发育密切相关', + 'desc'=>'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关', 'offset'=>$offset ]); } @@ -782,6 +791,7 @@ class Card extends Base{ $min_key = array_search($min_value,$temporary_arr); $type_num = $this->card_body_level[$min_key]['value']; $temporary_arr2 = Db::table($this->card_use_db_name['6'])->where(['Type'=>$type_num,'Level'=>$min_value,'IsDeleted'=>0])->field('Nutrition,Sport')->find(); + // dump($temporary_arr2); array_push($result['nutritionlist'],$temporary_arr2['Nutrition']); array_push($result['sportlist'],$temporary_arr2['Sport']); // $result['nutritionlist'] = $temporary_arr2['Nutrition']; diff --git a/application/app/controller/Cardparts.php b/application/app/controller/Cardparts.php index 105dce5..bde25eb 100644 --- a/application/app/controller/Cardparts.php +++ b/application/app/controller/Cardparts.php @@ -191,10 +191,10 @@ class Cardparts extends Base{ 'bottom_list'=>[], ]; // die; - $date_temporary = new \DateTime($temporary_arr['record_time']); + // $date_temporary = new \DateTime($temporary_arr['record_time']); // 使用 format 方法来指定新的日期和时间格式 - $temporary_arr['record_time'] = $date_temporary->format('Y年m月d日 H:i:s'); + // $temporary_arr['record_time'] = $date_temporary->format('Y年m月d日 H:i:s'); // 处理格式(顶部) foreach ($this->parameter_aggregate_top as $key => $value) { $data[$key]['key_name'] = $key; diff --git a/application/app/controller/Index.php b/application/app/controller/Index.php index 838d153..d501106 100644 --- a/application/app/controller/Index.php +++ b/application/app/controller/Index.php @@ -4,6 +4,8 @@ namespace app\app\controller; use think\Db; use \think\Validate; +use app\app\controller\Language; +// use ip2region\Ip2Region; class Index extends Base{ protected $moren_gufen_diqu = '北京,北京'; @@ -60,6 +62,39 @@ class Index extends Base{ ['min'=>'3','max'=>'16','value'=>'儿童'], ['min'=>'16','max'=>'500','value'=>'成人'] ]; + + protected $language_country = [ + 'en' => 'English', // 英语(通用)★ + 'zh-Hans' => '中文', // 中文(简体)★ + // 'es' => 'Español', // 西班牙语(西班牙)★ + // 'fr' => 'Français', // 法语(法国)★ + // 'pt' => 'Português', // 葡萄牙语(巴西)★ + // 'ar' => 'العربية', // 阿拉伯语(标准)★ + // 'ru' => 'Русский', // 俄语(俄罗斯)★ + // 'de' => 'Deutsch', // 德语(德国)★ + // 'ja' => '日本語', // 日语 + // 'ko' => '한국어', // 韩语 + // 'it' => 'Italiano', // 意大利语 + // 'nl' => 'Nederlands', // 荷兰语 + // 'hi' => 'हिन्दी', // 印地语 + // 'tr' => 'Türkçe', // 土耳其语 + // 'vi' => 'Tiếng Việt', // 越南语 + // 'th' => 'ไทย', // 泰语 + // 'pl' => 'Polski', // 波兰语 + // 'sv' => 'Svenska', // 瑞典语 + // 'fi' => 'Suomi', // 芬兰语 + // 'da' => 'Dansk', // 丹麦语 + // 'no' => 'Norsk', // 挪威语 + // 'he' => 'עברית', // 希伯来语 + // 'id' => 'Bahasa Indonesia', // 印尼语 + // 'ms' => 'Bahasa Melayu', // 马来语 + // 'cs' => 'Čeština', // 捷克语 + // 'hu' => 'Magyar', // 匈牙利语 + // 'el' => 'Ελληνικά', // 希腊语 + // 'ro' => 'Română', // 罗马尼亚语 + // 'sk' => 'Slovenčina', // 斯洛伐克语 + // 'uk' => 'Українська', // 乌克兰语 + ]; ################################################################个人资料卡################################################################ @@ -67,8 +102,35 @@ class Index extends Base{ ################################################################个人资料卡################################################################ // 检测版本及判断是否登录失效 - public function login_invalid_version($data = ['token'=>'']){ + public function login_invalid_version($data = ['token'=>'2d4ea9b3f44b169ddf64b2f3d2725ceb']){ try { + // 获取客户端IP + $ip = request()->ip(); + // 调用IP识别方法 + $region = $this->getIpInfo($ip); + // 解析地区信息 + $regionParts = explode('|', $region); + $country = $regionParts[0] ?? ''; + // 判断国家是否在支持的语言列表中 + $language = ''; + if ($country && $country !== '0') { + $languageMap = [ + '中国' => 'zh-Hans', + '美国' => 'en', + '英国' => 'en', + '西班牙' => 'es', + '法国' => 'fr', + '葡萄牙' => 'pt', + '阿拉伯联合酋长国' => 'ar', + '俄罗斯' => 'ru', + '德国' => 'de' + ]; + $language = $languageMap[$country] ?? ''; + } + // 检查语言是否在支持列表中 + $language_all = new Language(); + $isSupportedLanguage = array_key_exists($language, $language_all->getSupportedLanguages()); + // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -84,12 +146,13 @@ class Index extends Base{ $version = ''; $url = ''; } - if($this->token_time_validate($data['token']) === false){ - $this->record_api_log($data, null, ['code'=>-1,'msg'=>'未登录',['version'=>$version,'url'=>$url]]); - return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url]); + $user_token_state = $this->token_time_validate($data['token']); + + $language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language); + if($user_token_state['state'] === false){ + return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->language_country]); }else{ - $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',['version'=>$version,'url'=>$url]]); - return $this->msg(['version'=>$version,'url'=>$url]); + return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->language_country]); } } catch (\Exception $e) { @@ -100,12 +163,62 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\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); } } + + // 添加IP信息获取方法 + protected function getIpInfo($ip) { + // 默认IP + $ip = $ip ?: request()->ip(); + try { + $ip2region = new \Ip2Region(); + $info = $ip2region->memorySearch($ip); + // 返回国家信息 + return $info['region'] ?: '未知'; + } catch (\Exception $e) { + return '未知'; + } + } + + public function set_language_country($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','language'=>'zh']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data) || !array_key_exists('language', $data)){ + return $this->msg(10001); + } + + if(!array_key_exists($data['language'],$this->language_country)){ + return $this->msg(10007); + } + $result = Db::table($this->index_use_db_name['7'])->where(['token'=>$data['token']])->update(['language'=>$data['language']]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } 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'] .= "方法: " . __METHOD__ . "\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 create_user_data($data = ['aan_id'=>1,'height'=>'152.3','weight'=>'35.4','nickname'=>'钮祜禄测试1','birthday'=>'2019-04-20','gender'=>1,'grade'=>'grade_s_3','identity_id'=>'P3','identity_name'=>'大宝','address'=>'河南,郑州','token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){ @@ -143,14 +256,12 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\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_data($data = ['id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级','identity_id'=>'P3','identity_name'=>'大宝','address'=>'河南,郑州','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ @@ -187,6 +298,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -230,6 +342,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -238,7 +351,6 @@ class Index extends Base{ } - // 获取账号下用户列表 // $type 1获取列表,2获取详细信息 public function get_user_card_list($data = ['aan_id'=>4,'type'=>2,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ @@ -298,6 +410,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -307,7 +420,7 @@ class Index extends Base{ } // 获取指定用户详细信息 - public function get_user_data_information($data = ['aud_id'=>113]){ + public function get_user_data_information($data = ['aud_id'=>61]){ // try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -449,6 +562,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -498,6 +612,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -535,6 +650,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -583,6 +699,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -1025,6 +1142,20 @@ class Index extends Base{ return $parameter; } + public function pd_language($user_language,$isSupportedLanguage,$language){ + if(!$user_language){ + if($isSupportedLanguage){ + $result = $language; + }else{ + $result = 'zh-Hans'; // 默认语言为中文 + } + }else{ + $result = $user_language; + } + return $result; + } + + diff --git a/application/app/controller/Language.php b/application/app/controller/Language.php new file mode 100644 index 0000000..141bcac --- /dev/null +++ b/application/app/controller/Language.php @@ -0,0 +1,211 @@ + 'English', + 'zh-Hans' => 'Chinese', + 'es' => 'Spanish', + 'fr' => 'French', + 'pt' => 'Portuguese', + 'ar' => 'Arabic', + 'ru' => 'Russian', + 'de' => 'German' + ]; + + // 语言映射表 + protected $languageMap = [ + 'en' => [ + '操作成功' => 'Success', + '体重' => 'Weight', + '身高' => 'Height', + '消瘦' => 'Slim', + '正常' => 'Normal', + '偏重' => 'Overweight', + '肥胖' => 'Obesity', + '反映和衡量一个人健康状况的重要标志之一' => "One of the important indicators reflecting and measuring a person's health status", + '人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大' => "The length of the longitudinal part of the human body is derived from its longitudinal growth and is greatly influenced by genetic factors", + 'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.", + '公斤' => "kg", + 'CM' => "cm", + '年' => "-", + '月' => "-", + '日' => "", + '身体得分' => "Physical score", + '分' => "score", + '身体类型' => "body type", + '健美肌肉型' => "Bodybuilding muscle type", + '低' => "Low", + '偏低' => "Slightly low", + '标准' => "Standard", + '偏高' => "Slightly high", + '高' => "High", + '矮' => "Short", + '偏矮' => "Slightly short", + '脂肪率' => "Body Fat Percentage", + '体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.", + '脂肪量' => "Fat Mass", + '人体脂肪的重量' => "Body Fat Weight", + '肌肉率' => "Muscle Percentage", + '优' => "Excellent", + '根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.", + '肌肉量' => "Muscle Mass", + '不足' => "Insufficient", + '肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage", + '水分' => "Body Water", + '指人体内水分比例。' => "Refers to the proportion of water in the human body.", + '蛋白量' => "Protein Mass", + '蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage", + '骨重' => "Bone Mass", + '单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.", + '蛋白率' => "Protein Percentage", + '人体内蛋白率含量。' => "The proportion of protein in the human body.", + '基础代谢' => "Basal Metabolic Rate (BMR)", + '指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.", + '内脏指数' => "Visceral Fat Index", + '警惕' => "Caution", + '危险' => "Danger", + '内脏脂肪指数' => "Visceral Fat Level", + '皮下脂肪' => "Subcutaneous Fat", + '皮下脂脂肪就是贮存于皮下的脂肪组织,人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.", + '肥胖等级' => "Obesity Level", + '体重不足' => "Underweight", + '肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.", + '孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.", + '孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => "The child may be malnourished: For children in their growth and development stage, the most beneficial nutrients for height growth are proteins, carbohydrates, vitamins, and minerals. It is recommended to ensure adequate intake of nutrients such as protein, zinc, iron, calcium, vitamin D, and lysine.", + '坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.", + '3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.", + '该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.", + '孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').", + '《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》", + '《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》", + '《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》", + '《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》", + '头围' => "Head Circumference", + '头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.", + + ], + // 可以添加更多语言映射 + ]; + + /** + * 处理多国语言翻译 + * + * @param string $language 目标语言代码 + * @param mixed $data 要翻译的数据(字符串或数组) + * @return mixed 翻译后的数据 + */ + public function handling_languages_from_multiple_countries($language, $data) + { + + // dump($data); + // 验证语言是否支持 + if (!$this->isLanguageSupported($language)) { + return $this->msg($data['data']); + } + + // 如果是数组,递归处理每个元素 + if (is_array($data)) { + // dump(2); + $data = $this->translateArray($language, $data); + return $this->msg($data['data']); + } + + // 如果是字符串,直接翻译 + if (is_string($data)) { + // dump(3); + return $this->translateString($language, $data); + } + + // dump($data); + // 其他类型直接返回 + return $this->msg($data['data']); + } + + /** + * 检查语言是否支持 + * + * @param string $language 语言代码 + * @return bool + */ + protected function isLanguageSupported($language) + { + return isset($this->supportedLanguages[$language]); + } + + /** + * 翻译数组 + * + * @param string $language 目标语言 + * @param array $array 要翻译的数组 + * @return array 翻译后的数组 + */ + protected function translateArray($language, array $array) + { + $result = []; + foreach ($array as $key => $value) { + // 保持键不变,只翻译值 + $result[$key] = is_array($value) + ? $this->translateArray($language, $value) + : $this->translateString($language, $value); + } + return $result; + } + + /** + * 翻译字符串 + * + * @param string $language 目标语言 + * @param string $string 要翻译的字符串 + * @return string 翻译后的字符串 + */ + protected function translateString($language, $string) + { + // dump($string); + // 检查是否有该语言的映射表 + if (!isset($this->languageMap[$language])) { + return $string; + } + + // 检查是否有对应的翻译 + return $this->languageMap[$language][$string] ?? $string; + } + + /** + * 获取支持的语言列表 + * + * @return array + */ + public function getSupportedLanguages() + { + return $this->supportedLanguages; + } + + /** + * 添加新的语言翻译 + * + * @param string $language 语言代码 + * @param array $translations 翻译映射数组 + * @return bool + */ + public function addTranslations($language, array $translations) + { + if (!$this->isLanguageSupported($language)) { + return false; + } + + if (!isset($this->languageMap[$language])) { + $this->languageMap[$language] = []; + } + + $this->languageMap[$language] = array_merge( + $this->languageMap[$language], + $translations + ); + + return true; + } +} \ No newline at end of file diff --git a/application/app/controller/Login.php b/application/app/controller/Login.php index 8f3dc38..cd8f044 100644 --- a/application/app/controller/Login.php +++ b/application/app/controller/Login.php @@ -91,7 +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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -156,7 +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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -240,7 +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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -318,7 +318,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'] .= "方法: (wechat_quick_login)" . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -356,7 +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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -392,7 +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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); diff --git a/application/appbackups/controller/Base.php b/application/appbackups/controller/Base.php index 3d86444..7138526 100644 --- a/application/appbackups/controller/Base.php +++ b/application/appbackups/controller/Base.php @@ -141,17 +141,17 @@ class Base extends Controller{ $length = strlen($token); if ($length < 10 ) { Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,字符串长度小于10', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } }else{ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,不是字符串', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } - $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time')->find(); + $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->field('id,login_time,language')->find(); if(!$user_login){ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,未找到用户token', 'token_log'); - return false; + return ['state'=>false,'language'=>null]; } // 创建 DateTime 对象来表示指定的日期和时间 @@ -174,16 +174,16 @@ class Base extends Controller{ if ($daysDifference > $this->token_time) { // echo "超过 {$specifiedDays} 天"; Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token,或该token已经超过30天', 'token_log'); - return false; + return ['state'=>false,'language'=>$user_login['language']]; } else { // echo "未超过 {$specifiedDays} 天"; $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]); if($user_login){ Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.date('Y-m-d H:i:s'), 'token_log'); - return true; + return ['state'=>true,'language'=>$user_login['language']]; }else{ Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,数据库更新时间未成功', 'token_log'); - return true; + return ['state'=>true,'language'=>$user_login['language']]; } } @@ -612,6 +612,103 @@ class Base extends Controller{ } + + // 处理身高体重的单位,转换它们为cm和kg。 + public function convertHeightAndWeight($height, $weight) { + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + // 定义单位转换比例 + $heightConversion = [ + 'cm' => 1, + 'inch' => 2.54, + 'ft-in' => function($value) { + list($ft, $in) = explode('-', $value); + return $ft * 30.48 + $in * 2.54; // 1 foot = 30.48 cm, 1 inch = 2.54 cm + } + ]; + $weightConversion = [ + 'kg' => 1, + '斤' => 0.5, // 1斤 = 0.5kg + 'st:lb' => function($value) { + list($st, $lb) = explode(':', $value); + return $st * 6.35029318 + $lb * 0.45359237; // 1 stone = 6.35029318 kg, 1 lb = 0.45359237 kg + }, + 'lb' => 0.45359237 // 1 lb = 0.45359237 kg + ]; + // 处理 height + if (preg_match('/([\d.]+)(cm|inch|ft-in)/', $height, $matches)) { + // $heightValue = floatval($matches[1]); + $heightValue = $matches[1]; + $heightUnit = $matches[2]; + if($heightUnit == 'ft-in'){ + // 如果单位为st:lb但是数据格式不对 + $heightValue = str_replace($heightUnit, "", $height); + if(count(explode('-', $heightValue)) < 2){ + $heightValue = str_replace("-", "", $heightValue); + $heightValue = $heightValue."-0"; + } + } + if (isset($heightConversion[$heightUnit])) { + if (is_callable($heightConversion[$heightUnit])) { + $heightInCm = $heightConversion[$heightUnit]($heightValue); + } else { + $heightInCm = $heightValue * $heightConversion[$heightUnit]; + } + } else { + // 未知单位,返回错误 + $heightInCm = false; + } + } else { + // 未找到指定单位判断是否是数字 + if (preg_match('/^-?\d+(\.\d+)?$/', $height)) { + $heightInCm = $height; + } else { + $heightInCm = false; + } + } + + + // 处理 weight + if (preg_match('/([\d.:]+)(kg|斤|st:lb|lb)/', $weight, $matches)) { + $weightValue = $matches[1]; + $weightUnit = $matches[2]; + if($weightUnit == 'st:lb'){ + // 如果单位为st:lb但是数据格式不对 + $weightValue = str_replace($weightUnit, "", $weight); + if(count(explode(':', $weightValue)) < 2){ + $weightValue = str_replace(":", "", $weightValue); + $weightValue = $weightValue.":0"; + } + } + if (isset($weightConversion[$weightUnit])) { + if (is_callable($weightConversion[$weightUnit])) { + $weightInKg = $weightConversion[$weightUnit]($weightValue); + } else { + $weightInKg = $weightValue * $weightConversion[$weightUnit]; + } + } else { + // 未知单位,返回错误 + $weightInKg = false; + } + } else { + // 未找到指定单位判断是否是数字 + if (preg_match('/^-?\d+(\.\d+)?$/', $weight)) { + $weightInKg = $weight; + } else { + $weightInKg = false; + } + } + + return [ + 'height_in_cm' => bcmul($heightInCm,1,2), + 'weight_in_kg' => bcmul($weightInKg,1,2) + ]; + } + + + public function ceshiyong($aa = 4,$gd = 0.2){ diff --git a/application/appbackups/controller/Card.php b/application/appbackups/controller/Card.php index a873635..e9a0ef2 100644 --- a/application/appbackups/controller/Card.php +++ b/application/appbackups/controller/Card.php @@ -88,7 +88,7 @@ class Card extends Base{ // 详细卡片信息 // $data = ['id'=>'2'] - public function card_data_detailed($data=['aud_id'=>'38']){ + public function card_data_detailed($data=['aud_id'=>'144']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -100,9 +100,10 @@ class Card extends Base{ if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); } + // $return_data; $return_data = $this->get_user_body_data($data); - // 成功 - $this->record_api_log($data, null, $return_data); + // $language_data = new Language(); + // $return_data = $language_data->handling_languages_from_multiple_countries('en', $return_data->getData()); return $return_data; } catch (\Exception $e) { // 捕获异常 @@ -181,12 +182,21 @@ class Card extends Base{ if(!$this->verify_data_is_ok($data['time'],'datetime')){ return $this->msg(10005); } - if(!$this->verify_data_is_ok($data['height'],'num')){ - return $this->msg(10005); + $temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']); + if($temporary_data['height_in_cm'] == false){ + return $this->msg(10005,'身高单位错误'); } - if(!$this->verify_data_is_ok($data['weight'],'num')){ - return $this->msg(10005); + if($temporary_data['weight_in_kg'] == false){ + return $this->msg(10005,'体重单位错误'); } + $data['height'] = $temporary_data['height_in_cm']; + $data['weight'] = $temporary_data['weight_in_kg']; + // if(!$this->verify_data_is_ok($data['height'],'num')){ + // return $this->msg(10005); + // } + // if(!$this->verify_data_is_ok($data['weight'],'num')){ + // return $this->msg(10005); + // } // $data['height'] = explode(',',$data['height']); // if(count($data['height']) < 2){ // return $this->msg(10005); @@ -232,7 +242,7 @@ class Card extends Base{ // 设备记录 // $data = ['id'=>'2','time'=>'1991-04-20 10:10:10','height'=>'15.1','weight'=>'75.1'] // public function card_manual_recording_device($data = ['aud_id'=>'37','height'=>'169.60,inch','weight'=>'52.45,lb','adc'=>'520.3','token'=>'591b70e0d80b5fa6d77e6e1384453ab9']){ - public function card_manual_recording_device($data = ['aud_id'=>'37','height'=>'169.60','weight'=>'52.45','adc'=>'520.3','token'=>'591b70e0d80b5fa6d77e6e1384453ab9']){ + public function card_manual_recording_device($data = ['aud_id'=>'37','height'=>'169.60斤','weight'=>'52.45斤','adc'=>'520.3','token'=>'591b70e0d80b5fa6d77e6e1384453ab9']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -246,12 +256,25 @@ class Card extends Base{ if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); } - if(!$this->verify_data_is_ok($data['height'],'num')){ + if(!$this->verify_data_is_ok($data['adc'],'num')){ return $this->msg(10005); } - if(!$this->verify_data_is_ok($data['weight'],'num')){ - return $this->msg(10005); + $temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']); + if($temporary_data['height_in_cm'] == false){ + return $this->msg(10005,'身高单位错误'); } + if($temporary_data['weight_in_kg'] == false){ + return $this->msg(10005,'体重单位错误'); + } + $data['height'] = $temporary_data['height_in_cm']; + $data['weight'] = $temporary_data['weight_in_kg']; + + // if(!$this->verify_data_is_ok($data['height'],'num')){ + // return $this->msg(10005); + // } + // if(!$this->verify_data_is_ok($data['weight'],'num')){ + // return $this->msg(10005); + // } // $data['height'] = explode(',',$data['height']); // if(count($data['height']) < 2){ // return $this->msg(10005); @@ -272,9 +295,7 @@ class Card extends Base{ // if(!in_array($data['weight'][1],$this->unit_data['weight'])){ // return $this->msg(10005); // } - if(!$this->verify_data_is_ok($data['adc'],'num')){ - return $this->msg(10005); - } + $data['time'] = date('Y-m-d H:i:s'); $data['acd_id'] = '2'; $return_data = $this->set_user_body_data($data,'by_device'); @@ -571,9 +592,11 @@ class Card extends Base{ // 处理返回数据 $result_end = $this->processing_return_data_new($result[0]); + $cardparts = new Cardparts; $result_end['gender'] = $result[0]['gender']; $result_end['record_time'] = $result[0]['record_time']; + $result_end['score'] = $result_end['score']; $result_end['body_type'] = $result_end['body_type']; $result_end = $cardparts->conversion_interval($result_end); @@ -585,6 +608,7 @@ class Card extends Base{ 'bmi'=>$result[0]['bmi'] ], ]); + // 只有含有阻抗的记录才有数据参考 if($result[0]['record_type'] == 'by_device_adc'){ if(count($result_end['cplist']['nutritionlist']) <= 0){ @@ -608,7 +632,7 @@ class Card extends Base{ 'initial_weight'=>$result[0]['initial_weight']>0?$result[0]['initial_weight']:0, 'initial_date'=>$result[0]['initial_date']!=null?$result[0]['initial_date']:0, ]); - + // dump($result_end); if(count($result_end['top_list'][2]['list']) <= 0){ // 这是16岁以上人群 $data = [ @@ -619,15 +643,20 @@ class Card extends Base{ ]; $temporary_arr_bmi_list = $this->card_bmi_evaluation($data,true); + // dump($temporary_arr_bmi_list); $temporary_arr_bmi_list = $temporary_arr_bmi_list->getData(); - + // dump($temporary_arr_bmi_list); + // die; if($temporary_arr_bmi_list['code'] == 0){ $result_end['top_list'][2]['standard'] = $temporary_arr_bmi_list['data']['bmilevel']; $result_end['top_list'][2]['color'] = $temporary_arr_bmi_list['data']['bmilevelcolor']; $result_end['top_list'][2]['list'] = $temporary_arr_bmi_list['data']['bmilevellist']; $result_end['top_list'][2]['offset'] = $temporary_arr_bmi_list['data']['offset']; } + // dump($result_end); + // die; } + // 加入曲线板块底部的减肥计划数据end // 添加头围数据(如果有的话)start if($head_circumference !== false && $this->calculate_age($result[0]['birthday']) < 3){ @@ -644,7 +673,7 @@ class Card extends Base{ 'color'=>'', 'list'=>$head_circumference['list2'], 'key_name'=>'head_circumference', - 'desc'=>'头围是指绕头部一周的最大长度,头围的大小与闹的发育密切相关', + 'desc'=>'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关', 'offset'=>$offset ]); } @@ -762,6 +791,7 @@ class Card extends Base{ $min_key = array_search($min_value,$temporary_arr); $type_num = $this->card_body_level[$min_key]['value']; $temporary_arr2 = Db::table($this->card_use_db_name['6'])->where(['Type'=>$type_num,'Level'=>$min_value,'IsDeleted'=>0])->field('Nutrition,Sport')->find(); + // dump($temporary_arr2); array_push($result['nutritionlist'],$temporary_arr2['Nutrition']); array_push($result['sportlist'],$temporary_arr2['Sport']); // $result['nutritionlist'] = $temporary_arr2['Nutrition']; diff --git a/application/appbackups/controller/Cardparts.php b/application/appbackups/controller/Cardparts.php index 105dce5..bde25eb 100644 --- a/application/appbackups/controller/Cardparts.php +++ b/application/appbackups/controller/Cardparts.php @@ -191,10 +191,10 @@ class Cardparts extends Base{ 'bottom_list'=>[], ]; // die; - $date_temporary = new \DateTime($temporary_arr['record_time']); + // $date_temporary = new \DateTime($temporary_arr['record_time']); // 使用 format 方法来指定新的日期和时间格式 - $temporary_arr['record_time'] = $date_temporary->format('Y年m月d日 H:i:s'); + // $temporary_arr['record_time'] = $date_temporary->format('Y年m月d日 H:i:s'); // 处理格式(顶部) foreach ($this->parameter_aggregate_top as $key => $value) { $data[$key]['key_name'] = $key; diff --git a/application/appbackups/controller/Deepseek.php b/application/appbackups/controller/Deepseek.php new file mode 100644 index 0000000..bf4d722 --- /dev/null +++ b/application/appbackups/controller/Deepseek.php @@ -0,0 +1,210 @@ +'admin_editor_text_content', + '2'=>'admin_editor_text_like_up_log', + '3'=>'admin_notice_banner', + '4'=>'admin_business_cooperation' + ]; + protected $page_num = 10; + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + + + public function test_index(){ + + return $this->fetch(); + } + + + // 获取板块,及板块下类型标签 + public function send_msg_deepseek(){ + // dump('456'); + // die; + try { + $data = input('post.'); + // dump($data); + // dump(array_key_exists('xinxi', $data)); + + if(!array_key_exists('xinxi', $data)){ + return $this->msg(10001); + } + + if(!$this->verify_data_is_ok($data['xinxi'],'str')){ + return $this->msg(10005); + } + // $data['msg'] = ""; + // dump($data); + // die; + $return_data = $this->deepseek_only_onec_action($data); + // $return_data = $this->deepseek_ceshiyongjiekou($data); + return $return_data; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] = "接口:send_msg_deepseek\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([], $logContent, null); + return $this->msg(99999); + } + + } + + public function deepseek_only_onec_action($xinxi){ + // DeepSeek API密钥 + // $apiKey = 'sk-28dd23215ef84772b64d77011419e271'; + $apiKey = 'bd739e8c-91af-40bb-85d4-0804060b2390'; + // DeepSeek API的端点 + // $apiUrl = 'https://api.deepseek.com/v1/chat/completions'; + $apiUrl = 'https://ark.cn-beijing.volces.com/api/v3/chat/completions'; + + + // 准备请求数据 + $data = [ + "messages" => [ + [ + "content" => "你是一个有关身体健康的专家,能根据用户提供的身体数据给出对应的分析和建议", + "role" => "system" + ], + [ + "content" => $xinxi['xinxi'], + "role" => "user" + ] + ], + // "model" => "deepseek-chat", + "model" => "ep-20250304141108-x9d7l", + "frequency_penalty" => 0, + "max_tokens" => 2048, + "presence_penalty" => 0, + "response_format" => [ + "type" => "text" //指定生成文本的格式。"type": 指定格式类型,例如"text"(纯文本)或"json"(JSON格式)。 + ], + "stop" => null, + "stream" => false, + "stream_options" => null, + "temperature" => 1, + "top_p" => 1, + "tools" => null, + "tool_choice" => "none", + "logprobs" => false, + "top_logprobs" => null + ]; + + // 初始化cURL会话 + $ch = curl_init(); + + // 设置cURL选项 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 禁用证书验证 + curl_setopt($ch, CURLOPT_URL, $apiUrl); // 设置API URL + curl_setopt($ch, CURLOPT_POST, true); // 使用POST方法 + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // 设置POST数据 + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Authorization: Bearer ' . $apiKey, // 设置API密钥 + 'Content-Type: application/json', // 设置请求头为JSON + ]); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回响应而不是直接输出 + + // 执行cURL请求并获取响应 + $response = curl_exec($ch); + + // 检查是否有cURL错误 + if (curl_errno($ch)) { + echo 'cURL请求失败: ' . curl_error($ch); + } else { + // 获取HTTP状态码 + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($httpCode === 200) { + // 解析JSON响应 + $result = json_decode($response, true); + // print_r($result); // 输出API响应 + + return $this->msg(0,$result['choices'][0]['message']['content']); + // dump($result); + } else { + return $this->msg(['code'=>$httpCode]); + // echo 'API请求失败,HTTP状态码: ' . $httpCode; + // echo '响应内容: ' . $response; + } + } + + // 关闭cURL会话 + curl_close($ch); + + } + + + public function deepseek_ceshiyongjiekou(){ + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => 'https://api.deepseek.com/chat/completions', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "messages": [ + { + "content": "You are a helpful assistant", + "role": "system" + }, + { + "content": "Hi", + "role": "user" + } + ], + "model": "deepseek-chat", + "frequency_penalty": 0, + "max_tokens": 2048, + "presence_penalty": 0, + "response_format": { + "type": "text" + }, + "stop": null, + "stream": false, + "stream_options": null, + "temperature": 1, + "top_p": 1, + "tools": null, + "tool_choice": "none", + "logprobs": false, + "top_logprobs": null + }', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Bearer ' + ), + )); + + $response = curl_exec($curl); + + curl_close($curl); + echo $response; + } + + + + +} \ No newline at end of file diff --git a/application/appbackups/controller/Download.php b/application/appbackups/controller/Download.php index ab6723a..0d5efc2 100644 --- a/application/appbackups/controller/Download.php +++ b/application/appbackups/controller/Download.php @@ -31,6 +31,28 @@ class Download extends Base{ return $this->fetch(); } + public function business_cooperation(){ + return $this->fetch(); + } + + public function business_cooperation_action(){ + $data = input(); + $result = Db::table('admin_business_cooperation_log')->insert([ + 'name'=>$data['name'], + 'tel'=>$data['phone'], + 'company'=>$data['company'], + 'intention_data'=>implode(',',$data['selectedValues']), + 'notes_data'=>$data['remark'], + 'create_time'=>date('Y-m-d H:i:s'), + ]); + if($result){ + $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'商户合作','from_user_name'=>'reedaw商务','content'=>'有一封商户合作']); + return json(['code'=>0,'msg'=>'提交成功']); + }else{ + return json(['code'=>10001,'msg'=>'网络错误,请直接联系商务合作电话/微信:13590959084']); + } + } + public function ceshi(){ $data = input(); $url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3'; diff --git a/application/appbackups/controller/Index.php b/application/appbackups/controller/Index.php index d3bc2c3..8ca076c 100644 --- a/application/appbackups/controller/Index.php +++ b/application/appbackups/controller/Index.php @@ -4,6 +4,8 @@ namespace app\app\controller; use think\Db; use \think\Validate; +use app\app\controller\Language; +// use ip2region\Ip2Region; class Index extends Base{ protected $moren_gufen_diqu = '北京,北京'; @@ -60,6 +62,39 @@ class Index extends Base{ ['min'=>'3','max'=>'16','value'=>'儿童'], ['min'=>'16','max'=>'500','value'=>'成人'] ]; + + protected $language_country = [ + 'en' => 'English', // 英语(通用)★ + 'zh' => '中文', // 中文(简体)★ + 'es' => 'Español', // 西班牙语(西班牙)★ + 'fr' => 'Français', // 法语(法国)★ + 'pt' => 'Português', // 葡萄牙语(巴西)★ + 'ar' => 'العربية', // 阿拉伯语(标准)★ + 'ru' => 'Русский', // 俄语(俄罗斯)★ + 'de' => 'Deutsch', // 德语(德国)★ + // 'ja' => '日本語', // 日语 + // 'ko' => '한국어', // 韩语 + // 'it' => 'Italiano', // 意大利语 + // 'nl' => 'Nederlands', // 荷兰语 + // 'hi' => 'हिन्दी', // 印地语 + // 'tr' => 'Türkçe', // 土耳其语 + // 'vi' => 'Tiếng Việt', // 越南语 + // 'th' => 'ไทย', // 泰语 + // 'pl' => 'Polski', // 波兰语 + // 'sv' => 'Svenska', // 瑞典语 + // 'fi' => 'Suomi', // 芬兰语 + // 'da' => 'Dansk', // 丹麦语 + // 'no' => 'Norsk', // 挪威语 + // 'he' => 'עברית', // 希伯来语 + // 'id' => 'Bahasa Indonesia', // 印尼语 + // 'ms' => 'Bahasa Melayu', // 马来语 + // 'cs' => 'Čeština', // 捷克语 + // 'hu' => 'Magyar', // 匈牙利语 + // 'el' => 'Ελληνικά', // 希腊语 + // 'ro' => 'Română', // 罗马尼亚语 + // 'sk' => 'Slovenčina', // 斯洛伐克语 + // 'uk' => 'Українська', // 乌克兰语 + ]; ################################################################个人资料卡################################################################ @@ -67,8 +102,35 @@ class Index extends Base{ ################################################################个人资料卡################################################################ // 检测版本及判断是否登录失效 - public function login_invalid_version($data = ['token'=>'']){ + public function login_invalid_version($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){ try { + // 获取客户端IP + $ip = request()->ip(); + // 调用IP识别方法 + $region = $this->getIpInfo($ip); + // 解析地区信息 + $regionParts = explode('|', $region); + $country = $regionParts[0] ?? ''; + // 判断国家是否在支持的语言列表中 + $language = ''; + if ($country && $country !== '0') { + $languageMap = [ + '中国' => 'zh', + '美国' => 'en', + '英国' => 'en', + '西班牙' => 'es', + '法国' => 'fr', + '葡萄牙' => 'pt', + '阿拉伯联合酋长国' => 'ar', + '俄罗斯' => 'ru', + '德国' => 'de' + ]; + $language = $languageMap[$country] ?? ''; + } + // 检查语言是否在支持列表中 + $language_all = new Language(); + $isSupportedLanguage = array_key_exists($language, $language_all->getSupportedLanguages()); + // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -84,12 +146,18 @@ class Index extends Base{ $version = ''; $url = ''; } - if($this->token_time_validate($data['token']) === false){ - $this->record_api_log($data, null, ['code'=>-1,'msg'=>'未登录',['version'=>$version,'url'=>$url]]); - return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url]); + $user_token_state = $this->token_time_validate($data['token']); + + $user_language_data = Db::table($this->index_use_db_name['7'])->where(['token'=>$data['token']])->field('language')->find(); + if($user_language_data != null){ + $language_data = $user_language_data['language']; }else{ - $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',['version'=>$version,'url'=>$url]]); - return $this->msg(['version'=>$version,'url'=>$url]); + $language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language); + } + if($user_token_state['state'] === false){ + return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->language_country]); + }else{ + return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->language_country]); } } catch (\Exception $e) { @@ -100,12 +168,62 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\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); } } + + // 添加IP信息获取方法 + protected function getIpInfo($ip) { + // 默认IP + $ip = $ip ?: request()->ip(); + try { + $ip2region = new \Ip2Region(); + $info = $ip2region->memorySearch($ip); + // 返回国家信息 + return $info['region'] ?: '未知'; + } catch (\Exception $e) { + return '未知'; + } + } + + public function set_language_country($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a','language'=>'zh']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data) || !array_key_exists('language', $data)){ + return $this->msg(10001); + } + + if(!array_key_exists($data['language'],$this->language_country)){ + return $this->msg(10007); + } + $result = Db::table($this->index_use_db_name['7'])->where(['token'=>$data['token']])->update(['language'=>$data['language']]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } 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'] .= "方法: " . __METHOD__ . "\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 create_user_data($data = ['aan_id'=>1,'height'=>'152.3','weight'=>'35.4','nickname'=>'钮祜禄测试1','birthday'=>'2019-04-20','gender'=>1,'grade'=>'grade_s_3','identity_id'=>'P3','identity_name'=>'大宝','address'=>'河南,郑州','token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){ @@ -143,14 +261,12 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\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_data($data = ['id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级','identity_id'=>'P3','identity_name'=>'大宝','address'=>'河南,郑州','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ @@ -187,6 +303,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -230,6 +347,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -238,7 +356,6 @@ class Index extends Base{ } - // 获取账号下用户列表 // $type 1获取列表,2获取详细信息 public function get_user_card_list($data = ['aan_id'=>4,'type'=>2,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ @@ -298,6 +415,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -307,8 +425,8 @@ class Index extends Base{ } // 获取指定用户详细信息 - public function get_user_data_information($data = ['aud_id'=>11]){ - try { + public function get_user_data_information($data = ['aud_id'=>61]){ + // try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -334,7 +452,7 @@ class Index extends Base{ } } // 从这里开始进入体脂还是体测的判断 - $result['card_order'] = explode(',',$result['card_order']); + $result['card_order'] = $result['card_order'] == ""?[]:explode(',',$result['card_order']); if($result['measure_model'] == 1){// 这里是体测 $calculation_results = $this->get_user_card_data_list($result,$result['id']); $result['card_data_list'] = $calculation_results[0]; @@ -377,19 +495,19 @@ class Index extends Base{ } $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',$result]); return $this->msg($result); - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // $this->record_api_log($data, $logContent, null); + // return $this->msg(99999); + // } } @@ -449,6 +567,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -498,6 +617,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -535,6 +655,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -583,6 +704,7 @@ class Index extends Base{ $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -594,8 +716,6 @@ class Index extends Base{ // 获取账号下首页卡片的基础数据 public function get_user_card_data_list($data,$aud_id){ - // try { - // 你的业务逻辑 $result = []; $db_arr = []; foreach ($data['card_order'] as $key => $value) { @@ -641,7 +761,7 @@ class Index extends Base{ // 'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0, // ]); // } - + if(count($db_arr) <= 0){ // 没有数据,传递一个空的卡片 foreach ($data['card_order'] as $key => $value) { @@ -726,13 +846,7 @@ class Index extends Base{ array_push($result,$temporary_arr); } } - // 成功 - // $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[$result,$target_current]]); return [$result,$data['card_order']]; - // } catch (\Exception $e) { - // // 捕获异常 - // $this->record_api_log($data, $e->getMessage(), null); - // } } @@ -1033,6 +1147,20 @@ class Index extends Base{ return $parameter; } + public function pd_language($user_language,$isSupportedLanguage,$language){ + if(!$user_language){ + if($isSupportedLanguage){ + $result = $language; + }else{ + $result = 'en'; // 默认语言为中文 + } + }else{ + $result = $user_language; + } + return $result; + } + + diff --git a/application/appbackups/controller/Language.php b/application/appbackups/controller/Language.php new file mode 100644 index 0000000..65ee50c --- /dev/null +++ b/application/appbackups/controller/Language.php @@ -0,0 +1,211 @@ + 'English', + 'zh' => 'Chinese', + 'es' => 'Spanish', + 'fr' => 'French', + 'pt' => 'Portuguese', + 'ar' => 'Arabic', + 'ru' => 'Russian', + 'de' => 'German' + ]; + + // 语言映射表 + protected $languageMap = [ + 'en' => [ + '操作成功' => 'Success', + '体重' => 'Weight', + '身高' => 'Height', + '消瘦' => 'Slim', + '正常' => 'Normal', + '偏重' => 'Overweight', + '肥胖' => 'Obesity', + '反映和衡量一个人健康状况的重要标志之一' => "One of the important indicators reflecting and measuring a person's health status", + '人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大' => "The length of the longitudinal part of the human body is derived from its longitudinal growth and is greatly influenced by genetic factors", + 'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.", + '公斤' => "kg", + 'CM' => "cm", + '年' => "-", + '月' => "-", + '日' => "", + '身体得分' => "Physical score", + '分' => "score", + '身体类型' => "body type", + '健美肌肉型' => "Bodybuilding muscle type", + '低' => "Low", + '偏低' => "Slightly low", + '标准' => "Standard", + '偏高' => "Slightly high", + '高' => "High", + '矮' => "Short", + '偏矮' => "Slightly short", + '脂肪率' => "Body Fat Percentage", + '体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.", + '脂肪量' => "Fat Mass", + '人体脂肪的重量' => "Body Fat Weight", + '肌肉率' => "Muscle Percentage", + '优' => "Excellent", + '根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.", + '肌肉量' => "Muscle Mass", + '不足' => "Insufficient", + '肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage", + '水分' => "Body Water", + '指人体内水分比例。' => "Refers to the proportion of water in the human body.", + '蛋白量' => "Protein Mass", + '蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage", + '骨重' => "Bone Mass", + '单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.", + '蛋白率' => "Protein Percentage", + '人体内蛋白率含量。' => "The proportion of protein in the human body.", + '基础代谢' => "Basal Metabolic Rate (BMR)", + '指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.", + '内脏指数' => "Visceral Fat Index", + '警惕' => "Caution", + '危险' => "Danger", + '内脏脂肪指数' => "Visceral Fat Level", + '皮下脂肪' => "Subcutaneous Fat", + '皮下脂脂肪就是贮存于皮下的脂肪组织,人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.", + '肥胖等级' => "Obesity Level", + '体重不足' => "Underweight", + '肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.", + '孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.", + '孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => "The child may be malnourished: For children in their growth and development stage, the most beneficial nutrients for height growth are proteins, carbohydrates, vitamins, and minerals. It is recommended to ensure adequate intake of nutrients such as protein, zinc, iron, calcium, vitamin D, and lysine.", + '坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.", + '3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.", + '该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.", + '孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').", + '《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》", + '《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》", + '《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》", + '《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》", + '头围' => "Head Circumference", + '头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.", + + ], + // 可以添加更多语言映射 + ]; + + /** + * 处理多国语言翻译 + * + * @param string $language 目标语言代码 + * @param mixed $data 要翻译的数据(字符串或数组) + * @return mixed 翻译后的数据 + */ + public function handling_languages_from_multiple_countries($language, $data) + { + + // dump($data); + // 验证语言是否支持 + if (!$this->isLanguageSupported($language)) { + return $this->msg($data['data']); + } + + // 如果是数组,递归处理每个元素 + if (is_array($data)) { + // dump(2); + $data = $this->translateArray($language, $data); + return $this->msg($data['data']); + } + + // 如果是字符串,直接翻译 + if (is_string($data)) { + // dump(3); + return $this->translateString($language, $data); + } + + // dump($data); + // 其他类型直接返回 + return $this->msg($data['data']); + } + + /** + * 检查语言是否支持 + * + * @param string $language 语言代码 + * @return bool + */ + protected function isLanguageSupported($language) + { + return isset($this->supportedLanguages[$language]); + } + + /** + * 翻译数组 + * + * @param string $language 目标语言 + * @param array $array 要翻译的数组 + * @return array 翻译后的数组 + */ + protected function translateArray($language, array $array) + { + $result = []; + foreach ($array as $key => $value) { + // 保持键不变,只翻译值 + $result[$key] = is_array($value) + ? $this->translateArray($language, $value) + : $this->translateString($language, $value); + } + return $result; + } + + /** + * 翻译字符串 + * + * @param string $language 目标语言 + * @param string $string 要翻译的字符串 + * @return string 翻译后的字符串 + */ + protected function translateString($language, $string) + { + // dump($string); + // 检查是否有该语言的映射表 + if (!isset($this->languageMap[$language])) { + return $string; + } + + // 检查是否有对应的翻译 + return $this->languageMap[$language][$string] ?? $string; + } + + /** + * 获取支持的语言列表 + * + * @return array + */ + public function getSupportedLanguages() + { + return $this->supportedLanguages; + } + + /** + * 添加新的语言翻译 + * + * @param string $language 语言代码 + * @param array $translations 翻译映射数组 + * @return bool + */ + public function addTranslations($language, array $translations) + { + if (!$this->isLanguageSupported($language)) { + return false; + } + + if (!isset($this->languageMap[$language])) { + $this->languageMap[$language] = []; + } + + $this->languageMap[$language] = array_merge( + $this->languageMap[$language], + $translations + ); + + return true; + } +} \ No newline at end of file diff --git a/application/appbackups/controller/Login.php b/application/appbackups/controller/Login.php index 7306654..cd8f044 100644 --- a/application/appbackups/controller/Login.php +++ b/application/appbackups/controller/Login.php @@ -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{ @@ -20,7 +21,7 @@ class Login extends Base{ ################################################################接口################################################################ // 注册 - public function register_action($data = ['data'=>18530934717,'password'=>'ceshi','code'=>'746119']){ + public function register_action($data = ['data'=>13408173311,'password'=>'123','code'=>'746119']){ try { // 你的业务逻辑 // 验证是否前段发送过来的数据 @@ -46,11 +47,14 @@ class Login extends Base{ if($montage_data == false){ return $this->msg(10005); } + // 查询账号是否已经注册 $inspect_repeat = Db::table($this->login_use_db_name['1'])->where([$montage_data=>$data['data'],'is_del'=>0])->count(); - if($inspect_repeat >= 0){ + + if($inspect_repeat > 0){ return $this->msg(10002,'注册失败,账号已存在'); } + // 检查验证码 $code_result = $this->check_code($data['data'],$data['code']); if($code_result !== true){ @@ -87,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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -151,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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -158,7 +164,6 @@ class Login extends Base{ } } - // 登录 public function login_action($data = ['data'=>'18530934717','validate_data'=>'0932','type'=>'login','validate_type'=>'password']){ try { @@ -235,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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -242,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'] .= "方法: " . __METHOD__ . "\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']){ @@ -263,8 +345,6 @@ class Login extends Base{ }else{ $return_data = $this->msg(10002); } - - // 成功 $this->record_api_log($data, null, $return_data); return $return_data; @@ -276,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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -283,8 +364,6 @@ class Login extends Base{ } } - - // 删除账号 public function delete_account($data=['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ try { @@ -313,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'] .= "方法: " . __METHOD__ . "\n"; $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; $this->record_api_log($data, $logContent, null); @@ -333,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.'); @@ -349,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]); @@ -383,26 +464,31 @@ class Login extends Base{ curl_setopt($ch, CURLOPT_URL, $url); // 设置为POST请求 curl_setopt($ch, CURLOPT_POST, 1); - // 设置POST数据 + // 设置POST数据 $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); - // 设置返回结果不直接输出,而是返回到变量中 + // 设置返回结果不直接输出,而是返回到变量中 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - // 发送请求并获取响应 + // 发送请求并获取响应 $response = curl_exec($ch); // 检查是否有错误发生 if (curl_errno($ch)) { $error_message = curl_error($ch); return "请求错误: " . $error_message; - } - // 关闭cURL会话 - curl_close($ch); - // 处理响应 + } + // 关闭cURL会话 + curl_close($ch); + // 处理响应 if ($response) { return json_decode($response,true); diff --git a/application/appbackups/controller/Msginformation.php b/application/appbackups/controller/Msginformation.php index f1fa095..9139895 100644 --- a/application/appbackups/controller/Msginformation.php +++ b/application/appbackups/controller/Msginformation.php @@ -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', @@ -25,9 +28,7 @@ class Msginformation extends Base{ // 获取板块,及板块下类型标签 public function get_sector_label_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){ try { - if(count(input('post.')) > 0){ - $data = input('post.'); - } + $data = input('post.'); if(!array_key_exists('token', $data)){ return $this->msg(10001); } @@ -72,6 +73,10 @@ class Msginformation extends Base{ } if(!$this->verify_data_is_ok($data['page'],'intnum')){ return $this->msg(10005); + }else{ + if($data['page'] < 1){ + return $this->msg(10005,'页码不能小于1'); + } } $return_data = $this->get_sector_content_msg_action($data); @@ -131,7 +136,7 @@ class Msginformation extends Base{ } // 获取公告文章信息列表&banner public function get_recommend_information($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){ - // try { + try { if(count(input('post.')) > 0){ $data = input('post.'); } @@ -145,19 +150,19 @@ class Msginformation extends Base{ $return_result = $this->get_recommend_information_action($data); $this->record_api_log($data, null, $return_result); return $return_result; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 获取商务合作链接 @@ -214,9 +219,44 @@ class Msginformation extends Base{ return $this->msg(99999); } } + + + // 给微信使用的中间页(拉起微信) + // public function open_wechat_content($data=['id'=>8]){ + public function open_wechat_content(){ + try { + $data = input(); + if(!array_key_exists('id', $data)){ + $this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]); + return $this->msg(10001); + } + $url = Db::table('admin_notice_banner')->where(['id'=>$data['id']])->field('type,jump_url')->find(); + if(!$url['type'] || $url['type'] != 2){ + echo '
页面跑丢了... =。=!
'; + die; + } + header('Location: '.$url['jump_url']); + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } ################################################################业务################################################################ ################################################################get_sector_label_msg public function get_sector_label_msg_action($data){ + + + $Template_arr = [ 1=>[ 'id'=>'1', @@ -232,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 @@ -251,7 +302,6 @@ class Msginformation extends Base{ // 填充进去版块的轮播start $return_data = []; foreach ($sector_all as $key => $value) { - $loop_result = Db::query(" SELECT id, @@ -265,12 +315,14 @@ class Msginformation extends Base{ "); if(count($loop_result) > 0){ foreach ($loop_result as $k => $v) { - $loop_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content?id=".$v['id']."&token=".$data['token']; + // $loop_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content?id=".$v['id']."&token=".$data['token']; + $loop_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content"; } } $Template_arr[$value]['loop_data'] = $loop_result; array_push($return_data, $Template_arr[$value]); } + // 填充进去版块的轮播end return $this->msg($return_data); } @@ -281,6 +333,9 @@ class Msginformation extends Base{ 'page_num'=>$this->page_num, 'content_data'=>[] ]; + if($this->judge_wechat_release === true){ + return $this->msg($return_result); + } if($data['type'] != 0){ $type_str = " AND type LIKE '%".$data['type']."%'"; }else{ @@ -307,7 +362,8 @@ class Msginformation extends Base{ "); if(count($content_result) > 0){ foreach ($content_result as $key => $value) { - $content_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content?id=".$value['id']."&token=".$data['token']; + // $content_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content?id=".$value['id']."&token=".$data['token']; + $content_result[$key]['jump_url'] = "https://tc.pcxbc.com/editortext/model_content"; } } $return_result['content_data'] = $content_result; @@ -390,8 +446,9 @@ class Msginformation extends Base{ 'notice'=>[], 'banner'=>[] ]; - // 所有可用记录 - $all_data = Db::table($this->msginformation_use_db_name['3'])->where(['is_del'=>0])->select(); + // return $this->msg($return_data); + // 所有可用记录. + $all_data = Db::table($this->msginformation_use_db_name['3'])->where("is_del = 0 AND scene_data IN (1,2,3)")->select(); // 用户阅读记录 $user_read_log = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->field('aetc_id')->select(); $user_read_data = []; @@ -406,12 +463,14 @@ class Msginformation extends Base{ if($value['scene_data'] != 3){ unset($all_data[$key]); }else{ - $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token']; + // $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token']; + $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']; $all_data[$key]['type'] = 'h5'; $all_data[$key]['id'] = $value['parameter_data']; } }else{ - $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token']; + // $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token']; + $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']; $all_data[$key]['type'] = 'h5'; $all_data[$key]['id'] = $value['parameter_data']; } @@ -429,6 +488,9 @@ class Msginformation extends Base{ $all_data[$key]['appid'] = $appid; $all_data[$key]['path'] = $path; + + // 重新定义跳转链接为中间页 + $all_data[$key]['jump_url'] = "https://tc.pcxbc.com/open_wechat_content"; } // $all_data[$key]['id'] = $all_data[$key]['parameter_data']; unset($all_data[$key]['parameter_data']); @@ -454,7 +516,18 @@ class Msginformation extends Base{ return $this->msg($return_data); } - + + + ################################################################小工具################################################################ + ################################################################小工具################################################################ + ################################################################小工具################################################################ + ################################################################小工具################################################################ + ################################################################小工具################################################################ + + // 判断微信发版工具 + public function judge_wechat_release(){ + + } } \ No newline at end of file diff --git a/application/appbackups/controller/Myinformation.php b/application/appbackups/controller/Myinformation.php index 990de72..69c9574 100644 --- a/application/appbackups/controller/Myinformation.php +++ b/application/appbackups/controller/Myinformation.php @@ -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){ diff --git a/application/appbackups/controller/Pagingcontrast.php b/application/appbackups/controller/Pagingcontrast.php index 9d9f04e..29a543a 100644 --- a/application/appbackups/controller/Pagingcontrast.php +++ b/application/appbackups/controller/Pagingcontrast.php @@ -24,13 +24,13 @@ class Pagingcontrast extends Base{ ################################################请求接口################################################ ################################################请求接口################################################ // 获取记录信息(分组)(包含身体、跳绳、肺活量) - public function get_all_record_data_group($data = ['aud_id'=>'26','s_time'=>'2024-04-01','e_time'=>'2024-06-12','token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'6']){ + public function get_all_record_data_group($data = ['aud_id'=>'202','s_time'=>'2024-04-01','e_time'=>'2025-06-12','type'=>'2']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); } - if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data) || !array_key_exists('type', $data)){ + if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('type', $data)){ $return_data = $this->msg(10001); } if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ @@ -45,7 +45,6 @@ class Pagingcontrast extends Base{ if(!$this->verify_data_is_ok($data['type'],'intnum')){ return $this->msg(10005); } - unset($data['token']); if(array_key_exists($data['type'],$this->db_name)){ $return_data = $this->jump_transfer_interface_record($data,'group'); }else{ @@ -281,9 +280,9 @@ class Pagingcontrast extends Base{ foreach ($result as $key => $value) { array_push($return_result, [ 'id'=>$value['id'], - 'v1'=>$value['v1'], - 'v2'=>$value['v2'], - 'v3'=>$value['v3'], + 'v1'=>floatval(sprintf("%.2f", $value['v1'])), + 'v2'=>floatval(sprintf("%.2f", $value['v2'])), + 'v3'=>floatval(sprintf("%.2f", $value['v3'])), 'v1_name'=>'身高', 'v2_name'=>'体重', 'v3_name'=>'BMI', @@ -301,9 +300,9 @@ class Pagingcontrast extends Base{ foreach ($result as $key => $value) { array_push($return_result['rows'],[ 'id'=>$value['id'], - 'v1'=>$value['height_val'], - 'v2'=>$value['weight_val'], - 'v3'=>$value['bmi_val'], + 'v1'=>floatval(sprintf("%.2f", $value['height_val'])), + 'v2'=>floatval(sprintf("%.2f", $value['weight_val'])), + 'v3'=>floatval(sprintf("%.2f", $value['bmi_val'])), 'v1_name'=>'身高', 'v2_name'=>'体重', 'v3_name'=>'BMI', diff --git a/application/appbackups/controller/Skip.php b/application/appbackups/controller/Skip.php index b5985b7..0dbc8fe 100644 --- a/application/appbackups/controller/Skip.php +++ b/application/appbackups/controller/Skip.php @@ -47,7 +47,11 @@ class Skip extends Base{ if(!$this->verify_data_is_ok($data['type'],'str')){ return $this->msg(10005); } - if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){ + // {"aud_id":"331","num":"100","r_time":"2025-01-15","time_m":"","time_s":"","type":"free","token":"2581d40766e7cfd25ca140f3514072bd","aan_id":"254"} + // if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){ + // $return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); + // } + if(!$this->verify_data_is_ok($data['num'],'intnum') || !$this->verify_data_is_ok($data['time_m'],'intnum') || !$this->verify_data_is_ok($data['time_s'],'intnum')){ $return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数'); } if($data['num'] <= 0){ diff --git a/application/appbackups/controller/Wechat.php b/application/appbackups/controller/Wechat.php new file mode 100644 index 0000000..53d19e4 --- /dev/null +++ b/application/appbackups/controller/Wechat.php @@ -0,0 +1,124 @@ +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); + } + } + + + // 注册 + + + +} \ No newline at end of file diff --git a/application/appbackups/view/deepseek/test_index.html b/application/appbackups/view/deepseek/test_index.html new file mode 100644 index 0000000..b791ccc --- /dev/null +++ b/application/appbackups/view/deepseek/test_index.html @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + deepseek测试页面 + + + + + +
+
+ +
+
+ + +
+
+
+ + + + + + diff --git a/application/appbackups/view/download/business_cooperation.html b/application/appbackups/view/download/business_cooperation.html new file mode 100644 index 0000000..01c3b37 --- /dev/null +++ b/application/appbackups/view/download/business_cooperation.html @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + 商务合作 + + + + + + + +
+
+ +
+
商务合作意向登记表
+
+ 智能设备产品包含身高测量仪、体重体脂秤、宠物秤, 母婴秤,厨房秤,商业秤,身高体重/体脂秤,八电极体脂秤,运动训练设备等;软件包含就智能健康管理系统,智能硬件管理系统等,支持智能设备选购/定制、健康系统对接/定制,行业解决方案等,您也可以直接拨打或微信联系:13590959084,期待与您合作! +
+
+
+ *  1.客户姓名 +
+
+ +
+
+
+
+ *  2.联系电话 +
+
+ +
+
+
+
+ *  3.公司名称 +
+
+ +
+
+
+
+ *  4.合作意向 +
+
+
+
此题已选择 0/6 项
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ *  5.备注 +
+
+ +
+
+
+ 商务合作电话/微信:13590959084 +
+ +
+
提交
+
+
+ + + + \ No newline at end of file diff --git a/application/appbackups/view/download/demo2.html b/application/appbackups/view/download/demo2.html index a6c1c48..20d48a5 100644 --- a/application/appbackups/view/download/demo2.html +++ b/application/appbackups/view/download/demo2.html @@ -16,7 +16,7 @@ 下载页面 + + + +
+
+ +
+
+ + +
+
+
+ + + + + + diff --git a/application/testapp/view/download/business_cooperation.html b/application/testapp/view/download/business_cooperation.html index ef3e08a..01c3b37 100644 --- a/application/testapp/view/download/business_cooperation.html +++ b/application/testapp/view/download/business_cooperation.html @@ -15,6 +15,8 @@ 商务合作 + +