예제 #1
0
 public function run()
 {
     $to_user_id = $this->getDataItem('user_id');
     if (!(is_numeric($to_user_id) && $to_user_id > 0)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户id不能为空.');
     }
     /**
      * 验证用户权限
      */
     /*if(!empty($this->parameters->userToken) && $this->verifyUserAuth() && $this->getUserAuth()->userId == $userid){
           return $this->errorLog(111, '请跳转我的问答.');
       }*/
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $to_user_id)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($to_user_id, 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($to_user_id, 1);
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     $this->verifyUserAuth(false);
     if ($user_id = $this->getUserAuth()->userId) {
         $info['is_follow'] = $UserFollow->is_follow($user_id, $to_user_id, 1) ? '1' : '0';
     } else {
         $info['is_follow'] = '0';
     }
     $this->setResult($info);
 }
예제 #2
0
 public function run()
 {
     $account = $this->getDataItem('account');
     // 验证电话号码格式
     $password = $this->getDataItem('password');
     $pushId = $this->getDataItem('push_id', '');
     // push id
     $osType = $this->getDataItem('os_type');
     //        $account = '18723568682';
     //        $password = '******';
     // 验证数据完整
     if (empty($account) || empty($password)) {
         $this->message = '账户名和密码都不能为空!';
     } else {
         if ($this->verifyAccount($account, $password)) {
             // 获取 user token
             if ($this->saveuserauth($this->apiAccessToken->id, $this->userInfo['user_id'])) {
                 $this->success = 1;
                 $this->message = '登录成功!';
                 $this->userToken = $this->getUserAuth()->userToken;
                 $this->saveUserPushId($this->userInfo['user_id'], $pushId, $osType);
                 $this->userInfo['user_mobile'] = $this->userInfo['bind_phone'] ?: $this->userInfo['user_account'];
                 $this->userInfo['user_cover'] = $this->userInfo['user_cover'] ? PicUrl::UserCover($this->userInfo['user_cover'], $this->getDi()) : '';
                 $this->userInfo['persional_sign'] = $this->userInfo['persional_sign'] ? unserialize(base64_decode($this->userInfo['persional_sign'])) : '';
                 // 获取城市信息
                 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
                 $city = $SysAreaZipDistrictPhonecode->getOne($this->userInfo['user_district']);
                 $this->userInfo['user_district'] = $city['FULL_NAME'] ?: '';
                 // 加入关注数和粉丝数
                 $UserFollow = new UserFollow();
                 $this->userInfo['follow_count'] = $UserFollow->getFollowCount($this->userInfo['user_id'], 1);
                 $this->userInfo['fans_count'] = $UserFollow->getToFollowCount($this->userInfo['user_id'], 1);
                 // 删除不要的字段
                 unset($this->userInfo['user_account'], $this->userInfo['user_password'], $this->userInfo['user_state'], $this->userInfo['user_addtime'], $this->userInfo['is_manage'], $this->userInfo['bind_phone']);
             } else {
                 $this->message = '获取User Token异常!';
             }
         }
     }
     if (!$this->userInfo) {
         // 登录失败依然保留字段
         $this->userInfo = ["user_id" => "", "user_nickname" => "", "user_mobile" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0];
     }
     $info = ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message];
     $info = array_merge($info, $this->userInfo);
     $this->setResult($info);
 }
예제 #3
0
 public function run()
 {
     // 验证用户权限
     if (!$this->verifyUserAuth()) {
         return false;
     }
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_id', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $this->getUserAuth()->userId)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1);
     $this->setResult($info);
 }
예제 #4
0
 public function run()
 {
     $type = $this->getDataItem('type');
     $openId = $this->getDataItem('openid');
     $nickname = $this->getDataItem('nickname');
     $cover = $this->getDataItem('cover');
     $otherData = $this->getDataItem('other_data');
     $pushId = $this->getDataItem('push_id');
     // push id
     $osType = $this->getDataItem('os_type');
     // 验证数据完整性
     if (empty($type) || empty($openId) || empty($nickname)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "业务参数不全.");
     }
     if (!in_array($type, ['weixin', 'weibo'])) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "类型不支持.");
     }
     $attrType = 101;
     if ($type == 'weibo') {
         $attrType = 102;
     }
     // 判断用户是否已经注册了
     $userId = $this->isRegister($attrType, $openId);
     if ($userId === false) {
         // 注册新账号
         $userId = $this->register($type, $attrType, $openId, $nickname, $cover, $otherData);
         if ($userId === false) {
             return;
         }
     }
     $info = [];
     // 获取 user token
     if ($this->saveUserAuth($this->apiAccessToken->id, $userId)) {
         $this->success = 1;
         $this->userid = $userId;
         $this->message = '登录成功!';
         $this->userToken = $this->getUserAuth()->userToken;
         $this->saveUserPushId($userId, $pushId, $osType);
         if ($model = UserBase::query()->where("user_id = {$userId}")->execute()->getFirst()) {
             $info = $model->toArray();
             $info['user_mobile'] = $info['bind_phone'] ?: $info['user_account'];
             if ($info['user_cover'] == 'default.png' && $attrType == 101) {
                 $info['user_cover'] = json_decode($otherData)->headimgurl;
             } else {
                 $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
             }
             $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
             // 获取城市信息
             $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
             $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
             $info['user_district'] = $city['FULL_NAME'] ?: '';
             // 加入关注数和粉丝数
             $UserFollow = new UserFollow();
             $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1);
             $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1);
             // 删除不要的字段
             unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']);
         }
     } else {
         $this->message = '获取User Token异常!';
     }
     if (!$info) {
         $info = ["user_id" => "", "user_nickname" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0];
     }
     $info = array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userid]);
     $this->setResult($info);
 }