garyvv /
node-sharp
| 1 | const ServiceSession = require('../../services/catering/session') |
||
| 2 | const Validate = require('request-validate'); |
||
| 3 | const Response = require('../../util/response'); |
||
| 4 | const Config = require('../../../config/config') |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 5 | |||
| 6 | module.exports = { |
||
| 7 | /** |
||
| 8 | * @api {post} /api/catering/v1/sessions 用户微信登陆 |
||
| 9 | * @apiGroup session |
||
| 10 | * @apiPermission guest |
||
| 11 | * @apiParam {String} wx_js_code 小程序js_code |
||
| 12 | * @apiParam {String} wx_encrypted_data 小程序用户加密数据 |
||
| 13 | * @apiParam {String} wx_iv 小程序微信iv |
||
| 14 | * @apiParam {String} store_id 访问的小程序id,从header传递 |
||
| 15 | * @apiVersion 1.0.0 |
||
| 16 | * @apiSuccessExample {json} Visual Preview: |
||
| 17 | { |
||
| 18 | "code": 200, |
||
| 19 | "message": "请求成功", |
||
| 20 | "data": { |
||
| 21 | "id": 2, |
||
| 22 | "username": "oTj1As__sB0-n5qv8Cs5Le99k1jk", |
||
| 23 | "unionid": "oTj1As__sB0-n5qv8Cs5Le99k1jk", |
||
| 24 | "nickname": "大飞", |
||
| 25 | "avatar": "https://wx.qlogo.cn/mmopen/vi_32/2I8gWeWUwNEXSNXaMVAmaCm48ibXBcCPWFc7pYT3b1XXD5KdkIIzd4Vyyoc3UHQQ2OgOFsialBJHv4MsI3YgHaCA/0", |
||
| 26 | "user_balance": 0, |
||
| 27 | "status": 1, |
||
| 28 | "uid": 2, |
||
| 29 | "gender": "0", |
||
| 30 | "token": "1102e330-07bf-11e8-a078-1ff77849336d", |
||
| 31 | "wx_openid": "oAXj6jnk9PEyDlTZRxktZ3kfUifo" |
||
| 32 | } |
||
| 33 | } |
||
| 34 | */ |
||
| 35 | wxLogin:async function (ctx, next) { |
||
|
0 ignored issues
–
show
|
|||
| 36 | Validate(ctx.input, { |
||
| 37 | // 'wx_js_code': 'required', |
||
| 38 | // 'wx_encrypted_data': 'required', |
||
| 39 | // 'wx_iv': 'required', |
||
| 40 | 'code': 'required', |
||
| 41 | }) |
||
| 42 | let storeId = ctx.header['store-id'] |
||
|
0 ignored issues
–
show
|
|||
| 43 | let config = ctx.header['mina-source'] |
||
| 44 | |||
| 45 | let result = await ServiceSession.wxLogin(ctx.input.code, config) |
||
| 46 | return Response.output(ctx, result); |
||
| 47 | }, |
||
| 48 | } |