Authored by zhangxiaoru

shop

1 'use strict'; 1 'use strict';
2 2
3 const shopModel = require('../models/shopCollect'), 3 const shopModel = require('../models/shopCollect'),
4 - headerModel = require('../../../doraemon/models/header'); 4 + headerModel = require('../../../doraemon/models/header'),
  5 + _ = require('lodash');
5 6
6 const crypto = global.yoho.crypto; 7 const crypto = global.yoho.crypto;
7 8
8 const shopIndex = (req, res) => { 9 const shopIndex = (req, res) => {
9 let isApp = req.query.app_version || req.query.appVersion || false; 10 let isApp = req.query.app_version || req.query.appVersion || false;
10 - let uid = req.user.uid; 11 + let uid = req.user.uid || req.query.uid;
11 let parameter = {}; 12 let parameter = {};
12 13
13 if (!isApp) { 14 if (!isApp) {
@@ -17,7 +18,7 @@ const shopIndex = (req, res) => { @@ -17,7 +18,7 @@ const shopIndex = (req, res) => {
17 }) 18 })
18 }; 19 };
19 } else { 20 } else {
20 - uid = crypto.encryption('', req.query.uid + ''); 21 + uid = crypto.encryption('', uid + '');
21 parameter = { 22 parameter = {
22 appVersion: true, 23 appVersion: true,
23 uid: uid 24 uid: uid
@@ -47,7 +48,7 @@ const shopNav = (req, res, next) => { @@ -47,7 +48,7 @@ const shopNav = (req, res, next) => {
47 48
48 49
49 const shopList = (req, res, next) => { 50 const shopList = (req, res, next) => {
50 - let uid = req.query.uid || req.user.uid || ''; 51 + let uid = req.query.uid ? _.trim(crypto.decrypt('', req.query.uid)) : req.user.uid;
51 let tabName = req.query.tabName; 52 let tabName = req.query.tabName;
52 53
53 shopModel.shopList(uid, tabName).then((result) => { 54 shopModel.shopList(uid, tabName).then((result) => {
@@ -57,7 +58,7 @@ const shopList = (req, res, next) => { @@ -57,7 +58,7 @@ const shopList = (req, res, next) => {
57 58
58 // 获取文章收藏状态 59 // 获取文章收藏状态
59 const shopFav = (req, res, next) => { 60 const shopFav = (req, res, next) => {
60 - let uid = req.query.uid || req.user.uid || ''; 61 + let uid = req.query.uid ? _.trim(crypto.decrypt('', req.query.uid)) : req.user.uid;
61 let shopIds = req.query.shopIds; 62 let shopIds = req.query.shopIds;
62 63
63 shopModel.shopFav(uid, shopIds).then((result) => { 64 shopModel.shopFav(uid, shopIds).then((result) => {
@@ -390,8 +390,11 @@ const favoriteBrand = (req, res, next) => { @@ -390,8 +390,11 @@ const favoriteBrand = (req, res, next) => {
390 390
391 let url = helpers.urlFormat('/signin.html') + '?refer=' + refer; 391 let url = helpers.urlFormat('/signin.html') + '?refer=' + refer;
392 392
  393 +
  394 +
393 if (appVersion && appVersion !== 'false') { 395 if (appVersion && appVersion !== 'false') {
394 uid = req.query.uid ? crypto.decrypt('', req.query.uid) : req.cookies.appUid; 396 uid = req.query.uid ? crypto.decrypt('', req.query.uid) : req.cookies.appUid;
  397 + uid = _.trim(uid);
395 398
396 if (!uid || uid === 'undefined') { 399 if (!uid || uid === 'undefined') {
397 uid = _getUidFromUserAgent(req); 400 uid = _getUidFromUserAgent(req);
@@ -119,7 +119,7 @@ function shopListData(tabName, stoping) { @@ -119,7 +119,7 @@ function shopListData(tabName, stoping) {
119 id: shopId, 119 id: shopId,
120 opt: opt, 120 opt: opt,
121 type: 'shop', 121 type: 'shop',
122 - uid: uid, 122 + uid: window.queryString.uid || uid,
123 appVersion: appVersion 123 appVersion: appVersion
124 }, 124 },
125 xhrFields: { 125 xhrFields: {