login.js 329 B

12345678910
  1. // 登录授权接口
  2. module.exports = async (ctx, next) => {
  3. // 通过 Koa 中间件进行登录之后
  4. // 登录信息会被存储到 ctx.state.$wxInfo
  5. // 具体查看:
  6. if (ctx.state.$wxInfo.loginState) {
  7. ctx.state.data = ctx.state.$wxInfo.userinfo
  8. ctx.state.data['time'] = Math.floor(Date.now() / 1000)
  9. }
  10. }