Showing
10 changed files
with
91 additions
and
17 deletions
@@ -33,7 +33,7 @@ module.exports = { | @@ -33,7 +33,7 @@ module.exports = { | ||
33 | 33 | ||
34 | res.locals.resources = resources; | 34 | res.locals.resources = resources; |
35 | 35 | ||
36 | - res.render('index', { | 36 | + res.render('cindex', { |
37 | module: 'channel', | 37 | module: 'channel', |
38 | page: 'home', | 38 | page: 'home', |
39 | channel: channel | 39 | channel: channel |
@@ -8,6 +8,11 @@ const homeModel = require('../models/index'); | @@ -8,6 +8,11 @@ const homeModel = require('../models/index'); | ||
8 | const helpers = global.yoho.helpers; | 8 | const helpers = global.yoho.helpers; |
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | 10 | ||
11 | +let channels = { | ||
12 | + men: 1, | ||
13 | + women: 2 | ||
14 | +}; | ||
15 | + | ||
11 | /** | 16 | /** |
12 | * 个人中心主页 | 17 | * 个人中心主页 |
13 | */ | 18 | */ |
@@ -19,7 +24,7 @@ const component = { | @@ -19,7 +24,7 @@ const component = { | ||
19 | }); | 24 | }); |
20 | }, | 25 | }, |
21 | userdata: (req, res, next) => { | 26 | userdata: (req, res, next) => { |
22 | - const uid = req.user.uid; // 8039759; | 27 | + const uid = req.user.uid; |
23 | 28 | ||
24 | homeModel.getUserHomeData(uid).then(data => { | 29 | homeModel.getUserHomeData(uid).then(data => { |
25 | const proData = data[0]; | 30 | const proData = data[0]; |
@@ -34,7 +39,7 @@ const component = { | @@ -34,7 +39,7 @@ const component = { | ||
34 | }).catch(next); | 39 | }).catch(next); |
35 | }, | 40 | }, |
36 | mydetails: (req, res, next) => { | 41 | mydetails: (req, res, next) => { |
37 | - const uid = req.user.uid; // 8039759; | 42 | + const uid = req.user.uid; |
38 | 43 | ||
39 | homeModel.getUserProfileData(uid).then(data => { | 44 | homeModel.getUserProfileData(uid).then(data => { |
40 | var gender = ''; | 45 | var gender = ''; |
@@ -266,12 +271,30 @@ const component = { | @@ -266,12 +271,30 @@ const component = { | ||
266 | }); | 271 | }); |
267 | }, | 272 | }, |
268 | gradeData(req, res, next) { | 273 | gradeData(req, res, next) { |
269 | - let uid = 11151547; // req.user.uid ; | ||
270 | - let channel = req.query.channel || 1; | 274 | + let uid = req.user.uid; |
275 | + let channel = req.cookies._Channel && channels[req.cookies._Channel] || 1; | ||
271 | 276 | ||
272 | homeModel.getGrade(uid, channel).then(result => { | 277 | homeModel.getGrade(uid, channel).then(result => { |
273 | res.json(result); | 278 | res.json(result); |
274 | }).catch(next); | 279 | }).catch(next); |
280 | + }, | ||
281 | + preferential(req, res, next) { | ||
282 | + | ||
283 | + let responseData = { | ||
284 | + module: 'me', | ||
285 | + page: 'grade', | ||
286 | + title: '会员特权详情' | ||
287 | + }; | ||
288 | + | ||
289 | + let param = { | ||
290 | + uid: req.user.uid, | ||
291 | + channel: req.cookies._Channel && channels[req.cookies._Channel] || 1 | ||
292 | + }; | ||
293 | + | ||
294 | + homeModel.getPreferential(param).then((result) => { | ||
295 | + res.render('privilege', Object.assign(result, responseData)); | ||
296 | + }).catch(next); | ||
297 | + | ||
275 | } | 298 | } |
276 | }; | 299 | }; |
277 | 300 |
@@ -324,13 +324,13 @@ exports.getGrade = (uid, channel) => { | @@ -324,13 +324,13 @@ exports.getGrade = (uid, channel) => { | ||
324 | 324 | ||
325 | _.forEach(result[0].data.enjoy_preferential, function(val) { | 325 | _.forEach(result[0].data.enjoy_preferential, function(val) { |
326 | 326 | ||
327 | - if (val.id === 7 || val.id === 8) { | 327 | + if (parseInt(val.id, 10) === 7 || parseInt(val.id, 10) === 8) { |
328 | return true; | 328 | return true; |
329 | } | 329 | } |
330 | 330 | ||
331 | obj.privilege.push({ | 331 | obj.privilege.push({ |
332 | description: val.description, | 332 | description: val.description, |
333 | - pic: iconId(parseInt(val.id)), | 333 | + pic: iconId(parseInt(val.id, 10)), |
334 | title: val.title | 334 | title: val.title |
335 | }); | 335 | }); |
336 | 336 | ||
@@ -339,7 +339,7 @@ exports.getGrade = (uid, channel) => { | @@ -339,7 +339,7 @@ exports.getGrade = (uid, channel) => { | ||
339 | switch (result[0].data.current_vip_level) { | 339 | switch (result[0].data.current_vip_level) { |
340 | case '0': // 普通会员 | 340 | case '0': // 普通会员 |
341 | obj = _.assign(obj, { | 341 | obj = _.assign(obj, { |
342 | - vip1: true | 342 | + vip0: true |
343 | }); | 343 | }); |
344 | break; | 344 | break; |
345 | case '1': // 银卡会员 | 345 | case '1': // 银卡会员 |
@@ -366,7 +366,7 @@ exports.getGrade = (uid, channel) => { | @@ -366,7 +366,7 @@ exports.getGrade = (uid, channel) => { | ||
366 | obj = _.assign(obj, { | 366 | obj = _.assign(obj, { |
367 | costOfThisYear: result[0].data.current_year_cost, | 367 | costOfThisYear: result[0].data.current_year_cost, |
368 | sumCost: result[0].data.current_total_cost, | 368 | sumCost: result[0].data.current_total_cost, |
369 | - allUrl: helpers.urlFormat('/home/privilege'), | 369 | + allUrl: helpers.urlFormat('/me/privilege'), |
370 | costGap: upg | 370 | costGap: upg |
371 | }); | 371 | }); |
372 | 372 | ||
@@ -401,3 +401,38 @@ exports.getGrade = (uid, channel) => { | @@ -401,3 +401,38 @@ exports.getGrade = (uid, channel) => { | ||
401 | } | 401 | } |
402 | }; | 402 | }; |
403 | 403 | ||
404 | +exports.getPreferential = (params) => { | ||
405 | + | ||
406 | + return api.get('', { | ||
407 | + method: 'app.passport.getPrivilege', | ||
408 | + uid: params.uid, | ||
409 | + channel: params.channel || 1 | ||
410 | + }, { | ||
411 | + code: 200 | ||
412 | + }).then((result) => { | ||
413 | + | ||
414 | + let obj = {}; | ||
415 | + | ||
416 | + let resu = { | ||
417 | + privilege: [] | ||
418 | + }; | ||
419 | + | ||
420 | + _.forEach(result.data, function(val) { | ||
421 | + | ||
422 | + if (parseInt(val.id, 10) === 7 || parseInt(val.id, 10) === 8) { | ||
423 | + return true; | ||
424 | + } | ||
425 | + | ||
426 | + resu.privilege.push({ | ||
427 | + description: val.description, | ||
428 | + pic: iconId(parseInt(val.id, 10)), | ||
429 | + title: val.title | ||
430 | + }); | ||
431 | + | ||
432 | + }); | ||
433 | + | ||
434 | + return resu; | ||
435 | + | ||
436 | + }); | ||
437 | +}; | ||
438 | + |
@@ -92,7 +92,8 @@ router.get('/me/prefer', require(cRoot + '/prefer').index); | @@ -92,7 +92,8 @@ router.get('/me/prefer', require(cRoot + '/prefer').index); | ||
92 | router.get('/me/preferlist', require(cRoot + '/prefer').list); | 92 | router.get('/me/preferlist', require(cRoot + '/prefer').list); |
93 | 93 | ||
94 | // 会员等级 | 94 | // 会员等级 |
95 | -router.get('/me/grade', home.grade); | ||
96 | -router.get('/me/gradeData', home.gradeData); | 95 | +router.get('/me/grade', auth, home.grade); |
96 | +router.get('/me/gradeData', auth, home.gradeData); | ||
97 | +router.get('/me/privilege', auth, home.preferential); | ||
97 | 98 | ||
98 | module.exports = router; | 99 | module.exports = router; |
apps/me/views/action/privilege.hbs
0 → 100644
@@ -143,9 +143,10 @@ | @@ -143,9 +143,10 @@ | ||
143 | font-size: 30px; | 143 | font-size: 30px; |
144 | margin-bottom: 0; | 144 | margin-bottom: 0; |
145 | 145 | ||
146 | - .iconfont { | 146 | + span { |
147 | float: right; | 147 | float: right; |
148 | color: #e0e0e0; | 148 | color: #e0e0e0; |
149 | + line-height: 90px; | ||
149 | } | 150 | } |
150 | } | 151 | } |
151 | } | 152 | } |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | <a class="user-info auth" id="user-info" href='/me/mydetails'> | 6 | <a class="user-info auth" id="user-info" href='/me/mydetails'> |
7 | <img class="user-avatar" :src="headIco" @error="setEmptyimg"> | 7 | <img class="user-avatar" :src="headIco" @error="setEmptyimg"> |
8 | </a> | 8 | </a> |
9 | - <a class="vip-level level-{{data.vipLevel}}" v-if="data.vipLevel"></a> | 9 | + <a class="vip-level level-{{data.vipLevel}}" v-if="data.vipLevel" href='/me/grade'></a> |
10 | <span class="username">{{ data.nickName }}</span> | 10 | <span class="username">{{ data.nickName }}</span> |
11 | </div> | 11 | </div> |
12 | <div class="my-order"> | 12 | <div class="my-order"> |
@@ -92,7 +92,7 @@ | @@ -92,7 +92,7 @@ | ||
92 | </li> | 92 | </li> |
93 | </ul> | 93 | </ul> |
94 | 94 | ||
95 | - <div class="privilege block" v-if="vipGrade.vip2"> | 95 | + <div class="privilege block" v-if="!vipGrade.vip0"> |
96 | <h3 class="title">当前可享受的特权</h3> | 96 | <h3 class="title">当前可享受的特权</h3> |
97 | <ul class="privilege-list"> | 97 | <ul class="privilege-list"> |
98 | <li v-for="pri in vipGrade.privilege"> | 98 | <li v-for="pri in vipGrade.privilege"> |
@@ -107,7 +107,7 @@ | @@ -107,7 +107,7 @@ | ||
107 | 107 | ||
108 | <a class="all-privilege block tap-hightlight" href="{{vipGrade.allUrl}}"> | 108 | <a class="all-privilege block tap-hightlight" href="{{vipGrade.allUrl}}"> |
109 | 查看全部VIP特权 | 109 | 查看全部VIP特权 |
110 | - <span class="iconfont"></span> | 110 | + <span class="icon icon-right"></span> |
111 | </a> | 111 | </a> |
112 | </template> | 112 | </template> |
113 | 113 | ||
@@ -133,7 +133,7 @@ | @@ -133,7 +133,7 @@ | ||
133 | ready() { | 133 | ready() { |
134 | this.reload(); | 134 | this.reload(); |
135 | } | 135 | } |
136 | - } | 136 | + }; |
137 | </script> | 137 | </script> |
138 | 138 | ||
139 | <style> | 139 | <style> |
-
Please register or login to post a comment