Authored by htoooth

add api

@@ -6,6 +6,10 @@ const cache = global.yoho.cache; @@ -6,6 +6,10 @@ const cache = global.yoho.cache;
6 const sign = global.yoho.sign; 6 const sign = global.yoho.sign;
7 const api = global.yoho.API; 7 const api = global.yoho.API;
8 8
  9 +const Promise = require('bluebird');
  10 +
  11 +const cartApi = require('./cart-api');
  12 +
9 const Auth = { 13 const Auth = {
10 signin(type, area, profile, password, shoppingKey) { 14 signin(type, area, profile, password, shoppingKey) {
11 let _that = this; 15 let _that = this;
@@ -108,7 +112,7 @@ const Auth = { @@ -108,7 +112,7 @@ const Auth = {
108 return api.get('', param); 112 return api.get('', param);
109 }, 113 },
110 syncUserSession(uid, req, res) { 114 syncUserSession(uid, req, res) {
111 - return Auth.profile(uid).then((userInfo) => { 115 + return Promise.all([Auth.profile(uid), cartApi.goodsCount(uid)]).spread((userInfo, count) => {
112 let token = sign.makeToken(uid); 116 let token = sign.makeToken(uid);
113 let data = userInfo.data; 117 let data = userInfo.data;
114 let encryptionUid = aes.encryptionUid(data.uid); 118 let encryptionUid = aes.encryptionUid(data.uid);
  1 +/**
  2 + * Created by TaoHuang on 2016/9/28.
  3 + */
  4 +
  5 +const api = global.yoho.API;
  6 +
  7 +const goodsCount = (uid) => {
  8 + api.get('', {
  9 + method: 'app.Shopping.count',
  10 + uid: uid
  11 + });
  12 +};
  13 +
  14 +module.exports = {
  15 + goodsCount
  16 +};