Authored by zhangxiaoru

添加isStudent

'use strict';
const shareBuyModel = require('../models/share-buy'),
headerModel = require('../../../doraemon/models/header');
headerModel = require('../../../doraemon/models/header'),
co = require('bluebird').coroutine;
exports.index = (req, res, next) => {
let activityId = req.query.act_id || 2023,
isApp = req.yoho.isApp,
uid = req.user.uid;
req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(data => {
co(function* () {
let isStudent = yield req.ctx(shareBuyModel).checkStudent(uid);
let indexData = yield req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid, isStudent);
res.render('share-buy/share-buy', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
... ... @@ -17,15 +21,14 @@ exports.index = (req, res, next) => {
localCss: true,
width750: true,
title: '分享购',
userCouponBoList: data.userCouponBoList,
newsFlash: data.newsFlash,
rebeatUrl: data.rebeatUrl,
strategyUrl: data.strategyUrl,
banner: data.banner,
isStudent: data.isStudent
userCouponBoList: indexData.userCouponBoList,
newsFlash: indexData.newsFlash,
rebeatUrl: indexData.rebeatUrl,
strategyUrl: indexData.strategyUrl,
banner: indexData.banner,
isStudent: indexData.isStudent
});
}).catch(next);
})().catch(next);
};
exports.detail = (req, res, next) => {
... ...
... ... @@ -11,10 +11,10 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 首页数据
*/
shareIndex(activityId, isApp, uid) {
shareIndex(activityId, isApp, uid, isStudent) {
return api.all([this._CouponInfo(activityId, uid), this._redeatList(), this._banner(),
this._checkStudent(uid)]).then(result => {
return api.all([this._CouponInfo(activityId, uid, isStudent), this._redeatList(),
this._banner()]).then(result => {
const indexData = {
newsFlash: []
... ... @@ -23,9 +23,7 @@ module.exports = class extends global.yoho.BaseModel {
const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
if (result[3]) {
indexData.isStudent = parseInt(result[3].isStudent, 10) === 1 ? true : false;
}
indexData.isStudent = isStudent;
if (result[0] && result[0].data && result[0].data.userCouponBoList) {
_.forEach(result[0].data.userCouponBoList, function(val) {
... ... @@ -104,11 +102,12 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 首页获取优惠券信息
*/
_CouponInfo(activityId, uid) {
_CouponInfo(activityId, uid, isStudent) {
return api.get('', {
method: 'app.activity.getActivityCouponInfo',
activity_id: activityId,
uid: uid
uid: uid,
isStudent: isStudent
}, {
code: 200
}).then((result) => {
... ... @@ -195,19 +194,19 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 判断是不是学生
*/
_checkStudent(uid) {
checkStudent(uid) {
return api.get('', {
method: 'app.student.checkIsStudent',
uid: uid
}).then(result => {
let resu = {};
let isStudent;
if (result && result.data && result.code === 200) {
resu = result.data;
isStudent = parseInt(result.data.isStudent, 10) === 1 ? true : false;
}
return resu;
return isStudent;
});
}
... ...