getParams(); $doctor = $this->getCache($this->getToken()); $return = $service->application_start($params,$doctor); return $this->success($return); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } public function myApplication(AppletsService $service) { try{ $params = $this->getParams(); $doctor = $this->getCache($this->getToken()); $return = $service->getMyApplication($params,$doctor); return $this->success($return); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } public function save_autograph(AppletsService $service) { $params = $this->getParams(); if(empty($params['attachment'])) { $this->throwError('找不到需要上传的文件','0009'); } $attachment = explode('base64,',$params['attachment']); $image = $attachment[1]; $file = base64_decode($image); if($file) { $name = UUIDUtils::uuid().'.png'; $path = ROOT_PATH . 'public' . DS . 'uploads'. DS .$name; $url = '/' . 'autograph' . '/' .$name; $r = file_put_contents($path, $file); if (!$r) { $this->throwError('图片生成失败','0008'); }else { $doctor = $this->getCache($this->getToken()); $type = Config::get('upload'); if($type == 1) { $r = $service->save_autograph($url,$doctor); $success = ['url'=>$url,'type'=>$type,'tokenUrl'=>$url]; return $this->success($success); } $key = 'autograph/' . $name; $source_file = './' . 'uploads' . '/' . $name; $upload = new uploadToCloud();; $s = $upload->upload($key,$source_file); if(($s['@metadata']['statusCode'] ?? '') == '200') { $r = $service->save_autograph($url,$doctor); gc_collect_cycles(); unset($info); unlink($source_file); $success = ['url'=>$key,'type'=>'2','tokenUrl'=>$upload->makeUrl($key)]; return $this->success($success); }else{ return '上传云失败'; } // return $this->success($url); } }else{ $this->throwError('无法获取上传的文件','0009'); } } public function autograph_switch(AppletsService $service) { $params = $this->getParams(); $doctor = $this->getCache($this->getToken()); $info = $service->autograph_switch($doctor,$params['is_use_autograph']); return $this->success($info); } public function getAutograph(AppletsService $service) { $doctor = $this->getCache($this->getToken()); if(empty($doctor)) { $this->throwError('无效的token,请重新进行登陆','0099'); } $data = $service->getAutograph($doctor['id']); $data['autograph_url'] = $data['autograph']; if($data['autograph_type'] == 2) { $data['autograph_url'] = $this->makeFileUrl($data['autograph'],$data['autograph_type']); } return $this->success($data); } }