文档
测试

获取微信授权地址

GET
/wechat/login_url

接口描述

获取需要用户跳转的授权url地址

请求参数

参数名
类型
描述
必填
path
String
登录之后跳转的页面
必填

响应参数

参数名
类型
描述
必填
code
Number
200
必填
msg
String
success
必填
data
必填
url
需要前端重定向的微信登录api
必填

说明 / 示例

## 请求示例 GET `/wechat/login_url?path=%2Fhome` ## 响应示例 #### 跳转url中的`state`字段就是传过去的`path`字段 ```json { "msg": "success", "code": 200, "data": { "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=http%3A%2F%2Fnba.bluewebgame.com%2Foauth_response.php&response_type=code&scope=snsapi_userinfo&state=%2Fhome#wechat_redirect" } } ``` ## 后续步骤 1. 前端定向到`data.url`完成用户同意授权 2. 微信带code回调服务器,并带有state参数(https://xxxxx/app/wechat/login?code=0816YzFa13RFzA0ib3Ia1OeJcO36YzF6&state=%2F) 3. 服务器获取用户信息后生成`token`字符串传给前端`http://url_to_web/#/?token=xxxx&expire=604800&path=%2Fhome`(expire:过期时间/秒)