|
@@ -351,6 +351,8 @@ class User extends Api
|
|
|
$emergencycontact = $this->request->post('emergencycontact', '', 'trim'); //紧急联系人
|
|
|
$contactmobile = $this->request->post('contactmobile', '', 'trim'); //紧急联系方式
|
|
|
$outdoorduration = $this->request->post('outdoorduration', '', 'trim'); //户外时长
|
|
|
+ $birthday = $this->request->post('birthday', '', 'strtotime'); //生日
|
|
|
+ $gender = $this->request->post('gender', 0, 'intval'); //性别
|
|
|
|
|
|
$data = [];
|
|
|
if ($avatar) {
|
|
@@ -402,6 +404,13 @@ class User extends Api
|
|
|
$data['outdoorduration'] = $outdoorduration;
|
|
|
}
|
|
|
|
|
|
+ if ($birthday) {
|
|
|
+ $data['birthday'] = $birthday;
|
|
|
+ }
|
|
|
+ if (in_array($gender, [1, 2])) {
|
|
|
+ $data['gender'] = $gender;
|
|
|
+ }
|
|
|
+
|
|
|
// $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
// if ($username) {
|
|
|
// $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
|
|
@@ -495,16 +504,24 @@ class User extends Api
|
|
|
public function changemobile()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
+ $code = $this->request->post('code');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$captcha = $this->request->post('captcha');
|
|
|
- if (!$mobile || !$captcha) {
|
|
|
+ if (!$code || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
+ if ($mobile == $user->mobile) {
|
|
|
+ $this->error('手机号没有改变');
|
|
|
+ }
|
|
|
+ $result = Sms::check($user->mobile, $code, 'changemobile');
|
|
|
+ if (!$result) {
|
|
|
+ $this->error(__('Captcha is incorrect'));
|
|
|
+ }
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}
|
|
|
if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
|
|
|
- $this->error(__('Mobile already exists'));
|
|
|
+ $this->error(__('手机号已存在'));
|
|
|
}
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
@@ -516,8 +533,9 @@ class User extends Api
|
|
|
$user->mobile = $mobile;
|
|
|
$user->save();
|
|
|
|
|
|
+ Sms::flush($user->mobile, 'changemobile');
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
- $this->success();
|
|
|
+ $this->success('修改成功');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1376,4 +1394,12 @@ class User extends Api
|
|
|
|
|
|
$this->success('查询当前会员等级信息', $vip_info);
|
|
|
}
|
|
|
+
|
|
|
+ //查询会员权益
|
|
|
+ public function vipprivilege() {
|
|
|
+ $list = Db::name('vip_privilege')->field('id, title, desc')
|
|
|
+ ->where(['vip_id' => $this->auth->maxlevel])->order('weigh desc')->select();
|
|
|
+
|
|
|
+ $this->success('查询会员权益', $list);
|
|
|
+ }
|
|
|
}
|