/**
  * 基本信息保存到数据库
  */
 public function addDetail()
 {
     if (IS_POST) {
         $id = I('id');
         $user_type = I('user_type');
         // 用户登录信息
         $user = array('id' => $id, 'photo' => I('photo'), 'photo_url' => I('photo_url'), 'is_founder' => I('user_type') == 1 ? 1 : 0);
         // 用户基本信息
         $detail = array('id' => $id, 'name' => I('name'), 'card_id' => I('card_id'), 'province' => I('province'), 'city' => I('city'), 'phone' => I('phone'), 'address' => I('address'));
         if (empty(I('name'))) {
             $this->error('真实姓名不能为空。');
         }
         if (empty(I('card_id'))) {
             $this->error('身份证号码不能为空。');
         }
         if ($user_type == 1) {
             // 创业者信息
             $user['is_founder'] = 1;
         } else {
             // 投资人信息
             $user['is_investor'] = 1;
             $user['investor_type'] = I('investor_type');
             // 证件照保存地址
             // $detail['card_photo'] = I('card_photo');
             // 用户个人描述
             $detail['describe'] = I('describe');
         }
         $ret = M('Users')->save($user);
         $ret = M('UsersDetail')->find($id);
         if (!$ret) {
             $ret = M('UsersDetail')->add($detail);
         } else {
             $ret = M('UsersDetail')->save($detail);
         }
         //保存用户类别
         $auth_id = I('user_type') == 1 ? 0 : 1;
         $ret = M('user_auth')->where(array('uid' => $id, 'auth_id' => $auth_id))->find();
         if (!$ret) {
             $data = array('uid' => $id, 'auth_id' => $auth_id);
             M('user_auth')->add($data);
         }
         memberupdate($id, $user['photo_url']);
         $this->success('操作成功', $_SERVER['HTTP_REFERER']);
     } else {
         $this->error('页面不存在');
     }
 }
示例#2
0
 public function changePhoto()
 {
     if (IS_POST) {
         $id = is_login();
         $basepath = substr($_POST['basepath'], 1);
         $image = new Image();
         $image->open($basepath);
         $image->crop($_POST['w'], $_POST['h'], $_POST['x'], $_POST['y'], 200, 200);
         $last = strrpos($basepath, '/') + 1;
         $ext = substr($basepath, strrpos($basepath, '.'));
         $path = substr($basepath, 0, $last);
         $filename = $path . 'crop_' . $id . $ext;
         $image->save($filename, null, 100, false);
         $filename = '/' . $filename . '?t=' . NOW_TIME;
         $user = array('id' => is_login(), 'photo' => $_POST['photo'], 'photo_url' => $filename);
         M('Users')->save($user);
         memberupdate($id, $user['photo_url']);
         $ret = array('status' => 1, 'info' => '头像更改成功!', 'photo_url' => $filename, 'photo' => $_POST['photo']);
         $this->ajaxReturn($ret);
         $this->success('头像更改成功!');
     } else {
         $this->display('changePhoto');
     }
 }