|
@@ -147,6 +147,7 @@ class User extends Api
|
|
|
'truename' => $this->auth->truename,
|
|
|
'nickname' => $this->auth->nickname,
|
|
|
//'group_id' => $this->auth->group_id,
|
|
|
+ 'alipay_account' => $this->auth->alipay_account,
|
|
|
'idcard_status' => $this->auth->idcard_status,
|
|
|
'bio' => $this->auth->bio,
|
|
|
'birthday' => $this->auth->birthday,
|
|
@@ -157,13 +158,19 @@ class User extends Api
|
|
|
'gender' => $this->auth->gender,
|
|
|
'email' => $this->auth->email,
|
|
|
'mobile' => $this->auth->mobile,
|
|
|
+ 'setpassword' => $this->auth->password ? 1 : 0,
|
|
|
// 'cover_image' => $this->auth->cover_image,
|
|
|
// 'photo_images' => $this->auth->photo_images,
|
|
|
// 'vip_endtime' => $this->auth->vip_endtime,
|
|
|
];
|
|
|
//$info['is_vip'] = intval($info['vip_endtime']) - time() > 0 ? 1 : 0;
|
|
|
$info['age'] = birthtime_to_age($info['birthday']);
|
|
|
- //$info = info_domain_image($info,['avatar','cover_image','photo_images']);
|
|
|
+
|
|
|
+ $info = info_domain_image($info,['avatar']);
|
|
|
+
|
|
|
+ //实名过了才行
|
|
|
+ $info['truename'] = $info['idcard_status'] == 1 ? $info['truename'] : '';
|
|
|
+ $info['alipay_account'] = $info['idcard_status'] == 1 ? $info['alipay_account'] : '';
|
|
|
|
|
|
if($type == 'return'){
|
|
|
$info = array_merge($info, Token::get($this->auth->getToken())); //token 等多个字段
|
|
@@ -175,7 +182,7 @@ class User extends Api
|
|
|
|
|
|
//实名认证信息
|
|
|
public function idcard_confirm_info(){
|
|
|
- $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->find();
|
|
|
+ $check = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->order('id desc')->find();
|
|
|
$this->success('success',$check);
|
|
|
}
|
|
|
|
|
@@ -184,16 +191,17 @@ class User extends Api
|
|
|
$truename = input('truename','');
|
|
|
$idcard = input('idcard','');
|
|
|
$idcard_images = input('idcard_images','');
|
|
|
+ $alipay_account = input('alipay_account','');
|
|
|
|
|
|
- if(empty($truename) || empty($idcard) || empty($idcard_images)){
|
|
|
+ if(empty($truename) || empty($idcard) || empty($idcard_images) || empty($alipay_account)){
|
|
|
$this->error('实名认证信息必填');
|
|
|
}
|
|
|
|
|
|
- if($this->auth->idcardstatus == 1){
|
|
|
+ if($this->auth->idcard_status == 1){
|
|
|
$this->error('您已经完成实名认证');
|
|
|
}
|
|
|
|
|
|
- if($this->auth->idcardstatus == 0){
|
|
|
+ if($this->auth->idcard_status == 0){
|
|
|
$this->error('您已经提交实名认证,请等待审核');
|
|
|
}
|
|
|
|
|
@@ -215,17 +223,17 @@ class User extends Api
|
|
|
'truename' => $truename,
|
|
|
'idcard' => $idcard,
|
|
|
'idcard_images' => $idcard_images,
|
|
|
+ 'alipay_account' => $alipay_account,
|
|
|
'status' => 0,
|
|
|
'createtime' => time(),
|
|
|
'updatetime' => time(),
|
|
|
];
|
|
|
|
|
|
//更新
|
|
|
+ $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['idcard_status'=>0]);
|
|
|
if(!empty($check)){
|
|
|
- $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['idcardstatus'=>0]);
|
|
|
$rs = Db::name('user_idconfirm')->where('id',$check['id'])->update($data);
|
|
|
}else{
|
|
|
- $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['idcardstatus'=>0]);
|
|
|
$rs = Db::name('user_idconfirm')->insertGetId($data);
|
|
|
}
|
|
|
|
|
@@ -327,22 +335,30 @@ class User extends Api
|
|
|
* 修改手机号
|
|
|
*
|
|
|
* @ApiMethod (POST)
|
|
|
- * @param string $mobile 手机号
|
|
|
+ * @param string $mobile 手机号
|
|
|
* @param string $captcha 验证码
|
|
|
*/
|
|
|
public function changemobile()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
- $mobile = $this->request->post('mobile');
|
|
|
- $captcha = $this->request->post('captcha');
|
|
|
- if (!$mobile || !$captcha) {
|
|
|
+ $oldcaptcha = $this->request->request('oldcaptcha');
|
|
|
+ $mobile = $this->request->request('mobile');
|
|
|
+ $captcha = $this->request->request('captcha');
|
|
|
+ if (!$oldcaptcha || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
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'));
|
|
|
+ if($user->mobile == $mobile){
|
|
|
+ $this->error('新手机号不能与旧手机号相同');
|
|
|
+ }
|
|
|
+ if (\app\common\model\User::where('mobile', $mobile)->find()) {
|
|
|
+ $this->error(__('Mobile already exist'));
|
|
|
+ }
|
|
|
+ $result = Sms::check($user->mobile, $oldcaptcha, 'changemobile');
|
|
|
+ if (!$result) {
|
|
|
+ $this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
@@ -354,6 +370,7 @@ class User extends Api
|
|
|
$user->mobile = $mobile;
|
|
|
$user->save();
|
|
|
|
|
|
+ Sms::flush($user->mobile, 'changemobile');
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
$this->success();
|
|
|
}
|
|
@@ -400,7 +417,8 @@ class User extends Api
|
|
|
*/
|
|
|
public function resetpwd()
|
|
|
{
|
|
|
- $type = $this->request->post("type");
|
|
|
+ //$type = $this->request->post("type");
|
|
|
+ $type = 'mobile';
|
|
|
$mobile = $this->request->post("mobile");
|
|
|
$email = $this->request->post("email");
|
|
|
$newpassword = $this->request->post("newpassword");
|
|
@@ -444,4 +462,35 @@ class User extends Api
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改密码
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $newpassword 新密码
|
|
|
+ * @param string $oldpassword 旧密码
|
|
|
+ */
|
|
|
+ public function changepwd(){
|
|
|
+ $newpassword = input('post.newpassword');
|
|
|
+ $oldpassword = input('post.oldpassword','');
|
|
|
+
|
|
|
+ if (!$newpassword) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ if($this->auth->password && empty($oldpassword)){
|
|
|
+ $this->error('原密码必填');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($this->auth->password)){
|
|
|
+ $ret = $this->auth->changepwd($newpassword, '', true);
|
|
|
+ }else{
|
|
|
+ $ret = $this->auth->changepwd($newpassword,$oldpassword,false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($ret) {
|
|
|
+ $this->success(__('Reset password successful'));
|
|
|
+ } else {
|
|
|
+ $this->error($this->auth->getError());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|