...
|
...
|
@@ -3,19 +3,23 @@ |
|
|
* @author: leo <qi.li@yoho.cn>
|
|
|
* @date: 27/09/2017
|
|
|
*/
|
|
|
const _ = require('lodash');
|
|
|
const GET_COUPON_SUCCESS = '获取优惠券列表成功';
|
|
|
const RECEIVE_COUPON_SUCCESS = '成功领取优惠券';
|
|
|
const NEED_YH_AUTH = '请先授权登录有货';
|
|
|
const HELP_SUCCESS = '助力成功';
|
|
|
|
|
|
|
|
|
const couponExp = {
|
|
|
|
|
|
/**
|
|
|
* 优惠券列表
|
|
|
* @param req
|
|
|
* @param res
|
|
|
*/
|
|
|
couponList(req, res) {
|
|
|
req.session.t = true;
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: '获取优惠券列表成功'
|
|
|
message: GET_COUPON_SUCCESS
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -25,20 +29,20 @@ const couponExp = { |
|
|
* @param res
|
|
|
*/
|
|
|
receiveCoupon(req, res) {
|
|
|
let yoho_login = _.get(req.session, 'yoho_logged');
|
|
|
let yhAuth = req.session.yh_auth_logged;
|
|
|
let urlBefore = req.body.url_before_auth;
|
|
|
|
|
|
// TODO 已经登录 领取优惠券
|
|
|
if (yoho_login) {
|
|
|
if (yhAuth) {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: '成功领取优惠券'
|
|
|
message: RECEIVE_COUPON_SUCCESS
|
|
|
});
|
|
|
} else {
|
|
|
req.session.target_url = req.url;
|
|
|
req.session.url_before_auth = urlBefore;
|
|
|
|
|
|
res.json({
|
|
|
code: 401,
|
|
|
message: '请先授权登录有货'
|
|
|
message: NEED_YH_AUTH
|
|
|
});
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -50,11 +54,14 @@ const couponExp = { |
|
|
*/
|
|
|
yhLoginSuccess(req, res) {
|
|
|
let uid = req.query.yh_uid;
|
|
|
let url = req.session.url_before_auth;
|
|
|
|
|
|
req.session.yh_auth_uid = uid;
|
|
|
req.session.yh_auth_logged = true;
|
|
|
|
|
|
req.session.yoho_uid = uid;
|
|
|
req.session.yoho_coupon_exp_login = true;
|
|
|
delete req.session.url_before_auth;
|
|
|
|
|
|
res.status(301).redirect('/couponExp/receiveCoupon');
|
|
|
res.status(301).redirect(url);
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -65,7 +72,7 @@ const couponExp = { |
|
|
expandOne(req, res) {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: '助力成功'
|
|
|
message: HELP_SUCCESS
|
|
|
});
|
|
|
}
|
|
|
};
|
...
|
...
|
|