uni-app多平台开发,小程序登录、APP微信登录(uni.login)
如图所示:
uni.login使用静脉方法: 小程序使用uni.login,只能获取到code。 而H5+APP,使用uni.login。可以获取:openid、unionid、access_token等等 小程序: { "code":"0236CqpO0a3kb42L0erO0bZ0pO06Cqpv","errMsg":"login:ok" } H5+APP: { "code":"0236CqpO0a3kb42L0erO0bZ0pO06Cqpv","authResult":{"openid":"oRrdQtx7RJw6w6zz9iZhGrHvp6Qc","scope":"snsapi_userinfo","refresh_token":"19_SJM14bZu08inkTe8J_aDsfNxH5v1ftPkqV6cpTwEcrMsSNAxX0mMTdq8YA3udOx4FJe6hlynfYc-FC5B64NqrZ7ucjarnEHGhsEg9aGgS00","code":"0236CqpO0a3kb42L0erO0bZ0pO06Cqpv","unionid":"oU5Yyt3qmzKTnWAdYmzcNBRO16Kw","access_token":"19_prXs1gdV1YT5vorMMY_GhRts4iZtVUCmrnqL2AAMHMShjvgQEtb7BSnRpcPBRoDHQk1CNPFrx0Gckhc9tLqFlrmyCwE-_f7XZBUttOw22EY","expires_in":7200},"errMsg":"login:ok" }
然后,传参数给接口,即可
注意:有些安卓手机登录时,返回没带code。所以上面res.code $$ ... 需要去除
相关推荐
jieq 2020-11-09
ZZZhangbingyi 2020-08-26
Develop 2020-06-25
powderhose 2020-06-02
戴翔的技术 2020-05-27
郴州小程序 2020-05-26
sucheng 2020-05-25
powderhose 2020-05-04
zengfanpei 2020-05-04
cbao 2020-04-16
sucheng 2020-04-11
sucheng 2020-03-27
zengfanpei 2020-03-20
且听真言 2020-02-14
tianping 2020-01-18
hgzhang 2020-06-16
浪味仙 2020-06-10
cbao 2020-06-07