feat(App身份): 新增 app_bind / app_identity 两个接口
- POST /api/wechat/app_bind(需登录):code → sns/oauth2/access_token → 落 wechat_user(user_type='app'),绑定到当前 uid;openid 唯一索引冲突时拒绝抢绑 - GET /api/wechat/app_identity(需登录):返回注入 H5 的规范身份 ① 当前 uid 的 routine openid ② 当前 uid 的 app openid ③ app unionid 命中其他 uid 的 routine openid ④ 空(前端引导授权) - 供 App(Android 一期)在短信登录后取 openid,宿主注入规则不变 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -147,6 +147,34 @@ class Wechat
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* App 微信绑定(需登录)
|
||||
* body: code(uni.login provider=weixin 拿到的 code)
|
||||
* 返回 {openid, unionid}:绑定到当前登录 uid
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function appBind(Request $request)
|
||||
{
|
||||
[$code] = $request->postMore([['code', '']], true);
|
||||
$data = $this->services->appBindCode((int)$request->uid(), (string)$code);
|
||||
return app('json')->success('绑定成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* App 取规范身份(需登录)
|
||||
* 返回 {openid, unionid, source}:routine 优先,其次 app,最后按 unionid 反查
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function appIdentity(Request $request)
|
||||
{
|
||||
$data = $this->services->appIdentity((int)$request->uid());
|
||||
return app('json')->success('ok', $data);
|
||||
}
|
||||
|
||||
public function follow()
|
||||
{
|
||||
$data = $this->services->follow();
|
||||
|
||||
Reference in New Issue
Block a user