Authored by zhangxiaoru

pulstar APP 获取不到 uid

... ... @@ -50,7 +50,8 @@ const shopNav = () => {
const banner = () => {
return service.get('operations/api/v5/resource/get', {
content_code: 'ec9eb72eae121fcd6c1b7d1de75caff1'
content_code: 'ec9eb72eae121fcd6c1b7d1de75caff1',
platform: 'iphone'
}, {
cache: true,
code: 200
... ...
... ... @@ -10,7 +10,8 @@ const optModel = require(`${mRoot}/opt`);
const brandModel = require(`${mRoot}/brand`);
const helpers = global.yoho.helpers;
const stringProcess = require(`${global.utils}/string-process`);
const crypto = global.yoho.crypto;
const _ = require('lodash');
/**
* [资讯文章点赞 (H5里显示点赞)]
... ... @@ -105,9 +106,10 @@ const favoriteBrand = (req, res, next) => {
/* 判断参数是否有效 */
let id = req.body.id,
opt = req.body.opt || 'ok',
uid = req.user.uid;
uid = req.user.uid || (req.body.uid && crypto.decrypt(null, req.body.uid)) || req.cookies.appUid;
if (!stringProcess.isNumeric(id) || !stringProcess.isNumeric(uid)) {
res.json(result);
return;
}
... ...
... ... @@ -11,6 +11,7 @@ const app = express();
const plustarModel = require(`${mRoot}/plustar`);
const htmlProcess = require(`${global.utils}/html-process`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const crypto = global.yoho.crypto;
let channels = {
boys: '1,3',
girl: '2,3',
... ... @@ -65,7 +66,7 @@ const getListData = (req, res, next) => {
const getDetailData = (req, res, next) => {
let id = req.query.id;
let uid = req.user.uid;
let uid = '';
let udid = req.sessionID || 'yoho';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let isApp = req.query.app_version || req.query.appVersion || false;
... ... @@ -74,6 +75,12 @@ const getDetailData = (req, res, next) => {
let userAgent = req.get('User-Agent');
let isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
if (req.yoho.isApp) {
uid = crypto.encryption('', req.query.uid + '');
} else {
uid = req.user.uid;
}
if (clientType.toLowerCase() === 'ios' && version) {
clientType = 'iphone';
} else if (clientType.toLowerCase() === 'android' && version) {
... ... @@ -99,7 +106,8 @@ const getDetailData = (req, res, next) => {
module: 'guang',
page: 'plustar-detail',
title: result.brandName,
ps: result
ps: result,
uid: uid
});
}
... ...
... ... @@ -182,7 +182,6 @@ const getNewProduct = (brandId, gender, url, isApp) => {
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html';
if (isApp) {
console.log(productUrl);
productUrl += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${list.product_skn}"}}`;
}
... ... @@ -309,25 +308,25 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
url = '//' + brandDomain + '.m.yohobuy.com';
}
if (isApp & !uid) {
if (isApp && !uid) {
jumpToApp = 1;
}
let likeUrl = helpers.urlFormat('/plustar/brandinfo', {
id: brandId
id: list.id
}, 'guang');
if (isApp) {
let $url = likeUrl;
$url += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ brandId + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + brandId + '"}},"priority":"Y"}}';
likeUrl += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ list.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + brandId + '"}},"priority":"Y"}}';
} else {
let $url = helpers.urlFormat('/signin.html', {refer: likeUrl});
likeUrl = helpers.urlFormat('/signin.html', {refer: likeUrl});
}
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
list = _.assign(list, {
likeUrl: likeUrl,
isLike: result[0],
infos: result[1],
newArrival: result[2],
... ...
... ... @@ -107,4 +107,6 @@
<input id="shareTitle" type="hidden" value="{{shareTitle}}">
<input id="shareDesc" type="hidden" value="{{shareDesc}}">
{{/ ps}}
<input type="hidden" name="uid" value="{{uid}}">
</div>
\ No newline at end of file
... ...
... ... @@ -16,15 +16,16 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
// api: 'http://api.yoho.yohoops.org/',
// service: 'http://service.yoho.yohoops.org/',
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -11,7 +11,8 @@ var $ = require('yoho-jquery'),
var $intro = $('#intro'),
$imt = $('#intro-more-txt'),
$infosContainer = $('#related-infos-container');
$infosContainer = $('#related-infos-container'),
uid = $('input[name="uid"]').val();
var info = require('./info');
... ... @@ -92,10 +93,9 @@ likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
//jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
if (jumpToApp === '1') {
return;
return false;
}
e.preventDefault();
... ... @@ -109,9 +109,11 @@ likeHammer.on('tap', function(e) {
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt
opt: opt,
uid: uid
},
success: function(data) {
console.log(data)
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
... ...
... ... @@ -11,7 +11,7 @@ const _EscapeMap = {lt: '<', gt: '>', nbsp: ' ', amp: '&', quot: '"'};
* [移除html标签]
*/
const removeHtml = (str) => {
return str.replace(/<[^>]+>/g, '');
return (str || '').replace(/<[^>]+>/g, '');
};
/**
... ...