|
@@ -140,8 +140,13 @@ class User extends Api
|
|
|
/**
|
|
|
* 第三方登录
|
|
|
* @ApiMethod (POST)
|
|
|
- * @param string $platform 平台名称
|
|
|
- * @param string $code Code码
|
|
|
+ * @ApiParams (name="code", type="string", required=true, description="code码")
|
|
|
+ * @ApiReturnParams (name=code,type="integer",description=错误码:0=失败1=成功401=未登录403=没有权限)
|
|
|
+ * @ApiReturnParams (name=msg,type="string",description=提示信息)
|
|
|
+ * @ApiReturnParams (name=data,type="array",description=要返回的数据)
|
|
|
+ * @ApiReturnParams (name=data.return_type,type="integer",description=返回类型:1=登录成功2=授权成功)
|
|
|
+ * @ApiReturnParams (name=data.token,type="string",description=token值(返回类型为1时返回的值))
|
|
|
+ * @ApiReturnParams (name=data.openid,type="string",description=token值(返回类型为2时返回的值))
|
|
|
*/
|
|
|
public function third()
|
|
|
{
|
|
@@ -160,16 +165,21 @@ class User extends Api
|
|
|
$user = \app\common\model\User::getByOpenid($openid);
|
|
|
if($user){
|
|
|
//如果已经有账号则直接登录
|
|
|
- $ret = $this->auth->direct($user->id);
|
|
|
+ $this->auth->direct($user->id);
|
|
|
+ $data = ['return_type'=>1,'token' => $this->auth->getUserinfo()['token']];
|
|
|
+ $this->success(__('Logged in successful'), $data);
|
|
|
+ }else{
|
|
|
+ $data = ['return_type'=>2,'openid' => $openid];
|
|
|
+ $this->success('授权成功', $data);
|
|
|
}
|
|
|
- $loginret = \addons\third\library\Service::connect($platform, $result);
|
|
|
+ /*$loginret = \addons\third\library\Service::connect($platform, $result);
|
|
|
if ($loginret) {
|
|
|
$data = [
|
|
|
'userinfo' => $this->auth->getUserinfo(),
|
|
|
'thirdinfo' => $result
|
|
|
];
|
|
|
$this->success(__('Logged in successful'), $data);
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
$this->error(__('Operation failed'), $url);
|
|
|
}
|