...
|
...
|
@@ -8,6 +8,8 @@ const Promise = require('bluebird'); |
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const MeGiftAPi = require('./me-gift-api');
|
|
|
const setPager = require(`${global.utils}/pager`).setPager;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -47,7 +49,8 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
getList(params, uid) {
|
|
|
let status = 1;
|
|
|
|
|
|
params.type = params.type > -1 && params.type < 4 ? params.type : 0;
|
|
|
params.type = Number(params.type > -1 && params.type < 4 ? params.type : 0);
|
|
|
params.page = Number(params.page) || 1;
|
|
|
|
|
|
switch (params.type) {
|
|
|
case 1: status = 3; break;
|
...
|
...
|
@@ -57,11 +60,22 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
return Promise.all([
|
|
|
this.meGiftAPi.getList(uid, status),
|
|
|
this.meGiftAPi.getList(uid, status, params.page),
|
|
|
this.verifyBinMobile(uid)
|
|
|
]).then(rlist => {
|
|
|
let giftData = {};
|
|
|
|
|
|
giftData.data = _.get(rlist[0], 'data.giftCardInfoBOList', []);
|
|
|
giftData.pager = Object.assign({
|
|
|
count: _.get(rlist[0], 'data.total', 0),
|
|
|
curPage: params.page,
|
|
|
totalPages: _.get(rlist[0], 'data.pageSize', 0)
|
|
|
}, setPager(_.get(rlist[0], 'data.pageSize', 0), {
|
|
|
page: params.page
|
|
|
}));
|
|
|
|
|
|
return {
|
|
|
giftData: giftData,
|
|
|
userInfo: rlist[1],
|
|
|
tabs: this.headTab(params)
|
|
|
};
|
...
|
...
|
@@ -76,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
// 礼品卡列表
|
|
|
verifyBinMobile(uid) {
|
|
|
let userInfo = {
|
|
|
isBinMobile: _.get(this.ctx, 'req.user.isBinMobile', false)
|
|
|
isBinMobile: _.get(this.ctx, 'req.session.isBinMobile', false)
|
|
|
};
|
|
|
|
|
|
if (userInfo.isBinMobile) {
|
...
|
...
|
@@ -85,12 +99,22 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
return this.meGiftAPi.getProfile(uid).then(lres => {
|
|
|
lres = _.get(lres, 'data', {});
|
|
|
|
|
|
let isBinMobile = Number(!!lres.verify_mobile);
|
|
|
|
|
|
_.set(this.ctx, 'req.session.isBinMobile', isBinMobile);
|
|
|
|
|
|
return Object.assign({}, userInfo, {
|
|
|
isBinMobile: Number(!!lres.verify_mobile),
|
|
|
isBinMobile: isBinMobile,
|
|
|
email: lres.verify_email,
|
|
|
mobile: lres.verify_mobile
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 激活礼品卡
|
|
|
activateGift(params, uid) {
|
|
|
return this.meGiftAPi.activateGift(uid, params.cardCode, crypto.encryption('yoho9646yoho9646', params.cardPwd));
|
|
|
}
|
|
|
|
|
|
}; |
...
|
...
|
|