/** * 更新账户信息 * * @param string phoneNum 登陆手机号 * @param string password 登陆密码md5 * @param string photo 头像地址 * @throws Exception 103 if 手机号格式不正确 * @throws Exception 112 if 尝试更新一个非公司人员的账户信息 * @todo 考虑一种特殊情况:输入的手机号是一个在数据库中已经存在的联系人的手机号码 */ public function updateProfile() { #参数检查 $this->checkAccessToken(); $this->params = $this->require_params(array('phoneNum', 'password')); $this->params['photo'] = F::request('photo', ''); if (!FValidator::phone($this->params['phoneNum'])) { throw new Exception('手机号格式不正确', 103); } #账户信息检查 $this->returnData = $this->userModel->getAccountType($GLOBALS['userId']); if ($this->returnData != self::ADMIN_ACCOUNT && $this->returnData != 3) { throw new Exception('该接口只可以更新内容人员账户信息', 112); } #更新账户信息 $this->userModel->updatePassword($GLOBALS['userId'], $this->params['password'], TRUE); if ($this->params['photo']) { $this->returnData = $this->userModel->get($GLOBALS['userId']); $this->params['username'] = $this->returnData[0]['nickname']; $this->userModel->updateUserProfile($GLOBALS['userId'], $this->params['username'], $this->params['photo']); } F::rest()->show_result(); }