...
|
...
|
@@ -2,67 +2,69 @@ |
|
|
|
|
|
const Promise = require('bluebird');
|
|
|
const co = Promise.coroutine;
|
|
|
const UserData=require('../models/UserData');
|
|
|
const moment =require('moment');
|
|
|
const UserData = require('../models/UserData');
|
|
|
const moment = require('moment');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const index=(req, res, next)=>{
|
|
|
const index = (req, res, next)=>{
|
|
|
let uid = '8041246';// req.user.uid;
|
|
|
co(function*(){
|
|
|
let vipInfo=yield UserData.getVIPInfoByUid(uid);
|
|
|
let data=vipInfo.data,proportion='0%';
|
|
|
|
|
|
console.info(data.current_total_cost);
|
|
|
if(+data.next_need_cost!=0){
|
|
|
proportion= Math.floor(data.current_year_cost*100/data.next_need_cost);
|
|
|
proportion=proportion>100?100:proportion;
|
|
|
proportion=proportion+'%';
|
|
|
co(function*() {
|
|
|
let vipInfo = yield UserData.getVIPInfoByUid(uid);
|
|
|
|
|
|
let data = vipInfo.data, proportion = '0%';
|
|
|
|
|
|
if (+data.next_need_cost !== 0) {
|
|
|
proportion = Math.floor(data.current_year_cost * 100 / data.next_need_cost);
|
|
|
proportion = proportion > 100 ? 100 : proportion;
|
|
|
proportion = proportion + '%';
|
|
|
}
|
|
|
|
|
|
let remainDays=Math.floor(((+data.vip_end_time)*1000-Date.now())/86400000);
|
|
|
let remainDays = Math.floor(((+data.vip_end_time) * 1000 - Date.now()) / 86400000);
|
|
|
|
|
|
// let preferences={};
|
|
|
// enjoyPreferences=data.enjoy_preferential;
|
|
|
|
|
|
if(data.enjoy_preferential){
|
|
|
data.enjoy_preferential=data.enjoy_preferential.map(function(item,inex){
|
|
|
if (data.enjoy_preferential) {
|
|
|
data.enjoy_preferential = data.enjoy_preferential.map(function(item) {
|
|
|
return {
|
|
|
id:item.id,
|
|
|
favTxt:item.title,
|
|
|
imgType:helpers.https(item.pic),
|
|
|
description:item.description
|
|
|
}
|
|
|
id: item.id,
|
|
|
favTxt: item.title,
|
|
|
imgType: helpers.https(item.pic),
|
|
|
description: item.description
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
let isVip = data.current_vip_level > 0 ? true : false;
|
|
|
|
|
|
let vip={
|
|
|
title:data.current_vip_title,
|
|
|
level:data.current_vip_level,
|
|
|
totalCost:(+data.current_total_cost).toFixed(2),
|
|
|
vipLevel:data.next_vip_title,
|
|
|
nextLevel:data.next_vip_level,
|
|
|
nextCost:(+data.next_need_cost).toFixed(2),
|
|
|
list:data.enjoy_preferential,
|
|
|
yearCost:(+data.current_year_cost).toFixed(2),
|
|
|
balan:(+data.upgrade_need_cost).toFixed(2),
|
|
|
proportion:proportion,
|
|
|
reach:moment(data.vip_reach_time*1000).format("YYYY-MM-DD"),
|
|
|
valid:moment(data.vip_start_time*1000).format("YYYY-MM-DD"),
|
|
|
end:moment(data.vip_end_time*1000).format("YYYY-MM-DD"),
|
|
|
remainDays:remainDays,
|
|
|
platinum:data.upgrade_need_cost>0?false:true,
|
|
|
doubtLevel:isVip,
|
|
|
let vip = {
|
|
|
title: data.current_vip_title,
|
|
|
level: data.current_vip_level,
|
|
|
totalCost: (+data.current_total_cost).toFixed(2),
|
|
|
vipLevel: data.next_vip_title,
|
|
|
nextLevel: data.next_vip_level,
|
|
|
nextCost: (+data.next_need_cost).toFixed(2),
|
|
|
list: data.enjoy_preferential,
|
|
|
yearCost: (+data.current_year_cost).toFixed(2),
|
|
|
balan: (+data.upgrade_need_cost).toFixed(2),
|
|
|
proportion: proportion,
|
|
|
reach: moment(data.vip_reach_time * 1000).format('YYYY-MM-DD'),
|
|
|
valid: moment(data.vip_start_time * 1000).format('YYYY-MM-DD'),
|
|
|
end: moment(data.vip_end_time * 1000).format('YYYY-MM-DD'),
|
|
|
remainDays: remainDays,
|
|
|
platinum: data.upgrade_need_cost > 0 ? false : true,
|
|
|
doubtLevel: isVip,
|
|
|
commonVip: !isVip
|
|
|
}
|
|
|
};
|
|
|
|
|
|
vip.morePreferences = helpers.urlFormat('/help', {category_id: 91});
|
|
|
|
|
|
console.info(vip);
|
|
|
res.render("vip",vip);
|
|
|
res.render('vip', vip);
|
|
|
|
|
|
})().catch(next);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
index
|
...
|
...
|
|