提交 7e6fecb6 编写于 作者: 雪洛's avatar 雪洛

feat: set user access token, set session key

上级 1122a86c
...@@ -35,14 +35,14 @@ async function saveQQUserKey ({ ...@@ -35,14 +35,14 @@ async function saveQQUserKey ({
} }
switch (qqPlatform) { switch (qqPlatform) {
case 'mp': case 'mp':
await this.uniOpenBridge.setUserKey(keyObj, { await this.uniOpenBridge.setSessionKey(keyObj, {
session_key: sessionKey session_key: sessionKey
}) })
break break
case 'app': case 'app':
case 'h5': case 'h5':
case 'web': case 'web':
await this.uniOpenBridge.setUserKey(keyObj, { await this.uniOpenBridge.setUserAccessToken(keyObj, {
access_token: accessToken, access_token: accessToken,
access_token_expired: accessTokenExpired access_token_expired: accessTokenExpired
}, Math.floor((accessTokenExpired - Date.now()) / 1000)) }, Math.floor((accessTokenExpired - Date.now()) / 1000))
...@@ -126,7 +126,8 @@ async function getQQCache ({ ...@@ -126,7 +126,8 @@ async function getQQCache ({
const openid = getQQOpenid.call(this, { const openid = getQQOpenid.call(this, {
userRecord userRecord
}) })
const userKey = await this.uniOpenBridge.getUserKey({ const getCacheMethod = qqPlatform === 'mp' ? 'getSessionKey' : 'getUserAccessToken'
const userKey = await this.uniOpenBridge[getCacheMethod]({
dcloudAppid: appId, dcloudAppid: appId,
platform: qqPlatform + '-qq', platform: qqPlatform + '-qq',
openid openid
......
...@@ -67,14 +67,14 @@ async function saveWeixinUserKey ({ ...@@ -67,14 +67,14 @@ async function saveWeixinUserKey ({
} }
switch (weixinPlatform) { switch (weixinPlatform) {
case 'mp': case 'mp':
await this.uniOpenBridge.setUserKey(keyObj, { await this.uniOpenBridge.setSessionKey(keyObj, {
session_key: sessionKey session_key: sessionKey
}) })
break break
case 'app': case 'app':
case 'h5': case 'h5':
case 'web': case 'web':
await this.uniOpenBridge.setUserKey(keyObj, { await this.uniOpenBridge.setUserAccessToken(keyObj, {
access_token: accessToken, access_token: accessToken,
refresh_token: refreshToken, refresh_token: refreshToken,
access_token_expired: accessTokenExpired access_token_expired: accessTokenExpired
...@@ -162,7 +162,8 @@ async function getWeixinCache ({ ...@@ -162,7 +162,8 @@ async function getWeixinCache ({
const openid = getWeixinOpenid.call(this, { const openid = getWeixinOpenid.call(this, {
userRecord userRecord
}) })
const userKey = await this.uniOpenBridge.getUserKey({ const getCacheMethod = weixinPlatform === 'mp' ? 'getSessionKey' : 'getUserAccessToken'
const userKey = await this.uniOpenBridge[getCacheMethod]({
dcloudAppid: appId, dcloudAppid: appId,
platform: weixinPlatform + '-weixin', platform: weixinPlatform + '-weixin',
openid openid
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册