Authored by zhangxiaoru

特权列表页

... ... @@ -33,7 +33,7 @@ module.exports = {
res.locals.resources = resources;
res.render('index', {
res.render('cindex', {
module: 'channel',
page: 'home',
channel: channel
... ...
... ... @@ -8,6 +8,11 @@ const homeModel = require('../models/index');
const helpers = global.yoho.helpers;
const _ = require('lodash');
let channels = {
men: 1,
women: 2
};
/**
* 个人中心主页
*/
... ... @@ -19,7 +24,7 @@ const component = {
});
},
userdata: (req, res, next) => {
const uid = req.user.uid; // 8039759;
const uid = req.user.uid;
homeModel.getUserHomeData(uid).then(data => {
const proData = data[0];
... ... @@ -34,7 +39,7 @@ const component = {
}).catch(next);
},
mydetails: (req, res, next) => {
const uid = req.user.uid; // 8039759;
const uid = req.user.uid;
homeModel.getUserProfileData(uid).then(data => {
var gender = '';
... ... @@ -266,12 +271,30 @@ const component = {
});
},
gradeData(req, res, next) {
let uid = 11151547; // req.user.uid ;
let channel = req.query.channel || 1;
let uid = req.user.uid;
let channel = req.cookies._Channel && channels[req.cookies._Channel] || 1;
homeModel.getGrade(uid, channel).then(result => {
res.json(result);
}).catch(next);
},
preferential(req, res, next) {
let responseData = {
module: 'me',
page: 'grade',
title: '会员特权详情'
};
let param = {
uid: req.user.uid,
channel: req.cookies._Channel && channels[req.cookies._Channel] || 1
};
homeModel.getPreferential(param).then((result) => {
res.render('privilege', Object.assign(result, responseData));
}).catch(next);
}
};
... ...
... ... @@ -324,13 +324,13 @@ exports.getGrade = (uid, channel) => {
_.forEach(result[0].data.enjoy_preferential, function(val) {
if (val.id === 7 || val.id === 8) {
if (parseInt(val.id, 10) === 7 || parseInt(val.id, 10) === 8) {
return true;
}
obj.privilege.push({
description: val.description,
pic: iconId(parseInt(val.id)),
pic: iconId(parseInt(val.id, 10)),
title: val.title
});
... ... @@ -339,7 +339,7 @@ exports.getGrade = (uid, channel) => {
switch (result[0].data.current_vip_level) {
case '0': // 普通会员
obj = _.assign(obj, {
vip1: true
vip0: true
});
break;
case '1': // 银卡会员
... ... @@ -366,7 +366,7 @@ exports.getGrade = (uid, channel) => {
obj = _.assign(obj, {
costOfThisYear: result[0].data.current_year_cost,
sumCost: result[0].data.current_total_cost,
allUrl: helpers.urlFormat('/home/privilege'),
allUrl: helpers.urlFormat('/me/privilege'),
costGap: upg
});
... ... @@ -401,3 +401,38 @@ exports.getGrade = (uid, channel) => {
}
};
exports.getPreferential = (params) => {
return api.get('', {
method: 'app.passport.getPrivilege',
uid: params.uid,
channel: params.channel || 1
}, {
code: 200
}).then((result) => {
let obj = {};
let resu = {
privilege: []
};
_.forEach(result.data, function(val) {
if (parseInt(val.id, 10) === 7 || parseInt(val.id, 10) === 8) {
return true;
}
resu.privilege.push({
description: val.description,
pic: iconId(parseInt(val.id, 10)),
title: val.title
});
});
return resu;
});
};
... ...
... ... @@ -92,7 +92,8 @@ router.get('/me/prefer', require(cRoot + '/prefer').index);
router.get('/me/preferlist', require(cRoot + '/prefer').list);
// 会员等级
router.get('/me/grade', home.grade);
router.get('/me/gradeData', home.gradeData);
router.get('/me/grade', auth, home.grade);
router.get('/me/gradeData', auth, home.gradeData);
router.get('/me/privilege', auth, home.preferential);
module.exports = router;
... ...
<div class="vip-privilege-page yoho-page">
<ul class="privilege-list">
{{#each privilege}}
<li>
<span class="icon {{pic}}"></span>
<p>
{{title}}
<span>{{description}}</span>
</p>
</li>
{{/each}}
</ul>
</div>
\ No newline at end of file
... ...
@import "help";
@import "feedback";
@import "about-us";
@import "vip-grade";
... ...
... ... @@ -40,7 +40,7 @@
height: 32px;
line-height: 36px;
}
.grade-desc {
margin-top: 20px;
font-size: 22px;
... ... @@ -143,9 +143,10 @@
font-size: 30px;
margin-bottom: 0;
.iconfont {
span {
float: right;
color: #e0e0e0;
line-height: 90px;
}
}
}
... ...
... ... @@ -6,7 +6,7 @@
<a class="user-info auth" id="user-info" href='/me/mydetails'>
<img class="user-avatar" :src="headIco" @error="setEmptyimg">
</a>
<a class="vip-level level-{{data.vipLevel}}" v-if="data.vipLevel"></a>
<a class="vip-level level-{{data.vipLevel}}" v-if="data.vipLevel" href='/me/grade'></a>
<span class="username">{{ data.nickName }}</span>
</div>
<div class="my-order">
... ...
... ... @@ -29,7 +29,7 @@
</li>
<li>
<label>会员等级
<a class="grade">
<a class="grade" href="/me/grade">
<span class="icon icon-right"></span>
</a>
</label>
... ...
... ... @@ -92,7 +92,7 @@
</li>
</ul>
<div class="privilege block" v-if="vipGrade.vip2">
<div class="privilege block" v-if="!vipGrade.vip0">
<h3 class="title">当前可享受的特权</h3>
<ul class="privilege-list">
<li v-for="pri in vipGrade.privilege">
... ... @@ -107,7 +107,7 @@
<a class="all-privilege block tap-hightlight" href="{{vipGrade.allUrl}}">
查看全部VIP特权
<span class="iconfont">&#xe604;</span>
<span class="icon icon-right"></span>
</a>
</template>
... ... @@ -128,12 +128,12 @@
}).then(result => {
this.vipGrade = result || {};
});
}
}
},
ready() {
this.reload();
}
}
};
</script>
<style>
... ...