// 登录接口
router.get('/login', authorizationMiddleware, controllers.login)
//访问前缀
const router = require('koa-router')({
prefix: '/weapp'
})
登录地址就是:https://xxx.qcloud.la/weapp/login
// 登录授权接口
module.exports = async (ctx, next) => {
// 通过 Koa 中间件进行登录之后
// 登录信息会被存储到 ctx.state.$wxInfo
// 具体查看:
if (ctx.state.$wxInfo.loginState) {
ctx.state.data = ctx.state.$wxInfo.userinfo
ctx.state.data['time'] = Math.floor(Date.now() / 1000)
}
}
网友评论