|
@@ -343,56 +343,63 @@ class User extends Api
|
|
*/
|
|
*/
|
|
public function profile()
|
|
public function profile()
|
|
{
|
|
{
|
|
- if ($this->auth->is_auth == 1) {
|
|
|
|
- $this->error('认证正在审核,不能修改');
|
|
|
|
- }
|
|
|
|
- if ($this->auth->is_auth == 2) {
|
|
|
|
- $this->error('认证已通过审核,不能修改');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $nickname = $this->request->post('nickname', '', 'trim'); //姓名
|
|
|
|
|
|
+ $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); //头像
|
|
|
|
+ $nickname = $this->request->post('nickname', '', 'trim'); //昵称
|
|
|
|
+ $realname = $this->request->post('realname', '', 'trim'); //真实姓名
|
|
$idcard = $this->request->post('idcard', '', 'trim,strip_tags,htmlspecialchars'); //身份证号
|
|
$idcard = $this->request->post('idcard', '', 'trim,strip_tags,htmlspecialchars'); //身份证号
|
|
- $province = $this->request->post('province', '', 'trim'); //省
|
|
|
|
- $city = $this->request->post('city', '', 'trim'); //市
|
|
|
|
- $area = $this->request->post('area', '', 'trim'); //区
|
|
|
|
- $address = $this->request->post('address', '', 'trim'); //详细地址
|
|
|
|
- $recommender = $this->request->post('recommender', '', 'trim'); //推荐人姓名
|
|
|
|
- $recommender_mobile = $this->request->post('recommender_mobile', '', 'trim'); //推荐人手机号
|
|
|
|
- $zimage = $this->request->post('zimage', '', 'trim,strip_tags,htmlspecialchars'); //身份证正面照
|
|
|
|
- $fimage = $this->request->post('fimage', '', 'trim,strip_tags,htmlspecialchars'); //身份证反面照
|
|
|
|
|
|
+ $passport = $this->request->post('passport', '', 'trim,strip_tags,htmlspecialchars'); //护照号
|
|
|
|
+ $emergencycontact = $this->request->post('emergencycontact', '', 'trim'); //紧急联系人
|
|
|
|
+ $contactmobile = $this->request->post('contactmobile', '', 'trim'); //紧急联系方式
|
|
|
|
+ $outdoorduration = $this->request->post('outdoorduration', '', 'trim'); //户外时长
|
|
|
|
|
|
- if (!$nickname) {
|
|
|
|
- $this->error('请输入姓名');
|
|
|
|
- }
|
|
|
|
- if (iconv_strlen($nickname, 'utf-8') > 30) {
|
|
|
|
- $this->error('姓名最多30位');
|
|
|
|
- }
|
|
|
|
- if (!$idcard) {
|
|
|
|
- $this->error('请输入身份证号');
|
|
|
|
- }
|
|
|
|
- if (iconv_strlen($idcard, 'utf-8') != 18) {
|
|
|
|
- $this->error('身份证号错误');
|
|
|
|
|
|
+ $data = [];
|
|
|
|
+ if ($avatar) {
|
|
|
|
+ if (iconv_strlen($avatar, 'utf-8') > 255) {
|
|
|
|
+ $this->error('图片超出范围');
|
|
|
|
+ }
|
|
|
|
+ $data['avatar'] = $avatar;
|
|
}
|
|
}
|
|
- if (!$province || !$city || !$area) {
|
|
|
|
- $this->error('请选择养殖场地址');
|
|
|
|
|
|
+ if ($nickname) {
|
|
|
|
+ if (iconv_strlen($nickname, 'utf-8') > 30) {
|
|
|
|
+ $this->error('昵称最多30字');
|
|
|
|
+ }
|
|
|
|
+ $data['nickname'] = $nickname;
|
|
}
|
|
}
|
|
- if (!$address) {
|
|
|
|
- $this->error('请输入详细地址');
|
|
|
|
|
|
+ if ($realname) {
|
|
|
|
+ if(iconv_strlen($realname, 'utf-8') > 30) {
|
|
|
|
+ $this->error('真实姓名最多30字');
|
|
|
|
+ }
|
|
|
|
+ $data['realname'] = $realname;
|
|
}
|
|
}
|
|
- if (iconv_strlen($address, 'utf-8') > 255) {
|
|
|
|
- $this->error('详细地址最多255位');
|
|
|
|
|
|
+ if ($idcard) {
|
|
|
|
+ if (iconv_strlen($idcard, 'utf-8') != 18) {
|
|
|
|
+ $this->error('身份证号错误');
|
|
|
|
+ }
|
|
|
|
+ $data['idcard'] = $idcard;
|
|
}
|
|
}
|
|
- if (!$recommender) {
|
|
|
|
- $this->error('请输入推荐人姓名');
|
|
|
|
|
|
+ if ($passport) {
|
|
|
|
+ if (iconv_strlen($passport, 'utf-8') > 30) {
|
|
|
|
+ $this->error('护照号错误');
|
|
|
|
+ }
|
|
|
|
+ $data['passport'] = $passport;
|
|
}
|
|
}
|
|
- if (iconv_strlen($recommender, 'utf-8') > 30) {
|
|
|
|
- $this->error('推荐人姓名最多30位');
|
|
|
|
|
|
+ if ($emergencycontact) {
|
|
|
|
+ if(iconv_strlen($emergencycontact, 'utf-8') > 30) {
|
|
|
|
+ $this->error('紧急联系人最多30字');
|
|
|
|
+ }
|
|
|
|
+ $data['emergencycontact'] = $emergencycontact;
|
|
}
|
|
}
|
|
- if (!$recommender_mobile || !is_mobile($recommender_mobile)) {
|
|
|
|
- $this->error('请输入正确推荐人手机号');
|
|
|
|
|
|
+ if ($contactmobile) {
|
|
|
|
+ if(!is_mobile($contactmobile)) {
|
|
|
|
+ $this->error('请输入正确紧急联系方式');
|
|
|
|
+ }
|
|
|
|
+ $data['contactmobile'] = $contactmobile;
|
|
}
|
|
}
|
|
- if (!$zimage || !$fimage) {
|
|
|
|
- $this->error('请上传身份证相关照片');
|
|
|
|
|
|
+ if ($outdoorduration) {
|
|
|
|
+ if(iconv_strlen($outdoorduration, 'utf-8') > 50) {
|
|
|
|
+ $this->error('户外时长最多50字');
|
|
|
|
+ }
|
|
|
|
+ $data['outdoorduration'] = $outdoorduration;
|
|
}
|
|
}
|
|
|
|
|
|
// $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
// $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
@@ -412,41 +419,15 @@ class User extends Api
|
|
// }
|
|
// }
|
|
// $user->avatar = $avatar;
|
|
// $user->avatar = $avatar;
|
|
|
|
|
|
- $data = [
|
|
|
|
- 'nickname' => $nickname,
|
|
|
|
- 'province' => $province,
|
|
|
|
- 'city' => $city,
|
|
|
|
- 'area' => $area,
|
|
|
|
- 'address' => $address,
|
|
|
|
- 'updatetime' => time()
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- //开启事务
|
|
|
|
- Db::startTrans();
|
|
|
|
-
|
|
|
|
|
|
+ if (!$data) {
|
|
|
|
+ $this->error('暂无修改内容');
|
|
|
|
+ }
|
|
//修改用户表
|
|
//修改用户表
|
|
- $data['is_auth'] = 1;
|
|
|
|
$rt = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
|
|
$rt = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
|
|
- if ($rt === false) {
|
|
|
|
- Db::rollback();
|
|
|
|
- $this->error('修改失败');
|
|
|
|
- }
|
|
|
|
- //修改认证表
|
|
|
|
- unset($data['is_auth']);
|
|
|
|
- $data['idcard'] = $idcard;
|
|
|
|
- $data['zimage'] = $zimage;
|
|
|
|
- $data['fimage'] = $fimage;
|
|
|
|
- $data['recommender'] = $recommender;
|
|
|
|
- $data['recommender_mobile'] = $recommender_mobile;
|
|
|
|
- $data['status'] = 0;
|
|
|
|
- $rs = Db::name('user_auth')->where(['user_id' => $this->auth->id])->setField($data);
|
|
|
|
-
|
|
|
|
- if (!$rs) {
|
|
|
|
- Db::rollback();
|
|
|
|
|
|
+ if (!$rt) {
|
|
$this->error('修改失败');
|
|
$this->error('修改失败');
|
|
}
|
|
}
|
|
|
|
|
|
- Db::commit();
|
|
|
|
$this->success('修改成功');
|
|
$this->success('修改成功');
|
|
}
|
|
}
|
|
|
|
|