提交 06ea0cdd 编写于 作者: d-u-a's avatar d-u-a

bridge: 完善示例代码

上级 0a427de7
...@@ -173,7 +173,7 @@ const { ...@@ -173,7 +173,7 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
const key = { const key = {
dcloudAppid: '', dcloudAppid: '__UNI__xxx',
platform: 'mp-weixin' platform: 'mp-weixin'
} }
const value = { const value = {
...@@ -239,12 +239,13 @@ exports.main = async (event, context) => { ...@@ -239,12 +239,13 @@ exports.main = async (event, context) => {
const { const {
getUserAccessToken, getUserAccessToken,
setUserAccessToken setUserAccessToken,
removeUserAccessToken
} = require('uni-open-bridge-common') } = require('uni-open-bridge-common')
exports.main = async (event, context) => { exports.main = async (event, context) => {
const key = { const key = {
dcloudAppid: '', dcloudAppid: '__UNI__xxx',
platform: 'h5-weixin', platform: 'h5-weixin',
openid: '' openid: ''
} }
...@@ -259,6 +260,14 @@ exports.main = async (event, context) => { ...@@ -259,6 +260,14 @@ exports.main = async (event, context) => {
// 读取 (redis / 数据库) // 读取 (redis / 数据库)
let result1 = await getUserAccessToken(key) let result1 = await getUserAccessToken(key)
// 删除
await removeUserAccessToken(key)
// 删除后读取, 返回 null
let result2 = await getUserAccessToken(key)
console.log(result2) // null
return null return null
}; };
``` ```
...@@ -309,7 +318,7 @@ const { ...@@ -309,7 +318,7 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
const key = { const key = {
dcloudAppid: '', dcloudAppid: '__UNI__xxx',
platform: 'mp-weixin', platform: 'mp-weixin',
openid: '' openid: ''
} }
...@@ -385,7 +394,7 @@ const { ...@@ -385,7 +394,7 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
const key = { const key = {
dcloudAppid: '', dcloudAppid: '__UNI__xxx',
platform: 'mp-weixin', platform: 'mp-weixin',
openid: '', openid: '',
version: 1 version: 1
...@@ -418,11 +427,11 @@ exports.main = async (event, context) => { ...@@ -418,11 +427,11 @@ exports.main = async (event, context) => {
读取 ticket 读取 ticket
### setTicket(key: Object, value: Object, expiresIn: Number) #### setTicket(key: Object, value: Object, expiresIn: Number)
写入 ticket 写入 ticket
### removeTicket(key: Object) #### removeTicket(key: Object)
删除 ticket 删除 ticket
...@@ -458,7 +467,7 @@ const { ...@@ -458,7 +467,7 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
const key = { const key = {
dcloudAppid: '', dcloudAppid: '__UNI__xxx',
platform: 'h5-weixin' platform: 'h5-weixin'
} }
const value = { const value = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册