Authored by lijing

会员页优化

... ... @@ -155,10 +155,12 @@ exports.grade = (req, res, next) => {
pageFooter: true
};
indexModel.getGrade({
let param = {
uid: req.user.uid,
channel: req.query.channel || 1
}).then((result) => {
};
indexModel.getGrade(param).then((result) => {
res.render('vip-grade/vip-grade', Object.assign(result, responseData));
}).catch(next);
... ... @@ -185,10 +187,12 @@ exports.preferential = (req, res, next) => {
pageFooter: true
};
indexModel.getPreferential({
let param = {
uid: req.user.uid,
channel: req.query.channel || 1
}).then((result) => {
};
indexModel.getPreferential(param).then((result) => {
res.render('vip-grade/privilege', Object.assign(result, responseData));
}).catch(next);
... ...
... ... @@ -220,7 +220,7 @@ const delRecord = (uid, skn) => {
* 会员等级
* @param params
*/
const getGradeGrade = (channel, uid) => {
const getGradeGrade = (uid, channel) => {
return api.get('', {
method: 'app.passport.vip',
uid: uid,
... ... @@ -228,108 +228,119 @@ const getGradeGrade = (channel, uid) => {
}, {code: 200});
};
const getGradeUser = (channel, uid) => {
if (uid) {
return api.get('', {
method: 'app.passport.profile',
uid: uid,
channel: channel || 1
}, {code: 200});
}
const getGradeUser = (uid, channel) => {
return api.get('', {
method: 'app.passport.profile',
uid: uid,
channel: channel || 1
}, {code: 200});
};
const getGrade = (channel, uid) => {
const getGrade = (param) => {
if (param.uid) {
return api.all([
getGradeGrade(param.uid, param.channel),
getGradeUser(param.uid, param.channel)
]).then((result) => {
return api.all([
getGradeGrade(channel, uid),
getGradeUser(channel, uid)
]).then((result) => {
let resu = {
vipGrade: []
};
let resu = {
vipGrade: []
};
let enp = {};
let enp = {};
let obj = {
privilege: []
};
let obj = {
privilege: []
};
if (result[0] && result[0].data) {
if (result[0] && result[0].data) {
_.forEach(result[0].data.enjoy_preferential, function(val) {
_.forEach(result[0].data.enjoy_preferential, function(val) {
enp = {
description: val.description,
pic: val.pic,
title: val.title
};
enp = {
description: val.description,
pic: val.pic,
title: val.title
};
obj.privilege.push(enp);
obj.privilege.push(enp);
});
});
switch (result[0].data.current_vip_level) {
case '0':// 普通会员
obj = _.assign(obj, {
vip0: true
});
break;
case '1':// 银卡会员
obj = _.assign(obj, {
vip1: true
});
break;
case '2':// 金卡会员
obj = _.assign(obj, {
vip2: true
});
break;
case '3':// 白金会员
obj = _.assign(obj, {
vip3: true
});
break;
default :
switch (result[0].data.current_vip_level) {
case '0':// 普通会员
obj = _.assign(obj, {
vip0: true
});
break;
case '1':// 银卡会员
obj = _.assign(obj, {
vip1: true
});
break;
case '2':// 金卡会员
}
let upg = (1 * (result[0].data.upgrade_need_cost)).toFixed(2);
obj = _.assign(obj, {
costOfThisYear: result[0].data.current_year_cost,
sumCost: result[0].data.current_total_cost,
allUrl: helpers.urlFormat('/home/preferential'),
costGap: upg
});
if (result[0].data.next_need_cost === 0) {
// 当vip等级升至顶级时,进度条满格
obj = _.assign(obj, {
vip2: true
percent: 100
});
break;
case '3':// 白金会员
} else {
let perf = (100 * (result[0].data.current_year_cost / result[0].data.next_need_cost)).toFixed(2);
obj = _.assign(obj, {
vip3: true
percent: perf
});
break;
default :
}
let upg = (1 * (result[0].data.upgrade_need_cost)).toFixed(2);
}
obj = _.assign(obj, {
costOfThisYear: result[0].data.current_year_cost,
sumCost: result[0].data.current_total_cost,
allUrl: helpers.urlFormat('/home/preferential'),
costGap: upg
});
}
if (result[0].data.next_need_cost === 0) {
// 当vip等级升至顶级时,进度条满格
if (result[0] && result[0].data) {
obj = _.assign(obj, {
percent: 100
name: result[1].data.nickname
});
} else {
let perf = (100 * (result[0].data.current_year_cost / result[0].data.next_need_cost)).toFixed(2);
}
obj = _.assign(obj, {
percent: perf
});
resu.vipGrade.push(obj);
}
return resu;
});
} else {
return api.get('', {
}
}).then(() => {
if (result[0] && result[0].data) {
obj = _.assign(obj, {
name: result[1].data.nickname
});
}
let resu = {
vipGrade: []
};
resu.vipGrade.push(obj);
return resu;
});
return resu;
});
}
};
/**
... ...
... ... @@ -49,7 +49,7 @@ router.get('/cancelOrder', orderDetailController.cancelOrder); // 取消订单
router.get('/', homeController.index); // 个人中心首页
router.get('/mydetails', homeController.myDetails); // 个人基本资料页面
router.get('/grade', homeController.grade); // 会员等级页
router.get('/grade', auth, homeController.grade); // 会员等级页
router.get('/privilege', homeController.preferential); // 会员特权列表页
router.get('/mycurrency', currencyController.myCurrency); // yoho币总数
... ...