合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ## 一、提交照片 ### 1.调试接口 +++ post:http://www.dakaifa.net/index.php?g=App&m=Doc&a=docReg *int:uid=默认值#用户id <<< success <<< error +++ ### 2. 接口代码 ``` public function docReg(){ $uid = $_POST['uid']; //提交医生的资质 $upload = new \Think\Upload();// 实例化上传类 $upload->maxSize = 3145728 ;// 设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 $upload->rootPath = './'.C("UPLOADPATH"); // 设置附件上传根目录 $upload->savePath = './docavatar/'; // 设置附件上传(子)目录 $info = $upload->upload(); if (!$info) { $ret = array('msg'=>0); echo json_encode($ret); }else{ $avatar = $info["upfile"]['savename']; $users_model = M('Users'); $data['ap_avatar'] = $avatar; $result = $users_model->where("id={$uid}")->save($data); $doc_arr = $users_model->where("id={$uid}")->find(); if ($doc_arr) { $msg['msg'] = 1; $doc = array_merge($msg,$doc_arr); $json= json_encode($doc); echo $json; } } } ``` ## 二、提交认证信息 ### 1.调试接口 +++ post:http://www.dakaifa.net/index.php?g=App&m=Doc&a=docNum *string:real_name=张某某#真实姓名 *string:ID_card=142601186910161336#身份证 *string:resume=哈哈哈哈#个人简介 *string:uid=111#用户id <<< success { "msg": 1 } <<< error { "msg": 0 } +++ ### 2.接口代码 ``` public function docNum(){ $real_name = $_POST['real_name']; $ID_card = $_POST['ID_card']; $resume = $_POST['resume']; $uid = $_POST['uid']; $users_model = M('Users'); $data['user_login'] = $real_name; //本人姓名 $data['identity'] = $ID_card; //身份证 $data['signature'] = $resume; //个人简介 $data['user_type'] = 3; //医生 $data['user_status'] = 2; //待验证 $result = $users_model->where("id={$uid}")->save($data); if ($result) { $ret = array('msg'=>1); echo json_encode($ret); }else{ $ret = array('msg'=>0); echo json_encode($ret); } } ``` ## 三、获取全部医生信息 ### 1.调试接口 +++ get:http://www.dakaifa.net/index.php?g=App&m=Doc&a=all_doc *int:start=0#开始位置 *int:num=2#限制个数 <<< success [ { "id": "109", "user_login": "喵喵喵", "user_pass": "###4754a287756db899932077ac79201504", "user_nicename": "123", "user_email": "", "user_url": "", "avatar": "http://www.dakaifa.net/index.php?g=user&m=public&a=avatar&id=109", "sex": "0", "birthday": "1990-01-01", "signature": "青少年儿童心理咨询,婚姻家庭,两性关系,亲子关系。", "last_login_ip": "", "last_login_time": "2016-07-22 10:16:56", "create_time": "2016-07-22 10:16:56", "user_activation_key": "", "user_status": "1", "score": "0", "user_type": "3", "coin": "0", "mobile": "15503601099", "address": "理工大社区", "region": "北京", "stature": "123", "weight": "123", "user_token": "UXtOus3GMITeOTJ025xjEbb68JCj0dfkGOlXu2QVJ4d4/ec8X1zexqYBo59eGMjXTkE7EN5guu4=", "ap_avatar": "http://dakaifa.net/data/upload/docavatar/579589437e5d1.jpg", "identity": "140181199212084732", "msg": "1" }, { "id": "111", "user_login": "张天", "user_pass": "###324029ce02bf4cf80bb06c95e2c5326a", "user_nicename": "张天", "user_email": "", "user_url": "", "avatar": "http://www.dakaifa.net/index.php?g=user&m=public&a=avatar&id=111", "sex": "0", "birthday": "1989-01-01", "signature": "擅长发热,头痛,咳嗽等", "last_login_ip": "221.205.231.136", "last_login_time": "2016-08-02 15:26:46", "create_time": "2016-07-22 14:34:39", "user_activation_key": "", "user_status": "1", "score": "0", "user_type": "3", "coin": "0", "mobile": "13834626385", "address": "理工大社区", "region": "安庆", "stature": "178", "weight": "60", "user_token": "kz2k2d7j4VKKVfw1U3yki7b68JCj0dfkGOlXu2QVJ4d4/ec8X1zexk+3kPt7LDSlPckOc2bsEv4=", "ap_avatar": "http://dakaifa.net/data/upload/docavatar/57b683e2d2b6b.jpg", "identity": null, "msg": "1" } ] <<< error +++ ### 2. 接口代码 ``` public function all_doc(){ $start = $_GET['start']; $num = $_GET['num']; // $start = 0; // $num = 4; $users_model = M('Users'); $map['user_type'] = '3'; $map['user_status'] = '1'; $doc_arr = $users_model->where($map)->limit($start,$num)->select(); foreach ($doc_arr as &$value) { $value['msg'] = '1'; // $value['avatar'] = "http://".$_SERVER['SERVER_NAME']."/data/upload/avatar/".$value['avatar']; $value['avatar'] = "http://www.dakaifa.net/index.php?g=user&m=public&a=avatar&id=".$value['id']; $value['ap_avatar'] = "http://".$_SERVER['SERVER_NAME']."/data/upload/docavatar/".$value['ap_avatar']; } if ($doc_arr) { echo json_encode($doc_arr); }else{ $ret = array('msg'=>0); echo json_encode($ret); } } } ```