123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 成员,就诊人
- */
- class Usermember extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- //添加成员
- public function add_one(){
- $field = [
- 'realname',
- 'idcard',
- 'relation',
- 'mobile',
- 'gender',
- 'birthday',
- 'marital_status',
- 'allergies_status',
- 'allergies_text',
- 'familymedical_status',
- 'familymedical_text',
- 'chronicdisease_status',
- 'chronicdisease_text',
- ];
- $data = request_post_hub($field);
- $data['user_id'] = $this->auth->id;
- $data['birthday'] = strtotime($data['birthday']);
- $id = Db::name('user_member')->insertGetId($data);
- $this->success('操作成功',$id);
- }
- //我的成员列表
- public function my_list(){
- $list = Db::name('user_member')->field('id,realname,gender,birthday')->where('user_id',$this->auth->id)->order('id desc')->select();
- if(!empty($list)){
- foreach($list as $key => &$val){
- $val['age'] = birthtime_to_age($val['birthday']);
- $val['avatar'] = localpath_to_netpath('/assets/img/avatar.png');
- }
- }
- $this->success('success',$list);
- }
- //获取详情
- public function info(){
- $id = input('id',0);
- $info = Db::name('user_member')->where('id',$id)->find();
- if(!empty($info)){
- $info['birthday'] = date('Y-m-d',$info['birthday']);
- }
- $this->success('success',$info);
- }
- //编辑
- public function edit_one(){
- $id = input('id',0);
- $field = [
- 'realname',
- 'idcard',
- 'relation',
- 'mobile',
- 'gender',
- 'birthday',
- 'marital_status',
- 'allergies_status',
- 'allergies_text',
- 'familymedical_status',
- 'familymedical_text',
- 'chronicdisease_status',
- 'chronicdisease_text',
- ];
- $data = request_post_hub($field);
- if(isset($data['birthday'])){
- $data['birthday'] = strtotime($data['birthday']);
- }
- Db::name('user_member')->where('id',$id)->where('user_id',$this->auth->id)->update($data);
- $this->success('操作成功');
- }
- //删除
- public function delete(){
- $id = input('id',0);
- Db::name('user_member')->where('id',$id)->where('user_id',$this->auth->id)->delete();
- $this->success('操作成功');
- }
- }
|