Showing
2 changed files
with
13 additions
and
9 deletions
@@ -4,12 +4,12 @@ | @@ -4,12 +4,12 @@ | ||
4 | 4 | ||
5 | const countModel = require('../models/count'); | 5 | const countModel = require('../models/count'); |
6 | 6 | ||
7 | -let cartCount = (req, res, next) => { | 7 | +const cartCount = (req, res, next) => { |
8 | 8 | ||
9 | let uid = req.user.uid; | 9 | let uid = req.user.uid; |
10 | let shoppingKey = req.cookies._SPK || ''; | 10 | let shoppingKey = req.cookies._SPK || ''; |
11 | 11 | ||
12 | - countModel.cartCount(uid, shoppingKey).then((result) => { | 12 | + req.ctx(countModel).cartCount(uid, shoppingKey).then((result) => { |
13 | res.json(result); | 13 | res.json(result); |
14 | }).catch(next); | 14 | }).catch(next); |
15 | }; | 15 | }; |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const api = global.yoho.API; | 3 | +class cartCountModel extends global.yoho.BaseModel { |
4 | + constructor(ctx) { | ||
5 | + super(ctx); | ||
6 | + } | ||
4 | 7 | ||
5 | -const cartCount = (uid, shoppingKey) => { | 8 | + cartCount(uid, shoppingKey) { |
6 | let params = { | 9 | let params = { |
7 | method: 'app.Shopping.count' | 10 | method: 'app.Shopping.count' |
8 | }; | 11 | }; |
@@ -23,11 +26,12 @@ const cartCount = (uid, shoppingKey) => { | @@ -23,11 +26,12 @@ const cartCount = (uid, shoppingKey) => { | ||
23 | }); | 26 | }); |
24 | } | 27 | } |
25 | 28 | ||
26 | - return api.get('', params).then((result) => { | 29 | + return this.get({ |
30 | + data: params | ||
31 | + }).then((result) => { | ||
27 | return result; | 32 | return result; |
28 | }); | 33 | }); |
29 | -}; | 34 | + } |
35 | +} | ||
30 | 36 | ||
31 | -module.exports = { | ||
32 | - cartCount | ||
33 | -}; | 37 | +module.exports = cartCountModel; |
-
Please register or login to post a comment