重装前推送

This commit is contained in:
tsf 2024-12-18 09:19:51 +08:00
parent ce913de43b
commit fcd7859cf4
44 changed files with 4413 additions and 1471 deletions

View File

@ -11,6 +11,7 @@ class Base extends Controller{
protected $ceshiyong_token = 'caadd1be045a65f30b92aa805f1de54a';
protected $token_time = 86400*30;//天
protected $file_size = 1024*1024*10;//10M
protected $return_data_all = [
// '0' => ['success',[]],
'10001'=>'关键参数缺失',
@ -235,17 +236,18 @@ class Base extends Controller{
// 使用 pathinfo() 函数获取文件名的扩展名
$pathinfo = pathinfo($name);
$extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较
$file_name = $pathinfo['filename'];
// 判断扩展名是否不是 .png 或 .gif
if ($extension !== 'png' && $extension !== 'gif') {
// 修改文件名,将扩展名改为 .jpg
$new_filename = date('YmdHis').$name . '.jpg';
$new_filename = date('YmdHis').$file_name . '.jpg';
} else {
$new_filename = date('YmdHis').$name;
}
$info = $file->move(ROOT_PATH . 'public' . DS . 'upload_pic',$new_filename);
$info = $file->validate(['size'=>$this->file_size,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'upload_pic',$new_filename);
if($info){
$insert_data = [
'url_data'=>"http://wm.tc.com/upload_pic/".$new_filename,
'url_data'=>"https://tc.pcxbc.com/upload_pic/".$new_filename,
'name'=>$name,
'create_time'=>date('Y-m-d H:i:s'),
];

View File

@ -76,7 +76,7 @@ class Editortext extends Base{
$data = input();
// $data['id'] = '3';
if(!array_key_exists('id', $data)){
return $this->msg(10001);
return $this->msg(10001,'id缺失');
}
// 查看文章是否存在
$article_data = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->find();
@ -139,75 +139,50 @@ class Editortext extends Base{
// 添加咨询动作
public function add_content_action(){
$file = request()->file('cover_image');
$data = request()->param();
if(!array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
$data = input();
if(!array_key_exists('cover_image', $data) || !array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
return $this->msg(10001);
}
$name = time().$file->getInfo()['name'];
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'cover',$name);
if($info){
$result = Db::table('admin_editor_text_content')->insert([
'title'=>$data['title'],
'cover_image'=>"editor_upload/cover/".$name,
'content'=>$data['content'],
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type'],
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
$pic_data = Db::table('admin_pic_manage')->where(['id'=>$data['cover_image']])->find();
$result = Db::table('admin_editor_text_content')->insert([
'title'=>$data['title'],
'content'=>$data['content'],
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>implode(',', $data['sector']),
'type'=>implode(',', $data['type']),
'cover_image'=>"upload_pic/".$pic_data['name'],
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002,$file->getError());
return $this->msg(10002);
}
}
// 修改咨询动作
public function edit_content_action(){
$file = request()->file('cover_image');
$data = request()->param();
if(!array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
$data = input();
if(!array_key_exists('cover_image', $data) || !array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
return $this->msg(10001);
}
if($file){
$name = time().$file->getInfo()['name'];
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'cover',$name);
if($info){
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
'title'=>$data['title'],
'cover_image'=>"editor_upload/cover/".$name,
'content'=>$data['content'],
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type']
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}else{
return $this->msg(10002,$file->getError());
}
$pic_data = Db::table('admin_pic_manage')->where(['id'=>$data['cover_image']])->find();
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
'title'=>$data['title'],
'content'=>$data['content'],
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>implode(',', $data['sector']),
'type'=>implode(',', $data['type']),
'cover_image'=>"upload_pic/".$pic_data['name']
]);
if($result){
return $this->msg([]);
}else{
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
'title'=>$data['title'],
'content'=>$data['content'],
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type']
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
return $this->msg(10002);
}
}
// 修改排序动作

View File

@ -23,6 +23,7 @@ class Notice extends Base{
###################################################banner图管理start###################################################
###################################################banner图管理start###################################################
###################################################banner图管理start###################################################
public function banner_index($page = 1){
$data = input();
$pd = true;
@ -69,13 +70,71 @@ class Notice extends Base{
return $this->fetch();
}
public function banner_edit(){
$data = input();
$return_data = Db::table('admin_notice_banner')->where(['id'=>$data['id']])->find();
$pic_id = Db::table('admin_pic_manage')->where(['url_data'=>$return_data['pic']])->find();
$return_data['pic_id'] = $pic_id['id'];
if($return_data['type'] == 1){
$return_data['jump_url'] = '';
}
$this->assign([
'result' => $return_data,
]);
return $this->fetch();
}
###################################################action
public function banner_add_or_update_action(){
$data = input();
$action_data = [
'title' => $data['title'],
'pic' => $data['banner_img'],
'type' => $data['type'],
'jump_url' => '',
'parameter_data' => $data['parameter_data'],
'create_time' => date('Y-m-d H:i:s'),
'scene_data' => $data['scene_data'],
];
$pic_data = Db::table('admin_pic_manage')->where(['id'=>$action_data['pic']])->find();
$action_data['pic'] = $pic_data['url_data'];
if($action_data['type'] == 1){
$action_data['jump_url'] = "https://tc.pcxbc.com/editortext/model_content?id=".$action_data['parameter_data'];
}else if($action_data['type'] == 2){
$action_data['jump_url'] = $data['jump_url'];
}else{
return $this->msg(10002,'选择类型错误');
}
if($data['action_type'] == 'add'){
$result = Db::table('admin_notice_banner')->insertGetId($action_data);
}else{
unset($action_data['create_time']);
unset($action_data['scene_data']);
$result = Db::table('admin_notice_banner')->where(['id'=>$data['id']])->update($action_data);
}
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
public function banner_update_sort(){
$data = input();
$result = Db::table('admin_notice_banner')->where(['id'=>$data['id']])->update(['sort_num'=>$data['data']]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
public function banner_stop_run(){
$data = input();
$result = Db::table('admin_notice_banner')->where(['id'=>$data['id']])->update(['is_del'=>$data['data']]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
###################################################banner图管理end###################################################
###################################################banner图管理end###################################################
@ -84,6 +143,48 @@ class Notice extends Base{
###################################################首页弹窗管理start###################################################
###################################################首页弹窗管理start###################################################
###################################################首页弹窗管理start###################################################
public function pop_index($page = 1){
$data = input();
$pd = true;
$parameter = [];
$parameter['scene_data'] = 1;
if(array_key_exists('tt', $data)){
$page = $data['page_num'];
unset($data['page_num']);
unset($data['tt']);
$pd = false;
// if($data['status_num'] === "0" || $data['status_num'] === "1"){
// $parameter['is_del'] = $data['status_num'];
// }
// if($data['tel']){
// $parameter['tel'] = $data['tel'];
// }
// if($data['email']){
// $parameter['email'] = $data['email'];
// }
// if($data['s_time']){
// $parameter['create_time'] = ['>=',$data['s_time']];
// }
// if($data['e_time']){
// $parameter['create_time'] = ['<=',$data['e_time']];
// }
}
$num = Db::table('admin_notice_banner')->where($parameter)->count();
$result = Db::table('admin_notice_banner')->where($parameter)->order('is_del,sort_num desc')->page($page,$this->page_num)->select();
// dump($result);
// die;
if(!$pd){
$return_result['num'] = $num;
$return_result['data'] = $result;
return $this->msg(0,'success',$return_result);
}
$this->assign([
'result' => $result,
'num' => $num,
]);
return $this->fetch();
}
###################################################首页弹窗管理end###################################################
###################################################首页弹窗管理end###################################################
@ -132,310 +233,5 @@ class Notice extends Base{
###################################################公共用接口end###################################################
###################################################公共用接口end###################################################
public function index($page = 1){
$data = input();
$pd = true;
$parameter = [];
// $parameter['is_del'] = 0;
if(array_key_exists('tt', $data)){
$page = $data['page_num'];
unset($data['page_num']);
unset($data['tt']);
$pd = false;
// if($data['status_num'] === "0" || $data['status_num'] === "1"){
// $parameter['is_del'] = $data['status_num'];
// }
// if($data['tel']){
// $parameter['tel'] = $data['tel'];
// }
// if($data['email']){
// $parameter['email'] = $data['email'];
// }
// if($data['s_time']){
// $parameter['create_time'] = ['>=',$data['s_time']];
// }
// if($data['e_time']){
// $parameter['create_time'] = ['<=',$data['e_time']];
// }
}
$num = Db::table('admin_editor_text_content')->where($parameter)->count();
$result = Db::table('admin_editor_text_content')->where($parameter)->order('is_del,id desc')->page($page,$this->page_num)->select();
if(!$pd){
$return_result['num'] = $num;
$return_result['data'] = $result;
return $this->msg(0,'success',$return_result);
}
$this->assign([
'result' => $result,
'num' => $num,
]);
return $this->fetch();
}
public function add_content(){
return $this->fetch();
}
public function edit_content(){
$data = input();
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->find();
// $result['sector'] = explode(',',$result['sector']);
// dump($result);
// die;
// .replace(/'/g, '&apos;').replace(/"/g, '&quot;')
// $result['content'] = htmlspecialchars_decode($result['content']);
// $result['content'] = str_replace("'", "&apos;", $result['content']);
// $result['content'] = str_replace('"', '&quot;', $result['content']);
$this->assign([
'result' => $result,
'content' => $result['content'],
]);
return $this->fetch();
}
public function model_content(){
$data = input();
// $data['id'] = '3';
if(!array_key_exists('id', $data)){
return $this->msg(10001);
}
// 查看文章是否存在
$article_data = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->find();
if(!$article_data){
return $this->msg(10004);
}
$result = $article_data;
// 处理是否有过点赞
if(array_key_exists('token', $data)){
$result['token'] = $data['token'];
// 启动事务处理用户已读记录&文章阅读数
Db::startTrans();
try{
Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->setInc('reading');
// 查看文章是否有被观看过
$is_like = Db::table('admin_editor_text_like_up_log')->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->find();
if (!$is_like) {
// 如果不存在,则插入新记录
$save_data = ['token'=>$result['token'],'aetc_id'=>$data['id'],'create_time'=>date('Y-m-d H:i:s')];
Db::name('admin_editor_text_like_up_log')->insert($save_data);
}else{
Db::table('admin_editor_text_like_up_log')->where(['id'=>$is_like['id']])->setInc('reading');
}
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
}
if($is_like){
if($is_like['is_like'] == 0){
// 用户没点赞
$result['user_like'] = 0;
}else{
// 用户点过点赞
$result['user_like'] = 1;
}
}else{
// 用户没点过赞
$result['user_like'] = 2;
}
}else{
// 没有用户信息提示要登录
Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->setInc('reading');
$result['user_like'] = 3;
$result['token'] = '';
}
// dump($result);
// die;
$this->assign([
'result' => $result
]);
return $this->fetch();
}
################################################################action################################################################
################################################################action################################################################
################################################################action################################################################
// 添加咨询动作
public function add_content_action(){
$file = request()->file('cover_image');
$data = request()->param();
if(!array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
return $this->msg(10001);
}
$name = time().$file->getInfo()['name'];
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'cover',$name);
if($info){
$result = Db::table('admin_editor_text_content')->insert([
'title'=>$data['title'],
'cover_image'=>"editor_upload/cover/".$name,
'content'=>$data['content'],
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type'],
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}else{
return $this->msg(10002,$file->getError());
}
}
// 修改咨询动作
public function edit_content_action(){
$file = request()->file('cover_image');
$data = request()->param();
if(!array_key_exists('title', $data) || !array_key_exists('sector', $data) || !array_key_exists('type', $data) || !array_key_exists('content', $data)){
return $this->msg(10001);
}
if($file){
$name = time().$file->getInfo()['name'];
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'cover',$name);
if($info){
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
'title'=>$data['title'],
'cover_image'=>"editor_upload/cover/".$name,
'content'=>$data['content'],
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type']
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}else{
return $this->msg(10002,$file->getError());
}
}else{
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
'title'=>$data['title'],
'content'=>$data['content'],
'update_time'=>date('Y-m-d H:i:s'),
'sector'=>$data['sector'],
'type'=>$data['type']
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
}
// 修改排序动作
public function edit_order_action(){
$data = input();
if(!array_key_exists('id', $data) || !array_key_exists('data', $data) || !array_key_exists('str', $data)){
return $this->msg(10001);
}
$data['str'] = $data['str'] == 'loop'?'loop_img':'top_up';
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update([
$data['str']=>$data['data'],
'update_time'=>date('Y-m-d H:i:s'),
]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
// 上传图片动作
public function upload_pic_action(){
// $file1 = request()->file('file');
$file = request()->file('wangeditor-uploaded-image');
if($file){
$name = $file->getInfo()['name'];
// 使用 pathinfo() 函数获取文件名的扩展名
$pathinfo = pathinfo($name);
$extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较
// 判断扩展名是否不是 .png 或 .gif
if ($extension !== 'png' && $extension !== 'gif') {
// 修改文件名,将扩展名改为 .jpg
$new_filename = time().$pathinfo['filename'] . '.jpg';
} else {
$new_filename = time().$name;
}
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'pic',$new_filename);
if($info){
$return_data = [
'errno'=>0,
'data'=>[
'url'=>'http://tc.pcxbc.com/editor_upload/pic/'.$new_filename,
]
];
return json($return_data);
}else{
// 上传失败获取错误信息
// echo $file->getError();
$return_data = [
'errno'=>9999,
'message'=>$file->getError()
];
return json($return_data);
}
}
}
// 上传视频动作
public function upload_video_action(){
// $file1 = request()->file('file');
$file = request()->file('wangeditor-uploaded-video');
// dump($file);
// die;
if($file){
$name = time().$file->getInfo()['name'];
$info = $file->move(ROOT_PATH . 'public' . DS . 'editor_upload' . DS . 'video',$name);
if($info){
$return_data = [
'errno'=>0,
'data'=>[
'url'=>'http://tc.pcxbc.com/editor_upload/video/'.$name,
]
];
return json($return_data);
}else{
// 上传失败获取错误信息
// echo $file->getError();
$return_data = [
'errno'=>9999,
'message'=>$file->getError()
];
return json($return_data);
}
}
}
// 停用启用动作
public function stop_action(){
$data = input();
if(is_array($data['id'])){
$data['id'] = implode(',',$data['id']);
$result = Db::table('admin_editor_text_content')->where("id in (".$data['id'].")")->update(['is_del'=>$data['is_del']]);
}else{
$result = Db::table('admin_editor_text_content')->where(['id'=>$data['id']])->update(['is_del'=>$data['is_del']]);
}
if($result){
return $this->msg(0,'success');
}else{
return $this->msg(10001,'success');
}
}
################################################################other################################################################
################################################################other################################################################
################################################################other################################################################
}

View File

@ -40,9 +40,7 @@
<span class="x-red"></span>上传封面
</label>
<div class="layui-input-inline">
<!-- <span onclick="app_stop()" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">上传</span> -->
<!-- <input type="file" id="upload_file_app" lay-verify="upload_file_app" name="data_excel" class="layui-btn layui-btn-normal layui-btn-mini"> -->
<input type="file" id="upload_file_app" accept="image/*" lay-verify="upload_file_app" name="data_excel" class="layui-btn layui-btn-normal layui-btn-mini">
<div class="layui-btn" onclick="xadmin.open('图片管理','/admin/pic','80%','80%')">点击选择</div>
</div>
</div>
<div class="layui-form-item">
@ -50,7 +48,8 @@
<span class="x-red"></span>预览
</label>
<div class="layui-input-inline">
<img id="preview_img" style="max-width:500px;" src="" alt="">
<img id="preview_img" style="max-width:500px;box-shadow: 0px 0px 1px;" src="" alt="">
<input type="hidden" name="banner_img" id="banner_img" lay-verify="banner_img" value=""></input>
</div>
</div>
<div class="layui-form-item layui-form-text" style="max-width: 440px;">
@ -118,24 +117,15 @@
</div>
</div>
<script>
$('#upload_file_app').on('change', function() {
// 获取被选择的文件
var fileInput = $(this)[0];
var file = fileInput.files[0];
// 检查是否有文件被选择
if (file) {
var reader = new FileReader();
reader.onload = function(e) {
var img = document.getElementById('preview_img');
img.src = e.target.result; // 设置图片预览的src属性
img.style.display = 'block'; // 显示图片预览
};
reader.readAsDataURL(file); // 读取文件内容作为Data URL
}
});
</script>
<script>
function receiveParamFromIframe(param) {
pic_data = param
if(pic_data.length > 0){
var img = document.getElementById('preview_img');
img.src = pic_data[1]; // 设置图片预览的src属性
img.style.display = 'block'; // 显示图片预览
$('#banner_img').val(pic_data[0])
}
}
var html
const { createEditor, createToolbar } = window.wangEditor
@ -287,22 +277,28 @@
if(pd === false){
return
}
var formdata = new FormData();
formdata.append('cover_image',$('#upload_file_app')[0].files[0])
formdata.append('title',$("#title_v").val())
formdata.append('sector',sector_arr)
formdata.append('type',type_arr)
formdata.append('content',html)
console.log(formdata)
var data = {
'cover_image':$('#banner_img').val(),
'title':$('#title_v').val(),
'sector':sector_arr,
'type':type_arr,
'content':html,
}
// var formdata = new FormData();
// formdata.append('cover_image',$('#upload_file_app')[0].files[0])
// formdata.append('title',$("#title_v").val())
// formdata.append('sector',sector_arr)
// formdata.append('type',type_arr)
// formdata.append('content',html)
// console.log(formdata)
pd = false
load()
$.ajax({
url:"/editortext/add_content_action", //请求的url地址
contentType:false,
processData:false,
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:formdata, //参数值
type:"POST", //请求方式
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success:function(req){
c_load()
pd = true

View File

@ -40,7 +40,7 @@
<span class="x-red"></span>上传封面
</label>
<div class="layui-input-inline">
<input type="file" id="upload_file_app" accept="image/*" lay-verify="upload_file_app" name="data_excel" class="layui-btn layui-btn-normal layui-btn-mini">
<div class="layui-btn" onclick="xadmin.open('图片管理','/admin/pic','80%','80%')">点击选择</div>
</div>
</div>
<div class="layui-form-item">
@ -48,7 +48,8 @@
<span class="x-red"></span>预览
</label>
<div class="layui-input-inline">
<img id="preview_img" style="max-width:500px;" src="http://tc.pcxbc.com/{$result.cover_image}" alt="">
<img id="preview_img" style="max-width:500px;box-shadow: 0px 0px 1px;" src="http://tc.pcxbc.com/{$result.cover_image}" alt="">
<input type="hidden" name="banner_img" id="banner_img" lay-verify="banner_img" value=""></input>
</div>
</div>
<div class="layui-form-item layui-form-text" style="max-width: 440px;">
@ -157,25 +158,17 @@
</form>
</div>
</div>
<script>
$('#upload_file_app').on('change', function() {
// 获取被选择的文件
var fileInput = $(this)[0];
var file = fileInput.files[0];
// 检查是否有文件被选择
if (file) {
var reader = new FileReader();
reader.onload = function(e) {
var img = document.getElementById('preview_img');
img.src = e.target.result; // 设置图片预览的src属性
img.style.display = 'block'; // 显示图片预览
};
reader.readAsDataURL(file); // 读取文件内容作为Data URL
}
});
</script>
<script>
function receiveParamFromIframe(param) {
pic_data = param
if(pic_data.length > 0){
var img = document.getElementById('preview_img');
img.src = pic_data[1]; // 设置图片预览的src属性
img.style.display = 'block'; // 显示图片预览
$('#banner_img').val(pic_data[0])
}
}
var content_str = '{$result.content}';
// var content_str = '';
var html
@ -332,24 +325,32 @@
if(pd === false){
return
}
var formdata = new FormData();
formdata.append('cover_image',$('#upload_file_app')[0].files[0])
formdata.append('id',id)
formdata.append('title',$("#title_v").val())
formdata.append('sector',sector_arr)
formdata.append('type',type_arr)
html = html.replace(/['"]/g, '\\$&');
formdata.append('content',html)
console.log(formdata)
var data = {
'cover_image':$('#banner_img').val(),
'id':id,
'title':$('#title_v').val(),
'sector':sector_arr,
'type':type_arr,
'content':html,
}
// var formdata = new FormData();
// formdata.append('cover_image',$('#upload_file_app')[0].files[0])
// formdata.append('id',id)
// formdata.append('title',$("#title_v").val())
// formdata.append('sector',sector_arr)
// formdata.append('type',type_arr)
// formdata.append('content',html)
// console.log(formdata)
load()
pd = false
$.ajax({
url:"/editortext/edit_content_action", //请求的url地址
contentType:false,
processData:false,
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:formdata, //参数值
type:"POST", //请求方式
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success:function(req){
c_load()
pd = true

View File

@ -136,24 +136,24 @@
<li>
<a href="javascript:;">
<i class="iconfont left-nav-li" lay-tips="Banner图&公告管理">&#xe723;</i>
<cite>Banner图&公告管理</cite>
<cite>Banner图&公告&弹窗</cite>
<i class="iconfont nav_right">&#xe697;</i></a>
<ul class="sub-menu">
<li>
<a onclick="xadmin.add_tab('banner图管理','/notice/banner_index')">
<a onclick="xadmin.add_tab('操作管理','/notice/banner_index')">
<i class="iconfont">&#xe6a7;</i>
<cite>banner图管理</cite></a>
<cite>操作管理</cite></a>
</li>
<li>
<a onclick="xadmin.add_tab('首页弹窗管理','/editortext/index')">
<!-- <li>
<a onclick="xadmin.add_tab('首页弹窗管理','/notice/pop_index')">
<i class="iconfont">&#xe6a7;</i>
<cite>首页弹窗管理</cite></a>
</li>
<li>
<a onclick="xadmin.add_tab('资讯推荐栏管理','/editortext/index')">
<a onclick="xadmin.add_tab('公告管理','/notice/notice_index')">
<i class="iconfont">&#xe6a7;</i>
<cite>公告管理</cite></a>
</li>
</li> -->
</ul>
</li>
<li>

View File

@ -43,6 +43,19 @@
<input type="hidden" name="banner_img" id="banner_img" lay-verify="banner_img" value=""></input>
</div>
</div>
<div class="layui-form-item">
<label for="scene_data" class="layui-form-label">
<span class="x-red"></span>选择场景
</label>
<div class="layui-input-inline" style="width: 80%;">
<select id="scene_data" name="scene_data" lay-filter="scene_data" lay-verify="scene_data">
<option value="0">请选择使用场景</option>
<option value="1">首屏弹窗</option>
<option value="2">滚动公告</option>
<option value="3">首页banner</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label for="data_type" class="layui-form-label">
<span class="x-red"></span>选择类型
@ -125,6 +138,11 @@
return '请先选择类型';
}
},
scene_data: function(value) {
if (value == 0) {
return '请先选择使用场景';
}
},
parameter_data: function(value) {
if (value == 0) {
return '请先填写关键参数信息';
@ -151,22 +169,22 @@
function add_data(){
load()
var data = {
'title':$('#title').val(),
'pic_id':$('#url').val(),
'type':$('#img').val(),
'parameter_data':$('#sort').val(),
'jump_url':$('#status').val(),
'title':$('#title_v').val(),
'banner_img':$('#banner_img').val(),
'type':$('#data_type').val(),
'scene_data':$('#scene_data').val(),
'parameter_data':$('#parameter_data').val(),
'jump_url':$('#jump_url').val(),
'action_type':'add',
}
$.ajax({
url: "index", //请求的url地址s
url: "banner_add_or_update_action", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success:function(req){
c_load()
pd = true
console.log()
if(req.code == 0){
layer.alert("增加成功", {icon: 6},function() {
//关闭当前frame
@ -182,9 +200,6 @@
xadmin.father_reload();
});
}
//请求成功时处理
console.log(req)
},
error:function(){
//请求出错处理

View File

@ -0,0 +1,255 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>添加banner</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
</head>
<body>
<div class="layui-fluid">
<div class="layui-row" id="app_all">
<form action="" method="post" class="layui-form layui-form-pane">
<div class="layui-form-item">
<label for="title_v" class="layui-form-label">
<span class="x-red"></span>标题描述
</label>
<div class="layui-input-inline" style="width: 80%;">
<input type="text" id="title_v" name="title_v" lay-verify="title_v" autocomplete="off" class="layui-input" value="{$result.title}">
</div>
</div>
<div class="layui-form-item">
<label for="pic_v" class="layui-form-label">
<span class="x-red"></span>选择封面
</label>
<div class="layui-input-inline">
<div class="layui-btn" onclick="xadmin.open('图片管理','/admin/pic','80%','80%')">点击选择</div>
<!-- <input type="file" id="upload_file_app" accept="image/*" lay-verify="upload_file_app" name="data_excel" class="layui-btn layui-btn-normal layui-btn-mini"> -->
</div>
</div>
<div class="layui-form-item">
<label for="yulan_v" class="layui-form-label">
<span class="x-red"></span>预览
</label>
<div class="layui-input-inline">
<img id="preview_img" style="max-width:500px;box-shadow: 0px 0px 1px;" src="{$result.pic}" alt="">
<input type="hidden" name="banner_img" id="banner_img" lay-verify="banner_img" value="{$result.pic_id}"></input>
</div>
</div>
<div class="layui-form-item">
<label for="scene_data" class="layui-form-label">
<span class="x-red"></span>选择场景
</label>
<div class="layui-input-inline" style="width: 80%;">
<select id="scene_data" name="scene_data" lay-filter="scene_data" lay-verify="scene_data">
{if condition="$result.type == 1"}
<option value="0">请选择使用场景</option>
<option value="1" selected>首屏弹窗</option>
<option value="2">滚动公告</option>
<option value="3">首页banner</option>
{elseif condition="$result.type == 2"/}
<option value="0">请选择使用场景</option>
<option value="1">首屏弹窗</option>
<option value="2" selected>滚动公告</option>
<option value="3">首页banner</option>
{elseif condition="$result.type == 3"/}
<option value="0">请选择使用场景</option>
<option value="1">首屏弹窗</option>
<option value="2">滚动公告</option>
<option value="3" selected>首页banner</option>
{else /}
<option value="0" selected>请选择使用场景</option>
<option value="1">首屏弹窗</option>
<option value="2">滚动公告</option>
<option value="3">首页banner</option>
{/if}
</select>
</div>
</div>
<div class="layui-form-item">
<label for="data_type" class="layui-form-label">
<span class="x-red"></span>选择类型
</label>
<div class="layui-input-inline" style="width: 80%;">
<select id="data_type" name="data_type" lay-filter="data_type" lay-verify="data_type">
{if condition="$result.type == 1"}
<option value="0">请选择跳转类型</option>
<option value="1" selected>站内文章</option>
<option value="2">微信小程序</option>
{elseif condition="$result.type == 2"/}
<option value="0">请选择跳转类型</option>
<option value="1">站内文章</option>
<option value="2" selected>微信小程序</option>
{else /}
<option value="0" selected>请选择跳转类型</option>
<option value="1">站内文章</option>
<option value="2">微信小程序</option>
{/if}
</select>
</div>
</div>
<div class="layui-form-item">
<label for="parameter_data" class="layui-form-label">
<span class="x-red"></span>填写关键参数
</label>
<div class="layui-input-inline" style="width: 80%;">
<input type="text" id="parameter_data" name="parameter_data" lay-verify="parameter_data" autocomplete="off" class="layui-input" onfocus="pd_data_type()" value="{$result.parameter_data}">
</div>
</div>
<div class="layui-form-item">
<label for="jump_url" class="layui-form-label">
<span class="x-red"></span>页面路径
</label>
<div class="layui-input-inline" style="width: 80%;">
<input type="text" id="jump_url" name="jump_url" lay-verify="jump_url" autocomplete="off" class="layui-input" placeholder="若选择站内文章,则无需填写该项" value="{$result.jump_url}">
</div>
</div>
<div class="layui-form-item" style="display: flex;flex-direction: row;justify-content: center;">
<button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
</div>
</form>
</div>
</div>
<script>
var data_id = "{$result.id}"
var pic_data = []
function receiveParamFromIframe(param) {
pic_data = param
if(pic_data.length > 0){
var img = document.getElementById('preview_img');
img.src = pic_data[1]; // 设置图片预览的src属性
img.style.display = 'block'; // 显示图片预览
$('#banner_img').val(pic_data[0])
}
}
function receiveParamFromIframe_information(param) {
$('#parameter_data').val(param);
layer.msg('已选择文章ID为'+param)
}
function pd_data_type(){
console.log($('#data_type').val())
if($('#data_type').val() == 1){
xadmin.open('资讯简易列表','/notice/information_msg_list','80%','80%')
$('#parameter_data').blur()
}else if($('#data_type').val() == 2){
layer.msg('请填写微信小程序APPID')
}else{
layer.msg('请选择跳转类型')
}
}
</script>
<script>
var form
layui.use(['form'], function () {
form = layui.form;
form.verify({
title_v: function(value) {
if (value == '') {
return '请先填写标题描述';
}
},
banner_img: function(value) {
if (value == '') {
return '请先选择封面';
}
},
data_type: function(value) {
if (value == 0) {
return '请先选择类型';
}
},
scene_data: function(value) {
if (value == 0) {
return '请先选择使用场景';
}
},
parameter_data: function(value) {
if (value == 0) {
return '请先填写关键参数信息';
}
},
jump_url: function(value) {
if ($('#data_type').val() == 2) {
return '请先填写微信小程序页面路径';
}
},
});
//监听提交
form.on('submit(add)',function(data) {
//发异步把数据提交给php
add_data()
return false;
});
});
// 功能性~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function add_data(){
load()
var data = {
'id':data_id,
'title':$('#title_v').val(),
'banner_img':$('#banner_img').val(),
'type':$('#data_type').val(),
'scene_data':$('#scene_data').val(),
'parameter_data':$('#parameter_data').val(),
'jump_url':$('#jump_url').val(),
'action_type':'update',
}
$.ajax({
url: "banner_add_or_update_action", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success:function(req){
c_load()
if(req.code == 0){
layer.alert("修改成功", {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}else{
layer.alert("修改失败"+req.msg, {icon: 6},function() {
//关闭当前frame
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
});
}
},
error:function(){
//请求出错处理
pd = true
}
});
}
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
</script>
</body>
</html>

View File

@ -70,6 +70,7 @@
<th>标题</th>
<th style="min-width: 30px;width:115px;">创建时间</th>
<th>封面预览</th>
<th>场景</th>
<th style="min-width: 30px;width:50px;">轮播排序</th>
<th>操作</th>
</tr>
@ -81,9 +82,18 @@
<td>{$vo.title}</td>
<td>{$vo.create_time}</td>
<td><img src="{$vo.pic}" alt=""></td>
<td><input type="text" class="layui-input x-sort loop_img_edit" name="order_edit" value="{$vo.sort_num}" onblur="edit_order_action(this,'{$vo.sort_num}','loop','{$vo.id}')"></td>
{if condition="$vo.scene_data == 1"}
<td>首屏弹窗</td>
{elseif condition="$vo.scene_data == 2"/}
<td>滚动公告</td>
{elseif condition="$vo.scene_data == 3"/}
<td>首页banner</td>
{else /}
<td>未知</td>
{/if}
<td><input type="text" class="layui-input x-sort loop_img_edit" name="order_edit" value="{$vo.sort_num}" onblur="edit_order_action(this,'{$vo.sort_num}','{$vo.id}')"></td>
<td class="td-status">
<button class="layui-btn" onclick="xadmin.open('查看','/editortext/edit_content?id={$vo.id}','100%','100%')">查看</button>
<button class="layui-btn" onclick="xadmin.open('查看','/notice/banner_edit?id={$vo.id}','80%','80%')">查看</button>
{if condition="$vo.is_del == 1"}
<span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
{else /}
@ -147,19 +157,18 @@
});
});
function edit_order_action(e,data,str,id){
function edit_order_action(e,data,id){
if($(e).val() == data){
return
}
load()
$.ajax({
url:"/editortext/edit_order_action", //请求的url地址
url:"/notice/banner_update_sort", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{
"id":id,
'data':$(e).val(),
'str':str,
}, //参数值
type:"POST", //请求方式
success:function(req){
@ -191,14 +200,13 @@
is_del = 0
num = 6
}
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
layer.confirm('确认要'+ title +'吗?',function(index){
load()
$.ajax({
url:"/editortext/stop_action", //请求的url地址
url:"/notice/banner_stop_run", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id,'is_del':is_del}, //参数值
data:{"id":id,'data':is_del}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()

View File

@ -0,0 +1,314 @@
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>弹窗图管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/x_admin/css/font.css">
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
<style>
/* th{
min-width:30px;
} */
</style>
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">演示</a>
<a>
<cite>导航元素</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<!-- <div class="layui-card-body ">
<form class="layui-form layui-col-space5">
<div class="layui-inline layui-show-xs-block">
<input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="s_time">
</div>
<div class="layui-inline layui-show-xs-block">
<input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="e_time">
</div>
<div class="layui-inline layui-show-xs-block">
<input type="text" name="username" placeholder="请输入用户手机" autocomplete="off" class="layui-input" id="tel">
</div>
<div class="layui-inline layui-show-xs-block">
<input type="text" name="username" placeholder="请输入用户邮箱" autocomplete="off" class="layui-input" id="email">
</div>
<div class="layui-input-inline layui-show-xs-block">
<select name="contrller" id="status_num">
<option value="">状态</option>
<option value="0">启用</option>
<option value="1">停用</option>
</select>
</div>
<div class="layui-inline layui-show-xs-block">
<div class="layui-btn" lay-submit="" lay-filter="sreach" onclick="find('y')"><i class="layui-icon">&#xe615;</i></div>
</div>
</form>
</div> -->
<div class="layui-card-header">
<!-- <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量停用</button> -->
<!-- <button class="layui-btn" onclick="xadmin.open('添加用户','/appversion/app_add','100%','100%')"><i class="layui-icon"></i>添加</button> -->
<button class="layui-btn" onclick="xadmin.open('添加banner','/notice/banner_add','80%','80%')"><i class="layui-icon"></i>添加</button>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
<table class="layui-table layui-form">
<thead>
<tr>
<th style="min-width: 30px;width:50px;">ID</th>
<th>标题</th>
<th style="min-width: 30px;width:115px;">创建时间</th>
<th>封面预览</th>
<th style="min-width: 30px;width:50px;">轮播排序</th>
<th>操作</th>
</tr>
</thead>
<tbody id='content'>
{volist name="result" id="vo"}
<tr>
<td>{$vo.id}</td>
<td>{$vo.title}</td>
<td>{$vo.create_time}</td>
<td><img src="{$vo.pic}" alt=""></td>
<td><input type="text" class="layui-input x-sort loop_img_edit" name="order_edit" value="{$vo.sort_num}" onblur="edit_order_action(this,'{$vo.sort_num}','{$vo.id}')"></td>
<td class="td-status">
<button class="layui-btn" onclick="xadmin.open('查看','/notice/banner_edit?id={$vo.id}','80%','80%')">查看</button>
{if condition="$vo.is_del == 1"}
<span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
{else /}
<span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>
{/if}
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
<div class="layui-card-body ">
<div id="page" style="text-align: center;">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
var form
layui.use(['laydate','form'], function(){
var laydate = layui.laydate;
form = layui.form;
//执行一个laydate实例
laydate.render({
elem: '#s_time' //指定元素
});
//执行一个laydate实例
laydate.render({
elem: '#e_time' //指定元素
});
});
var page_num;
var laypage;
var all_page = "{$num}";
layui.use('laypage', function () {
laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page',
count: all_page, //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
find("n")
}
}
});
});
function edit_order_action(e,data,id){
if($(e).val() == data){
return
}
load()
$.ajax({
url:"/notice/pop_update_sort", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{
"id":id,
'data':$(e).val(),
}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
//请求成功时处理
if(req['code'] == 0){
layer.msg('操作成功!',{icon: 6});
}else{
layer.msg('操作失败!',{icon: 5});
}
},
error:function(){
//请求出错处理
}});
}
/*用户-停用*/
function app_stop(obj,id){
// return
var title = '',is_del,num
if($(obj).attr('title')=='启用'){
title = '停用'
is_del = 1
num = 5
}else{
title = '启用'
is_del = 0
num = 6
}
layer.confirm('确认要'+ title +'吗?',function(index){
load()
$.ajax({
url:"/notice/pop_stop_run", //请求的url地址
dataType:"json", //返回格式为json
async:true,//请求是否异步默认为异步这也是ajax重要特性
data:{"id":id,'data':is_del}, //参数值
type:"POST", //请求方式
success:function(req){
c_load()
//请求成功时处理
if(req['code'] == 0){
//发异步把用户状态进行更改
$(obj).attr('title',title)
if(is_del == 1){
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
}else{
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
}
layer.msg('已'+ title,{icon: num});
}else{
layer.msg('操作失败!',{icon: 5});
}
},
error:function(){
//请求出错处理
}});
});
}
function find(pd) {
if(!page_num || pd == 'y'){
page_num = 1;
}
page({
"page_num":page_num,
"tt":1},pd);
}
function page(data,pd) {
console.log(data)
load()
$.ajax({
url: "index", //请求的url地址s
dataType: "json", //返回格式为json
async: true,//请求是否异步默认为异步这也是ajax重要特性
data: data, //参数值
type: "POST", //请求方式
success: function (req) {
console.log(req)
c_load();
if (req['code'] == 0) {
var str,str_s,str_c,str_all="";
for (let i = 0; i < req['data']['data'].length; i++) {
if(req['data']['data'][i]['is_del'] == 1){
str = '<span onclick="app_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
}else{
str = '<span onclick="app_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
}
str_c = "<tr>"+
"<td>"+ req['data']['data'][i]['id'] +"</td>"+
"<td>"+ req['data']['data'][i]['title'] +"</td>"+
"<td>"+ req['data']['data'][i]['create_time'] +"</td>"+
"<td>"+ req['data']['data'][i]['update_time'] +"</td>"+
'<td><input type="text" class="layui-input x-sort top_up_edit" name="order_edit" value="'+ req['data']['data'][i]['top_up'] +'" onblur="edit_order_action(this,\''+ req['data']['data'][i]['top_up'] +'\',\'top\',\''+ req['data']['data'][i]['id'] +'\')"></td>'+
'<td><input type="text" class="layui-input x-sort loop_img_edit" name="order_edit" value="'+ req['data']['data'][i]['loop_img'] +'" onblur="edit_order_action(this,\''+ req['data']['data'][i]['loop_img'] +'\',\'loop\',\''+ req['data']['data'][i]['id'] +'\')"></td>'+
'<td class="td-status">'+
'<button class="layui-btn" onclick="xadmin.open(\'查看\',\'/editortext/edit_content?id='+ req['data']['data'][i]['id'] +'\',\'100%\',\'100%\')">查看</button>'+
str+
'</td></tr>'
str_all = str_all+str_c;
}
$('#content').html(str_all);
form.render();
if(pd == 'y'){
$("#page").html("")
laypage.render({
elem: 'page',
count: req['data']['num'], //数据总数,从服务端得到
limit: 10,
groups:10,
jump: function (obj, first) {
//首次不执行
if (!first) {
//obj包含了当前分页的所有参数比如
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page_num = obj.curr;
// page({"page":page_num,"tt":1});
find("n")
}
}
});
}
} else {
layer.msg(req['msg'])
}
},
error: function () {
//请求出错处理
}
});
}
//加载提示开启
function load() {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
// 关闭加载提示
function c_load() {
layer.close(layer.index)
}
</script>
</html>

View File

@ -612,6 +612,79 @@ class Base extends Controller{
}
// 处理身高体重的单位转换它们为cm和kg。
function convertHeightAndWeight($height, $weight) {
// 定义单位转换比例
$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]);
$heightUnit = $matches[2];
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 = floatval($matches[1]);
$weightUnit = $matches[2];
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' => $heightInCm,
'weight_in_kg' => $weightInKg
];
}
public function ceshiyong($aa = 4,$gd = 0.2){

View File

@ -58,13 +58,26 @@ class Calculatebody extends Base{
// 使用接口调用之前的进行计算start
$url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3';
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>round($data['age']),//四舍五入取整
'adc'=>round($data['adc']),//四舍五入取整
'gender'=>$data['gender'],
];
if($data['age'] < '3'){
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>round($data['age']),//四舍五入取整
'adc'=>round($data['adc']),//四舍五入取整
'gender'=>$data['gender'],
'head'=>$data['head_circumference'],
'hasStandardList'=>true,
'birthDay'=>$data['birthday'],
];
}else{
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>round($data['age']),//四舍五入取整
'adc'=>round($data['adc']),//四舍五入取整
'gender'=>$data['gender'],
];
}
$request_result = $this->postRequest($url,$temporary_parameter);
if($request_result['code'] != 0){
return false;
@ -92,6 +105,7 @@ class Calculatebody extends Base{
$result['body'] = $request_result['data']['body'];
// 使用接口调用之前的进行计算end
$return_data['standardlist'] = $request_result['data']['standardlist'];
$return_data['体重'] = $data['weight'];
$return_data['身高'] = $data['height'];
$return_data['BMI'] = $result['bmi'];

View File

@ -88,7 +88,7 @@ class Card extends Base{
// 详细卡片信息
// $data = ['id'=>'2']
public function card_data_detailed($data=['aud_id'=>'37']){
public function card_data_detailed($data=['aud_id'=>'38']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -121,7 +121,7 @@ class Card extends Base{
}
// 曲线页面-曲线接口
public function card_curve_chart($data = ['aud_id'=>'11','s_time'=>'2024-04-01','e_time'=>'2024-10-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_curve_chart($data = ['aud_id'=>'11','s_time'=>'2024-04-01','e_time'=>'2024-12-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -163,7 +163,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($data = ['aud_id'=>'37','time'=>'2024-10-12','height'=>'144.7,cm','weight'=>'36.8,kg','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_manual_recording($data = ['aud_id'=>'37','time'=>'2024-10-12','height'=>'144.7','weight'=>'36.8','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_manual_recording($data = ['aud_id'=>'38','time'=>'2024-10-12','height'=>'88.5','weight'=>'10','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -181,12 +181,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);
@ -207,6 +216,8 @@ class Card extends Base{
// if(!in_array($data['weight'][1],$this->unit_data['weight'])){
// return $this->msg(10005);
// }
// $data['head_data'] = '48';
$data['acd_id'] = '2';
$return_data = $this->set_user_body_data($data,'by_hand_means');
// 成功
@ -230,7 +241,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){
@ -244,12 +255,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);
@ -270,9 +294,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');
@ -493,6 +515,7 @@ class Card extends Base{
acbd.weight_val,
acbd.bmi,
acbd.body_age,
acbd.head_circumference,
aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date
from ".$this->card_use_db_name['1']." as acbd
left join ".$this->card_use_db_name['2']." as aud on acbd.aud_id=aud.id
@ -561,15 +584,19 @@ class Card extends Base{
];
return $this->msg($result_return);
}else{
// 存储头围数据
$head_circumference = $result[0]['head_circumference']?json_decode($result[0]['head_circumference'],true):false;
unset($result[0]['head_circumference']);
// 处理返回数据
$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);
$result_end['cplist'] = $this->grow_up_recommendation([
'birthday'=>$result[0]['birthday'],
'body'=>[
@ -621,8 +648,28 @@ class Card extends Base{
$result_end['top_list'][2]['offset'] = $temporary_arr_bmi_list['data']['offset'];
}
}
// 加入曲线板块底部的减肥计划数据end
// 添加头围数据如果有的话start
if($head_circumference !== false && $this->calculate_age($result[0]['birthday']) < 3){
if($head_circumference['level'] == '异常' || $head_circumference['value'] == 0){
$offset = 0;
}else{
$offset = $cardparts->calculate_landing_point($head_circumference['list2'],$head_circumference['value'],$head_circumference['level']);
}
array_push($result_end['top_list'],[
'name'=>'头围',
'value'=>$head_circumference['value'],
'unit'=>'CM',
'standard'=>$head_circumference['level'],
'color'=>'',
'list'=>$head_circumference['list2'],
'key_name'=>'head_circumference',
'desc'=>'头围是指绕头部一周的最大长度,头围的大小与闹的发育密切相关',
'offset'=>$offset
]);
}
// 添加头围数据如果有的话end
return $this->msg($result_end);
}
}
@ -783,7 +830,7 @@ class Card extends Base{
$user_data_list = Db::table($this->card_use_db_name['1'])
->where('aud_id', $data['aud_id'])
->whereTime('record_time', 'between', [$data['s_time'], $data['e_time']])
->field("record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '-') AS b_time,$card_body_curve_arr")
->field("record_type,record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '-') AS b_time,$card_body_curve_arr")
// ->field("record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '/') AS b_time,$card_body_curve_arr")
->order('record_time desc')
->select();
@ -805,6 +852,7 @@ class Card extends Base{
array_push($record_arr2,$user_data_list[$key]);
}
}
foreach ($this->card_body_curve_arr as $key => $value) {
$temporary_arr = [];
$temporary_arr['title'] = $this->card_body_curve_arr2[$key];
@ -813,8 +861,15 @@ class Card extends Base{
$temporary_arr['line']['series'][0]['color'] = $this->card_body_curve_arr3[$key];
$temporary_arr['line']['series'][0]['data'] = [];
foreach ($record_arr2 as $k => $v) {
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
if($value == 'fat_r'){
if($v['record_type'] == 'by_device_adc'){
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
}
}else{
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
}
}
array_push($data_arr,$temporary_arr);
}
@ -842,11 +897,24 @@ class Card extends Base{
// }
// // 这里开始转换不同单位的身高体重为cm跟kgend
// $adc_type = $type;
$data['type'] = 1;
// $data['type'] = 1;
// 判断头围数据是否存在是否合理
if(array_key_exists('head_data', $data)){
if(!$this->verify_data_is_ok($data['head_data'],'num')){
return $this->msg(10005);
}
$data['head_circumference'] = $data['head_data'];
}else{
$data['head_circumference'] = 0;
}
// 查询用户信息
$user_data = Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->field('birthday,gender,target_weight,initial_weight,initial_date')->find();
if(!$user_data){
return $this->msg(10003);
}
// 如果最初体重设置为null
if($user_data['initial_date'] == null){
Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
$target_current = $this->base_target_initial_cumulative_weight([
@ -863,10 +931,13 @@ class Card extends Base{
'initial_date'=>$user_data['initial_date'],
]);
}
// 设置身高、体重、年龄、性别、阶段称谓、头围、生日、阻抗
$result_data['height'] = $data['height'];
$result_data['weight'] = $data['weight'];
$result_data['age'] = $this->calculate_age($user_data['birthday']);
$result_data['gender'] = $user_data['gender'];
$result_data['head_circumference'] = $data['head_circumference'];
$result_data['birthday'] = $user_data['birthday'];
if(array_key_exists('adc', $data)){
if($data['adc'] > 0){
$result_data['adc'] = $data['adc'];
@ -880,12 +951,42 @@ class Card extends Base{
// 计算身体数据
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
if($get_body_value === false){
return $this->msg(10005);
}
// 如果年纪小于三岁处理头围数据star
$standardlist = [];
if($result_data['age'] < 3){
if(array_key_exists('standardlist',$get_body_value)){
$standardlist = $get_body_value['standardlist'];
foreach ($standardlist as $key => $value) {
if($value['name'] == 'head' && count($value['list'] ) > 0){
$standardlist = $value;
}
}
$standardlist['list2'] = [];
foreach ($standardlist['list'] as $key => $value) {
array_push($standardlist['list2'],[
'min_val'=>$value['minvalue'],
'max_val'=>$value['maxvalue'],
'text'=>$value['text'],
'color'=>$value['color']
]);
}
unset($standardlist['list']);
unset($get_body_value['standardlist']);
}
}else{
if(array_key_exists('standardlist',$get_body_value)){
unset($get_body_value['standardlist']);
}
}
// 如果年纪小于三岁处理头围数据end
$get_body_value['gender'] = $user_data['gender'];
$get_body_value['birthday'] = $user_data['birthday'];
// 添加身高体重bmi的标尺标准
// 添加身高体重bmi、头围(如果有)的标尺标准
$get_body_value = $this->hwb_standard($get_body_value);
$set_data = [
'acd_id'=>$data['acd_id'],
@ -915,7 +1016,8 @@ class Card extends Base{
'body_level'=>$get_body_value['肥胖等级'],
'body_type'=>$get_body_value['身体类型'],
'body_age'=>$get_body_value['身体年龄'],
'record_type' => $type
'record_type' => $type,
'head_circumference' => $result_data['age'] < 3?json_encode($standardlist):"",
];
if(strlen($set_data['record_time']) <= 12){
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
@ -925,8 +1027,14 @@ class Card extends Base{
Db::startTrans();
try{
$set_user_data = Db::table($this->card_use_db_name['1'])->insert($set_data);
$update_user_data = Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update(['height'=>$get_body_value['身高'],'weight'=>$get_body_value['体重']]);
$update_arr = [
'height'=>$get_body_value['身高'],
'weight'=>$get_body_value['体重']
];
if($data['head_circumference']>0){
$update_arr['head_data'] = $data['head_circumference'];
}
$update_user_data = Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update($update_arr);
// 提交事务
Db::commit();
return $this->msg([
@ -943,7 +1051,6 @@ class Card extends Base{
Db::rollback();
return $this->msg(10002);
}
}
// 添加身高体重bmi的标准
@ -1001,14 +1108,18 @@ class Card extends Base{
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
// 如果落在区间内
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
break;
}
}
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
// 如果$key.'2'没有被设置
if(!array_key_exists($key.'2', $data)){
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
}
}
}
// die;

View File

@ -213,11 +213,11 @@ class Cardparts extends Base{
}
// 处理顶部list
foreach ($temporary_arr['top_list'] as $key => $value) {
if(count($temporary_arr['top_list'][$key]['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($temporary_arr['top_list'][$key]['list'],$temporary_arr['top_list'][$key]['value'],$temporary_arr['top_list'][$key]['standard']);
if(count($value['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']);
}
}
// 如果是没有阻抗的测试,那么就不要底部的其他数据了
if($data['record_type']['value'] != 'by_device_adc'){
$temporary_arr['bottom_list'] = [];
@ -356,12 +356,15 @@ class Cardparts extends Base{
}
// 计算落点百分比
// 计算落点百分比(区间字典,值,值描述)
public function calculate_landing_point($data,$val,$t_val){
// 根据字典确认有几个区间
$num = count($data);
// 没个区间占比
$a_section = bcdiv(100,$num,2);
$temporary_data = [];
$num_0 = 0;
// 看看值是在哪个区间
foreach ($data as $key => $value) {
if($t_val == $value['text']){
$temporary_data = $value;
@ -369,16 +372,25 @@ class Cardparts extends Base{
break;
}
}
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
$max_num = trim($temporary_data['max_val']);
$min_num = trim($temporary_data['min_val']);
if($val < $temporary_data['max_val']){
// 这个值比最小值多出来多少
$num_1 = bcsub($val,$min_num,2);
// 这个区间的值是多少
$num_2 = bcsub($max_num,$min_num,2);
$num_3 = bcdiv(bcdiv($num_1,$num_2,4),$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// 算出这个值在这个区间的占比
$num_3 = bcdiv($num_1,$num_2,2);
$num_4 = bcmul($num_3,$a_section,2);
$result = bcadd($num_4,bcmul($a_section,$num_0,2),2);
}else{
$num_3 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// $num_4 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$a_section,2);
}
return $result;
}

View File

@ -54,6 +54,13 @@ class Index extends Base{
['id'=>'grade_u_12','name'=>'大学一、二年级'],
['id'=>'grade_u_34','name'=>'大学三、四年级']
];
// 阶段性称谓
protected $stage_appellation = [
['min'=>'0','max'=>'3','value'=>'婴儿'],
['min'=>'3','max'=>'16','value'=>'儿童'],
['min'=>'16','max'=>'500','value'=>'成人']
];
################################################################个人资料卡################################################################
################################################################个人资料卡################################################################
@ -98,10 +105,6 @@ class Index extends Base{
$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']){
@ -260,7 +263,6 @@ class Index extends Base{
->where(['aan_id'=>$data['aan_id'],'is_del'=>0])
->field('id,aan_id,nickname,birthday,gender,card_order,target_weight,initial_weight,initial_date,grade,head_pic,weight,height,identity_name,address,identity_id,measure_model')
->select();
$temporary_data = [];
if($data['type'] == 1){
for ($i=0; $i < count($result); $i++) {
@ -274,6 +276,12 @@ class Index extends Base{
}else{
for ($i=0; $i < count($result); $i++) {
$result[$i]['age'] = $this->calculate_age($result[$i]['birthday']);
// 添加阶段称谓、婴儿、儿童、成人
foreach ($this->stage_appellation as $key => $value) {
if($result[$i]['age'] >= $value['min'] && $result[$i]['age'] < $value['max']){
$result[$i]['stage'] = $value['value'];
}
}
}
$temporary_data = $result;
}
@ -299,8 +307,8 @@ class Index extends Base{
}
// 获取指定用户详细信息
public function get_user_data_information($data = ['aud_id'=>79]){
try {
public function get_user_data_information($data = ['aud_id'=>113]){
// try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
@ -315,18 +323,18 @@ class Index extends Base{
return $this->msg(10005);
}
// 获取用户信息
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date,height,weight,address,identity_id,measure_model')->find();
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date,height,weight,address,identity_id,measure_model,head_data')->find();
if(!$result){
return $this->msg(10004);
}
$result['age'] = $this->calculate_age($result['birthday']);
// 从这里开始进入体脂还是体测的判断
if($result['card_order'] != ""){
$result['card_order'] = explode(',',$result['card_order']);
}else{
$result['card_order'] = [];
foreach ($this->stage_appellation as $key => $value) {
if($result['age'] >= $value['min'] && $result['age'] < $value['max']){
$result['stage'] = $value['value'];
}
}
// 从这里开始进入体脂还是体测的判断
$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];
@ -364,21 +372,24 @@ class Index extends Base{
if($result['address'] == ''){
$result['address'] = $this->moren_gufen_diqu;
}
if($result['head_data'] == null){
$result['head_data'] = 0;
}
$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);
// }
}
@ -578,12 +589,11 @@ class Index extends Base{
return $this->msg(99999);
}
}
################################获取账号下信息操作################################
// 获取账号下首页卡片的基础数据
public function get_user_card_data_list($data,$aud_id){
// try {
// 你的业务逻辑
$result = [];
$db_arr = [];
foreach ($data['card_order'] as $key => $value) {
@ -629,6 +639,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) {
@ -713,18 +724,13 @@ 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);
// }
}
################################################################other################################################################
################################################################other################################################################
################################################################other################################################################

View File

@ -23,9 +23,18 @@ class Msginformation extends Base{
################################################################接口################################################################
// 获取板块,及板块下类型标签
public function get_sector_label_msg(){
public function get_sector_label_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
$return_data = $this->get_sector_label_msg_action();
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->get_sector_label_msg_action($data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
@ -43,7 +52,7 @@ class Msginformation extends Base{
}
// 获取板块下信息
public function get_sector_content_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5','sector_id'=>1,'type'=>4,'page'=>1]){
public function get_sector_content_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5','sector_id'=>1,'type'=>0,'page'=>1]){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -120,6 +129,36 @@ class Msginformation extends Base{
}
}
// 获取公告文章信息列表&banner
public function get_recommend_information($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$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);
}
}
// 获取商务合作链接
public function get_business_cooperation_url(){
@ -141,10 +180,43 @@ class Msginformation extends Base{
return $this->msg(99999);
}
}
// 删除掉所有已经读过的文章记录
public function del_all_read_log($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$is_ok = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->delete();
if($is_ok){
echo '删除成功';
}else{
echo '删除失败';
}
} 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(){
public function get_sector_label_msg_action($data){
$Template_arr = [
1=>[
'id'=>'1',
@ -160,6 +232,8 @@ class Msginformation extends Base{
]
],
];
// 获取需要版块id start
$sector = Db::query("
SELECT
@ -179,7 +253,6 @@ class Msginformation extends Base{
// 填充进去版块的轮播start
$return_data = [];
foreach ($sector_all as $key => $value) {
$loop_result = Db::query("
SELECT
id,
@ -191,6 +264,11 @@ class Msginformation extends Base{
ORDER BY
loop_img desc
");
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'];
}
}
$Template_arr[$value]['loop_data'] = $loop_result;
array_push($return_data, $Template_arr[$value]);
}
@ -228,8 +306,14 @@ class Msginformation extends Base{
FETCH NEXT
".$this->page_num." ROWS ONLY
");
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'];
}
}
$return_result['content_data'] = $content_result;
$user_like = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token'],'is_like'=>0])->column('aetc_id');
$user_like = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->column('aetc_id');
foreach ($return_result['content_data'] as $key => $value) {
if(array_key_exists($value['id'], $user_like)){
@ -246,16 +330,16 @@ class Msginformation extends Base{
if($user_like_data){
// 如果找到有点赞记录
if($user_like_data['is_del'] == 0){
if($user_like_data['is_like'] == 1){
// 如果已经点了
// 启动事务
Db::startTrans();
try{
Db::table($this->msginformation_use_db_name['1'])->where(['id'=>$data['id']])->setDec('i_like');
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_del'=>1,'update_time'=>date('Y-m-d H:i:s')]);
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_like'=>0,'update_time'=>date('Y-m-d H:i:s')]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>1]);
return $this->msg(['user_like'=>0]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
@ -267,10 +351,10 @@ class Msginformation extends Base{
Db::startTrans();
try{
Db::table($this->msginformation_use_db_name['1'])->where(['id'=>$data['id']])->setInc('i_like');
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_del'=>0,'update_time'=>date('Y-m-d H:i:s')]);
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_like'=>1,'update_time'=>date('Y-m-d H:i:s')]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>0]);
return $this->msg(['user_like'=>1]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
@ -286,18 +370,89 @@ class Msginformation extends Base{
Db::table($this->msginformation_use_db_name['2'])->insert([
'aetc_id'=>$data['id'],
'token'=>$data['token'],
'is_like'=>1,
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s')
]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>0]);
return $this->msg(['user_like'=>1]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $this->msg(10002);
}
}
}
################################################################get_recommend_information
public function get_recommend_information_action($data){
$return_data = [
'pop'=>[],
'notice'=>[],
'banner'=>[]
];
// 所有可用记录
$all_data = Db::table($this->msginformation_use_db_name['3'])->where(['is_del'=>0])->select();
// 用户阅读记录
$user_read_log = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->field('aetc_id')->select();
$user_read_data = [];
// 先过滤一遍用户已经看过的文章记录
foreach ($user_read_log as $key => $value) {
array_push($user_read_data,$value['aetc_id']);
}
// 删掉已经读过的信息
foreach ($all_data as $key => $value) {
if($value['type'] == '1'){
if(in_array($value['parameter_data'], $user_read_data)){
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]['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]['type'] = 'h5';
$all_data[$key]['id'] = $value['parameter_data'];
}
}else{
$all_data[$key]['type'] = 'wechat';
// 提取查询字符串部分(?后面的部分)
$queryString = substr($all_data[$key]['jump_url'], strpos($all_data[$key]['jump_url'], '?') + 1);
// 使用parse_str解析查询字符串
$params = [];
parse_str($queryString, $params);
// 提取appid和path的值
$appid = isset($params['appid']) ? $params['appid'] : null;
$path = isset($params['path']) ? $params['path'] : null;
$all_data[$key]['appid'] = $appid;
$all_data[$key]['path'] = $path;
}
// $all_data[$key]['id'] = $all_data[$key]['parameter_data'];
unset($all_data[$key]['parameter_data']);
unset($all_data[$key]['is_del']);
unset($all_data[$key]['ROW_NUMBER']);
}
// 分类信息
foreach ($all_data as $key => $value) {
// 1:首屏弹窗2滚动公告3banner
if($value['scene_data'] == '1'){
array_push($return_data['pop'],$value);
}else if($value['scene_data'] == '2'){
array_push($return_data['notice'],$value);
}else if($value['scene_data'] == '3'){
array_push($return_data['banner'],$value);
}
}
// 设置pop当中只有一个数据
if(count($return_data['pop'])>0){
$return_data['pop'] = [$return_data['pop'][0]];
}
return $this->msg($return_data);
}

View File

@ -15,7 +15,7 @@ class Pagingcontrast extends Base{
'4'=>'app_user_data',
];
protected $request_result = [
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
];
@ -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{
@ -113,7 +112,7 @@ class Pagingcontrast extends Base{
}
// 获取详细历史数据信息(包含身体、跳绳、肺活量)
public function get_all_record_detailed_information($data = ['id'=>'52','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_all_record_detailed_information($data = ['id'=>'36','type'=>'8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -146,10 +145,9 @@ class Pagingcontrast extends Base{
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 数据对比(包含身体、跳绳、肺活量)
public function get_all_card_data_contrast($data = ['before_id'=>'51','after_id'=>'52','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_all_card_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -282,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',
@ -302,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',
@ -454,6 +452,7 @@ class Pagingcontrast extends Base{
// 设置排除在外的数据类型end
$result = Db::table($this->db_name[$data['type']])->where(['id'=>$data['id']])->find();
$for_data_arr = $this->request_result[$data['type']];
if($result){
// if($data['type'] == 2 && $result['record_type'] != 'by_device_adc'){
// $for_data_arr = ['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI','']];
@ -465,6 +464,7 @@ class Pagingcontrast extends Base{
if($data['type'] == 2){
// 身体数据处理,如果没有阻抗,则只显示四项$exclude_data_arr
if($result['record_type'] != 'by_device_adc'){
if(!in_array($key, $exclude_data_arr)){
continue;
}else{
@ -477,12 +477,26 @@ class Pagingcontrast extends Base{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
}
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
$temporary_arr['unit'] = $value[1];
array_push($result_data,$temporary_arr);
}
//
// 添加头围详细start
if($data['type'] == 2){
if($result['head_circumference'] != null){
array_unshift($result_data,[
'key_name'=>'head_circumference',
'name'=>'头围',
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0":json_decode($result['head_circumference'],true)['value'],
'unit'=>'cm',
]);
}
}
// 添加头围详细end
return $this->msg($result_data);
}else{
return $this->msg(10004);
@ -515,6 +529,7 @@ class Pagingcontrast extends Base{
acbd.sfr,
acbd.record_time,
acbd.record_type,
acbd.head_circumference,
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
aud.nickname,
aud.gender,
@ -537,22 +552,49 @@ class Pagingcontrast extends Base{
$calculate_arr['after'] = $value;
}
}
$return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time'];
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
$return_data['name'] = $calculate_arr['before']['nickname'];
$return_data['gender'] = $calculate_arr['before']['gender'];
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
$return_data['list'] = [];
// 处理如果没有阻抗的数据为0显示异常start;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
if($calculate_arr['before']['record_type'] != 'by_device_adc' && $calculate_arr['after']['record_type'] != 'by_device_adc'){
foreach ($calculate_arr['before'] as $key => $value) {
if(!in_array($key, ['height','weight','bmi'])){
if(!in_array($key, ['height','weight','bmi','head_circumference'])){
unset($calculate_arr['before'][$key]);
unset($calculate_arr['after'][$key]);
}
}
if($return_data['age']>=3){
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}else{
$calculate_arr['before']['head_circumference'] = json_decode($calculate_arr['before']['head_circumference'],true);
$calculate_arr['after']['head_circumference'] = json_decode($calculate_arr['after']['head_circumference'],true);
foreach ($calculate_arr as $key => $value) {
if(array_key_exists('value',$value['head_circumference'])){
$calculate_arr[$key]['head'][0] = $value['head_circumference']['value'];
}else{
$calculate_arr[$key]['head'][0] = 0;
}
if(array_key_exists('level',$value['head_circumference'])){
$calculate_arr[$key]['head'][1] = $value['head_circumference']['level'];
}else{
$calculate_arr[$key]['head'][1] = '异常';
}
if(array_key_exists('color',$value['head_circumference'])){
$calculate_arr[$key]['head'][2] = $value['head_circumference']['color'];
}else{
$calculate_arr[$key]['head'][2] = '';
}
$calculate_arr[$key]['head'] = implode(',',$calculate_arr[$key]['head']);
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}
}
}else{
foreach ($calculate_arr as $key => $value) {
if($value['record_type'] != 'by_device_adc'){
@ -572,7 +614,7 @@ class Pagingcontrast extends Base{
}
// 处理如果没有阻抗的数据为0显示异常end同步处理如果两个对比数据都没有阻抗数据则只显示基础信息
foreach ($calculate_arr['before'] as $key => $value) {
if(in_array($key, ['height','weight','bmi','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
if(in_array($key, ['height','weight','bmi','head','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
$before_arr = explode(',', $value);
$after_arr = explode(',', $calculate_arr['after'][$key]);
array_push($return_data['list'], [
@ -596,6 +638,12 @@ class Pagingcontrast extends Base{
]);
}
}
// 添加头围数据如果需要的话start
// if($calculate_arr['before']['head_circumference'] != null || $calculate_arr['after']['head_circumference'] != null){
// }
// 添加头围数据如果需要的话end
return $this->msg($return_data);
}
// 数据对比

View File

@ -36,6 +36,304 @@ class Sportstesting extends Base{
'4'=>'分钟秒钟例1000米跑',
];
protected $ceshiyongde_data_baocun_canshu = '{
"code": 0,
"msg": "操作成功",
"data": [
{
"name": "现场考试",
"key": "现场考试",
"list": [
{
"name": "第一类项目(3选1)",
"key": "第一类项目",
"is_choice": "1",
"list": [
{
"name": "1000米跑",
"proportion": "1",
"value": "4:23",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 1
},
{
"name": "200米游泳",
"proportion": "1",
"value": "6:12",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 0
},
{
"name": "4分钟跳绳",
"proportion": "1",
"value": 340,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 6,
"choice_state": 0
}
]
},
{
"name": "第二类项目(5选1)",
"key": "第二类项目",
"is_choice": "1",
"list": [
{
"name": "50米跑",
"proportion": "1",
"value": 8.1,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "立定跳远",
"proportion": "1",
"value": 2.02,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "实心球",
"proportion": "1",
"value": 7.3,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "引体向上",
"proportion": "1",
"value": 6,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "25米游泳",
"proportion": "1",
"value": 30,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第三类项目(5选1)",
"key": "第三类项目",
"is_choice": "1",
"list": [
{
"name": "乒乓球",
"proportion": "1",
"value": 15,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "羽毛球",
"proportion": "1",
"value": 60,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "网球",
"proportion": "1",
"value": 55,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "武术",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "体操",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第四类项目(3选1)",
"key": "第四类项目",
"is_choice": "1",
"list": [
{
"name": "足球运球",
"proportion": "1",
"value": 15.5,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "篮球",
"proportion": "1",
"value": 31,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "排球",
"proportion": "1",
"value": 23,
"proportion_value": null,
"unit": "40秒/次",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
}
]
},
{
"name": "日常考核",
"key": "日常考核",
"list": [
{
"name": "体育与健身",
"key": "体育与健身",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
}
]
},
{
"name": "体质健康综合评定",
"key": "体质健康综合评定",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
}
]
}
]
}
]
}';
// 加 bcadd(,,20)
// 减 bcsub(,,20)
@ -82,14 +380,14 @@ class Sportstesting extends Base{
}
// 获取地区类型列表
public function sportstesting_get_region_list($data = ['parameter_data'=>'河北,石家庄市','gender'=>'0']){
public function sportstesting_get_region_list($data = ['parameter_data'=>'上海,上海','gender'=>'1','aud_id'=>'83','choice_last_time'=>'0']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data)){
$return_data = $this->msg(10001);
if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('choice_last_time', $data) || !array_key_exists('aud_id', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['parameter_data'],'str')){
return $this->msg(10005);
@ -97,6 +395,13 @@ class Sportstesting extends Base{
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['choice_last_time'],'intnum')){
return $this->msg(10005);
}else{
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
}
$return_data = $this->sportstesting_get_region_list_action($data);
// 成功
@ -152,13 +457,14 @@ class Sportstesting extends Base{
}
// 计算并存储数据
public function sportstesting_set_once_data($data = ['aud_id'=>'83','parameter_data'=>'辽宁,沈阳市','result_data'=>'','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function sportstesting_set_once_data($data = ['aud_id'=>'83','parameter_data'=>'上海,上海','result_data'=>'','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
// $data['result_data'] = json_decode($this->ceshiyongde_data_baocun_canshu,true)['data'];
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('result_data', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
$return_data = $this->msg(10001);
}
@ -191,6 +497,7 @@ class Sportstesting extends Base{
}else{
return $this->msg(10006);
}
// die;
unset($data['token']);
$return_data = $this->sportstesting_set_once_data_action2($data);
@ -251,7 +558,7 @@ class Sportstesting extends Base{
}
// 获取估分历史详情
public function sportstesting_get_one_details($data = ['id'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function sportstesting_get_one_details($data = ['id'=>'38','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -364,26 +671,32 @@ class Sportstesting extends Base{
// 全省地市一个规则start
$db_condition = "province = '".$parameter_data[0]."'";
// 全省地市一个规则end
$result['list'] = [];
$result['total_score'] = 0;
$data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->select();
if(count($data) > 0){
if(count($data) > 1){
// 查到不止一条规则
return $this->msg(10004,'查询地址不够详细,请重新选择省市地区');
$result = false;
if($data['choice_last_time'] == 1){
$last_tiame_data = Db::table($this->sportstesting_use_db_name['2'])->where(['aud_id'=>$data['aud_id'],'address'=>$data['parameter_data']])->order('id desc')->find();
if($last_tiame_data){
$result = json_decode($last_tiame_data['content'],true);
}else{
$result = false;
}
$data = json_decode($data[0]['content'],true);
$result = $this->handle_default_rule_list($data,$gender);
// die;
return $this->msg($result);
}else{
return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区');
}
if($result === false){
$rule_data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->select();
if(count($rule_data) > 0){
if(count($rule_data) > 1){
// 查到不止一条规则
return $this->msg(10004,'查询地址不够详细,请重新选择省市地区');
}
$rule_data = json_decode($rule_data[0]['content'],true);
$result = $this->handle_default_rule_list($rule_data,$gender);
}else{
return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区');
}
}
return $this->msg($result);
}
################################################sportstesting_get_last_data
public function sportstesting_get_last_data_action($data){
@ -448,13 +761,17 @@ class Sportstesting extends Base{
################################################sportstesting_get_one_details
public function sportstesting_get_one_details_action($data){
$user_data = Db::table($this->sportstesting_use_db_name['2'])->where(['id'=>$data['id']])->find();
if($user_data){
$temporary_data['list'] = json_decode($user_data['content'],true);
// 压入表头
foreach ($temporary_data['list'] as $key => $value) {
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
unset($temporary_data['list'][$key]['list'][$v1k]['list'][$i]);
}
}
array_unshift($temporary_data['list'][$key]['list'][$v1k]['list'],[
'name'=>'项目名',
'value'=>'成绩',
@ -496,6 +813,7 @@ class Sportstesting extends Base{
$find_data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->find();
$find_data = json_decode($find_data['content'],true);
$recognition_rule = $find_data[$gender];
foreach ($data['result_data'] as $key => $value) {
// 遍历一级($value['key'] = 现场考试)
foreach ($value['list'] as $k2 => $v2) {
@ -505,11 +823,39 @@ class Sportstesting extends Base{
$temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
$data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
if(array_key_exists('choice_state',$v3) && $v3['choice_state'] == 0){
continue;
}
$return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
$return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// if(array_key_exists('choice_state',$v3)){
// if($v3['choice_state'] == 1){
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }else{
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
// }else{
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
}
}
}
$return_result['list'] = $data['result_data'];
$user_sportstesting_set = Db::table($this->sportstesting_use_db_name['2'])->insert([
'aud_id'=>$data['aud_id'],
@ -519,10 +865,17 @@ class Sportstesting extends Base{
'create_time'=>date('Y-m-d H:i:s'),
'address'=>$data['parameter_data'],
]);
// $user_sportstesting_set = true;
if($user_sportstesting_set){
foreach ($return_result['list'] as $key => $value) {
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
unset($return_result['list'][$key]['list'][$v1k]['list'][$i]);
}
}
array_unshift($return_result['list'][$key]['list'][$v1k]['list'],[
'name'=>'项目名',
'value'=>'成绩',
@ -631,13 +984,14 @@ class Sportstesting extends Base{
$temporary_arr = $data[2];
}
// die;
$result = [];
foreach ($temporary_arr as $key => $value) {
$num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]);
foreach ($value as $s_c_k => $s_c_v) {
if($s_c_v['choose_num'] == 0){
// 如果是必选项
$num2 = array_push($result[$num-1]['list'],[
'name'=>$s_c_k,
'key'=>$s_c_k,
@ -657,7 +1011,28 @@ class Sportstesting extends Base{
]);
}
}else{
$num2 = array_push($result[$num-1]['list'],['name'=>$s_c_k,'key'=>$s_c_k,'is_choice'=>$s_c_v['choose_num'],'list'=>[]]);
// 如果不是必选项
$num2 = array_push($result[$num-1]['list'],[
'name'=>$s_c_k."(".count($s_c_v['list'])."".$s_c_v['choose_num'].")",
'key'=>$s_c_k,
'is_choice'=>$s_c_v['choose_num'],
'list'=>[]
]);
$choice_state_num = $s_c_v['choose_num'];
foreach ($s_c_v['list'] as $x_m_k => $x_m_v) {
array_push($result[$num-1]['list'][$num2-1]['list'],[
'name'=>$x_m_k,
'proportion'=>$x_m_v['proportion'],
'value'=>$x_m_v['value'],
'proportion_value'=>null,
'unit'=>$x_m_v['unit_data'],
'type'=>$x_m_v['type'],
'describe'=>$x_m_v['describe'],
'total_score'=>$x_m_v['score'],
'choice_state'=>$choice_state_num > 0?1:0,
]);
$choice_state_num = $choice_state_num-1;
}
}
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace app\app\controller;
use think\Db;
class Wechatabout extends Base{
protected $msginformation_use_db_name = [
'1'=>'admin_editor_text_content',
'2'=>'admin_editor_text_like_up_log',
];
protected $page_num = 10;
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
// 获取板块,及板块下类型标签
public function get_access_token_action(){
try {
$return_data = $this->get_sector_label_msg_action();
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log([], $logContent, null);
return $this->msg(99999);
}
}
}

View File

@ -138,7 +138,6 @@ class Base extends Controller{
public function token_time_validate($token){
// 591b70e0d80b5fa6d77e6e1384453ab9
if(is_string($token)){
$length = strlen($token);
if ($length < 10 ) {
Log::record('用户尝试更新token时间token' . $token.',但是更新token失败字符串长度小于10', 'token_log');
@ -282,10 +281,43 @@ class Base extends Controller{
['min_val'=>'10','max_val'=>'59','text'=>'不及格','color'=>'#FF5656'],
['min_val'=>'0','max_val'=>'9','text'=>'无效','color'=>'#FF5656'],
];
$grade = Db::table($this->base_use_db_name['3'])->where(['id'=>$id])->field('id,grade,gender')->find();
if(!$grade || $grade['grade'] == 'nothing'){
$grade = Db::table($this->base_use_db_name['3'])->where(['id'=>$id])->field('id,grade,gender,birthday')->find();
if(!$grade){
return [];
}
if($grade['grade'] == 'nothing'){
// 计算年龄判断是属于哪个年级
$user_age = $this->calculate_age($grade['birthday']);
if($user_age <= 7){
$grade['grade'] = 'grade_s_1';
}else if($user_age == 8){
$grade['grade'] = 'grade_s_2';
}else if($user_age == 9){
$grade['grade'] = 'grade_s_3';
}else if($user_age == 10){
$grade['grade'] = 'grade_s_4';
}else if($user_age == 11){
$grade['grade'] = 'grade_s_5';
}else if($user_age == 12){
$grade['grade'] = 'grade_s_6';
}else if($user_age == 13){
$grade['grade'] = 'grade_m_1';
}else if($user_age == 14){
$grade['grade'] = 'grade_m_2';
}else if($user_age == 15){
$grade['grade'] = 'grade_m_3';
}else if($user_age == 16){
$grade['grade'] = 'grade_h_1';
}else if($user_age == 17){
$grade['grade'] = 'grade_h_2';
}else if($user_age == 18){
$grade['grade'] = 'grade_h_3';
}else if($user_age == 19 || $user_age == 20){
$grade['grade'] = 'grade_u_12';
}else if($user_age >= 21){
$grade['grade'] = 'grade_u_34';
}
}
$sql_min = "WITH RankedGrades AS (
SELECT
id,
@ -434,6 +466,7 @@ class Base extends Controller{
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); // POST数据
// 设置请求头
if (!empty($headers)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}else{
// 如果需要发送JSON数据可以使用以下设置
@ -562,18 +595,13 @@ class Base extends Controller{
return false; // 匹配失败,返回 false
}
}else if($type == 'datetime'){
$errors = \DateTime::getLastErrors(); // 获取上一次的解析错误
$formats = ['Y-m-d','Y-m-d H:i:s'];
foreach ($formats as $format) {
$dateTime = \DateTime::createFromFormat($format, $data);
$newErrors = \DateTime::getLastErrors(); // 获取当前解析的错误
// 检查是否有新的错误产生(即当前解析是否失败)
if ($dateTime && ($newErrors['warning_count'] == $errors['warning_count'] && $newErrors['error_count'] == $errors['error_count'])) {
// 如果没有新的错误,说明当前格式解析成功
// 检查时间字符串是否成功解析,并且解析后的日期时间与原始字符串表示的时间一致
if ($dateTime && $dateTime->format($format) === $data) {
return true;
}
// 更新错误状态为当前解析的错误
$errors = $newErrors;
}
}
// 如果所有格式都解析失败,则返回 false
$this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为日期格式',[]]);
@ -588,7 +616,6 @@ class Base extends Controller{
public function ceshiyong($aa = 4,$gd = 0.2){
$token = 'cd3f27cf4c4002170ea7bceeb723ac91';
// dump(cache($token));
$data = Db::table('pc_bmistand2')->select();
for ($i=0; $i < count($data); $i++) {
@ -608,9 +635,7 @@ class Base extends Controller{
// 'z3sd'=>$data[$i]['z3sd'],
]);
}
dump('OK2');
die;
// dump('ok');
// $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
}

View File

@ -58,14 +58,31 @@ class Calculatebody extends Base{
// 使用接口调用之前的进行计算start
$url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3';
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>$data['age'],
'adc'=>$data['adc'],
'gender'=>$data['gender'],
];
if($data['age'] < '3'){
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>round($data['age']),//四舍五入取整
'adc'=>round($data['adc']),//四舍五入取整
'gender'=>$data['gender'],
'head'=>$data['head_circumference'],
'hasStandardList'=>true,
'birthDay'=>$data['birthday'],
];
}else{
$temporary_parameter = [
'weight'=>$data['weight'],
'height'=>$data['height'],
'age'=>round($data['age']),//四舍五入取整
'adc'=>round($data['adc']),//四舍五入取整
'gender'=>$data['gender'],
];
}
$request_result = $this->postRequest($url,$temporary_parameter);
if($request_result['code'] != 0){
return false;
}
$result['weight'] = $request_result['data']['weight'];
$result['height'] = $request_result['data']['height'];
$result['bmi'] = $request_result['data']['bmi'];
@ -88,6 +105,7 @@ class Calculatebody extends Base{
$result['body'] = $request_result['data']['body'];
// 使用接口调用之前的进行计算end
$return_data['standardlist'] = $request_result['data']['standardlist'];
$return_data['体重'] = $data['weight'];
$return_data['身高'] = $data['height'];
$return_data['BMI'] = $result['bmi'];

View File

@ -55,7 +55,7 @@ class Card extends Base{
'proteinval'=>['不足'=>'#FED966','标准'=>'#58CF6B','优'=>'#3A68D7'],
'bone'=>['不足'=>'#FED966','标准'=>'#58CF6B','优'=>'#3A68D7'],
'protein'=>['不足'=>'#FED966','标准'=>'#58CF6B','优'=>'#3A68D7'],
'kcal'=>['偏低'=>'#FF5656','优'=>'#5ad06d'],
'kcal'=>['偏低'=>'#FF5656','优'=>'#3A68D4'],
'visceral'=>['标准'=>'#55CF6C','警惕'=>'#FEAC00','危险'=>'#FB5A52'],
'sfr'=>['不足'=>'#FCDB68','标准'=>'#59D16F','偏高'=>'#FEAB03'],
];
@ -77,6 +77,10 @@ class Card extends Base{
'weight'=>['value'=>3,'list'=>['低'=>1,'偏低'=>1,'标准'=>2,'偏高'=>3,'高'=>3]],
'bmi'=>['value'=>2,'list'=>['消瘦'=>1,'正常'=>2,'偏重'=>3,'肥胖'=>4]],
];
protected $unit_data = [
'height'=>['cm','inch','ft-in'],
'weight'=>['kg','斤','st:lb','lb'],
];
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
@ -84,17 +88,15 @@ class Card extends Base{
// 详细卡片信息
// $data = ['id'=>'2']
public function card_data_detailed($data=['aud_id'=>'11','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_data_detailed($data=['aud_id'=>'38']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
if(!array_key_exists('aud_id', $data)){
return $this->msg(10001);
}
unset($data['token']);
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
@ -119,7 +121,7 @@ class Card extends Base{
}
// 曲线页面-曲线接口
public function card_curve_chart($data = ['aud_id'=>'11','s_time'=>'2024-04-01','e_time'=>'2024-10-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_curve_chart($data = ['aud_id'=>'11','s_time'=>'2024-04-01','e_time'=>'2024-12-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -160,7 +162,8 @@ 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($data = ['aud_id'=>'11','time'=>'2024-10-12','height'=>'155.7','weight'=>'46.7','token'=>'caadd1be045a65f30b92aa805f1de54a']){
// public function card_manual_recording($data = ['aud_id'=>'37','time'=>'2024-10-12','height'=>'144.7,cm','weight'=>'36.8,kg','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_manual_recording($data = ['aud_id'=>'38','time'=>'2024-10-12','height'=>'88.5','weight'=>'10','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -184,8 +187,30 @@ class Card extends Base{
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);
// }
// if(!$this->verify_data_is_ok($data['height'][0],'num')){
// return $this->msg(10005);
// }
// if(!in_array($data['height'][1],$this->unit_data['height'])){
// return $this->msg(10005);
// }
// $data['weight'] = explode(',',$data['weight']);
// if(count($data['height']) < 2){
// return $this->msg(10005);
// }
// if(!$this->verify_data_is_ok($data['weight'][0],'num')){
// return $this->msg(10005);
// }
// if(!in_array($data['weight'][1],$this->unit_data['weight'])){
// return $this->msg(10005);
// }
// $data['head_data'] = '48';
$data['acd_id'] = '2';
$return_data = $this->set_user_body_data($data);
$return_data = $this->set_user_body_data($data,'by_hand_means');
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
@ -206,7 +231,8 @@ 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'=>'58','height'=>'175','weight'=>'68','adc'=>'550','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
// 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']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -226,15 +252,32 @@ class Card extends Base{
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);
// }
// if(!$this->verify_data_is_ok($data['height'][0],'num')){
// return $this->msg(10005);
// }
// if(!in_array($data['height'][1],$this->unit_data['height'])){
// return $this->msg(10005);
// }
// $data['weight'] = explode(',',$data['weight']);
// if(count($data['height']) < 2){
// return $this->msg(10005);
// }
// if(!$this->verify_data_is_ok($data['weight'][0],'num')){
// return $this->msg(10005);
// }
// 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);
}
if($data['adc'] == 0){
$data['adc'] = 550;
}
$data['time'] = date('Y-m-d H:i:s');
$data['acd_id'] = '2';
$return_data = $this->set_user_body_data($data);
$return_data = $this->set_user_body_data($data,'by_device');
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
@ -302,6 +345,117 @@ class Card extends Base{
}
}
// 身高预测
public function card_height_prediction($data = ['dadHeight'=>'199','momHeight'=>'160','birthday'=>'2014-07-24','sex'=>'1',]){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!is_array($data)){
return $this->msg(10005);
}
if(!array_key_exists('dadHeight', $data) || !array_key_exists('momHeight', $data) || !array_key_exists('birthday', $data) || !array_key_exists('sex', $data)){
return $this->msg(10001);
}
unset($data['token']);
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['dadHeight'],'num')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['momHeight'],'num')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['sex'],'intnum')){
return $this->msg(10005);
}
// 直接开始业务请求外部接口start
$url = 'https://ybapi.pcxbc.com/api/child/predictheight';
$temporary_parameter = [
'dadHeight'=>$data['dadHeight'],
'momHeight'=>$data['momHeight'],
'birthday'=>$data['birthday'],
'sex'=>$data['sex'],
];
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
// 直接开始业务请求外部接口end
$this->record_api_log($data, null, $request_result);
return json($request_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);
}
}
// BMI测评
public function card_bmi_evaluation($cbe_data = ['height'=>'177','weight'=>'177','birthday'=>'2024-10-03','sex'=>'1'],$type = false){
try {
// 你的业务逻辑
if(count(input('post.')) > 0 && $type == false){
$cbe_data = input('post.');
}
if(!is_array($cbe_data)){
return $this->msg(10005);
}
if(!array_key_exists('height', $cbe_data) || !array_key_exists('weight', $cbe_data) || !array_key_exists('birthday', $cbe_data) || !array_key_exists('sex', $cbe_data)){
return $this->msg(10001);
}
unset($cbe_data['token']);
if(!$this->verify_data_is_ok($cbe_data['birthday'],'datetime')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($cbe_data['height'],'num')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($cbe_data['weight'],'num')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($cbe_data['sex'],'intnum')){
return $this->msg(10005);
}
// 直接开始业务请求外部接口start
$url = 'http://ybdevice.pcxbc.com/api/result/calcbmi';
$temporary_parameter = [
'height'=>$cbe_data['height'],
'weight'=>$cbe_data['weight'],
'birthday'=>$cbe_data['birthday'],
'sex'=>$cbe_data['sex'],
];
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
// 直接开始业务请求外部接口end
// 处理进度点
$request_result =$this->bmi_evaluation_action($request_result);
$this->record_api_log($cbe_data, null, $request_result);
return $request_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($cbe_data, $logContent, null);
return $this->msg(99999);
}
}
################################################################业务接口################################################################
################################################################业务接口################################################################
@ -314,6 +468,7 @@ class Card extends Base{
Top 1
acbd.id,
acbd.acd_id,
acbd.record_type,
acbd.create_time,
acbd.last_update_time,
acbd.score,
@ -335,20 +490,87 @@ class Card extends Base{
acbd.age,
acbd.is_del,
acbd.height,
acbd.height_val,
acbd.weight,
acbd.weight_val,
acbd.bmi,
acbd.body_age,
acbd.head_circumference,
aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date
from ".$this->card_use_db_name['1']." as acbd
left join ".$this->card_use_db_name['2']." as aud on acbd.aud_id=aud.id
where acbd.aud_id='".$data['aud_id']."'
where acbd.is_del=0 and acbd.aud_id='".$data['aud_id']."'
order by acbd.record_time desc
");
if(!$result){
return $this->msg(10004);
if(count($result) <= 0){
$result_return = [
"score_name"=>"",
"score_value"=>"",
"score_unit"=>"",
"body_type_name"=>"",
"body_type_value"=>"",
"body_type_unit"=>"",
"record_time"=>"",
'top_list'=>[
[
"name"=>"体重",
"value"=>"0",
"unit"=>"公斤",
"standard"=>"",
"color"=>"",
"list"=>[],
"key_name"=>"weight",
"desc"=>"反映和衡量一个人健康状况的重要标志之一",
"offset"=>"0"
],
[
"name"=>"身高",
"value"=>"0",
"unit"=>"CM",
"standard"=>"",
"color"=>"",
"list"=>[],
"key_name"=>"height",
"desc"=>"人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大",
"offset"=>"0"
],
[
"name"=>"BMI",
"value"=>"0",
"unit"=>"公斤",
"standard"=>"",
"color"=>"",
"list"=>[],
"key_name"=>"bmi",
"desc"=>"BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。",
"offset"=>"0"
],
],
'bottom_list' => [],
'cplist'=>[
'nutritionlist'=>[],
'sportlist'=>[],
'sleeplist'=>[],
'moodlist'=>[],
],
'literature'=>[],
'target_current'=>[
'target_weight'=>'0',
'initial_weight'=>'0',
'cumulative_weight'=>'0',
'cumulative_day'=>'0'
],
];
return $this->msg($result_return);
}else{
// $curve_bottom = $this->card_curve_target_action($result);
// 存储头围数据
$head_circumference = $result[0]['head_circumference']?json_decode($result[0]['head_circumference'],true):false;
unset($result[0]['head_circumference']);
// 处理返回数据
$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'];
@ -363,17 +585,71 @@ class Card extends Base{
'bmi'=>$result[0]['bmi']
],
]);
if(count($result_end['cplist']['nutritionlist']) <= 0){
// $result_end['cplist'] = [];
$result_end['literature'] = [];
// 只有含有阻抗的记录才有数据参考
if($result[0]['record_type'] == 'by_device_adc'){
if(count($result_end['cplist']['nutritionlist']) <= 0){
$result_end['literature'] = [];
}else{
$result_end['literature'] = [
'《中华人民共和国卫生行业标准WS 423-2013》',
'《中华人民共和国卫生行业标准WS/T 612-2018》',
'《中华人民共和国卫生行业标准WS/T1586-2018》',
'《WHO 5~19岁身高/体重判定标准》',
];
}
}else{
$result_end['literature'] = [
'《中华人民共和国卫生行业标准WS 423-2013》',
'《中华人民共和国卫生行业标准WS/T 612-2018》',
'《中华人民共和国卫生行业标准WS/T1586-2018》',
'《WHO 5~19岁身高/体重判定标准》',
];
$result_end['literature'] = [];
}
// 加入曲线板块底部的减肥计划数据start
$result_end['target_current'] = $this->base_target_initial_cumulative_weight([
'weight'=>$result[0]['weight']>0?$result[0]['weight']:0,
'target_weight'=>$result[0]['target_weight']>0?$result[0]['target_weight']:0,
'initial_weight'=>$result[0]['initial_weight']>0?$result[0]['initial_weight']:0,
'initial_date'=>$result[0]['initial_date']!=null?$result[0]['initial_date']:0,
]);
if(count($result_end['top_list'][2]['list']) <= 0){
// 这是16岁以上人群
$data = [
'height'=>$result[0]['height_val'],
'weight'=>$result[0]['weight_val'],
'birthday'=>$result[0]['birthday'],
'sex'=>$result[0]['gender']
];
$temporary_arr_bmi_list = $this->card_bmi_evaluation($data,true);
$temporary_arr_bmi_list = $temporary_arr_bmi_list->getData();
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'];
}
}
// 加入曲线板块底部的减肥计划数据end
// 添加头围数据如果有的话start
if($head_circumference !== false && $this->calculate_age($result[0]['birthday']) < 3){
if($head_circumference['level'] == '异常' || $head_circumference['value'] == 0){
$offset = 0;
}else{
$offset = $cardparts->calculate_landing_point($head_circumference['list2'],$head_circumference['value'],$head_circumference['level']);
}
array_push($result_end['top_list'],[
'name'=>'头围',
'value'=>$head_circumference['value'],
'unit'=>'CM',
'standard'=>$head_circumference['level'],
'color'=>'',
'list'=>$head_circumference['list2'],
'key_name'=>'head_circumference',
'desc'=>'头围是指绕头部一周的最大长度,头围的大小与闹的发育密切相关',
'offset'=>$offset
]);
}
// 添加头围数据如果有的话end
return $this->msg($result_end);
}
}
@ -386,18 +662,22 @@ class Card extends Base{
if($key != 'aud_id' && $key != 'id' && $key != 'create_time' && $key != 'last_update_time' && $key != 'acd_id' && $key != 'ROW_NUMBER' && $key != 'record_time' && $key != 'gender' && $key != 'birthday'){
// 设置单个数据格式
$result_end_data[$key] = $this->result_end_data_mould;
// 该项名
if(array_key_exists($key, $this->unit_name)){
$result_end_data[$key]['name'] = $this->unit_name[$key];
}
// 该项单位
if(array_key_exists($key, $this->unit_symbol)){
$result_end_data[$key]['unit'] = $this->unit_symbol[$key];
}
$result_end_data[$key]['value'] = explode(',',$value)[0];
if(strpos($value, ',')){
$result_end_data[$key]['standard'] = explode(',',$value)[1];
}
if(array_key_exists($key, $this->standard_color)){
if($result_end_data[$key]['standard'] != '异常'){
if($result_end_data[$key]['standard'] != '异常' && $result_end_data[$key]['standard'] != ''){
$result_end_data[$key]['color'] = $this->standard_color[$key][$result_end_data[$key]['standard']];
}
}
@ -530,7 +810,7 @@ class Card extends Base{
$user_data_list = Db::table($this->card_use_db_name['1'])
->where('aud_id', $data['aud_id'])
->whereTime('record_time', 'between', [$data['s_time'], $data['e_time']])
->field("record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '-') AS b_time,$card_body_curve_arr")
->field("record_type,record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '-') AS b_time,$card_body_curve_arr")
// ->field("record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '/') AS b_time,$card_body_curve_arr")
->order('record_time desc')
->select();
@ -552,6 +832,7 @@ class Card extends Base{
array_push($record_arr2,$user_data_list[$key]);
}
}
foreach ($this->card_body_curve_arr as $key => $value) {
$temporary_arr = [];
$temporary_arr['title'] = $this->card_body_curve_arr2[$key];
@ -560,8 +841,15 @@ class Card extends Base{
$temporary_arr['line']['series'][0]['color'] = $this->card_body_curve_arr3[$key];
$temporary_arr['line']['series'][0]['data'] = [];
foreach ($record_arr2 as $k => $v) {
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
if($value == 'fat_r'){
if($v['record_type'] == 'by_device_adc'){
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
}
}else{
array_push($temporary_arr['line']['categories'],$record_arr2[$k]['b_time']);
array_push($temporary_arr['line']['series'][0]['data'],$record_arr2[$k][$value]);
}
}
array_push($data_arr,$temporary_arr);
}
@ -571,13 +859,42 @@ class Card extends Base{
################################################card_manual_recording
// 用户身体数据卡片记录
public function set_user_body_data($data){
public function set_user_body_data($data,$type){
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
// // 这里开始转换不同单位的身高体重为cm跟kgstart
// if($data['height'][1] == 'kg'){
// $data['height'] = $data['height'][0];
// }else if($data['height'][1] == '斤'){
// // 斤数除以2就是公斤
// $data['height'] = bcdiv($data['height'][0],2,2);
// }else if($data['height'][1] == 'st:lb'){
// $data['height'] = $data['height'][0];
// }else if($data['height'][1] == 'lb'){
// $data['height'] = $data['height'][0];
// }
// // 这里开始转换不同单位的身高体重为cm跟kgend
// $adc_type = $type;
// $data['type'] = 1;
$data['type'] = 1;
// 判断头围数据是否存在是否合理
if(array_key_exists('head_data', $data)){
if(!$this->verify_data_is_ok($data['head_data'],'num')){
return $this->msg(10005);
}
$data['head_circumference'] = $data['head_data'];
}else{
$data['head_circumference'] = 0;
}
// 查询用户信息
$user_data = Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->field('birthday,gender,target_weight,initial_weight,initial_date')->find();
if(!$user_data){
return $this->msg(10003);
}
// 如果最初体重设置为null
if($user_data['initial_date'] == null){
Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
$target_current = $this->base_target_initial_cumulative_weight([
@ -594,20 +911,62 @@ class Card extends Base{
'initial_date'=>$user_data['initial_date'],
]);
}
// 设置身高、体重、年龄、性别、阶段称谓、头围、生日、阻抗
$result_data['height'] = $data['height'];
$result_data['weight'] = $data['weight'];
$result_data['age'] = $this->calculate_age($user_data['birthday']);
$result_data['gender'] = $user_data['gender'];
$result_data['head_circumference'] = $data['head_circumference'];
$result_data['birthday'] = $user_data['birthday'];
if(array_key_exists('adc', $data)){
$result_data['adc'] = $data['adc'];
if($data['adc'] > 0){
$result_data['adc'] = $data['adc'];
$type = "by_device_adc";
}else{
$result_data['adc'] = 550;
$type = "by_device";
}
}
$calculate_body_formula = new Calculatebody();
// 计算身体数据
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
if($get_body_value === false){
return $this->msg(10005);
}
// 如果年纪小于三岁处理头围数据star
$standardlist = [];
if($result_data['age'] < 3){
if(array_key_exists('standardlist',$get_body_value)){
$standardlist = $get_body_value['standardlist'];
foreach ($standardlist as $key => $value) {
if($value['name'] == 'head' && count($value['list'] ) > 0){
$standardlist = $value;
}
}
$standardlist['list2'] = [];
foreach ($standardlist['list'] as $key => $value) {
array_push($standardlist['list2'],[
'min_val'=>$value['minvalue'],
'max_val'=>$value['maxvalue'],
'text'=>$value['text'],
'color'=>$value['color']
]);
}
unset($standardlist['list']);
unset($get_body_value['standardlist']);
}
}else{
if(array_key_exists('standardlist',$get_body_value)){
unset($get_body_value['standardlist']);
}
}
// 如果年纪小于三岁处理头围数据end
$get_body_value['gender'] = $user_data['gender'];
$get_body_value['birthday'] = $user_data['birthday'];
// 添加身高体重bmi的标尺标准
// 添加身高体重bmi、头围(如果有)的标尺标准
$get_body_value = $this->hwb_standard($get_body_value);
$set_data = [
'acd_id'=>$data['acd_id'],
@ -636,27 +995,40 @@ class Card extends Base{
'sfr'=>implode(',',$get_body_value['皮下脂肪']),
'body_level'=>$get_body_value['肥胖等级'],
'body_type'=>$get_body_value['身体类型'],
'body_age'=>$get_body_value['身体年龄']
'body_age'=>$get_body_value['身体年龄'],
'record_type' => $type,
'head_circumference' => $result_data['age'] < 3?json_encode($standardlist):"",
];
if(strlen($set_data['record_time']) <= 12){
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
$set_data['record_time'] = $this->addCurrentTimeToDateString($set_data['record_time']);
}
$set_user_data = Db::table($this->card_use_db_name['1'])->insert($set_data);
if($set_user_data){
// 返回简要数据
if($data['type'] == 1){
return $this->msg([
'acd_id'=>2,
'height'=>$get_body_value['身高'].',CM',
'weight'=>$get_body_value['体重'].',公斤',
'bmi'=>$get_body_value['BMI'],
'target_current'=>$target_current,
]);
// 启动事务
Db::startTrans();
try{
$set_user_data = Db::table($this->card_use_db_name['1'])->insert($set_data);
$update_arr = [
'height'=>$get_body_value['身高'],
'weight'=>$get_body_value['体重']
];
if($data['head_circumference']>0){
$update_arr['head_data'] = $data['head_circumference'];
}
}else{
$update_user_data = Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update($update_arr);
// 提交事务
Db::commit();
return $this->msg([
'acd_id'=>2,
'height'=>$get_body_value['身高'].',CM',
'weight'=>$get_body_value['体重'].',公斤',
'bmi'=>$get_body_value['BMI'],
// 'user_set_height'=>$get_body_value['身高'],
// 'user_set_weight'=>$get_body_value['体重'],
'target_current'=>$target_current,
]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $this->msg(10002);
}
}
@ -716,14 +1088,18 @@ class Card extends Base{
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
// 如果落在区间内
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
break;
}
}
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
// 如果$key.'2'没有被设置
if(!array_key_exists($key.'2', $data)){
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
}
}
}
// die;
@ -779,7 +1155,69 @@ class Card extends Base{
}
################################################card_record_detailed_information
################################################card_bmi_evaluation
public function bmi_evaluation_action($data){
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
if(!array_key_exists('code',$data) || !array_key_exists('data',$data)){
return $this->msg(99999,'网络异常请稍后重试1');
}
if($data['code'] != 0){
return $this->msg(99999,'网络异常请稍后重试2');
}
if(!is_array($data['data'])){
return $this->msg(99999,'网络异常请稍后重试3');
}
if(!array_key_exists('bmi',$data['data']) || !array_key_exists('bmilevel',$data['data']) || !array_key_exists('bmilevelcolor',$data['data']) || !array_key_exists('bmilevellist',$data['data'])){
return $this->msg(99999,'网络异常请稍后重试4');
}
if(!is_array($data['data']['bmilevellist'])){
return $this->msg(99999,'网络异常请稍后重试5');
}
$num = 0;
$subsection_val = 0;
$temporary_subsection_val = null;
foreach ($data['data']['bmilevellist'] as $key => $value) {
if(!array_key_exists('maxvalue',$value) || !array_key_exists('minvalue',$value)){
return $this->msg(99999,'网络异常请稍后重试6');
}
// 判断是否可以进行比较,规则是否正确
if(is_numeric($value['maxvalue']) && is_numeric($value['minvalue'])){
if($data['data']['bmi'] >= $value['minvalue'] && $data['data']['bmi'] < $value['maxvalue']){
// 在落点内
$subsection_val = bcsub($value['maxvalue'],$value['minvalue'],1);//获取最大最小值差
$temporary_subsection_val = bcsub($data['data']['bmi'],$value['minvalue'],1);//获取当前值与最小值差
$temporary_subsection_val = bcdiv($temporary_subsection_val,$subsection_val,1);//获取当前值与最小值差与最大最小值差之比
$subsection_val = bcdiv(100,count($data['data']['bmilevellist']),1);//每段应该的百分比
$temporary_subsection_val = bcmul($subsection_val,$temporary_subsection_val,1);//获取当前值与最小值差与最大最小值差之比与总段数之比
$temporary_subsection_val = bcadd($temporary_subsection_val,bcmul($subsection_val,$num,1),1);
}else{
$num = $num + 1;
}
}
}
if($temporary_subsection_val === null){
if($data['data']['bmi'] >= $data['data']['bmilevellist'][count($data['data']['bmilevellist'])-1]['maxvalue']){
$temporary_subsection_val = 100;
}else{
return $this->msg(99999,'网络异常请稍后重试7');
}
}
$data['data']['offset'] = $temporary_subsection_val;
$data = $data['data'];
// 处理key名称一致start
foreach ($data['bmilevellist'] as $key => $value) {
$data['bmilevellist'][$key]['max_val'] = $value['maxvalue'];
$data['bmilevellist'][$key]['min_val'] = $value['minvalue'];
unset($data['bmilevellist'][$key]['minvalue']);
unset($data['bmilevellist'][$key]['maxvalue']);
}
// 处理key名称一致end
return $this->msg($data);
}
################################################################其他接口################################################################

View File

@ -179,17 +179,18 @@ class Cardparts extends Base{
$age = $data['age']['value'];
$weight = 0;
$temporary_arr = [
'score_name' =>$data['score']['name'],
'score_value' =>$data['score']['value'],
'score_unit' =>$data['score']['unit'],
'body_type_name' =>$data['body_type']['name'],
'body_type_value' =>$data['body_type']['value'],
'body_type_unit' =>$data['body_type']['unit'],
'score_name' =>$data['record_type']['value'] == 'by_device_adc'?$data['score']['name']:'',
'score_value' =>$data['record_type']['value'] == 'by_device_adc'?$data['score']['value']:'',
'score_unit' =>$data['record_type']['value'] == 'by_device_adc'?$data['score']['unit']:'',
'body_type_name' =>$data['record_type']['value'] == 'by_device_adc'?$data['body_type']['name']:'',
'body_type_value' =>$data['record_type']['value'] == 'by_device_adc'?$data['body_type']['value']:'',
'body_type_unit' =>$data['record_type']['value'] == 'by_device_adc'?$data['body_type']['unit']:'',
// 'record_time' =>str_replace('-', '/', $data['record_time']),
'record_time' =>$data['record_time'],
'top_list'=>[],
'bottom_list'=>[],
];
// die;
$date_temporary = new \DateTime($temporary_arr['record_time']);
// 使用 format 方法来指定新的日期和时间格式
@ -212,10 +213,16 @@ class Cardparts extends Base{
}
// 处理顶部list
foreach ($temporary_arr['top_list'] as $key => $value) {
if(count($temporary_arr['top_list'][$key]['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($temporary_arr['top_list'][$key]['list'],$temporary_arr['top_list'][$key]['value'],$temporary_arr['top_list'][$key]['standard']);
if(count($value['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']);
}
}
// 如果是没有阻抗的测试,那么就不要底部的其他数据了
if($data['record_type']['value'] != 'by_device_adc'){
$temporary_arr['bottom_list'] = [];
return $temporary_arr;
}
// 处理底部list
foreach ($temporary_arr['bottom_list'] as $key => $value) {
// 脂肪率&
@ -349,12 +356,15 @@ class Cardparts extends Base{
}
// 计算落点百分比
// 计算落点百分比(区间字典,值,值描述)
public function calculate_landing_point($data,$val,$t_val){
// 根据字典确认有几个区间
$num = count($data);
// 没个区间占比
$a_section = bcdiv(100,$num,2);
$temporary_data = [];
$num_0 = 0;
// 看看值是在哪个区间
foreach ($data as $key => $value) {
if($t_val == $value['text']){
$temporary_data = $value;
@ -362,16 +372,25 @@ class Cardparts extends Base{
break;
}
}
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
$max_num = trim($temporary_data['max_val']);
$min_num = trim($temporary_data['min_val']);
if($val < $temporary_data['max_val']){
// 这个值比最小值多出来多少
$num_1 = bcsub($val,$min_num,2);
// 这个区间的值是多少
$num_2 = bcsub($max_num,$min_num,2);
$num_3 = bcdiv(bcdiv($num_1,$num_2,4),$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// 算出这个值在这个区间的占比
$num_3 = bcdiv($num_1,$num_2,2);
$num_4 = bcmul($num_3,$a_section,2);
$result = bcadd($num_4,bcmul($a_section,$num_0,2),2);
}else{
$num_3 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// $num_4 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$a_section,2);
}
return $result;
}

View File

@ -25,7 +25,7 @@ class Cardpublic extends Base{
// 获取卡片数据
public function get_card_content($data = ['aud_id'=>'11','acd_id'=>'16','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_card_content($data = ['aud_id'=>'11','acd_id'=>'13','token'=>'caadd1be045a65f30b92aa805f1de54a']){
// try {
// // 你的业务逻辑
// $return_data =
@ -363,178 +363,77 @@ class Cardpublic extends Base{
}
// 获取手动记录内容
public function obtain_manual_record_content($data = ['aud_id'=>11]){
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('aud_id', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
if(!$user_data){
return $this->msg(10004);
}
$card_data_c = Db::table($this->cardpublic_use_db_name['2'])
->where(['is_del'=>0])
->field('id,name,type,unit,unit2,suit_gender,acd_id')
->select();
$card_data_c2 = [];
foreach ($card_data_c as $key => $value) {
$temporary_arr = [];
$temporary_arr['id'] = $value['acd_id'];
$temporary_arr['height'] = false;
$temporary_arr['weight'] = false;
$temporary_arr['number'] = false;
$temporary_arr['time'] = false;
$temporary_arr['list'] = [];
$card_data_c2[$value['acd_id']] = $temporary_arr;
}
foreach ($card_data_c as $key => $value) {
if(in_array($user_data['gender'], explode(",", $value['suit_gender']))){
$temporary_arr = [];
$temporary_arr['id'] = $value['id'];
$temporary_arr['name'] = $value['name'];
$temporary_arr['number'] = $value['unit2'] == '时长'?false:true;
$temporary_arr['type'] = $value['type'];
$temporary_arr['time'] = $value['unit2'] == '时长'?true:false;
$temporary_arr['describe'] = $value['unit2'];
$temporary_arr['unit'] = $value['unit'] == "分/秒"?'': $value['unit'];
array_push($card_data_c2[$value['acd_id']]['list'],$temporary_arr);
}else{
continue;
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
}
$card_data = [
['id'=>'2','height'=>true,'weight'=>true,'number'=>false,'time'=>false,'list'=>[]],
['id'=>'6','height'=>false,'weight'=>false,'number'=>true,'time'=>true,'list'=>[]],
];
foreach ($card_data_c2 as $key => $value) {
array_push($card_data,$value);
}
// $card_data = [
// ['id'=>'2','height'=>true,'weight'=>true,'number'=>false,'time'=>false,'list'=>[]],
// ['id'=>'6','height'=>false,'weight'=>false,'number'=>true,'time'=>true,'list'=>[]],
// [
// 'id'=>'10',
// 'height'=>false,
// 'weight'=>false,
// 'number'=>false,
// 'time'=>false,
// 'list'=>[
// [
// 'id'=>'1',
// 'name'=>'1000米',
// 'number'=>false,
// 'type'=>4,
// 'time'=>true,
// 'describe'=>'时长',
// 'unit'=>'',
// ],
// [
// 'id'=>'2',
// 'name'=>'800米',
// 'number'=>false,
// 'type'=>4,
// 'time'=>true,
// 'describe'=>'时长',
// 'unit'=>'',
// ],
// [
// 'id'=>'3',
// 'name'=>'50米',
// 'number'=>true,
// 'type'=>2,
// 'time'=>false,
// 'describe'=>'时长',
// 'unit'=>'秒',
// ],
// ]
// ],
// [
// 'id'=>'12',
// 'height'=>false,
// 'weight'=>false,
// 'number'=>false,
// 'time'=>false,
// 'list'=>[
// [
// 'id'=>'7',
// 'name'=>'立定跳远',
// 'number'=>true,
// 'type'=>1,
// 'time'=>false,
// 'describe'=>'距离',
// 'unit'=>'CM',
// ],
// ]
// ],
// [
// 'id'=>'13',
// 'height'=>false,
// 'weight'=>false,
// 'number'=>false,
// 'time'=>false,
// 'list'=>[
// [
// 'id'=>'8',
// 'name'=>'引体向上',
// 'number'=>true,
// 'type'=>1,
// 'time'=>false,
// 'describe'=>'个数',
// 'unit'=>'个',
// ],
// [
// 'id'=>'9',
// 'name'=>'1分钟仰卧起坐',
// 'number'=>true,
// 'type'=>1,
// 'time'=>false,
// 'describe'=>'个数',
// 'unit'=>'个',
// ],
// ]
// ],
// [
// 'id'=>'14',
// 'height'=>false,
// 'weight'=>false,
// 'number'=>false,
// 'time'=>false,
// 'list'=>[
// [
// 'id'=>'10',
// 'name'=>'坐位体前屈',
// 'number'=>true,
// 'type'=>1,
// 'time'=>false,
// 'describe'=>'距离',
// 'unit'=>'CM',
// ],
// ]
// ],
// ];
// if($user_data['gender'] == 1){
// unset($card_data[2]['list'][1]);//800米
// unset($card_data[4]['list'][1]);//仰卧起坐
// }else if($user_data['gender'] == 2){
// unset($card_data[2]['list'][0]);//1000米
// unset($card_data[4]['list'][0]);//引体向上
// }
// foreach ($card_data as $key => $value) {
// $card_data[$key]['list'] = array_values($card_data[$key]['list']);
// }
return $this->msg($card_data);
if(!array_key_exists('aud_id', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
if(!$user_data){
return $this->msg(10004);
}
$card_data_c = Db::table($this->cardpublic_use_db_name['2'])
->where(['is_del'=>0])
->field('id,name,type,unit,unit2,suit_gender,acd_id')
->select();
$card_data_c2 = [];
foreach ($card_data_c as $key => $value) {
$temporary_arr = [];
$temporary_arr['id'] = $value['acd_id'];
$temporary_arr['height'] = false;
$temporary_arr['weight'] = false;
$temporary_arr['number'] = false;
$temporary_arr['time'] = false;
$temporary_arr['list'] = [];
$card_data_c2[$value['acd_id']] = $temporary_arr;
}
foreach ($card_data_c as $key => $value) {
if(in_array($user_data['gender'], explode(",", $value['suit_gender']))){
$temporary_arr = [];
$temporary_arr['id'] = $value['id'];
$temporary_arr['name'] = $value['name'];
$temporary_arr['number'] = $value['unit2'] == '时长'?false:true;
$temporary_arr['type'] = $value['type'];
$temporary_arr['time'] = $value['unit2'] == '时长'?true:false;
$temporary_arr['describe'] = $value['unit2'];
$temporary_arr['unit'] = $value['unit'] == "分/秒"?'': $value['unit'];
array_push($card_data_c2[$value['acd_id']]['list'],$temporary_arr);
}else{
continue;
}
}
$card_data = [
['id'=>'2','height'=>true,'weight'=>true,'number'=>false,'time'=>false,'list'=>[]],
['id'=>'6','height'=>false,'weight'=>false,'number'=>true,'time'=>true,'list'=>[]],
];
foreach ($card_data_c2 as $key => $value) {
array_push($card_data,$value);
}
// 成功
$this->record_api_log($data, null, $card_data);
return $this->msg($card_data);
// return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
################################################################action################################################################
################################################################action################################################################
@ -589,6 +488,7 @@ class Cardpublic extends Base{
$return_data['line_list'] = $this->level_data;
// 查询最后一次成绩
$data_this_time = Db::table($this->cardpublic_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$value['id'],'is_del'=>0])->order('record_time desc')->field('id,detailed_msg,achievement,record_time')->find();
if($data_this_time){
$data_this_time['detailed_msg'] = json_decode($data_this_time['detailed_msg'],true);
// 设置基础数据
@ -643,6 +543,11 @@ class Cardpublic extends Base{
$temporary_arr_c['today_times'] = $temporary_arr_c['today_times'].'次';
$temporary_arr_c['all_times'] = $temporary_arr_c['all_times'].'次';
}else{
$project_describe = Db::table($this->cardpublic_use_db_name['2'])->where(['id'=>$value['id'],'is_del'=>0])->field('id,project_describe')->find();
if($project_describe){
$temporary_arr_c['describe'] = $project_describe['project_describe'];
}
}
array_push($return_data['label_data'],$temporary_arr_c);
}

View File

@ -88,7 +88,6 @@ class Device extends Base{
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 获取用户设备列表
public function device_user_data_list($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){

View File

@ -6,7 +6,7 @@ use think\Db;
use \think\Validate;
class Index extends Base{
protected $moren_gufen_diqu = '上海,上海';
protected $moren_gufen_diqu = '北京,北京';
protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data','10'=>'app_card_data_sub_item_data'];
protected $index_use_db_name = [
'1'=>'app_version_log',
@ -54,13 +54,20 @@ class Index extends Base{
['id'=>'grade_u_12','name'=>'大学一、二年级'],
['id'=>'grade_u_34','name'=>'大学三、四年级']
];
// 阶段性称谓
protected $stage_appellation = [
['min'=>'0','max'=>'3','value'=>'婴儿'],
['min'=>'3','max'=>'16','value'=>'儿童'],
['min'=>'16','max'=>'500','value'=>'成人']
];
################################################################个人资料卡################################################################
################################################################个人资料卡################################################################
################################################################个人资料卡################################################################
// 检测版本及判断是否登录失效
public function login_invalid_version($data = ['token'=>NULL]){
public function login_invalid_version($data = ['token'=>'']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -98,10 +105,6 @@ class Index extends Base{
$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']){
@ -111,7 +114,11 @@ class Index extends Base{
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
if(!array_key_exists('token', $data) || !array_key_exists('measure_model', $data)){
return $this->msg(10001);
}
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
return $this->msg(10001);
}
@ -234,7 +241,7 @@ class Index extends Base{
// 获取账号下用户列表
// $type 1获取列表2获取详细信息
public function get_user_card_list($data = ['aan_id'=>1,'type'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_user_card_list($data = ['aan_id'=>4,'type'=>2,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -252,15 +259,29 @@ class Index extends Base{
return $this->msg(10005);
}
unset($data['token']);
$result = Db::table($this->index_use_db_name['2'])->where(['aan_id'=>$data['aan_id'],'is_del'=>0])->select();
$result = Db::table($this->index_use_db_name['2'])
->where(['aan_id'=>$data['aan_id'],'is_del'=>0])
->field('id,aan_id,nickname,birthday,gender,card_order,target_weight,initial_weight,initial_date,grade,head_pic,weight,height,identity_name,address,identity_id,measure_model')
->select();
$temporary_data = [];
if($data['type'] == 1){
for ($i=0; $i < count($result); $i++) {
array_push($temporary_data,['id'=>$result[$i]['id'],'nickname'=>$result[$i]['nickname'],'identity_name'=>$result[$i]['identity_name'],'identity_id'=>$result[$i]['identity_id']]);
array_push($temporary_data,[
'id'=>$result[$i]['id'],
'nickname'=>$result[$i]['nickname'],
'identity_name'=>$result[$i]['identity_name'],
'identity_id'=>$result[$i]['identity_id'],
]);
}
}else{
for ($i=0; $i < count($result); $i++) {
$result[$i]['age'] = $this->calculate_age($result[$i]['birthday']);
// 添加阶段称谓、婴儿、儿童、成人
foreach ($this->stage_appellation as $key => $value) {
if($result[$i]['age'] >= $value['min'] && $result[$i]['age'] < $value['max']){
$result[$i]['stage'] = $value['value'];
}
}
}
$temporary_data = $result;
}
@ -302,82 +323,60 @@ class Index extends Base{
return $this->msg(10005);
}
// 获取用户信息
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date,weight,address,identity_id')->find();
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date,height,weight,address,identity_id,measure_model,head_data')->find();
if(!$result){
return $this->msg(10004);
}
// 获取用户身体卡片信息
$weight_data_pd = Db::table($this->index_use_db_name['3'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc')->field('id,weight_val,record_time')->find();
if(!$result){
// 失败
$this->record_api_log($data, null, ['code'=>10003,'msg'=>'',[]]);
return $this->msg(10003);
}
unset($result['ROW_NUMBER']);
$result['age'] = $this->calculate_age($result['birthday']);
if($result['card_order'] === ''){
$result['card_order'] = [];
$result['card_data_list'] = [];
$result['target_current'] = $this->base_target_initial_cumulative_weight([]);
}else{
$result['card_order'] = explode(',',$result['card_order']);
foreach ($this->stage_appellation as $key => $value) {
if($result['age'] >= $value['min'] && $result['age'] < $value['max']){
$result['stage'] = $value['value'];
}
}
// 从这里开始进入体脂还是体测的判断
$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];
$result['target_current'] = $calculation_results[1];
$result['card_order'] = $calculation_results[1];
}else if($result['measure_model'] == 2){// 这里是体脂
$result['card_data_list'] = [];
$result['card_order'] = [];
}else{
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'measure_model数据不是1或者2',[]]);
return $this->msg(10004);
}
if($weight_data_pd){
$result['weight'] = $weight_data_pd['weight_val'];
}
unset($result['target_weight']);
unset($result['initial_weight']);
unset($result['initial_date']);
// 获取设备信息进入卡片 start
$likePattern = '%' . $result['aan_id'] . '%';
$result_device = Db::table($this->index_use_db_name['4'])
->alias('adcd')
->join(''.$this->index_use_db_name['5'].' add','adcd.add_id = add.id','LEFT')
// ->where(['adcd.bind_account_id'=>$result['aan_id']])
->where("adcd.bind_account_id LIKE ?", [$likePattern])
->field('adcd.id,add.acd_id')
->select();
$device_arr = [];
foreach ($result_device as $key => $value) {
if(!in_array($value['acd_id'],$device_arr)){
array_push($device_arr,$value['acd_id']);
}
}
foreach ($result['card_data_list'] as $key => $value) {
if(in_array($value['acd_id'],$device_arr)){
$result['card_data_list'][$key]['device_determine'] = true;
}else{
$result['card_data_list'][$key]['device_determine'] = false;
}
// // 处理卡片的背景色背景图
// foreach ($card_pic_color as $ck => $cv) {
// if($cv['id'] == $value['acd_id']){
// $result['card_data_list'][$key]['background_color'] = $cv['background_color'];
// $result['card_data_list'][$key]['background_pic'] = $cv['background_pic'];
// }
// }
}
// 获取设备信息进入卡片 end
// 插入肺活量的卡片标准
// // 获取设备信息进入卡片 start
// $likePattern = '%' . $result['aan_id'] . '%';
// $result_device = Db::table($this->index_use_db_name['4'])
// ->alias('adcd')
// ->join(''.$this->index_use_db_name['5'].' add','adcd.add_id = add.id','LEFT')
// ->where("adcd.bind_account_id LIKE ?", [$likePattern])
// ->field('adcd.id,add.acd_id')
// ->select();
// $device_arr = [];
// foreach ($result_device as $key => $value) {
// if(!in_array($value['acd_id'],$device_arr)){
// array_push($device_arr,$value['acd_id']);
// }
// }
// foreach ($result['card_data_list'] as $key => $value) {
// if(in_array($value['acd_id'],$device_arr)){
// $result['card_data_list'][$key]['device_determine'] = true;
// }else{
// $result['card_data_list'][$key]['device_determine'] = false;
// }
// }
// // 获取设备信息进入卡片 end
if($result['address'] == ''){
$result['address'] = $this->moren_gufen_diqu;
}
$result['vitalcapacity_data'] = $this->get_vitalcapacity_data($result['id']);
// 成功
if($result['head_data'] == null){
$result['head_data'] = 0;
}
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',$result]);
return $this->msg($result);
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
@ -395,7 +394,7 @@ class Index extends Base{
}
// 获取所有卡片列表信息
public function get_card_all_list($data = ['aud_id'=>1,'token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){
public function get_card_all_list($data = ['aud_id'=>11,'token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -414,13 +413,20 @@ class Index extends Base{
if(!$user_card_list){
// 失败
$this->record_api_log($data, null, ['code'=>10003,'msg'=>'',[]]);
$this->record_api_log($data, null, ['code'=>10003,'msg'=>'',[]]);
return $this->msg(10003);
}
unset($user_card_list['ROW_NUMBER']);
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
$all_card_list = Db::table($this->index_use_db_name['6'])->where(['is_del'=>0])->field('id,name,pic')->select();
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
foreach ($user_card_list['card_order'] as $key => $value) {
if(in_array($value,$this->default_card)){
unset($user_card_list['card_order'][$key]);
}
}
$user_card_list['card_order'] = array_values($user_card_list['card_order']);
$all_card_list = Db::table($this->index_use_db_name['6'])->where(['is_del'=>0])->field('id,name,pic')->select();
// die;
$result = ['user'=>[],'all'=>[]];
foreach ($all_card_list as $key => $value) {
if(in_array($value['id'],$user_card_list['card_order'])){
@ -583,6 +589,7 @@ class Index extends Base{
return $this->msg(99999);
}
}
################################获取账号下信息操作################################
// 获取账号下首页卡片的基础数据
@ -592,8 +599,10 @@ class Index extends Base{
$result = [];
$db_arr = [];
foreach ($data['card_order'] as $key => $value) {
if($value<10){
$db_arr[$value] = Db::table($this->db_name[$value])->where(['aud_id'=>$aud_id,'is_del'=>'0'])->order('record_time desc')->limit(1)->select();
if(in_array($value,$this->default_card)){
// 过滤掉老版本的268选项卡
unset($data['card_order'][$key]);
continue;
}else{
// 公共卡牌
$db_arr[$value] = Db::table($this->index_use_db_name['9'])->where(['aud_id'=>$aud_id,'acd_id'=>$value,'is_del'=>'0'])->order('record_time desc')->limit(1)->select();
@ -601,36 +610,38 @@ class Index extends Base{
$temporary_data = Db::table($this->index_use_db_name['8'])->where(['id'=>$db_arr[$value][0]['acdsi_id']])->field('id,name')->find();
$db_arr[$value][0]['acdsi_name'] = $temporary_data['name'];
}
}
if(count($db_arr[$value]) > 0){
$db_arr[$value] = $db_arr[$value][0];
}else{
unset($db_arr[$value]);
if(count($db_arr[$value]) > 0){
$db_arr[$value] = $db_arr[$value][0];
}else{
unset($db_arr[$value]);
}
}
}
$data['card_order'] = array_values($data['card_order']);
// 获取卡片背景图,及背景色信息及其他信息
$card_all_data = Db::table($this->index_use_db_name['6'])->field('id,name,page_url_record,page_url_report,page_url_bluetooth,key_word,background_color,background_pic')->select();
$card_all_data = Db::table($this->index_use_db_name['6'])->where(['is_del'=>0])->field('id,name,page_url_record,page_url_report,page_url_bluetooth,key_word,background_color,background_pic')->select();
$card_all_data_result = [];
foreach ($card_all_data as $key => $value) {
$card_all_data_result[$value['id']] = $value;
}
// 获取卡片路径及卡片数组处理end
// 添加目标体重于当前体重差数据
if(array_key_exists('2', $db_arr)){
$target_current = $this->base_target_initial_cumulative_weight([
'weight'=>$db_arr['2']['weight']>0?$db_arr['2']['weight']:0,
'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
]);
}else{
$target_current = $this->base_target_initial_cumulative_weight([
'weight'=>0,
'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
]);
}
// // 添加目标体重于当前体重差数据
// if(array_key_exists('2', $db_arr)){
// $target_current = $this->base_target_initial_cumulative_weight([
// 'weight'=>$db_arr['2']['weight']>0?$db_arr['2']['weight']:0,
// 'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
// 'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
// 'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
// ]);
// }else{
// $target_current = $this->base_target_initial_cumulative_weight([
// 'weight'=>0,
// 'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
// 'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
// 'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
// ]);
// }
if(count($db_arr) <= 0){
// 没有数据,传递一个空的卡片
foreach ($data['card_order'] as $key => $value) {
@ -646,27 +657,14 @@ class Index extends Base{
$temporary_arr['background_color'] = $card_all_data_result[$value]['background_color'];
$temporary_arr['background_pic'] = $card_all_data_result[$value]['background_pic'];
$temporary_arr['inside_data'] = [];
if(array_key_exists($value, $this->card_data)){
foreach ($this->card_data[$value][2] as $k => $v) {
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
'value'=>$v[2],
'unit'=>$v[1]!='无'?$v[1]:'',
'standard'=>'',
'color'=>''
]);
}
}else{
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
'name'=>'最近一次',
'value'=>"--",
'unit'=>'',
'standard'=>'*分',
'color'=>''
]);
}
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
'name'=>'最近一次',
'value'=>"--",
'unit'=>'',
'standard'=>'*分',
'color'=>''
]);
array_push($result,$temporary_arr);
}
}else{
@ -681,95 +679,56 @@ class Index extends Base{
$temporary_arr['background_color'] = $card_all_data_result[$value]['background_color'];
$temporary_arr['background_pic'] = $card_all_data_result[$value]['background_pic'];
$temporary_arr['inside_data'] = [];
if(array_key_exists($value, $this->card_data)){
if(array_key_exists($value,$db_arr)){
$temporary_arr['id'] = $db_arr[$value]['id'];
$temporary_arr['record_time'] = $db_arr[$value]['record_time'];
foreach ($this->card_data[$value][2] as $k => $v) {
if($value == '2'){
$tem_arr_2 = explode(',', $db_arr[$value][$k]);
}else if($value == '6' && $k == 'jump_time'){
$time_conversion = $this->handle_hour_branch_second($db_arr[$value][$k]);
$tem_arr_2 = [$time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'],'',''];
}else{
$tem_arr_2 = [$db_arr[$value][$k],'',''];
}
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
'value'=>$tem_arr_2[0],
'unit'=>$v[1]!='无'?$v[1]:'',
'standard'=>$tem_arr_2[1]!='无'?$tem_arr_2[1]:'',
'color'=>$tem_arr_2[2]!='无'?$tem_arr_2[2]:''
]);
}
}else{
$temporary_arr['id'] = '';
$temporary_arr['record_time'] = '';
foreach ($this->card_data[$value][2] as $k => $v) {
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
'value'=>$v[2],
'unit'=>$v[1]!='无'?$v[1]:'',
'standard'=>'',
'color'=>''
]);
}
}
if(array_key_exists($value,$db_arr)){
// 公共卡片内容
$temporary_arr['id'] = $db_arr[$value]['id'];
$temporary_arr['record_time'] = $db_arr[$value]['record_time'];
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>"项目名称",
'value'=>$db_arr[$value]['acdsi_name'],
'unit'=>'',
'standard'=>'',
'color'=>''
]);
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>"成绩",
'value'=>$db_arr[$value]['achievement'],
'unit'=>$db_arr[$value]['unit'],
'standard'=>'',
'color'=>''
]);
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>'得分',
// 'value'=>$db_arr[$value]['score'],
'value'=>$this->convertStringToNumber($db_arr[$value]['score']),
'unit'=>'分',
'standard'=>"",
'color'=>''
]);
}else{
if(array_key_exists($value,$db_arr)){
// 公共卡片内容
$temporary_arr['id'] = $db_arr[$value]['id'];
$temporary_arr['record_time'] = $db_arr[$value]['record_time'];
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>"项目名称",
'value'=>$db_arr[$value]['acdsi_name'],
'unit'=>'',
'standard'=>'',
'color'=>''
]);
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>"成绩",
'value'=>$db_arr[$value]['achievement'],
'unit'=>$db_arr[$value]['unit'],
'standard'=>'',
'color'=>''
]);
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
// 'name'=>'最近一次',
'name'=>'得分',
// 'value'=>$db_arr[$value]['score'],
'value'=>$this->convertStringToNumber($db_arr[$value]['score']),
'unit'=>'分',
'standard'=>"",
'color'=>''
]);
}else{
$temporary_arr['id'] = '';
$temporary_arr['record_time'] = '';
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
'name'=>'最近一次',
'value'=>"--",
'unit'=>'',
'standard'=>'*分',
'color'=>''
]);
}
$temporary_arr['id'] = '';
$temporary_arr['record_time'] = '';
array_push($temporary_arr['inside_data'],[
'key'=>'last_time',
'name'=>'最近一次',
'value'=>"--",
'unit'=>'',
'standard'=>'*分',
'color'=>''
]);
}
array_push($result,$temporary_arr);
}
}
// 成功
// $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[$result,$target_current]]);
return [$result,$target_current];
return [$result,$data['card_order']];
// } catch (\Exception $e) {
// // 捕获异常
// $this->record_api_log($data, $e->getMessage(), null);
@ -779,6 +738,7 @@ class Index extends Base{
################################################################other################################################################
################################################################other################################################################
################################################################other################################################################
@ -786,159 +746,290 @@ class Index extends Base{
public function verify_parameters($data,$type){
// 设置验证
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'identity_id' => 'require',
'identity_name' => 'require',
'address' => 'require',
];
$msg = [
'aan_id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'identity_id.require' => '身份缺失',
'identity_name.require' => '身份缺失',
'address.require' => '区域缺失',
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
// 'identity.number' => '身份信息格式错误',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['aan_id'] = $data['aan_id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
$parameter['grade'] = $data['grade'];
$parameter['card_order'] = '2,6,8';
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['identity_id'] = $data['identity_id'];
$parameter['identity_name'] = $data['identity_name'];
$parameter['address'] = $data['address'];
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$parameter_pd = Db::table($this->index_use_db_name['7'])->where(['id'=>$parameter['aan_id']])->count();
if($parameter_pd <= 0){
return '该账户不存在';
}
$result = Db::table($this->index_use_db_name['2'])->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
if($result>0){
return '该成员已存在';
}
if(!array_key_exists($parameter['identity_id'],$this->identity_list)){
return '身份信息错误';
}else{
if($parameter['identity_id'] != 'P0'){
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
$result = Db::table($this->index_use_db_name['2'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
if($result>0){
return '该身份已存在';
if($data['measure_model'] == 1){
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'measure_model' => 'require|in:1,2',
'identity_id' => 'require',
'identity_name' => 'require',
'address' => 'require',
];
$msg = [
'aan_id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'measure_model.require' => '测量模式缺失',
'identity_id.require' => '身份缺失',
'identity_name.require' => '身份缺失',
'address.require' => '区域缺失',
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母和数字',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'measure_model.number' => '测量模式错误',
'measure_model.in' => '测量模式信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['aan_id'] = $data['aan_id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
$parameter['card_order'] = '';
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$parameter['measure_model'] = $data['measure_model'];
$parameter['grade'] = $data['grade'];
$parameter['identity_id'] = $data['identity_id'];
$parameter['identity_name'] = $data['identity_name'];
$parameter['address'] = $data['address'];
if(!array_key_exists($parameter['identity_id'],$this->identity_list)){
return '身份信息错误';
}else{
if($parameter['identity_id'] != 'P0'){
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
$result = Db::table($this->index_use_db_name['2'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
if($result>0){
return '该身份已存在';
}
}
}
$address_data = Db::table($this->index_use_db_name['10'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
$parameter['card_order'] = $address_data['recommend_cards'];
}else{
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
// 'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'measure_model' => 'require|in:1,2',
// 'identity_id' => 'require',
// 'identity_name' => 'require',
// 'address' => 'require',
];
$msg = [
'aan_id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
// 'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'measure_model.require' => '测量模式缺失',
// 'identity_id.require' => '身份缺失',
// 'identity_name.require' => '身份缺失',
// 'address.require' => '区域缺失',
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母和数字',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'measure_model.number' => '测量模式错误',
'measure_model.in' => '测量模式信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['aan_id'] = $data['aan_id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
$parameter['card_order'] = '2';
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$parameter['measure_model'] = $data['measure_model'];
$parameter['grade'] = "nothing";
$parameter['identity_id'] = "P0";
$parameter['identity_name'] = "陌生人";
$parameter['address'] = '';
$parameter_pd = Db::table($this->index_use_db_name['7'])->where(['id'=>$parameter['aan_id']])->count();
if($parameter_pd <= 0){
return '该账户不存在';
}
$result = Db::table($this->index_use_db_name['2'])->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
if($result>0){
return '该成员已存在';
}
}
$address_data = Db::table($this->index_use_db_name['10'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
$parameter['card_order'] = $address_data['recommend_cards'];
return $parameter;
}
public function verify_parameters2($data,$type){
// 设置验证
$rule = [
'id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'identity_id' => 'require',
'identity_name' => 'require',
'address' => 'require',
];
$msg = [
'id.require' => '用户信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'identity_id.require' => '身份缺失',
'identity_name.require' => '身份缺失',
'address.require' => '区域缺失',
'id.number' => '用户信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母、数字',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
// 'identity.number' => '身份信息格式错误',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['id'] = $data['id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['gender'] = $data['gender'];
$parameter['grade'] = $data['grade'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['identity_id'] = $data['identity_id'];
$parameter['identity_name'] = $data['identity_name'];
$parameter['address'] = $data['address'];
// $parameter['identity_data'] = $data['identity'];
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$aan_id = $data['aan_id'];
if(!array_key_exists($parameter['identity_id'],$this->identity_list)){
return '身份信息错误';
}else{
if($parameter['identity_id'] != 'P0'){
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
$result = Db::table($this->index_use_db_name['2'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$aan_id,'is_del'=>0])->field('id,identity_id')->find();
if($result && $parameter['id'] != $result['id']){
return '该身份已存在';
if($data['measure_model'] == 1){
$rule = [
'id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'measure_model' => 'require|in:1,2',
'identity_id' => 'require',
'identity_name' => 'require',
'address' => 'require',
];
$msg = [
'id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'measure_model.require' => '测量模式缺失',
'identity_id.require' => '身份缺失',
'identity_name.require' => '身份缺失',
'address.require' => '区域缺失',
'id.number' => '账号信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母和数字',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'measure_model.number' => '测量模式错误',
'measure_model.in' => '测量模式信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['id'] = $data['id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
$parameter['card_order'] = '2';
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$parameter['measure_model'] = $data['measure_model'];
$parameter['grade'] = $data['grade'];
$parameter['identity_id'] = $data['identity_id'];
$parameter['identity_name'] = $data['identity_name'];
$parameter['address'] = $data['address'];
$aan_id = $data['aan_id'];
if(!array_key_exists($parameter['identity_id'],$this->identity_list)){
return '身份信息错误';
}else{
if($parameter['identity_id'] != 'P0'){
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
$result = Db::table($this->index_use_db_name['2'])
// ->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$aan_id,'is_del'=>0])
->where("identity_id = '".$parameter['identity_id']."' and aan_id = '".$aan_id."' and is_del = 0 and id <> ".$parameter['id']."")
->field('id,identity_id')
->find();
if($result && $parameter['id'] != $result['id']){
return '该身份已存在';
}
}
}
}
if($data['address'] != ''){
$address_data = explode(',', $data['address']);
$card_result = Db::table($this->index_use_db_name['10'])->where(['province'=>$address_data[0],'is_del'=>0])->field('id,recommend_cards')->find();
$parameter['card_order'] = $card_result['recommend_cards'];
$address_data = Db::table($this->index_use_db_name['10'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
$parameter['card_order'] = $address_data['recommend_cards'];
}else{
$parameter['card_order'] = '2';
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlphaNum',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
// 'grade' => 'require',
'height' => 'require|number',
'weight' => 'require|number',
'measure_model' => 'require|in:1,2',
// 'identity_id' => 'require',
// 'identity_name' => 'require',
// 'address' => 'require',
];
$msg = [
'aan_id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
// 'grade.require' => '年级缺失',
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
'measure_model.require' => '测量模式缺失',
// 'identity_id.require' => '身份缺失',
// 'identity_name.require' => '身份缺失',
// 'address.require' => '区域缺失',
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母和数字',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
'measure_model.number' => '测量模式错误',
'measure_model.in' => '测量模式信息错误',
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['id'] = $data['id'];
$parameter['aan_id'] = $data['aan_id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
// $parameter['card_order'] = '2';
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
$parameter['measure_model'] = $data['measure_model'];
$parameter_pd = Db::table($this->index_use_db_name['7'])->where(['id'=>$parameter['aan_id']])->count();
if($parameter_pd <= 0){
return '该账户不存在';
}
$result = Db::table($this->index_use_db_name['2'])
// ->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])
->where("nickname = '".$parameter['nickname']."' and aan_id = '".$parameter['aan_id']."' and is_del = 0 and id <> ".$parameter['id']."")
->count();
if($result>0){
return '该成员已存在';
}
unset($parameter['aan_id']);
}
return $parameter;
}

View File

@ -0,0 +1,460 @@
<?php
namespace app\app\controller;
use think\Db;
class Msginformation extends Base{
protected $msginformation_use_db_name = [
'1'=>'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 get_sector_label_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->get_sector_label_msg_action($data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $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 get_sector_content_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5','sector_id'=>1,'type'=>0,'page'=>1]){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data) || !array_key_exists('sector_id', $data) || !array_key_exists('type', $data) || !array_key_exists('page', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['sector_id'],'intnum')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['type'],'intnum')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['page'],'intnum')){
return $this->msg(10005);
}
$return_data = $this->get_sector_content_msg_action($data);
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 资讯点赞
public function user_like_it($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','id'=>'44']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['id'],'intnum')){
return $this->msg(10005);
}
$return_data = $this->user_like_it_action($data);
// 成功
$this->record_api_log($data, null, $return_data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 获取公告文章信息列表&banner
public function get_recommend_information($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
// try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$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);
// }
}
// 获取商务合作链接
public function get_business_cooperation_url(){
try {
$business_cooperation_data = Db::table($this->msginformation_use_db_name['4'])->where(['is_del'=>0])->field('title,data_url as url')->select();
$this->record_api_log([], null, $business_cooperation_data);
return $this->msg($business_cooperation_data);
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log([], $logContent, null);
return $this->msg(99999);
}
}
// 删除掉所有已经读过的文章记录
public function del_all_read_log($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$is_ok = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->delete();
if($is_ok){
echo '删除成功';
}else{
echo '删除失败';
}
} 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',
'name'=>'推荐',
'loop_data'=>[],
'list'=>[
['id'=>0,'name'=>'全部'],
['id'=>1,'name'=>'身高管理'],
['id'=>2,'name'=>'体重管理'],
['id'=>3,'name'=>'肺活训练'],
['id'=>4,'name'=>'跳绳训练'],
['id'=>5,'name'=>'中考体测'],
]
],
];
// 获取需要版块id start
$sector = Db::query("
SELECT
sector
FROM ".$this->msginformation_use_db_name['1']."
group by sector
");
$sector_all = [];
foreach ($sector as $key => $value) {
foreach (explode(',', $value['sector']) as $k => $v) {
if(!in_array($v, $sector_all)){
array_push($sector_all, $v);
}
}
}
// 获取需要版块id end
// 填充进去版块的轮播start
$return_data = [];
foreach ($sector_all as $key => $value) {
$loop_result = Db::query("
SELECT
id,
title,
CONCAT('https://tc.pcxbc.com/', cover_image) AS cover_image
FROM ".$this->msginformation_use_db_name['1']."
WHERE
is_del = 0 AND loop_img > 0 AND sector LIKE '%".$value."%'
ORDER BY
loop_img desc
");
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'];
}
}
$Template_arr[$value]['loop_data'] = $loop_result;
array_push($return_data, $Template_arr[$value]);
}
// 填充进去版块的轮播end
return $this->msg($return_data);
}
################################################################get_sector_content_msg
public function get_sector_content_msg_action($data){
$return_result = [
'page_now'=>$data['page'],
'page_num'=>$this->page_num,
'content_data'=>[]
];
if($data['type'] != 0){
$type_str = " AND type LIKE '%".$data['type']."%'";
}else{
$type_str = "";
}
$content_result = Db::query("
SELECT
id,
title,
create_time,
i_like,
reading,
CONCAT('https://tc.pcxbc.com/', cover_image) AS cover_image,
top_up
FROM ".$this->msginformation_use_db_name['1']."
WHERE
is_del = 0 AND sector LIKE '%".$data['sector_id']."%'".$type_str."
ORDER BY
top_up desc,id
OFFSET
(".$data['page']." - 1) * ".$this->page_num." ROWS
FETCH NEXT
".$this->page_num." ROWS ONLY
");
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'];
}
}
$return_result['content_data'] = $content_result;
$user_like = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->column('aetc_id');
foreach ($return_result['content_data'] as $key => $value) {
if(array_key_exists($value['id'], $user_like)){
$return_result['content_data'][$key]['is_like'] = 1;
}else{
$return_result['content_data'][$key]['is_like'] = 0;
}
}
return $this->msg($return_result);
}
################################################################user_like_it
public function user_like_it_action($data){
$user_like_data = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token'],'aetc_id'=>$data['id']])->find();
if($user_like_data){
// 如果找到有点赞记录
if($user_like_data['is_like'] == 1){
// 如果已经点了
// 启动事务
Db::startTrans();
try{
Db::table($this->msginformation_use_db_name['1'])->where(['id'=>$data['id']])->setDec('i_like');
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_like'=>0,'update_time'=>date('Y-m-d H:i:s')]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>0]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $this->msg(10002);
}
}else{
// 如果之前点过又取消了
// 启动事务
Db::startTrans();
try{
Db::table($this->msginformation_use_db_name['1'])->where(['id'=>$data['id']])->setInc('i_like');
Db::table($this->msginformation_use_db_name['2'])->where(['aetc_id'=>$data['id'],'token'=>$data['token']])->update(['is_like'=>1,'update_time'=>date('Y-m-d H:i:s')]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>1]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $this->msg(10002);
}
}
}else{
// 如果没有记录
// 启动事务
Db::startTrans();
try{
Db::table($this->msginformation_use_db_name['1'])->where(['id'=>$data['id']])->setInc('i_like');
Db::table($this->msginformation_use_db_name['2'])->insert([
'aetc_id'=>$data['id'],
'token'=>$data['token'],
'is_like'=>1,
'create_time'=>date('Y-m-d H:i:s'),
'update_time'=>date('Y-m-d H:i:s')
]);
// 提交事务
Db::commit();
return $this->msg(['user_like'=>1]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $this->msg(10002);
}
}
}
################################################################get_recommend_information
public function get_recommend_information_action($data){
$return_data = [
'pop'=>[],
'notice'=>[],
'banner'=>[]
];
// 所有可用记录
$all_data = Db::table($this->msginformation_use_db_name['3'])->where(['is_del'=>0])->select();
// 用户阅读记录
$user_read_log = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->field('aetc_id')->select();
$user_read_data = [];
// 先过滤一遍用户已经看过的文章记录
foreach ($user_read_log as $key => $value) {
array_push($user_read_data,$value['aetc_id']);
}
// 删掉已经读过的信息
foreach ($all_data as $key => $value) {
if($value['type'] == '1'){
if(in_array($value['parameter_data'], $user_read_data)){
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]['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]['type'] = 'h5';
$all_data[$key]['id'] = $value['parameter_data'];
}
}else{
$all_data[$key]['type'] = 'wechat';
// 提取查询字符串部分(?后面的部分)
$queryString = substr($all_data[$key]['jump_url'], strpos($all_data[$key]['jump_url'], '?') + 1);
// 使用parse_str解析查询字符串
$params = [];
parse_str($queryString, $params);
// 提取appid和path的值
$appid = isset($params['appid']) ? $params['appid'] : null;
$path = isset($params['path']) ? $params['path'] : null;
$all_data[$key]['appid'] = $appid;
$all_data[$key]['path'] = $path;
}
// $all_data[$key]['id'] = $all_data[$key]['parameter_data'];
unset($all_data[$key]['parameter_data']);
unset($all_data[$key]['is_del']);
unset($all_data[$key]['ROW_NUMBER']);
}
// 分类信息
foreach ($all_data as $key => $value) {
// 1:首屏弹窗2滚动公告3banner
if($value['scene_data'] == '1'){
array_push($return_data['pop'],$value);
}else if($value['scene_data'] == '2'){
array_push($return_data['notice'],$value);
}else if($value['scene_data'] == '3'){
array_push($return_data['banner'],$value);
}
}
// 设置pop当中只有一个数据
if(count($return_data['pop'])>0){
$return_data['pop'] = [$return_data['pop'][0]];
}
return $this->msg($return_data);
}
}

View File

@ -4,7 +4,7 @@ namespace app\app\controller;
use think\Db;
use app\testapp\controller\Login;
use app\app\controller\Login;
class Myinformation extends Base{

View File

@ -15,7 +15,7 @@ class Pagingcontrast extends Base{
'4'=>'app_user_data',
];
protected $request_result = [
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
];
@ -70,7 +70,7 @@ class Pagingcontrast extends Base{
}
// 获取记录信息(分页)(包含身体、跳绳、肺活量)
public function get_all_record_data_page($data = ['aud_id'=>'25','page'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){
public function get_all_record_data_page($data = ['aud_id'=>'11','page'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -113,7 +113,7 @@ class Pagingcontrast extends Base{
}
// 获取详细历史数据信息(包含身体、跳绳、肺活量)
public function get_all_record_detailed_information($data = ['id'=>'39','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_all_record_detailed_information($data = ['id'=>'36','type'=>'8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -146,10 +146,9 @@ class Pagingcontrast extends Base{
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 数据对比(包含身体、跳绳、肺活量)
public function get_all_card_data_contrast($data = ['before_id'=>'837','after_id'=>'836','type'=>'6','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_all_card_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -399,10 +398,10 @@ class Pagingcontrast extends Base{
// $time_t = $this->handle_hour_branch_second($value['v2']);
array_push($return_result, [
'id'=>$value['id'],
'v1'=>$value['v1'],
'v2'=>$value['v2'],
'v3'=>$value['v3'],
'v4'=>$value['v4'],
'v1'=>$value['v1'] == '.00'?'0':$value['v1'],
'v2'=>$value['v2'] == '.00'?'0':$value['v2'],
'v3'=>$value['v3'] == '.00'?'0':$value['v3'],
'v4'=>$value['v4'] == '.00'?'0':$value['v4'],
'v5'=>explode(',',$value['v5'])[0],
'v1_name'=>'第一次',
'v2_name'=>'第二次',
@ -424,10 +423,10 @@ class Pagingcontrast extends Base{
// $time_t = $this->handle_hour_branch_second($value['jump_time']);
array_push($return_result['rows'],[
'id'=>$value['id'],
'v1'=>$value['one_val'],
'v2'=>$value['two_val'],
'v3'=>$value['three_val'],
'v4'=>$value['average_val'],
'v1'=>$value['one_val'] == '.00'?'0':$value['one_val'],
'v2'=>$value['two_val'] == '.00'?'0':$value['two_val'],
'v3'=>$value['three_val'] == '.00'?'0':$value['three_val'],
'v4'=>$value['average_val'] == '.00'?'0':$value['average_val'],
'v5'=>explode(',',$value['score'])[0],
'v1_name'=>'第一次',
'v2_name'=>'第二次',
@ -444,24 +443,61 @@ class Pagingcontrast extends Base{
// 获取详细历史数据信息
public function get_all_detaile_data_msg($data){
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
// 设置排除在外的数据类型start
// $exclude_data_arr = ['height','weight','age','bmi','body_level','body_type'];
$exclude_data_arr = ['height','weight','age','bmi'];
// 设置排除在外的数据类型end
$result = Db::table($this->db_name[$data['type']])->where(['id'=>$data['id']])->find();
$for_data_arr = $this->request_result[$data['type']];
if($result){
// if($data['type'] == 2 && $result['record_type'] != 'by_device_adc'){
// $for_data_arr = ['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI','']];
// }
$result_data = [];
foreach ($this->request_result[$data['type']] as $key => $value) {
foreach ($for_data_arr as $key => $value) {
$temporary_arr['key_name'] = $key;
$temporary_arr['name'] = $value[0];
if($data['type'] == 2){
if($key == 'un_fat_w_weight'){
$temporary_arr['value'] = bcsub(explode(',',$result['weight'])[0],explode(',',$result['fat_w'])[0],2);
// 身体数据处理,如果没有阻抗,则只显示四项$exclude_data_arr
if($result['record_type'] != 'by_device_adc'){
if(!in_array($key, $exclude_data_arr)){
continue;
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
if($key == 'un_fat_w_weight'){
$temporary_arr['value'] = bcsub(explode(',',$result['weight'])[0],explode(',',$result['fat_w'])[0],2);
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
}
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
$temporary_arr['unit'] = $value[1];
array_push($result_data,$temporary_arr);
}
//
// 添加头围详细start
if($data['type'] == 2){
if($result['head_circumference'] != null){
array_unshift($result_data,[
'key_name'=>'head_circumference',
'name'=>'头围',
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0":json_decode($result['head_circumference'],true)['value'],
'unit'=>'cm',
]);
}
}
// 添加头围详细end
return $this->msg($result_data);
}else{
return $this->msg(10004);
@ -493,6 +529,8 @@ class Pagingcontrast extends Base{
acbd.visceral,
acbd.sfr,
acbd.record_time,
acbd.record_type,
acbd.head_circumference,
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
aud.nickname,
aud.gender,
@ -503,6 +541,7 @@ class Pagingcontrast extends Base{
where acbd.id in ($data3)
and acbd.is_del = 0
");
if(!$result || count($result)<2){
return $this->msg(10004);
}
@ -514,21 +553,71 @@ class Pagingcontrast extends Base{
$calculate_arr['after'] = $value;
}
}
$return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
$return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time'];
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
$return_data['name'] = $calculate_arr['before']['nickname'];
$return_data['gender'] = $calculate_arr['before']['gender'];
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
$return_data['list'] = [];
// 处理如果没有阻抗的数据为0显示异常start;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
if($calculate_arr['before']['record_type'] != 'by_device_adc' && $calculate_arr['after']['record_type'] != 'by_device_adc'){
foreach ($calculate_arr['before'] as $key => $value) {
if(!in_array($key, ['height','weight','bmi','head_circumference'])){
unset($calculate_arr['before'][$key]);
unset($calculate_arr['after'][$key]);
}
}
if($return_data['age']>=3){
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}else{
$calculate_arr['before']['head_circumference'] = json_decode($calculate_arr['before']['head_circumference'],true);
$calculate_arr['after']['head_circumference'] = json_decode($calculate_arr['after']['head_circumference'],true);
foreach ($calculate_arr as $key => $value) {
if(array_key_exists('value',$value['head_circumference'])){
$calculate_arr[$key]['head'][0] = $value['head_circumference']['value'];
}else{
$calculate_arr[$key]['head'][0] = 0;
}
if(array_key_exists('level',$value['head_circumference'])){
$calculate_arr[$key]['head'][1] = $value['head_circumference']['level'];
}else{
$calculate_arr[$key]['head'][1] = '异常';
}
if(array_key_exists('color',$value['head_circumference'])){
$calculate_arr[$key]['head'][2] = $value['head_circumference']['color'];
}else{
$calculate_arr[$key]['head'][2] = '';
}
$calculate_arr[$key]['head'] = implode(',',$calculate_arr[$key]['head']);
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}
}
}else{
foreach ($calculate_arr as $key => $value) {
if($value['record_type'] != 'by_device_adc'){
$calculate_arr[$key]['fat_r'] = "0,异常";
$calculate_arr[$key]['fat_w'] = "0,异常";
$calculate_arr[$key]['muscle'] = "0,异常";
$calculate_arr[$key]['muscleval'] = "0,异常";
$calculate_arr[$key]['water'] = "0,异常";
$calculate_arr[$key]['proteinval'] = "0,异常";
$calculate_arr[$key]['bone'] = "0,异常";
$calculate_arr[$key]['protein'] = "0,异常";
$calculate_arr[$key]['kcal'] = "0,异常";
$calculate_arr[$key]['visceral'] = "0,异常";
$calculate_arr[$key]['sfr'] = "0,异常";
}
}
}
// 处理如果没有阻抗的数据为0显示异常end同步处理如果两个对比数据都没有阻抗数据则只显示基础信息
foreach ($calculate_arr['before'] as $key => $value) {
if(in_array($key, ['height','weight','bmi','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
if(in_array($key, ['height','weight','bmi','head','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
$before_arr = explode(',', $value);
$after_arr = explode(',', $calculate_arr['after'][$key]);
// $calculate_arr['before'][$key] = explode(',', $value);
array_push($return_data['list'], [
'firstresult'=>[
'color'=>'',
@ -550,6 +639,12 @@ class Pagingcontrast extends Base{
]);
}
}
// 添加头围数据如果需要的话start
// if($calculate_arr['before']['head_circumference'] != null || $calculate_arr['after']['head_circumference'] != null){
// }
// 添加头围数据如果需要的话end
return $this->msg($return_data);
}
// 数据对比

View File

@ -36,6 +36,304 @@ class Sportstesting extends Base{
'4'=>'分钟秒钟例1000米跑',
];
protected $ceshiyongde_data_baocun_canshu = '{
"code": 0,
"msg": "操作成功",
"data": [
{
"name": "现场考试",
"key": "现场考试",
"list": [
{
"name": "第一类项目(3选1)",
"key": "第一类项目",
"is_choice": "1",
"list": [
{
"name": "1000米跑",
"proportion": "1",
"value": "4:23",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 1
},
{
"name": "200米游泳",
"proportion": "1",
"value": "6:12",
"proportion_value": null,
"unit": "分/秒",
"type": "4",
"describe": null,
"total_score": 6,
"choice_state": 0
},
{
"name": "4分钟跳绳",
"proportion": "1",
"value": 340,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 6,
"choice_state": 0
}
]
},
{
"name": "第二类项目(5选1)",
"key": "第二类项目",
"is_choice": "1",
"list": [
{
"name": "50米跑",
"proportion": "1",
"value": 8.1,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "立定跳远",
"proportion": "1",
"value": 2.02,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "实心球",
"proportion": "1",
"value": 7.3,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "引体向上",
"proportion": "1",
"value": 6,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "25米游泳",
"proportion": "1",
"value": 30,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第三类项目(5选1)",
"key": "第三类项目",
"is_choice": "1",
"list": [
{
"name": "乒乓球",
"proportion": "1",
"value": 15,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "羽毛球",
"proportion": "1",
"value": 60,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "网球",
"proportion": "1",
"value": 55,
"proportion_value": null,
"unit": "得分",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "武术",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "体操",
"proportion": "1",
"value": "6",
"proportion_value": null,
"unit": "得分",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
},
{
"name": "第四类项目(3选1)",
"key": "第四类项目",
"is_choice": "1",
"list": [
{
"name": "足球运球",
"proportion": "1",
"value": 15.5,
"proportion_value": null,
"unit": "",
"type": "2",
"describe": null,
"total_score": 3,
"choice_state": 1
},
{
"name": "篮球",
"proportion": "1",
"value": 31,
"proportion_value": null,
"unit": "",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
},
{
"name": "排球",
"proportion": "1",
"value": 23,
"proportion_value": null,
"unit": "40秒/次",
"type": "1",
"describe": null,
"total_score": 3,
"choice_state": 0
}
]
}
]
},
{
"name": "日常考核",
"key": "日常考核",
"list": [
{
"name": "体育与健身",
"key": "体育与健身",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "2"
}
]
},
{
"name": "体质健康综合评定",
"key": "体质健康综合评定",
"is_choice": "0",
"list": [
{
"name": "7年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "8年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
},
{
"name": "9年级",
"proportion": "1",
"value": "60",
"proportion_value": null,
"unit": "",
"type": "1",
"describe": "满分100分",
"total_score": "3"
}
]
}
]
}
]
}';
// 加 bcadd(,,20)
// 减 bcsub(,,20)
@ -82,14 +380,14 @@ class Sportstesting extends Base{
}
// 获取地区类型列表
public function sportstesting_get_region_list($data = ['parameter_data'=>'河北,石家庄市','gender'=>'0']){
public function sportstesting_get_region_list($data = ['parameter_data'=>'上海,上海','gender'=>'1','aud_id'=>'83','choice_last_time'=>'0']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data)){
$return_data = $this->msg(10001);
if(!array_key_exists('gender', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('choice_last_time', $data) || !array_key_exists('aud_id', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['parameter_data'],'str')){
return $this->msg(10005);
@ -97,6 +395,13 @@ class Sportstesting extends Base{
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005);
}
if(!$this->verify_data_is_ok($data['choice_last_time'],'intnum')){
return $this->msg(10005);
}else{
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
return $this->msg(10005);
}
}
$return_data = $this->sportstesting_get_region_list_action($data);
// 成功
@ -152,13 +457,14 @@ class Sportstesting extends Base{
}
// 计算并存储数据
public function sportstesting_set_once_data($data = ['aud_id'=>'83','parameter_data'=>'辽宁,沈阳市','result_data'=>'','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function sportstesting_set_once_data($data = ['aud_id'=>'83','parameter_data'=>'上海,上海','result_data'=>'','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
$data = input('post.');
}
// $data['result_data'] = json_decode($this->ceshiyongde_data_baocun_canshu,true)['data'];
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('result_data', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
$return_data = $this->msg(10001);
}
@ -191,6 +497,7 @@ class Sportstesting extends Base{
}else{
return $this->msg(10006);
}
// die;
unset($data['token']);
$return_data = $this->sportstesting_set_once_data_action2($data);
@ -251,7 +558,7 @@ class Sportstesting extends Base{
}
// 获取估分历史详情
public function sportstesting_get_one_details($data = ['id'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function sportstesting_get_one_details($data = ['id'=>'38','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -364,26 +671,32 @@ class Sportstesting extends Base{
// 全省地市一个规则start
$db_condition = "province = '".$parameter_data[0]."'";
// 全省地市一个规则end
$result['list'] = [];
$result['total_score'] = 0;
$data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->select();
if(count($data) > 0){
if(count($data) > 1){
// 查到不止一条规则
return $this->msg(10004,'查询地址不够详细,请重新选择省市地区');
$result = false;
if($data['choice_last_time'] == 1){
$last_tiame_data = Db::table($this->sportstesting_use_db_name['2'])->where(['aud_id'=>$data['aud_id'],'address'=>$data['parameter_data']])->order('id desc')->find();
if($last_tiame_data){
$result = json_decode($last_tiame_data['content'],true);
}else{
$result = false;
}
$data = json_decode($data[0]['content'],true);
$result = $this->handle_default_rule_list($data,$gender);
// die;
return $this->msg($result);
}else{
return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区');
}
if($result === false){
$rule_data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->select();
if(count($rule_data) > 0){
if(count($rule_data) > 1){
// 查到不止一条规则
return $this->msg(10004,'查询地址不够详细,请重新选择省市地区');
}
$rule_data = json_decode($rule_data[0]['content'],true);
$result = $this->handle_default_rule_list($rule_data,$gender);
}else{
return $this->msg(10004,'暂无该地区的估分规则,请选择其它地区');
}
}
return $this->msg($result);
}
################################################sportstesting_get_last_data
public function sportstesting_get_last_data_action($data){
@ -448,13 +761,17 @@ class Sportstesting extends Base{
################################################sportstesting_get_one_details
public function sportstesting_get_one_details_action($data){
$user_data = Db::table($this->sportstesting_use_db_name['2'])->where(['id'=>$data['id']])->find();
if($user_data){
$temporary_data['list'] = json_decode($user_data['content'],true);
// 压入表头
foreach ($temporary_data['list'] as $key => $value) {
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
unset($temporary_data['list'][$key]['list'][$v1k]['list'][$i]);
}
}
array_unshift($temporary_data['list'][$key]['list'][$v1k]['list'],[
'name'=>'项目名',
'value'=>'成绩',
@ -496,6 +813,7 @@ class Sportstesting extends Base{
$find_data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->find();
$find_data = json_decode($find_data['content'],true);
$recognition_rule = $find_data[$gender];
foreach ($data['result_data'] as $key => $value) {
// 遍历一级($value['key'] = 现场考试)
foreach ($value['list'] as $k2 => $v2) {
@ -505,11 +823,39 @@ class Sportstesting extends Base{
$temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
$data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
if(array_key_exists('choice_state',$v3) && $v3['choice_state'] == 0){
continue;
}
$return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
$return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// if(array_key_exists('choice_state',$v3)){
// if($v3['choice_state'] == 1){
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }else{
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
// }else{
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
// $return_result['total_score'] = bcadd($return_result['total_score'],$temporary_result['proportion_value'],2);
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
}
}
}
$return_result['list'] = $data['result_data'];
$user_sportstesting_set = Db::table($this->sportstesting_use_db_name['2'])->insert([
'aud_id'=>$data['aud_id'],
@ -519,10 +865,17 @@ class Sportstesting extends Base{
'create_time'=>date('Y-m-d H:i:s'),
'address'=>$data['parameter_data'],
]);
// $user_sportstesting_set = true;
if($user_sportstesting_set){
foreach ($return_result['list'] as $key => $value) {
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
unset($return_result['list'][$key]['list'][$v1k]['list'][$i]);
}
}
array_unshift($return_result['list'][$key]['list'][$v1k]['list'],[
'name'=>'项目名',
'value'=>'成绩',
@ -631,13 +984,14 @@ class Sportstesting extends Base{
$temporary_arr = $data[2];
}
// die;
$result = [];
foreach ($temporary_arr as $key => $value) {
$num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]);
foreach ($value as $s_c_k => $s_c_v) {
if($s_c_v['choose_num'] == 0){
// 如果是必选项
$num2 = array_push($result[$num-1]['list'],[
'name'=>$s_c_k,
'key'=>$s_c_k,
@ -657,7 +1011,28 @@ class Sportstesting extends Base{
]);
}
}else{
$num2 = array_push($result[$num-1]['list'],['name'=>$s_c_k,'key'=>$s_c_k,'is_choice'=>$s_c_v['choose_num'],'list'=>[]]);
// 如果不是必选项
$num2 = array_push($result[$num-1]['list'],[
'name'=>$s_c_k."(".count($s_c_v['list'])."".$s_c_v['choose_num'].")",
'key'=>$s_c_k,
'is_choice'=>$s_c_v['choose_num'],
'list'=>[]
]);
$choice_state_num = $s_c_v['choose_num'];
foreach ($s_c_v['list'] as $x_m_k => $x_m_v) {
array_push($result[$num-1]['list'][$num2-1]['list'],[
'name'=>$x_m_k,
'proportion'=>$x_m_v['proportion'],
'value'=>$x_m_v['value'],
'proportion_value'=>null,
'unit'=>$x_m_v['unit_data'],
'type'=>$x_m_v['type'],
'describe'=>$x_m_v['describe'],
'total_score'=>$x_m_v['score'],
'choice_state'=>$choice_state_num > 0?1:0,
]);
$choice_state_num = $choice_state_num-1;
}
}
}
}

View File

@ -39,7 +39,7 @@ class Vitalcapacity extends Base{
################################################################接口################################################################
// 手动数据记录
public function vitalcapacity_save_record_data($data = ['aud_id'=>'83','one'=>'1523','two'=>'1825','three'=>'1896','time'=>'2024-07-23','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function vitalcapacity_save_record_data($data = ['aud_id'=>'11','one'=>'4900','two'=>'5100','three'=>'5300','time'=>'2024-11-14','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -107,7 +107,7 @@ class Vitalcapacity extends Base{
}
// 数据报告
public function vitalcapacity_data_report($data = ['aud_id'=>'61','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function vitalcapacity_data_report($data = ['aud_id'=>'83','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -185,34 +185,60 @@ class Vitalcapacity extends Base{
$temporary_arr['three_val'] = $data['three'];
$temporary_arr['average_val'] = $temporary_arr['average'];
$temporary_arr['flow_val'] = array_key_exists('flow', $data)?$data['flow']:'0.00';
// die;
// 处理记录时间
if(strlen($temporary_arr['record_time']) <= 12){
$temporary_arr['record_time'] = $this->addCurrentTimeToDateString($temporary_arr['record_time']);
}
$user_msg = Db::name($this->vitalcapacity_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('grade,gender')->find();
$user_msg = Db::name($this->vitalcapacity_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,grade,gender,birthday')->find();
// die;
if($user_msg){
// 根据性别&年级&年龄查规则
if($user_msg['grade'] != 'nothing'){
// 有年级项
// 等级项(及格优秀良好等)
$achievement_judge_data = $this->vitalcapacity_achievement_judge(['average'=>$temporary_arr['average'],'grade'=>$user_msg['grade'],'gender'=>$user_msg['gender']]);
$temporary_arr['score'] = $achievement_judge_data['score'].','.$achievement_judge_data['level'].','.$this->color[$achievement_judge_data['level']];
$temporary_arr['score_val'] = $achievement_judge_data['score'];
// 获取肺活量标准
}else{
$achievement_judge_data['level'] = "";
$temporary_arr['score'] = "0,无,无";
$temporary_arr['score_val'] = "0";
if($user_msg['grade'] == 'nothing'){
// 计算年龄判断是属于哪个年级
$user_age = $this->calculate_age($user_msg['birthday']);
if($user_age <= 7){
$user_msg['grade'] = 'grade_s_1';
}else if($user_age == 8){
$user_msg['grade'] = 'grade_s_2';
}else if($user_age == 9){
$user_msg['grade'] = 'grade_s_3';
}else if($user_age == 10){
$user_msg['grade'] = 'grade_s_4';
}else if($user_age == 11){
$user_msg['grade'] = 'grade_s_5';
}else if($user_age == 12){
$user_msg['grade'] = 'grade_s_6';
}else if($user_age == 13){
$user_msg['grade'] = 'grade_m_1';
}else if($user_age == 14){
$user_msg['grade'] = 'grade_m_2';
}else if($user_age == 15){
$user_msg['grade'] = 'grade_m_3';
}else if($user_age == 16){
$user_msg['grade'] = 'grade_h_1';
}else if($user_age == 17){
$user_msg['grade'] = 'grade_h_2';
}else if($user_age == 18){
$user_msg['grade'] = 'grade_h_3';
}else if($user_age == 19 || $user_age == 20){
$user_msg['grade'] = 'grade_u_12';
}else if($user_age >= 21){
$user_msg['grade'] = 'grade_u_34';
}
}
$sql_str = "sex = ".$user_msg['gender']." and ".$user_msg['grade']." <= ".$temporary_arr['average_val'];
$user_achievement = Db::name($this->vitalcapacity_use_db_name['3'])->where($sql_str)->order($user_msg['grade'] .' desc')->field('level,score,'.$user_msg['grade'])->limit(1)->select();
if(count($user_achievement)<=0){
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
}
$temporary_arr['score'] = $user_achievement[0]['score'].','.$user_achievement[0]['level'].','.$this->color[$user_achievement[0]['level']];
$temporary_arr['score_val'] = $user_achievement[0]['score'];
}else{
return $this->msg(10004);
}
$standard_data = $this->get_vitalcapacity_data($data['aud_id']);
$temporary_arr['standard_data'] = json_encode($standard_data);
$result = Db::table($this->vitalcapacity_use_db_name['2'])->insert($temporary_arr);
@ -223,7 +249,7 @@ class Vitalcapacity extends Base{
$time = date('Y年m月d日 H:i:s', $time);
return $this->msg([
'average'=>$temporary_arr['average'].'ml',
'level'=>$achievement_judge_data['level'],
'level'=>$user_achievement[0]['level'],
'time'=>$time,
'flow_val'=>$temporary_arr['flow_val'],
'list'=>$standard_data,
@ -354,16 +380,6 @@ class Vitalcapacity extends Base{
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
// 肺活量成绩判断
public function vitalcapacity_achievement_judge($data){
$str = "sex = ".$data['gender']." and ".$data['grade']." <= ".$data['average'];
$user_achievement = Db::name($this->vitalcapacity_use_db_name['3'])->where($str)->order($data['grade'] .' desc')->field('level,score,'.$data['grade'])->limit(1)->select();
if(count($user_achievement)<=0){
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
}
return $user_achievement[0];
}
// 肺活量判断区间
public function vitalcapacity_standard_interval($val,$data){
// 缓存一周
@ -385,9 +401,15 @@ class Vitalcapacity extends Base{
}
$num = count($temporary_qj)-1-$num;
$temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
$result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
if($max == 0){
if($val >= $temporary_qj[0]['max_val']){
$result = 100;
}
}else{
$temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
$result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
}
return $result;
}
// 肺活量判断区间(根据得分)

View File

@ -0,0 +1,47 @@
<?php
namespace app\app\controller;
use think\Db;
class Wechatabout extends Base{
protected $msginformation_use_db_name = [
'1'=>'admin_editor_text_content',
'2'=>'admin_editor_text_like_up_log',
];
protected $page_num = 10;
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
// 获取板块,及板块下类型标签
public function get_access_token_action(){
try {
$return_data = $this->get_sector_label_msg_action();
return $return_data;
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log([], $logContent, null);
return $this->msg(99999);
}
}
}

View File

@ -44,30 +44,21 @@
font-size: 4vw;
}
.download{
width: 55vw;
height: 11vw;
background-color: #FFA940;
border-radius: 5.5vw;
text-align: center;
line-height: 11vw;
font-weight: bold;
text-decoration: none;
color: white;
margin-top: 10vw;
width: 60vw;
height: 12vw;
background: url('/download_img/download.png') no-repeat;
background-size: contain;
}
img{
width: 25vw;
width: 55vw;
}
.jump{
width: 55vw;
height: 11vw;
color: white;
background-color: #389E0D;
border-radius: 5.5vw;
text-align: center;
line-height: 11vw;
font-weight: bold;
width: 60vw;
height: 12vw;
margin-bottom: 10vw;
margin-top: 12vw;
background: url('/download_img/open_wechat_app.png') no-repeat;
background-size: contain;
}
.ts{
width: 100vw;
@ -107,18 +98,53 @@
text-decoration: none;
color: blue;
}
.bouncing-button-container {
transform-origin: center bottom; /* 设置旋转的基点在底部中心 */
animation: rotateAndRaise 2s ease-in-out forwards infinite;
}
@keyframes rotateAndRaise {
0% {
transform: rotate(0deg) translateY(0); /* 初始状态,不旋转也不升高 */
}
10% {
transform: rotate(5deg); /* 初始状态,不旋转也不升高 */
}
20% {
transform: rotate(0deg) translateY(-50px); /* 50%时旋转15°并升高50px */
}
30% {
transform: rotate(-5deg); /* 初始状态,不旋转也不升高 */
}
40% {
transform: rotate(0deg) translateY(0px); /* 结束状态往右旋转30°并升高50px */
}
100% {
transform: rotate(0deg) translateY(0px); /* 结束状态往右旋转30°并升高50px */
}
}
.bottom_d{
width: 100vw;
height: 65vw;
position: absolute;
bottom: 0;
left: 0;
background: url('/download_img/bottom.png') no-repeat;
background-position: bottom;
background-size: contain;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="content_1">
<img src="http://tc.pcxbc.com/tsf/logo.png" alt="">
<div style="font-size: 6vw;
font-weight: bold;
margin-bottom: 20vw;margin-top: 3vw;">reedaw</div>
<div class="jump" onclick="jump()">打开微信小程序</div>
<div class="download" onclick="download()">下载APP</div>
<img src="/download_img/title.png" alt="">
<div class="jump" onclick="jump()"></div>
<div class="download" onclick="download()"></div>
<div class="bottom_d"></div>
<!-- <a href="javascript:;">已安装? 打开Reedaw&nbsp;></a> -->
</div>
</div>
@ -135,7 +161,7 @@
<script>
var str_url = "{$url}";
function isWeixin() {
var ua = navigator.userAgent.toLowerCase();
var ua = navigator.userAgent.toLowerCase();
return /micromessenger/i.test(ua);
}
function isIOS() {
@ -144,29 +170,37 @@
}
function jump(){
window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
// window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
window.location.href = 'weixin://dl/business/?appid=wx9c0b7a436ada6d1e&path=pages/home/home';
}
$('.ts').on('click',function(){
$(this).hide()
})
// if(isWeixin() && !isIOS()){
// $('.ts').show()
// }else{
// // console.log('当前不在微信环境中');
// // $('.download').addClass('bouncing-button-container')
// }
function download(){
if (isWeixin()) {
console.log('当前在微信环境中');
$('.ts').show()
} else {
console.log('当前不在微信环境中');
if (isIOS()) {
console.log('当前是iOS设备');
// 在这里执行iOS设备下的特定代码
window.location.href = "https://apps.apple.com/app/reedaw/id6654906497";
} else {
if (isIOS()) {
console.log('当前是iOS设备');
window.location.href = "https://apps.apple.com/app/reedaw/id6654906497";
}else{
if (isWeixin()) {
console.log('当前在微信环境中');
$('.ts').show()
}else{
console.log('当前不是iOS设备');
// 在这里执行非iOS设备下的代码
window.location.href = str_url;
}
}
}
</script>

View File

@ -103,9 +103,16 @@ Route::any('/notice/information_msg_list', 'admin/notice/information_msg_list');
Route::any('/notice/banner_index', 'admin/notice/banner_index');
Route::any('/notice/banner_add', 'admin/notice/banner_add');
Route::any('/notice/banner_edit', 'admin/notice/banner_edit');
Route::any('/notice/banner_add_or_update_action', 'admin/notice/banner_add_or_update_action');
Route::any('/notice/banner_update_sort', 'admin/notice/banner_update_sort');
Route::any('/notice/banner_stop_run', 'admin/notice/banner_stop_run');
// 首页弹窗管理
Route::any('/notice/pop_index', 'admin/notice/pop_index');
Route::any('/notice/pop_add', 'admin/notice/pop_add');
Route::any('/notice/pop_edit', 'admin/notice/pop_edit');
Route::any('/notice/pop_add_or_update_action', 'admin/notice/pop_add_or_update_action');
Route::any('/notice/pop_update_sort', 'admin/notice/pop_update_sort');
Route::any('/notice/pop_stop_run', 'admin/notice/pop_stop_run');
// 公告管理
@ -357,7 +364,7 @@ Route::any('/testedition/user_like_it', 'testapp/Msginformation/user_like_it');
Route::any('/get_recommend_information', 'app/Msginformation/get_recommend_information');
Route::any('/testedition/get_recommend_information', 'testapp/Msginformation/get_recommend_information');
// 获取商务合作链接
// Route::any('/get_business_cooperation_url', 'app/Msginformation/get_business_cooperation_url');
Route::any('/get_business_cooperation_url', 'app/Msginformation/get_business_cooperation_url');
Route::any('/testedition/get_business_cooperation_url', 'testapp/Msginformation/get_business_cooperation_url');

View File

@ -612,6 +612,79 @@ class Base extends Controller{
}
// 处理身高体重的单位转换它们为cm和kg。
function convertHeightAndWeight($height, $weight) {
// 定义单位转换比例
$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]);
$heightUnit = $matches[2];
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 = floatval($matches[1]);
$weightUnit = $matches[2];
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' => $heightInCm,
'weight_in_kg' => $weightInKg
];
}
public function ceshiyong($aa = 4,$gd = 0.2){

View File

@ -56,8 +56,6 @@ class Calculatebody extends Base{
// $result['lbm'] = bcmul(bcsub('1',bcdiv($result['fat_r'],'100',20),20),$data['weight'],2);
// 青测自己写的计算end
// dump($data);
// die;
// 使用接口调用之前的进行计算start
$url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3';
if($data['age'] < '3'){
@ -80,17 +78,10 @@ class Calculatebody extends Base{
'gender'=>$data['gender'],
];
}
// dump($temporary_parameter);
$request_result = $this->postRequest($url,$temporary_parameter);
if($request_result['code'] != 0){
return false;
}
// return $this->msg($request_result);
// dump($request_result);
// foreach ($request_result['data']['standardlist'] as $key => $value) {
// dump($value['name']);
// }
// die;
$result['weight'] = $request_result['data']['weight'];
$result['height'] = $request_result['data']['height'];

View File

@ -163,7 +163,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($data = ['aud_id'=>'37','time'=>'2024-10-12','height'=>'144.7,cm','weight'=>'36.8,kg','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_manual_recording($data = ['aud_id'=>'37','time'=>'2024-10-12','height'=>'144.7','weight'=>'36.8','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function card_manual_recording($data = ['aud_id'=>'38','time'=>'2024-10-12','height'=>'88.5','weight'=>'10','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -181,12 +181,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);
@ -207,6 +216,8 @@ class Card extends Base{
// if(!in_array($data['weight'][1],$this->unit_data['weight'])){
// return $this->msg(10005);
// }
// $data['head_data'] = '48';
$data['acd_id'] = '2';
$return_data = $this->set_user_body_data($data,'by_hand_means');
// 成功
@ -230,7 +241,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){
@ -244,12 +255,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);
@ -270,9 +294,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');
@ -565,7 +587,10 @@ class Card extends Base{
// 存储头围数据
$head_circumference = $result[0]['head_circumference']?json_decode($result[0]['head_circumference'],true):false;
unset($result[0]['head_circumference']);
// 处理返回数据
$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'];
@ -625,8 +650,7 @@ class Card extends Base{
}
// 加入曲线板块底部的减肥计划数据end
// 添加头围数据如果有的话start
if($head_circumference !== false){
if($head_circumference !== false && $this->calculate_age($result[0]['birthday']) < 3){
if($head_circumference['level'] == '异常' || $head_circumference['value'] == 0){
$offset = 0;
}else{
@ -876,10 +900,11 @@ class Card extends Base{
// $data['type'] = 1;
// 判断头围数据是否存在是否合理
if(array_key_exists('head_circumference', $data)){
if(!$this->verify_data_is_ok($data['head_circumference'],'num')){
if(array_key_exists('head_data', $data)){
if(!$this->verify_data_is_ok($data['head_data'],'num')){
return $this->msg(10005);
}
$data['head_circumference'] = $data['head_data'];
}else{
$data['head_circumference'] = 0;
}
@ -889,7 +914,6 @@ class Card extends Base{
if(!$user_data){
return $this->msg(10003);
}
// dump($data['aud_id']);
// 如果最初体重设置为null
if($user_data['initial_date'] == null){
Db::table($this->card_use_db_name['2'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
@ -927,6 +951,7 @@ class Card extends Base{
// 计算身体数据
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
if($get_body_value === false){
return $this->msg(10005);
}
@ -963,7 +988,6 @@ class Card extends Base{
$get_body_value['birthday'] = $user_data['birthday'];
// 添加身高、体重、bmi、头围如果有的标尺标准
$get_body_value = $this->hwb_standard($get_body_value);
$set_data = [
'acd_id'=>$data['acd_id'],
'aud_id'=>$data['aud_id'],
@ -1079,20 +1103,23 @@ class Card extends Base{
}
}
}
foreach ($linshi_data as $key => $value) {
foreach ($value as $k => $v) {
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
// 如果落在区间内
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
break;
}
}
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
// 如果$key.'2'没有被设置
if(!array_key_exists($key.'2', $data)){
if($data[$key] < $value[0]['min_val']){
// 如果小于最小值
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
}else if($data[$key] >= $value[count($value)-1]['max_val']){
// 如果大于最大值
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
}
}
}
// die;

View File

@ -213,11 +213,11 @@ class Cardparts extends Base{
}
// 处理顶部list
foreach ($temporary_arr['top_list'] as $key => $value) {
if(count($temporary_arr['top_list'][$key]['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($temporary_arr['top_list'][$key]['list'],$temporary_arr['top_list'][$key]['value'],$temporary_arr['top_list'][$key]['standard']);
if(count($value['list']) > 0){
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']);
}
}
// 如果是没有阻抗的测试,那么就不要底部的其他数据了
if($data['record_type']['value'] != 'by_device_adc'){
$temporary_arr['bottom_list'] = [];
@ -358,10 +358,13 @@ class Cardparts extends Base{
// 计算落点百分比(区间字典,值,值描述)
public function calculate_landing_point($data,$val,$t_val){
// 根据字典确认有几个区间
$num = count($data);
// 没个区间占比
$a_section = bcdiv(100,$num,2);
$temporary_data = [];
$num_0 = 0;
// 看看值是在哪个区间
foreach ($data as $key => $value) {
if($t_val == $value['text']){
$temporary_data = $value;
@ -369,16 +372,25 @@ class Cardparts extends Base{
break;
}
}
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
$max_num = trim($temporary_data['max_val']);
$min_num = trim($temporary_data['min_val']);
if($val < $temporary_data['max_val']){
// 这个值比最小值多出来多少
$num_1 = bcsub($val,$min_num,2);
// 这个区间的值是多少
$num_2 = bcsub($max_num,$min_num,2);
$num_3 = bcdiv(bcdiv($num_1,$num_2,4),$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// 算出这个值在这个区间的占比
$num_3 = bcdiv($num_1,$num_2,2);
$num_4 = bcmul($num_3,$a_section,2);
$result = bcadd($num_4,bcmul($a_section,$num_0,2),2);
}else{
$num_3 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$num_3,2);
// $num_4 = bcdiv(1,$num,4)*100;
$result = bcadd(bcmul($num_0,$a_section,2),$a_section,2);
}
return $result;
}

View File

@ -334,7 +334,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];

View File

@ -23,9 +23,18 @@ class Msginformation extends Base{
################################################################接口################################################################
// 获取板块,及板块下类型标签
public function get_sector_label_msg(){
public function get_sector_label_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
$return_data = $this->get_sector_label_msg_action();
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005);
}
$return_data = $this->get_sector_label_msg_action($data);
return $return_data;
} catch (\Exception $e) {
// 捕获异常
@ -43,7 +52,7 @@ class Msginformation extends Base{
}
// 获取板块下信息
public function get_sector_content_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5','sector_id'=>1,'type'=>4,'page'=>1]){
public function get_sector_content_msg($data = ['token'=>'6441bf7dabea7b3360a30240d3b19fc5','sector_id'=>1,'type'=>0,'page'=>1]){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -122,7 +131,7 @@ class Msginformation extends Base{
}
// 获取公告文章信息列表&banner
public function get_recommend_information($data=['token'=>'6441bf7dabea7b3360a30240d3b19fc5']){
try {
// try {
if(count(input('post.')) > 0){
$data = input('post.');
}
@ -136,19 +145,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);
// }
}
// 获取商务合作链接
@ -207,7 +216,7 @@ class Msginformation extends Base{
}
################################################################业务################################################################
################################################################get_sector_label_msg
public function get_sector_label_msg_action(){
public function get_sector_label_msg_action($data){
$Template_arr = [
1=>[
'id'=>'1',
@ -242,7 +251,6 @@ class Msginformation extends Base{
// 填充进去版块的轮播start
$return_data = [];
foreach ($sector_all as $key => $value) {
$loop_result = Db::query("
SELECT
id,
@ -254,9 +262,15 @@ class Msginformation extends Base{
ORDER BY
loop_img desc
");
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'];
}
}
$Template_arr[$value]['loop_data'] = $loop_result;
array_push($return_data, $Template_arr[$value]);
}
// 填充进去版块的轮播end
return $this->msg($return_data);
}
@ -291,8 +305,14 @@ class Msginformation extends Base{
FETCH NEXT
".$this->page_num." ROWS ONLY
");
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'];
}
}
$return_result['content_data'] = $content_result;
$user_like = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token'],'is_del'=>0])->column('aetc_id');
$user_like = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->column('aetc_id');
foreach ($return_result['content_data'] as $key => $value) {
if(array_key_exists($value['id'], $user_like)){
@ -370,6 +390,7 @@ class Msginformation extends Base{
'notice'=>[],
'banner'=>[]
];
return $this->msg($return_data);
// 所有可用记录
$all_data = Db::table($this->msginformation_use_db_name['3'])->where(['is_del'=>0])->select();
// 用户阅读记录
@ -388,14 +409,29 @@ class Msginformation extends Base{
}else{
$all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token'];
$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]['type'] = 'h5';
$all_data[$key]['id'] = $value['parameter_data'];
}
}else{
$all_data[$key]['type'] = 'wechat';
// 提取查询字符串部分(?后面的部分)
$queryString = substr($all_data[$key]['jump_url'], strpos($all_data[$key]['jump_url'], '?') + 1);
// 使用parse_str解析查询字符串
$params = [];
parse_str($queryString, $params);
// 提取appid和path的值
$appid = isset($params['appid']) ? $params['appid'] : null;
$path = isset($params['path']) ? $params['path'] : null;
$all_data[$key]['appid'] = $appid;
$all_data[$key]['path'] = $path;
}
// $all_data[$key]['id'] = $all_data[$key]['parameter_data'];
unset($all_data[$key]['parameter_data']);
unset($all_data[$key]['is_del']);
unset($all_data[$key]['ROW_NUMBER']);

View File

@ -13,9 +13,10 @@ class Pagingcontrast extends Base{
'2'=>'test_app_card_skip_data',
'3'=>'test_app_card_vitalcapacity_data',
'4'=>'test_app_user_data',
// '4'=>'test_app_user_data',
];
protected $request_result = [
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
];
@ -24,13 +25,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 +46,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{
@ -113,7 +113,7 @@ class Pagingcontrast extends Base{
}
// 获取详细历史数据信息(包含身体、跳绳、肺活量)
public function get_all_record_detailed_information($data = ['id'=>'170','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
public function get_all_record_detailed_information($data = ['id'=>'36','type'=>'8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -146,10 +146,9 @@ class Pagingcontrast extends Base{
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
// 数据对比(包含身体、跳绳、肺活量)
public function get_all_card_data_contrast($data = ['before_id'=>'51','after_id'=>'52','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
public function get_all_card_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
try {
// 你的业务逻辑
if(count(input('post.')) > 0){
@ -282,9 +281,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',
@ -302,9 +301,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',
@ -466,6 +465,7 @@ class Pagingcontrast extends Base{
if($data['type'] == 2){
// 身体数据处理,如果没有阻抗,则只显示四项$exclude_data_arr
if($result['record_type'] != 'by_device_adc'){
if(!in_array($key, $exclude_data_arr)){
continue;
}else{
@ -478,20 +478,26 @@ class Pagingcontrast extends Base{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
}
}else{
$temporary_arr['value'] = explode(',',$result[$key])[0];
}
$temporary_arr['unit'] = $value[1];
array_push($result_data,$temporary_arr);
}
if($result['head_circumference'] != null){
array_unshift($result_data,[
'key_name'=>'head_circumference',
'name'=>'头围',
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0(异常)":json_decode($result['head_circumference'],true)['value'],
'unit'=>'cm',
]);
//
// 添加头围详细start
if($data['type'] == 2){
if($result['head_circumference'] != null){
array_unshift($result_data,[
'key_name'=>'head_circumference',
'name'=>'头围',
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0":json_decode($result['head_circumference'],true)['value'],
'unit'=>'cm',
]);
}
}
// 添加头围详细end
return $this->msg($result_data);
}else{
return $this->msg(10004);
@ -524,6 +530,7 @@ class Pagingcontrast extends Base{
acbd.sfr,
acbd.record_time,
acbd.record_type,
acbd.head_circumference,
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
aud.nickname,
aud.gender,
@ -546,22 +553,49 @@ class Pagingcontrast extends Base{
$calculate_arr['after'] = $value;
}
}
$return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time'];
$return_data['headimg'] = $calculate_arr['before']['head_pic'];
$return_data['name'] = $calculate_arr['before']['nickname'];
$return_data['gender'] = $calculate_arr['before']['gender'];
$return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
$return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
$return_data['list'] = [];
// 处理如果没有阻抗的数据为0显示异常start;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
if($calculate_arr['before']['record_type'] != 'by_device_adc' && $calculate_arr['after']['record_type'] != 'by_device_adc'){
foreach ($calculate_arr['before'] as $key => $value) {
if(!in_array($key, ['height','weight','bmi'])){
if(!in_array($key, ['height','weight','bmi','head_circumference'])){
unset($calculate_arr['before'][$key]);
unset($calculate_arr['after'][$key]);
}
}
if($return_data['age']>=3){
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}else{
$calculate_arr['before']['head_circumference'] = json_decode($calculate_arr['before']['head_circumference'],true);
$calculate_arr['after']['head_circumference'] = json_decode($calculate_arr['after']['head_circumference'],true);
foreach ($calculate_arr as $key => $value) {
if(array_key_exists('value',$value['head_circumference'])){
$calculate_arr[$key]['head'][0] = $value['head_circumference']['value'];
}else{
$calculate_arr[$key]['head'][0] = 0;
}
if(array_key_exists('level',$value['head_circumference'])){
$calculate_arr[$key]['head'][1] = $value['head_circumference']['level'];
}else{
$calculate_arr[$key]['head'][1] = '异常';
}
if(array_key_exists('color',$value['head_circumference'])){
$calculate_arr[$key]['head'][2] = $value['head_circumference']['color'];
}else{
$calculate_arr[$key]['head'][2] = '';
}
$calculate_arr[$key]['head'] = implode(',',$calculate_arr[$key]['head']);
unset($calculate_arr['before']['head_circumference']);
unset($calculate_arr['after']['head_circumference']);
}
}
}else{
foreach ($calculate_arr as $key => $value) {
if($value['record_type'] != 'by_device_adc'){
@ -581,7 +615,7 @@ class Pagingcontrast extends Base{
}
// 处理如果没有阻抗的数据为0显示异常end同步处理如果两个对比数据都没有阻抗数据则只显示基础信息
foreach ($calculate_arr['before'] as $key => $value) {
if(in_array($key, ['height','weight','bmi','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
if(in_array($key, ['height','weight','bmi','head','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
$before_arr = explode(',', $value);
$after_arr = explode(',', $calculate_arr['after'][$key]);
array_push($return_data['list'], [
@ -605,6 +639,12 @@ class Pagingcontrast extends Base{
]);
}
}
// 添加头围数据如果需要的话start
// if($calculate_arr['before']['head_circumference'] != null || $calculate_arr['after']['head_circumference'] != null){
// }
// 添加头围数据如果需要的话end
return $this->msg($return_data);
}
// 数据对比

View File

@ -464,8 +464,6 @@ class Sportstesting extends Base{
$data = input('post.');
}
// dump(json_decode($this->ceshiyongde_data_baocun_canshu,true)['data']);
// die;
// $data['result_data'] = json_decode($this->ceshiyongde_data_baocun_canshu,true)['data'];
if(!array_key_exists('aud_id', $data) || !array_key_exists('parameter_data', $data) || !array_key_exists('result_data', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
$return_data = $this->msg(10001);
@ -479,8 +477,6 @@ class Sportstesting extends Base{
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
return $this->msg(10005);
}
// dump($data['result_data']);
if(is_array($data['result_data']) && !empty($data['result_data'])){
// 是个数组且不为空数组
foreach ($data['result_data'] as $key => $value) {
@ -772,7 +768,7 @@ class Sportstesting extends Base{
foreach ($value['list'] as $v1k => $v1v) {
for( $i=0; $i < count($v1v['list']); $i++ ){
if(array_key_exists('choice_state',$v1v['list'][$i]) && $v1v['list'][$i]['choice_state'] == 0){
// dump(1);
unset($temporary_data['list'][$key]['list'][$v1k]['list'][$i]);
}
}
@ -817,8 +813,7 @@ class Sportstesting extends Base{
$find_data = Db::table($this->sportstesting_use_db_name['1'])->where($db_condition)->find();
$find_data = json_decode($find_data['content'],true);
$recognition_rule = $find_data[$gender];
// dump($recognition_rule);
// die;
foreach ($data['result_data'] as $key => $value) {
// 遍历一级($value['key'] = 现场考试)
foreach ($value['list'] as $k2 => $v2) {
@ -835,7 +830,7 @@ class Sportstesting extends Base{
$return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// if(array_key_exists('choice_state',$v3)){
// if($v3['choice_state'] == 1){
// // dump($v3['name']);
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
@ -849,7 +844,7 @@ class Sportstesting extends Base{
// $return_result['max_score'] = bcadd($return_result['max_score'],bcmul($v3['total_score'],$v3['proportion'],2),2);
// }
// }else{
// // dump($v3['name']);
// $temporary_result = $this->obtaining_grades($recognition_rule[$value['key']][$v2['key']]['list'][$v3['name']]['content'],$v3);
// $data['result_data'][$key]['list'][$k2]['list'][$k3] = $temporary_result;
// // $data['result_data'][$key]['list'][$k2]['list'][$k3]['name'] = $temporary_result['name']."(该项满分:".$temporary_result['total_score'].")";
@ -860,9 +855,7 @@ class Sportstesting extends Base{
}
}
}
// dump($data['result_data']);
// dump($return_result);
// die;
$return_result['list'] = $data['result_data'];
$user_sportstesting_set = Db::table($this->sportstesting_use_db_name['2'])->insert([
'aud_id'=>$data['aud_id'],
@ -990,14 +983,12 @@ class Sportstesting extends Base{
}else{
$temporary_arr = $data[2];
}
// dump($temporary_arr);
// return $temporary_arr;
// die;
$result = [];
foreach ($temporary_arr as $key => $value) {
$num = array_push($result,['name'=>$key,'key'=>$key,'list'=>[]]);
// dump($value);
foreach ($value as $s_c_k => $s_c_v) {
if($s_c_v['choose_num'] == 0){
// 如果是必选项

View File

@ -44,30 +44,21 @@
font-size: 4vw;
}
.download{
width: 55vw;
height: 11vw;
background-color: #FFA940;
border-radius: 5.5vw;
text-align: center;
line-height: 11vw;
font-weight: bold;
text-decoration: none;
color: white;
margin-top: 10vw;
width: 60vw;
height: 12vw;
background: url('/download_img/download.png') no-repeat;
background-size: contain;
}
img{
width: 25vw;
width: 55vw;
}
.jump{
width: 55vw;
height: 11vw;
color: white;
background-color: #389E0D;
border-radius: 5.5vw;
text-align: center;
line-height: 11vw;
font-weight: bold;
width: 60vw;
height: 12vw;
margin-bottom: 10vw;
margin-top: 12vw;
background: url('/download_img/open_wechat_app.png') no-repeat;
background-size: contain;
}
.ts{
width: 100vw;
@ -107,18 +98,53 @@
text-decoration: none;
color: blue;
}
.bouncing-button-container {
transform-origin: center bottom; /* 设置旋转的基点在底部中心 */
animation: rotateAndRaise 2s ease-in-out forwards infinite;
}
@keyframes rotateAndRaise {
0% {
transform: rotate(0deg) translateY(0); /* 初始状态,不旋转也不升高 */
}
10% {
transform: rotate(5deg); /* 初始状态,不旋转也不升高 */
}
20% {
transform: rotate(0deg) translateY(-50px); /* 50%时旋转15°并升高50px */
}
30% {
transform: rotate(-5deg); /* 初始状态,不旋转也不升高 */
}
40% {
transform: rotate(0deg) translateY(0px); /* 结束状态往右旋转30°并升高50px */
}
100% {
transform: rotate(0deg) translateY(0px); /* 结束状态往右旋转30°并升高50px */
}
}
.bottom_d{
width: 100vw;
height: 65vw;
position: absolute;
bottom: 0;
left: 0;
background: url('/download_img/bottom.png') no-repeat;
background-position: bottom;
background-size: contain;
}
</style>
</head>
<body id="box_k">
<div class="big_box">
<div class="content_1">
<img src="http://tc.pcxbc.com/tsf/logo.png" alt="">
<div style="font-size: 6vw;
font-weight: bold;
margin-bottom: 20vw;margin-top: 3vw;">reedaw</div>
<div class="jump" onclick="jump()">打开微信小程序</div>
<div class="download" onclick="download()">下载APP</div>
<img src="/download_img/title.png" alt="">
<div class="jump" onclick="jump()"></div>
<div class="download" onclick="download()"></div>
<div class="bottom_d"></div>
<!-- <a href="javascript:;">已安装? 打开Reedaw&nbsp;></a> -->
</div>
</div>
@ -135,7 +161,7 @@
<script>
var str_url = "{$url}";
function isWeixin() {
var ua = navigator.userAgent.toLowerCase();
var ua = navigator.userAgent.toLowerCase();
return /micromessenger/i.test(ua);
}
function isIOS() {
@ -144,29 +170,37 @@
}
function jump(){
window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
// window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
window.location.href = 'weixin://dl/business/?appid=wx9c0b7a436ada6d1e&path=pages/home/home';
}
$('.ts').on('click',function(){
$(this).hide()
})
// if(isWeixin() && !isIOS()){
// $('.ts').show()
// }else{
// // console.log('当前不在微信环境中');
// // $('.download').addClass('bouncing-button-container')
// }
function download(){
if (isWeixin()) {
console.log('当前在微信环境中');
$('.ts').show()
} else {
console.log('当前不在微信环境中');
if (isIOS()) {
console.log('当前是iOS设备');
// 在这里执行iOS设备下的特定代码
window.location.href = "https://apps.apple.com/app/reedaw/id6654906497";
} else {
if (isIOS()) {
console.log('当前是iOS设备');
window.location.href = "https://apps.apple.com/app/reedaw/id6654906497";
}else{
if (isWeixin()) {
console.log('当前在微信环境中');
$('.ts').show()
}else{
console.log('当前不是iOS设备');
// 在这里执行非iOS设备下的代码
window.location.href = str_url;
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB