From 89618c9b82df4cad319db11e8c805d3ece4596bc Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Fri, 30 Aug 2024 18:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/define.php | 13 +- control/index.php | 335 +++++++++++++++++++++-------------------- data/dCase.php | 1 + model/mRedis.php | 29 ++++ model/mUserCase.php | 247 ++++++++++++++++++++++++++++++ view/templates/index/home.html | 20 +-- 6 files changed, 467 insertions(+), 178 deletions(-) create mode 100644 model/mRedis.php diff --git a/config/define.php b/config/define.php index 8538d98..ad0c877 100644 --- a/config/define.php +++ b/config/define.php @@ -14,13 +14,22 @@ define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/'); define('LOG_TRACK_SAVE_PATH', LOG_PATH_BASE.'track/%s/%s.log'); // 监控日志的路径,如2014-02-14/1(检测类型).log + define('TCM_DOMAIN', 'http://tcm.pengda.checkcopy.com'); + define('CSS_URL', '//tcm.pengda.checkcopy.com'); + // 小程序获取openid define('MP_APPID',"wxb840b419525a63e2"); // 公众号APPID define('MP_SECRET',"85b9058789a45b6077e8380365ff4bbc"); // 公众号秘钥 - define('MP_GET_OPENID_HREF',"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&grant_type=authorization_code&code=%s"); + define('MP_GET_OPENID_HREF',"https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&grant_type=authorization_code&js_code=%s"); define('JWT_KEY','3f8aef32b8b77c6e'); - define('CONTACT_US_IMG_URL',''); + define('CONTACT_US_IMG_URL', TCM_DOMAIN.'/images/contact_us.png'); + + $GLOBALS['notice_qqmail_list'] = array( + 'wangpd5@163.com' => 'GTKEOWXEGEUOERNR', + ); + define('USER_CASE_PDF_PATH', DATACENTER_ROOT.'/tcm_pdf/%d/'); + define('USER_CASE_PDF_URL', TCM_DOMAIN.'/case_pdf/%d/%s.pdf'); diff --git a/control/index.php b/control/index.php index 8855d34..2018243 100644 --- a/control/index.php +++ b/control/index.php @@ -21,57 +21,33 @@ class index extends publicBase { $id = $this->post('id'); $name = $this->post('name'); $source = $this->post('source'); + $original = $this->post('original'); $method = $this->post('method'); $herbs = $this->post('herbs'); - if(empty($name)||empty($source)||empty($method)||empty($herbs))$this->ajax_json(false, '参数错误'); + if(empty($name))$this->ajax_json(false, '姓名不能为空'); + if(empty($source))$this->ajax_json(false, '药方来源不能为空'); + if(empty($herbs))$this->ajax_json(false, '药方药材不能为空'); $mCase = new mCase(); $case_data = array( 'name'=>$name, 'source'=>$source, + 'original'=>$original, 'method'=>$method, ); if($id){ - $case_id = $id; - $res = $mCase->updateCase($id, $case_data); - if(empty($res))$this->ajax_json(false, '保存失败'); - }else{ - $case_id = $mCase->createCase($case_data); - if(empty($case_id))$this->ajax_json(false, '添加失败'); - } - - $case_herb = array(); - foreach ($herbs as $key=>$item) { - $temp = array(); - $temp['case_id']=$case_id; - $temp['num']=$item['num']; - $temp['sort']=$key; - - $herb = $mCase->getHerbByName($item['name']); - if($herb){ - $temp['herb_id']=$herb['id']; - }else{ - $temp['herb_id'] = $mCase->createHerb(array('name'=>$item['name'])); - } - - if(empty($temp['herb_id'])){ - continue; - } - - $case_herb[] = $temp; - } - - if($id){ - $odata = $mCase->getCaseHerbByCaseId($id); - $mCase->compareCaseHerb($odata,$case_herb); + //更新药方 + $res = $mCase->updateCase($id, $case_data, $herbs); + if (!$res) $this->ajax_json(false, $mCase->getError()); $this->ajax_json(true, '保存成功'); } - $res = $mCase->createCaseHerb($case_herb); - if(empty($res))$this->ajax_json(false, '添加失败'); + //新增药方 + $id = $mCase->createCase($case_data, $herbs); + if (!$id) $this->ajax_json(false, $mCase->getError()); $this->ajax_json(true, '添加成功'); } @@ -81,7 +57,7 @@ class index extends publicBase { if(empty($content))$this->ajax_json(false, '非法请求'); $start = $this->post('start') ? $this->post('start') : 0; - $pagesize = $this->post('pagesize') ? $this->post('pagesize') : 200; + $pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; $mCase = new mCase(); $data = $mCase->getCaseByName($content,$start,$pagesize); @@ -91,18 +67,11 @@ class index extends publicBase { public function ajax_case_detail() { $id = $this->get('id'); - $is_search = $this->get('is_search'); if(empty($id))$this->ajax_json(false, '非法请求'); $mCase = new mCase(); - - if($is_search){ - //先更新搜索次数 - $mCase->updateCaseSearchNum($id); - } - - //查询药方信息 $data = $mCase->getCaseInfo($id); + if (empty($data)) $this->ajax_json(false, $mCase->getError()); $this->ajax_json(true, '获取成功', $data); } @@ -112,142 +81,108 @@ class index extends publicBase { $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); - $this->ajax_json(true, '保存成功'); + $mUser = new mUser(); + $is_login = $mUser->validateToken($uid,$token); + if(!$is_login)$this->ajax_json(false, '请登录后操作'); + + $mUserCase = new mUserCase(); + + $name = $this->post('name'); + if(empty($name)) $this->ajax_json(false, '药方名称不能为空'); + + $id = $this->post('id'); + if($id){ + $data = array( + 'uid' => $uid, + 'name' => $_POST['name'], + 'feedback' => $_POST['feedback'], + ); + + $res = $mUserCase->updateUserCase($id,$data); + if(!$res)$this->ajax_json(false, $mUserCase->getError()); + + $this->ajax_json(true, '保存成功'); + } + + $case_id = $this->post('case_id'); + $patient_name = $this->post('patient_name'); + $patient_age = $this->post('patient_age')+0; + $patient_sex = $this->post('patient_sex')+0; + $prescribe_num = $this->post('prescribe_num')+0; + $prescribe_herb = $this->post('prescribe_herb'); + $patient_say = $this->post('patient_say'); + $first_diagnosis = $this->post('first_diagnosis'); + $diagnosis = $this->post('diagnosis'); + + if(empty($case_id)) $this->ajax_json(false, '找不到相关药方'); + if(empty($patient_name)) $this->ajax_json(false, '患者姓名不能为空'); + if(empty($patient_age)) $this->ajax_json(false, '患者年龄不能为空'); + if(empty($prescribe_num)) $this->ajax_json(false, '开药数量不能为空'); + if(empty($prescribe_herb)) $this->ajax_json(false, '开药详情不能为空'); + if(empty($patient_say)) $this->ajax_json(false, '主诉不能为空'); + if(empty($first_diagnosis)) $this->ajax_json(false, '舌诊脉诊不能为空'); + if(empty($diagnosis)) $this->ajax_json(false, '诊断不能为空'); + + $prescribe_herb = $mUserCase->formatUserCaseHerbs($uid, $prescribe_herb); + if(!$prescribe_herb)$this->ajax_json(false, $mUserCase->getError()); + + $data = array( + 'name' => $name, + 'patient_name' => $patient_name, + 'patient_age' => $patient_age, + 'patient_sex' => $patient_sex, + 'patient_say' => $patient_say, + 'first_diagnosis' => $first_diagnosis, + 'diagnosis' => $diagnosis, + 'prescribe_num' => $prescribe_num, + 'prescribe_herb' => $prescribe_herb, + 'case_id' => $case_id, + 'uid' => $uid, + ); + + $id = $mUserCase->createUserCase($data); + if(!$id)$this->ajax_json(false, '保存失败'); + + //更新药方使用次数 这个后期会增加定时脚本去修正 + $mCase = new mCase(); + $mCase->updateCaseSearchNum($id); + + $this->ajax_json(true, '保存成功',array('id' => $id)); } - public function ajax_user_case_list() { + public function ajax_user_case() { $uid = $this->post('uid'); $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); + $mUser = new mUser(); + $is_login = $mUser->validateToken($uid,$token); + if(!$is_login)$this->ajax_json(false, '请登录后操作'); + + $start = $this->post('start') ? $this->post('start') : 0; + $pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; + + $mUserCase = new mUserCase(); + $id = $this->post('id'); if($id){ - $data = array( - 'user_case' =>array( - "id"=>"1", - "uid"=>"8112779578", - "case_id"=> "1", - "name"=> "11", - "patient_name"=> "11", - "patient_age"=> "1", - "patient_sex"=> "1", - "patient_say"=> "1", - "first_diagnosis"=> "1", - "diagnosis"=> "1", - "prescribe_num"=> "1", - "prescribe_herb"=> array( - array( - "herb_id"=> 1, - "num"=> 5 - ), - array( - "herb_id"=> 'u_1', - "num"=> 5 - ) - ), - "feedback"=> "111", - "case_time"=> "2024-08-28 11:49:46", - "create_time"=> "2024-08-28 11:49:46" - ), - 'case'=> array( - 'id'=>1, - 'name'=>"大陷胸丸方", - 'source'=>"仲景伤寒论卷第四", - 'search_num'=>100, - 'sort'=>1, - ), - 'herb'=>array( - '1'=>array( - "id"=> "1", - "name"=> "知母", - "desc"=> "", - ), - ), - 'user_herb'=>array( - '1'=>array( - "id"=> "1", - "uid"=> "12", - "name"=> "当归", - "desc"=> "", - ), - ) - ); - }else{ - $data = array( - 'user_case'=>array( - array( - "id"=>"1", - "uid"=>"8112779578", - "case_id"=> "1", - "name"=> "11", - "patient_name"=> "11", - "patient_age"=> "1", - "patient_sex"=> "1", - "patient_say"=> "1", - "first_diagnosis"=> "1", - "diagnosis"=> "1", - "prescribe_num"=> "1", - "prescribe_herb"=> "[{\"herb_id\":1,\"num\":5},{\"num\":5,\"herb_id\":\"u_1\"}]", - "feedback"=> "111", - "case_time"=> "2024-08-28 11:49:46", - "create_time"=> "2024-08-28 11:49:46" - ), - array( - "id"=>"2", - "uid"=>"8112779578", - "case_id"=> "1", - "name"=> "11", - "patient_name"=> "11", - "patient_age"=> "1", - "patient_sex"=> "1", - "patient_say"=> "1", - "first_diagnosis"=> "1", - "diagnosis"=> "1", - "prescribe_num"=> "1", - "prescribe_herb"=> "[{\"herb_id\":1,\"num\":5},{\"num\":5,\"herb_id\":\"u_1\"}]", - "feedback"=> "111", - "case_time"=> "2024-08-28 11:49:46", - "create_time"=> "2024-08-28 11:49:46" - ) - ), - 'case'=>array( - array( - 'id'=>1, - 'name'=>"大陷胸丸方", - 'source'=>"仲景伤寒论卷第四", - 'search_num'=>100, - 'sort'=>1, - ), - array( - 'id'=>2, - 'name'=>"大陷胸汤方", - 'source'=>"仲景伤寒论卷第四", - 'search_num'=>88, - 'sort'=>1, - ) - ), - ); + $data = $mUserCase->getUserCaseInfo($id, $uid); + if(!$data)$this->ajax_json(false, $mUserCase->getError()); + + $this->ajax_json(true, '获取成功', $data); } + $data = $mUserCase->getUserCaseList($uid, $start, $pagesize); + $this->ajax_json(true, '获取成功', $data); } public function ajax_collect_log() { $start = $this->get('start') ? $this->get('start') : 0; - $pagesize = $this->get('pagesize') ? $this->get('pagesize') : 200; + $pagesize = $this->get('pagesize') ? $this->get('pagesize') : 500; - $data = array( - array( - 'id'=>1, - 'collect_msg'=>"大陷胸丸方", - 'collect_time'=>"2024-08-28 11:13:39", - ), - array( - 'id'=>2, - 'collect_msg'=>"大陷胸丸方", - 'collect_time'=>"2024-08-28 11:13:35", - ) - ); + $mCase = new mCase(); + $data = $mCase->getCollectLog($start,$pagesize); $this->ajax_json(true, '获取成功', $data); } @@ -256,9 +191,31 @@ class index extends publicBase { $code = $this->get('code'); if(!$code)$this->ajax_json(false, '非法请求'); + $mUser = new mUser(); + + $openid = $mUser->getOpenid($code); + if(!$openid)$this->ajax_json(false, $mUser->getError()); + + $user = $mUser->getUserByOpenid($openid); + if($user){ + $data = array( + 'uid' => $user['uid'], + 'token'=> $mUser->getToken($user['uid']), + ); + $this->ajax_json(true, '登录成功', $data); + } + + //获取唯一uid串 + $uid = $mUser->createUniqueUid($openid); + $user = $mUser->getUserByUid($uid); + if($user)$this->ajax_json(false, 'uid生成失败'); + + $id = $mUser->createUser(array('uid'=>$uid,'openid'=>$openid)); + if(!$id)$this->ajax_json(false, '用户创建失败'); + $data = array( - 'uid'=>'12312321', - 'token'=>'asdasdasdsa' + 'uid' => $uid, + 'token'=> $mUser->getToken($uid), ); $this->ajax_json(true, '登录成功', $data); @@ -273,7 +230,32 @@ class index extends publicBase { $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); - $this->ajax_json(true, '获取成功',array('pdf_url'=>'')); + $mUser = new mUser(); + $is_login = $mUser->validateToken($uid,$token); + if(!$is_login)$this->ajax_json(false, '请登录后操作'); + + $mUserCase = new mUserCase(); + + $id = $this->post('id'); + if($id){ + $data = $mUserCase->getUserCaseInfo($id, $uid); + if (!$data) $this->ajax_json(false, $mUserCase->getError()); + + $pdf_url = $mUserCase->createUserCasePdf($uid, $data); + + $this->ajax_json(true, '获取成功',array('pdf_url'=> $pdf_url)); + } + + //如果id不存在默认保存前500个医案 + $start = $this->post('start') ? $this->post('start') : 0; + $pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500; + + $data = $mUserCase->getUserCaseList($uid, $start, $pagesize, true); + if (!$data) $this->ajax_json(false, $mUserCase->getError()); + + $pdf_url = $mUserCase->createUserCasePdf($uid, $data); + + $this->ajax_json(true, '获取成功',array('pdf_url'=> $pdf_url)); } public function ajax_mail(){ @@ -281,6 +263,25 @@ class index extends publicBase { $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); + $mUser = new mUser(); + $is_login = $mUser->validateToken($uid,$token); + if(!$is_login)$this->ajax_json(false, '请登录后操作'); + + $email = $this->post('email'); + if(empty($email))$this->ajax_json(false, '邮箱地址不能为空'); + if(!filter_var($email, FILTER_VALIDATE_EMAIL))$this->ajax_json(false, '邮箱地址无效'); + + $pdf_url = $this->post('pdf_url'); + if(empty($pdf_url))$this->ajax_json(false, 'pdf地址不能为空'); + if(!filter_var($pdf_url, FILTER_VALIDATE_URL))$this->ajax_json(false, 'pdf地址无效'); + + $directory_name = basename(dirname($pdf_url)); + if($directory_name != $uid)$this->ajax_json(false, '非法请求'); + + $mUserCase = new mUserCase(); + $res = $mUserCase->sendMail(array($email),date('Y年m月d日',time()).'-医案导出','',sprintf(USER_CASE_PDF_PATH, $uid) . basename($pdf_url)); + if(!$res)$this->ajax_json(true, '发送失败'); + $this->ajax_json(true, '发送成功'); } } diff --git a/data/dCase.php b/data/dCase.php index 1780472..08c1ac1 100644 --- a/data/dCase.php +++ b/data/dCase.php @@ -12,6 +12,7 @@ class dCase extends dBase { 'id', 'name', 'source', + 'original', 'method', 'use_num', 'sort', diff --git a/model/mRedis.php b/model/mRedis.php new file mode 100644 index 0000000..f63b085 --- /dev/null +++ b/model/mRedis.php @@ -0,0 +1,29 @@ +connect($cnf['host'], $cnf['port']); + self::$_instance->auth('zhicheng123*'); + if(!$res) { + $this->setError('redis_connect'); + return false; + } + } + return self::$_instance; + } +} diff --git a/model/mUserCase.php b/model/mUserCase.php index 31fac87..27082bc 100644 --- a/model/mUserCase.php +++ b/model/mUserCase.php @@ -15,4 +15,251 @@ class mUserCase extends mBase { $this->user_herb_tbl = 'tcm_user_herb'; } + public function updateUserCase($id,$data){ + if(empty($data['name'])){ + $this->setError('药方名称不能为空'); + return false; + } + if(empty($data['feedback'])){ + $this->setError('用药反馈不能为空'); + return false; + } + + $res = $this->obj->update($this->tbl, $data, array('sql'=>'`id`=? and `uid`=?', 'vals'=>array($id, $data['uid']))); + if(!$res){ + $this->setError('更新失败'); + return false; + } + + return true; + } + + public function formatUserCaseHerbs($uid, $prescribe_herb){ + $mCase = new mCase(); + + $prescribe_herb = json_decode($prescribe_herb,true); + if(empty($prescribe_herb)){ + $this->setError('开药详情为空'); + return false; + } + + $data = array(); + foreach ($prescribe_herb as $item){ + $temp = array(); + $temp['num'] = $item['num']; + if(isset($item['herb_id'])){ + $temp['herb_id'] = $item['herb_id']; + $data[] = $temp; + continue; + } + + $herb = $mCase->getHerbByName($item['name']); + if($herb){ + $temp['herb_id'] = $herb['id']; + $data[] = $temp; + continue; + } + + $userherb = $this->obj->select($this->user_herb_tbl, array('sql'=>'`name`=?', 'vals'=>array($item['name']))); + if($userherb){ + $temp['herb_id'] = 'u_'.$userherb['id']; + $data[] = $temp; + continue; + } + + $user_herb_id = $this->obj->insert($this->user_herb_tbl, array('uid' => $uid,'name'=> $item['name'])); + if(!$user_herb_id){ + $this->setError('添加自定义药材失败'); + return false; + } + + $temp['herb_id'] = 'u_'.$user_herb_id; + $data[] = $temp; + } + + return json_encode($data); + } + + public function createUserCase($info){ + return $this->obj->insert($this->tbl, $info); + } + + public function getUserCaseInfo($id, $uid){ + $user_case = $this->obj->select($this->tbl, array('sql'=>'`id`=? and `uid`=?', 'vals'=>array($id, $uid))); + if(empty($user_case)){ + $this->setError('找不到相关医案'); + return false; + } + + $prescribe_herb = json_decode($user_case['prescribe_herb'],true); + $user_case['prescribe_herb'] = $prescribe_herb; + + $mCase = new mCase(); + $case = $mCase->getCaseById($user_case['case_id']); + if(empty($case)){ + $this->setError('找不到相关药方'); + return false; + } + + $herb_ids = $user_herb_ids = array(); + foreach ($prescribe_herb as $item){ + if(strpos($item['herb_id'],'u_')!==false){ + $user_herb_ids[] = str_replace('u_','',$item['herb_id']); + continue; + } + $herb_ids[] =$item['herb_id']; + } + + $mCase = new mCase(); + $herb = $mCase->getHerbByIds($herb_ids); + $user_herb = $this->getUserHerbByIds($user_herb_ids); + if(empty($herb) && empty($user_herb)){ + $this->setError('找不到相关药材'); + return false; + } + + $data = array( + 'user_case' => $user_case, + 'case' => $case, + 'herb' => array_column($herb,null,'id'), + 'user_herb' => array_column($user_herb,null,'id'), + ); + + return $data; + } + + public function getUserCaseList($uid, $start, $pagesize, $get_case_herb = false){ + $user_case = $this->obj->selectAll($this->tbl, array('sql'=>'`uid`=?', 'vals'=>array($uid)), 'case_time desc ', array($start, $pagesize)); + if(empty($user_case)){ + $this->setError('找不到相关医案'); + return false; + } + $case_ids = array_column($user_case,'case_id'); + + $mCase = new mCase(); + $case = $mCase->getCaseByIds($case_ids); + if(empty($case)){ + $this->setError('找不到相关药方'); + return false; + } + $case = array_column($case,null,'id'); + + if(!$get_case_herb){ + $data = array( + 'user_case_list' => $user_case, + 'case_list' => $case, + ); + + return $data; + } + + $herb_ids = $user_herb_ids = array(); + foreach ($user_case as &$item){ + $prescribe_herb = json_decode($item['prescribe_herb'],true); + $item['prescribe_herb'] = $prescribe_herb; + + foreach ($prescribe_herb as $herb_item){ + if(strpos($herb_item['herb_id'],'u_')!==false){ + $user_herb_ids[] = str_replace('u_','',$herb_item['herb_id']); + continue; + } + $herb_ids[] = $herb_item['herb_id']; + } + } + + $mCase = new mCase(); + $herb = $mCase->getHerbByIds($herb_ids); + $user_herb = $this->getUserHerbByIds($user_herb_ids); + if(empty($herb) && empty($user_herb)){ + $this->setError('找不到相关药材'); + return false; + } + + $data = array( + 'user_case_list' => $user_case, + 'case_list' => $case, + 'herb' => array_column($herb,null,'id'), + 'user_herb' => array_column($user_herb,null,'id'), + ); + + return $data; + } + + public function getUserHerbByIds($ids){ + return $this->obj->selectIn($this->user_herb_tbl, array('id'=>$ids)); + } + + public function createUserCasePdf($uid, $data){ + //兼容单个医案导出pdf + if(isset($data['user_case'])){ + $data['user_case_list'][0] = $data['user_case']; + unset($data['user_case']); + $data['case_list'][$data['case']['id']] = $data['case']; + unset($data['case']); + } + + // 创建PDF对象 + $mpdf = new mPDF(); + + $pdf_name = ""; + + $htmlContent = "
我的医案
"; + foreach ($data['user_case_list'] as $item){ + $pdf_name .= $item['name']; + + $item['patient_sex'] = $item['patient_sex']==0?'男':'女'; + $item['case_time'] = date('Y年m月d日',strtotime($item['case_time'])); + + $htmlContent .= "{$item['name']}
"; + $htmlContent .= "{$item['patient_name']},{$item['patient_sex']},{$item['patient_age']}岁,{$item['case_time']}诊
"; + if($item['patient_say']){ + $htmlContent .= "{$item['patient_say']}
"; + } + if($item['first_diagnosis']){ + $htmlContent .= "{$item['first_diagnosis']}
"; + } + if($item['diagnosis']){ + $htmlContent .= "{$item['diagnosis']}
"; + } + $htmlContent .= "处方 共{$item['prescribe_num']}付
"; + + $case = $data['case_list'][$item['case_id']]; + $case_str = "选 ".$case['source']." ".$case['name']; + + $herb_arr = array(); + foreach ($item['prescribe_herb'] as $herb){ + if(strpos($herb['herb_id'],'u_')!==false){ + $herb['herb_id'] = str_replace('u_','',$herb['herb_id']); + $herb_name = $data['user_herb'][$herb['herb_id']]['name']; + }else{ + $herb_name = $data['herb'][$herb['herb_id']]['name']; + } + $herb_arr[] = $herb_name.$herb['num']."克"; + } + $herb_str = implode('、',$herb_arr); + + $htmlContent .= "{$case_str}: {$herb_str}
"; + + $htmlContent .= "{$item['feedback']}
"; + } + } + + $pdf_name = md5($pdf_name); + + $temp_dir = sprintf(USER_CASE_PDF_PATH, $uid); + if(!is_dir($temp_dir)) { + mkdir($temp_dir, 0755, true); + chown($temp_dir, 'nobody'); + chgrp($temp_dir, 'nobody'); + } + + $mpdf->WriteHTML($htmlContent); + + $mpdf->Output($temp_dir . $pdf_name . ".pdf" , 'F'); // D表示下载,I表示在浏览器中查看 + + return sprintf(USER_CASE_PDF_URL, $uid, $pdf_name); + } } \ No newline at end of file diff --git a/view/templates/index/home.html b/view/templates/index/home.html index 39d97af..cca79bc 100644 --- a/view/templates/index/home.html +++ b/view/templates/index/home.html @@ -10,15 +10,15 @@ {literal}