Authored by ccbikai

Merge branch 'master' into develop

... ... @@ -22,7 +22,6 @@ const memcached = require('yoho-connect-memcached');
const uuid = require('uuid');
const _ = require('lodash');
const pkg = require('./package.json');
const sign = require('./library/sign');
const cookie = require('./library/cookie');
const app = express();
... ... @@ -77,14 +76,8 @@ app.use((req, res, next) => {
// session 没有读取到的时候,从 cookie 读取 UID
if (!req.user.uid && req.cookies._UID) {
let uid = cookie.getUid(req);
// 校验 cookie 的 uid 有没有被修改
if (req.cookies._TOKEN === sign.makeToken(uid)) {
req.user.uid = uid;
}
req.user.uid = cookie.getUid(req);
}
next();
});
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const passport = require('passport');
const WeixinStrategy = require('passport-weixin-plus');
const WeixinStrategy = require('passport-weixin');
const config = require('../../config/common');
... ... @@ -15,14 +15,14 @@ let siteUrl = config.siteUrl.indexOf('//') === 0 ? 'http:' + config.siteUrl : co
/**
* wechat登录
*/
passport.use(new WeixinStrategy({
authorizationURL: 'https://open.weixin.qq.com/connect/oauth2/authorize',
tokenURL: 'https://api.weixin.qq.com/sns/oauth2/access_token',
passport.use('weixin', new WeixinStrategy({
clientID: config.thirdLogin.wechat.appID,
clientSecret: config.thirdLogin.wechat.appSecret,
callbackURL: `${siteUrl}/passport/login/wechat/callback`,
requireState: false,
requireState: true,
authorizationURL: 'https://open.weixin.qq.com/connect/oauth2/authorize',
scope: 'snsapi_userinfo'
}, (accessToken, refreshToken, profile, done) => {
}, function(accessToken, refreshToken, profile, done) {
done(null, profile);
}));
... ...
... ... @@ -7,6 +7,7 @@
const library = '../../../library';
const passport = require('passport');
const uuid = require('uuid');
const cookie = require(`${library}/cookie`);
const helpers = require(`${library}/helpers`);
const log = require(`${library}/logger`);
... ... @@ -42,7 +43,6 @@ function doPassportCallback(openId, nickname, sourceType, req, res) {
});
}
}).then((redirectTo) => {
console.log('redirectTo=', redirectTo);
return res.redirect(redirectTo);
}).catch((e) => {
log.error('频道页面渲染错误:' + JSON.stringify(e));
... ... @@ -64,7 +64,9 @@ const wechat = {
next();
},
login: (req, res, next) => {
return passport.authenticate('weixin')(req, res, next);
return passport.authenticate('weixin', {
state: uuid.v4()
})(req, res, next);
},
callback: (req, res, next) => {
passport.authenticate('weixin', (err, user) => {
... ... @@ -72,8 +74,8 @@ const wechat = {
log.error(`wechat authenticate error : ${JSON.stringify(err)}`);
return res.redirect(loginPage);
}
let nickname = user.displayName || user._json.nickname;
let openId = user.id || user._json.unionid;
let nickname = user._json.nickname || user.displayName;
let openId = user._json.unionid || user.id;
doPassportCallback(openId, nickname, 'wechat', req, res);
})(req, res, next);
... ...
... ... @@ -13,8 +13,8 @@ module.exports = {
port: 6001,
siteUrl: '//m.yohobuy.com',
domains: {
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/',
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/',
search: 'http://192.168.10.64:8080/yohosearch/'
},
useOneapm: false,
... ...
... ... @@ -4,6 +4,7 @@
* @return {[string]}
*/
'use strict';
const sign = require('./sign');
exports.getUid = (req) => {
const cookie = req.cookies._UID;
... ... @@ -21,6 +22,11 @@ exports.getUid = (req) => {
}
}
// 校验 cookie 的 uid 有没有被修改
if (req.cookies._TOKEN !== sign.makeToken(_uid)) {
_uid = 0;
}
return _uid;
};
... ...
... ... @@ -44,7 +44,7 @@
"morgan": "^1.7.0",
"oneapm": "^1.2.20",
"passport": "^0.3.2",
"passport-weixin-plus": "0.0.4",
"passport-weixin": "^0.1.0",
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.2",
... ...
... ... @@ -90,7 +90,7 @@ a{
.iconfont{
text-decoration: none;
font-style: normal;
font-size: 0.8rem;
font-size: 0.6rem;
font-family: "iconfont" !important;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.4px;
... ... @@ -126,29 +126,29 @@ a{
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.1);
@keyframes scale{
0%{
transform: scale(1);
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
transform: scale(1);
}
45%{
transform: scale(0.1);
opacity: 0.7;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
transform: scale(0.1);
}
80%{
transform: scale(1);
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
transform: scale(1);
}
}
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.1);
}
.loading-mask .loading{
position: absolute;
... ... @@ -168,13 +168,13 @@ a{
background: #fff;
}
.loading-mask .loading > div:nth-child(1){
animation: scale 0.75s (1 + 1) * 0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
animation: scale 0.75s 0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
}
.loading-mask .loading > div:nth-child(2){
animation: scale 0.75s (2 + 1) * 0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
animation: scale 0.75s 0.24s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
}
.loading-mask .loading > div:nth-child(3){
animation: scale 0.75s (3 + 1) * 0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
animation: scale 0.75s 0.36s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08);
}
/* stylelint-disable */
/**
... ... @@ -730,6 +730,7 @@ a{
height: auto;
color: #fff;
line-height: 1rem;
font-size: 0.35rem;
}
.homebuttom.boys{
background-image: linear-gradient(#323232, #414141);
... ... @@ -2478,10 +2479,10 @@ a{
height: 100%;
}
.break-code-page .banner-swiper{
height: 5rem;
height: auto;
}
.break-code-page .banner-swiper ul{
height: 5rem;
height: auto;
}
.break-code-page .swiper-size{
display: none;
... ... @@ -2601,10 +2602,10 @@ a{
background-color: #fff;
}
.sale-page .banner-top .swiper-container{
height: 5rem;
height: auto;
}
.sale-page .banner-top .swiper-container ul{
height: 5rem;
height: auto;
}
.sale-page #thumb-row{
overflow: hidden;
... ... @@ -2635,10 +2636,10 @@ a{
white-space: nowrap;
}
.sale-vip-page .banner-swiper{
height: 5rem;
height: auto;
}
.sale-vip-page .banner-swiper ul{
height: 5rem;
height: auto;
}
.discount-page{
overflow: hidden;
... ... @@ -5438,5 +5439,451 @@ a{
color: #fff;
background: #000;
}
.star-page{
background: #333;
}
.star-page a{
text-decoration: none;
outline: none;
color: #000;
}
.star-page a:link, .star-page a:visited, .star-page a:hover, .star-page a:actived{
color: #000;
}
.star-page *:focus{
outline: none;
}
.star-page .font-bold{
font-weight: bold;
}
.star-page .head-tab{
position: relative;
width: 100%;
height: 2.2rem;
background: #000;
z-index: 1;
transform-origin: top;
transform: scale(1, 1);
transition: transform 400ms;
}
.star-page .head-tab li{
width: 33.3%;
text-align: center;
float: left;
line-height: 2.2rem;
font-size: 0.75rem;
}
.star-page .head-tab li a{
color: #b0b0b0;
display: inline-block;
}
.star-page .head-tab li.cur a{
color: #fff;
}
.star-page .head-tab.hide-tab{
transform: scale(1, 0);
}
.star-page .banner-top{
width: 100%;
height: auto;
position: relative;
}
.star-page .banner-top .banner-swiper{
width: 100%;
height: auto;
overflow: hidden;
position: relative;
}
.star-page .banner-top .banner-swiper ul{
position: relative;
height: auto;
}
.star-page .banner-top .banner-swiper ul li{
float: left;
width: 100%;
height: auto;
}
.star-page .banner-top .banner-swiper ul img{
width: 100%;
height: 100%;
}
.star-page .banner-top .swiper-pagination{
position: absolute;
left: 0;
right: 0;
bottom: 0.5rem;
text-align: center;
z-index: 1;
}
.star-page .banner-top .swiper-pagination .pagination-inner{
display: inline-block;
}
.star-page .banner-top .swiper-pagination span{
display: inline-block;
width: 0.35rem;
height: 0.35rem;
background: #fff;
opacity: 0.5;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
margin: 0 0.25rem;
border-radius: 50%;
}
.star-page .banner-top .swiper-pagination .swiper-pagination-bullet-active{
background: #fff;
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
.star-page .avatar-swiper{
overflow: hidden;
margin-top: 0.75rem;
background: #000;
}
.star-page .avatar-swiper li{
float: left;
width: auto;
width: 2.75rem;
height: 2.75rem;
margin-top: 0.85rem;
background: #282828;
}
.star-page .avatar-swiper li span{
display: block;
width: 100%;
height: 100%;
}
.star-page .avatar-swiper .swiper-slide-active{
width: 4.5rem;
height: 4.5rem;
margin-top: 0;
}
.star-page .avatar-swiper .swiper-slide-prev, .star-page .avatar-swiper .swiper-slide-next{
width: 3.25rem;
height: 3.25rem;
margin-top: 0.675rem;
}
.star-page .avatar-swiper.avatar-clone{
margin-top: 0;
position: relative;
padding: 0.125rem 0;
z-index: 9;
background: #000;
}
.star-page .star-info{
margin-top: 0.75rem;
background: #000;
}
.star-page .star-info li{
float: left;
margin-bottom: 0.75rem;
}
.star-page .star-avatar{
width: 3.35rem;
padding-left: 0.75rem;
box-sizing: border-box;
float: left;
overflow: hidden;
}
.star-page .star-avatar .article-avatar-swiper{
width: 2.6rem;
overflow: hidden;
}
.star-page .star-avatar .rank-avatar{
width: 2.6rem;
height: 2.6rem;
border-radius: 50%;
float: left;
}
.star-page .star-avatar .name{
font-size: 0.6rem;
width: 100%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: #fff;
margin-top: 0.2rem;
float: left;
text-align: center;
}
.star-page .star-article{
width: 11.8rem;
position: relative;
border-radius: 0.2rem;
background: #282828;
float: left;
padding: 0.5rem 0.75rem;
box-sizing: border-box;
margin-left: 0.45rem;
}
.star-page .star-article .article-arrow{
position: absolute;
left: -0.325rem;
width: 0;
height: 0;
border-top: 0.25rem solid transparent;
border-bottom: 0.25rem solid transparent;
border-right: 0.325rem solid #282828;
}
.star-page .star-article .article-title{
font-size: 0.7rem;
line-height: 0.95rem;
color: #fff;
}
.star-page .star-article .artice-cont{
margin-top: 0.25rem;
}
.star-page .star-article .artice-cont p{
font-size: 0.45rem;
line-height: 0.725rem;
color: #969696;
}
.star-page .star-article .artice-imgs-area{
width: 100%;
overflow: hidden;
}
.star-page .star-article .artice-imgs-area img{
width: 6.65rem;
float: left;
margin: 0.625rem 0;
}
.star-page .star-article .artice-imgs{
margin: 0.625rem 0 0;
width: 62.5rem;
float: left;
overflow: hidden;
}
.star-page .star-article .artice-imgs li{
display: inline-block;
margin-left: 0.15rem;
position: relative;
}
.star-page .star-article .artice-imgs li:first{
margin-left: 0;
}
.star-page .star-article .artice-imgs img{
width: 3.25rem;
border-radius: 0.1rem;
}
.star-page .star-article .artice-imgs .img-size{
width: 1.25rem;
height: 0.65rem;
line-height: 0.7rem;
border-radius: 0.325rem;
background-color: rgba(0, 0, 0, 0.4);
color: #fff;
position: absolute;
right: 0.25rem;
bottom: 0.25rem;
font-size: 0.45rem;
}
.star-page .star-article .artice-imgs .pic-icon{
width: 0.475rem;
height: 0.375rem;
background-image: url(../img/sprite.guang.png);
background-position: 0px 0px;
background-size: 0.475rem 0.375rem;
display: inline-block;
margin: 0.15rem 0.1rem 0 0.2rem;
vertical-align: top;
}
.star-page .star-article .artice-o{
width: 100%;
float: left;
border-top: 1px solid #b0b0b0;
padding-top: 0.5rem;
}
.star-page .star-article .artice-o span{
font-size: 0.45rem;
color: #b0b0b0;
height: 0.55rem;
line-height: 0.55rem;
}
.star-page .star-article .artice-o span i{
display: inline-block;
margin-right: 0.125rem;
font-size: 0.55rem;
vertical-align: text-bottom;
}
.star-page .star-article .artice-o .time{
float: left;
}
.star-page .star-article .artice-o .see{
float: left;
margin-left: 0.75rem;
}
.star-page .star-article .artice-o .time-ico{
width: 0.6rem;
height: 0.6rem;
}
.star-page .star-article .artice-o .see-ico{
width: 0.775rem;
height: 0.6rem;
}
.star-page .view-area{
height: 100%;
position: relative;
}
.star-page .swiper-view{
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
.star-page .view-img{
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
z-index: 9;
}
.star-page .view-img li{
float: left;
}
.star-page .view-img li img{
width: 90%;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
}
.star-page .rank-avatar{
background-image: url('../img/guang/star/user-avatar.png');
background-repeat: no-repeat;
background-size: contain;
}
.star-page .loading-tip{
display: none;
text-align: center;
color: #ccc;
font-size: 0.3rem;
margin: 0.75rem 0;
}
.star-page .swiper-num{
width: 1.375rem;
display: none;
}
.star-index-bg{
background: #000;
}
.star-index-bg .star-page{
background: #000;
}
.star-page .special-list{
width: 100%;
height: auto;
overflow: hidden;
}
.star-page .special-list li{
width: 100%;
float: left;
background: #000;
margin-top: 0.75rem;
}
.star-page .special-list li img{
width: 100%;
}
.star-page .special-list li p{
width: 100%;
height: 2.2rem;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding: 0 0.85rem;
font-size: 0.85rem;
line-height: 2.2rem;
}
.star-page .special-list li a{
color: #fff;
}
.star-page .collocation-list, .star-page .detail-list{
width: 100%;
float: left;
}
.star-page .collocation-list li, .star-page .detail-list li{
float: left;
width: 100%;
margin-top: 0.75rem;
background: #000;
}
.star-page .collocation-list li .cont-area, .star-page .detail-list li .cont-area{
width: 100%;
box-sizing: border-box;
padding: 0.75rem;
}
.star-page .collocation-list li .cont-txt, .star-page .detail-list li .cont-txt{
font-size: 0.7rem;
line-height: 1.15rem;
color: #b0b0b0;
margin-top: 0.25rem;
}
.star-page .collocation-list li img, .star-page .detail-list li img{
width: 100%;
}
.star-page .collocation-list li .title, .star-page .detail-list li .title{
font-size: 1rem;
line-height: 1.2rem;
color: #fff;
width: 100%;
}
.star-page .count-area{
position: relative;
width: 100%;
height: 0.8rem;
}
.star-page .count-area span{
font-size: 0.6rem;
color: #b0b0b0;
height: 0.8rem;
line-height: 0.8rem;
}
.star-page .count-area span i{
display: inline-block;
margin-right: 0.125rem;
font-size: 0.6rem;
position: relative;
top: -0.05rem;
}
.star-page .count-area .time{
float: left;
}
.star-page .count-area .see{
float: left;
margin-left: 0.5rem;
}
.star-page .count-area .time-ico{
width: 0.6rem;
height: 0.6rem;
}
.star-page .count-area .see-ico{
width: 0.775rem;
height: 0.6rem;
}
.star-page .count-area .collection{
float: right;
}
.star-page .count-area .collected-ico{
width: 0.85rem;
height: 0.8rem;
vertical-align: text-bottom;
}
.star-page .count-area .collected{
color: #d62927;
}
.star-page .count-area .forward{
width: 1rem;
height: 0.7rem;
float: right;
margin-left: 1.125rem;
font-size: 0.6rem;
color: #b0b0b0;
height: 0.8rem;
line-height: 0.8rem;
}
.star-class-body{
background: #333;
width: 100%;
font: 0.3rem/1.5 Arial, '黑体';
float: left;
}
/*# sourceMappingURL=index.css.map */
... ...
This diff could not be displayed because it is too large.