Authored by 李靖

Merge branch 'feature/family' of git.yoho.cn:fe/yohobuywap-node into feature/family

... ... @@ -19,11 +19,21 @@ exports.familyIndex = (req, res, next) => {
}).catch(next);
};
exports.integralCharts = (req, res, next) => {
let uid = req.user.uid;
req.ctx(family).integralCharts(uid).then(result => {
res.josn(result);
}).catch(next);
};
exports.familyVip = (req, res, next) => {
let udid = req.sessionID || 'yoho';
let uid = req.user.uid;
let yohoApp = req.yoho.isApp && !req.yoho.isMarsApp;
let marsApp = req.yoho.isMarsApp;
req.ctx(family).familyVip(udid, uid).then(result => {
req.ctx(family).familyVip(udid, uid, yohoApp, marsApp).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -79,217 +79,46 @@ class familyModel extends global.yoho.BaseModel {
/**
* 获取APP列表
*/
_getAppList() {
let result = {
code: 200,
data: [
{
uid: null,
iconUrl: 'http://img12.static.yhbimg.com/article/2017/08/23/10/02412723632a13bd6ad1eef8fe580095a5.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'yohobuy',
source: 1,
login: true
},
{
uid: null,
iconUrl: 'http://img13.static.yhbimg.com/article/2017/08/23/10/0222be3d6a9d8a1617b89fcf35357a3593.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'now',
source: 2,
login: true
},
{
uid: null,
iconUrl: 'http://img12.static.yhbimg.com/article/2017/08/23/10/02fe755abdc5d390252cf6df25c01dffae.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'mars',
source: 3,
login: true
},
{
uid: null,
iconUrl: 'http://img11.static.yhbimg.com/article/2017/08/23/10/0112f200ab5ae424173fa2df7a490c80bf.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'green',
source: 4,
login: true
},
{
uid: null,
iconUrl: 'http://img12.static.yhbimg.com/article/2017/08/23/10/022279d464ee6bd9ef86089c60e2832210.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'coffee',
source: 5,
login: true
},
{
uid: null,
iconUrl: 'http://img10.static.yhbimg.com/article/2017/08/23/10/01a1704bc87316008d769443a8ae50ad7e.png?imageView/{mode}/w/{width}/h/{height}',
sourceName: 'little',
source: 6,
login: true
}
]
};
_getAppList(uid) {
return family.get('vip/getUserVipInfo', {
uid: uid
}, {
code: 200
}).then((result => {
if (result && result.data && result.code === 200) {
let loginList = [];
let noLoginList = [];
let appList = [];
let loginList = [];
let noLoginList = [];
let appList = [];
_.forEach(result.data, function(val, key) {
val.nickname = key;
_.forEach(result.data, value => {
if (value.login === true) {
loginList.push(value);
} else {
noLoginList.push(value);
}
});
if (val.login === true) {
loginList.push(val);
} else {
noLoginList.push(val);
}
});
loginList.sort(this._sourceSort('source'));
noLoginList.sort(this._sourceSort('source'));
loginList.sort(this._sourceSort('source'));
noLoginList.sort(this._sourceSort('source'));
appList = loginList.concat(noLoginList);
appList = loginList.concat(noLoginList);
return appList;
return appList;
}
}));
}
/**
*查询各个体系成长等级信息及等级特权
*/
_getVipInfo(udid) {
return api.get('/yoho-family/vip/getVipInfo.json', {
return family.get('vip/getVipInfo.json', {
udid: udid
}, {
code: 200
}).then((result) => {
// result = {
// code: 200,
// data: {
// mars: {
// vipLevelList: [
// {
// growthValue: 100,
// level: 0,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/d1f9cb68a1e7aae4a1a6c4eeca7b1b0e.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 100
// },
// {
// growthValue: 400,
// level: 1,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/5336ef84190a715bd221fca50a9e9e3d.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 100
// },
// {
// growthValue: 1000,
// level: 2,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/1027321fcaf5311ab21963f925ecb0dd.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 95,
// privilege: "mars points 9.5折兑换"
// },
// {
// growthValue: 2000,
// level: 3,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/e4512e2c5e78140170bf4967c4368645.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 90,
// privilege: "mars points 9折兑换"
// },
// {
// growthValue: 5000,
// level: 4,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/312d0b334370eb8a9711065d489451ca.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 85,
// privilege: "mars points 8.5折兑换"
// },
// {
// growthVaue: 10000,
// level: 5,
// levelImg: "http://img01.yohomars.com/mars/2017/01/24/148be1f69f64ebc1872c43b5b4b7e620.png?imageView/{mode}/w/{width}/h/{height}",
// marsPointDiscount: 80,
// privilege: "mars points 8折兑换"
// }
// ]
// },
// yohobuy: {
// privilegeList: [
// {
// description: "在原折扣基础上享受VIP折上折",
// id: 1,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zhekou.png",
// title: "银卡会员购物9.5折"
// },
// {
// description: "在原折扣基础上享受VIP折上折",
// id: 2,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zhekou.png",
// title: "金卡会员购物9.0折"
// },
// {
// description: "在原折扣基础上享受VIP折上折",
// id: 3,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zhekou.png",
// title: "白金卡会员购物8.8折"
// },
// {
// description: "年度级的sale促销活动中,VIP会员可以享受优先购买权",
// id: 4,
// pic: "http://static.yohobuy.com/images/app/icon_2x_niandu.png",
// title: "年度活动优惠"
// },
// {
// description: "白金卡会员的订单将采用最快速度进行免费配送,金卡会员的订单免费配送",
// id: 5,
// pic: "http://static.yohobuy.com/images/app/icon_2x_kssd.png",
// title: "快速送达"
// },
// {
// description: "浏览《YOHO!潮流志》、《YOHO!GIRL》电子版,最新最权威的潮流资讯尽在掌握!",
// id: 6,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zzzy.png",
// title: "电子杂志赠阅"
// },
// {
// description: "赠送生日优惠券",
// id: 8,
// pic: "http://static.yohobuy.com/images/app/icon_2x_sryh.png",
// title: "生日特惠"
// },
// {
// description: "获取大量潮流新品及优惠活动的信息",
// id: 9,
// pic: "http://static.yohobuy.com/images/app/icon_2x_yhxx.png",
// title: "优惠信息"
// },
// {
// description: "参加\"VIP会员限定\"活动",
// id: 10,
// pic: "http://static.yohobuy.com/images/app/icon_2x_vip.png",
// title: "VIP活动优惠"
// }
// ],
// vipLevelLis: [
// {
// growthValue: 0,
// level: 0,
// name: "普通会员",
// privilege: ""
// },
// {
// growthValue: 600,
// level: 1,
// name: "银卡会员",
// privilege: "1,4,10,6,8,9"
// },
// {
// growthValue: 2000,
// level: 2,
// name: "金卡会员",
// privilege: "2,4,10,5,6,8,9"
// },
// {
// growthValue: 5000,
// level: 3,
// name: "白金会员",
// privilege: "3,4,10,5,6,8,9"
// }
// ]
// }
// }
// };
if (result.data.mars && result.data.mars.vipLevelList.length > 0) {
_.forEach(result.data.mars.vipLevelList, function(val) {
... ... @@ -305,77 +134,24 @@ class familyModel extends global.yoho.BaseModel {
*查询当前用户各个体系成长等级信息及等级特权
*/
_getUserVipInfo(udid, uid) {
return api.get('/yoho-family/vip/getUserVipInfo.json', {
return family.get('vip/getUserVipInfo.json', {
udid: udid,
uid: uid
}, {
code: 200
}).then((result) => {
// result = {
// data: {
// mars: {
// growthValue: 2000,
// level: 4,
// nextLevel: 5,
// privilege: "mars points 8.5折兑换",
// valueToNextLevel: 3000
// },
// yohobuy: {
// growthValue: 1500,
// level: 1,
// name: "银卡会员",
// nextLevel: 2,
// valueToNextLevel: 500,
// privilege: [
// {
// description: "在原折扣基础上享受VIP折上折",
// id: 1,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zhekou.png",
// title: "银卡会员购物9.5折"
// },
// {
// description: "年度级的sale促销活动中,VIP会员可以享受优先购买权",
// id: 4,
// pic: "http://static.yohobuy.com/images/app/icon_2x_niandu.png",
// title: "年度活动优惠"
// },
// {
// description: "浏览《YOHO!潮流志》、《YOHO!GIRL》电子版,最新最权威的潮流资讯尽在掌握!",
// id: 6,
// pic: "http://static.yohobuy.com/images/app/icon_2x_zzzy.png",
// title: "电子杂志赠阅"
// },
// {
// description: "赠送生日优惠券",
// id: 8,
// pic: "http://static.yohobuy.com/images/app/icon_2x_sryh.png",
// title: "生日特惠"
// },
// {
// description: "获取大量潮流新品及优惠活动的信息",
// id: 9,
// pic: "http://static.yohobuy.com/images/app/icon_2x_yhxx.png",
// title: "优惠信息"
// },
// {
// description: "参加\"VIP会员限定\"活动",
// id: 10,
// pic: "http://static.yohobuy.com/images/app/icon_2x_vip.png",
// title: "VIP活动优惠"
// }
// ]
// }
// }
// };
return result.data;
if (result && result.data) {
return result.data;
} else {
return {};
}
});
}
/**
*各个app的会员信息
*/
familyVip(udid, uid) {
familyVip(udid, uid, yohoApp, marsApp) {
return Promise.all([
this._getVipInfo(udid),
this._getUserVipInfo(udid, uid)
... ... @@ -390,7 +166,15 @@ class familyModel extends global.yoho.BaseModel {
});
if (key === 'yohobuy') {
if (val.growthValue <= 0) {
val.showLevel = true;
if (yohoApp) {
val.link = '//m.yohobuy.com/home/grade?openby:yohobuy={"action":"go.vipInfo"}';
} else if (marsApp) {
val.link = '//m.yohobuy.com/home/grade?openby:yohobuy={"action":"go.h5"}';
} else {
val.link = '//m.yohobuy.com/home/grade';
}
if (val.growthValue <= 0 || val.growthValue === null) {
val.percent = 0;
} else if (val.growthValue > 0 && val.growthValue < 800) {
val.percent = 17;
... ... @@ -407,8 +191,14 @@ class familyModel extends global.yoho.BaseModel {
}
}
if (key === 'mars') {
if (yohoApp) {
val.link = 'yohomars://yohomars.com/goapp?openby:mars=""';
} else if (marsApp) {
val.link = '//m.yohobuy.com/home/grade?openby:yohobuy={"action":"go.h5"}';
} else {
val.link = 'yohomars://yohomars.com/goapp?openby:mars=""';
}
if (val.growthValue <= 100) {
val.percent = 0;
} else if (val.growthValue > 100 && val.growthValue < 400) {
... ... @@ -497,9 +287,8 @@ class familyModel extends global.yoho.BaseModel {
val.percent = 100;
}
}
});
return result[1];
});
}
... ... @@ -565,24 +354,45 @@ class familyModel extends global.yoho.BaseModel {
}
/**
* 积分乐园数据
*/
integralCharts(uid) {
return family.get('user/getUserCoin', {
uid: uid
}, {
code: 200
}).then((result) => {
// if(result && result.data) {
// _.forEach(result.data, function(data) {
// });
// }
// console.log(result);
});
}
/**
* family主页
*/
familyIndex(uid, contentCodeOne, contentCodeTwo) {
return Promise.all([
this._userData(uid),
this._getCode(uid),
this._getAppList(),
this._getAppList(uid),
this._getTrendPop(contentCodeOne),
this._getTrendPop(contentCodeTwo)
this._getTrendPop(contentCodeTwo),
this.integralCharts(uid)
]).then((result) => {
let familyIndexData = {};
if (result[0] && result[0].data) {
familyIndexData = _.assign(familyIndexData, {
head_ico: result[0].data.head_ico,
nickname: result[0].data.nickname,
head_ico: result[0].data.headIco,
nickname: result[0].data.nickName,
gender: parseInt(result[0].data.gender, 10),
birthday: result[0].data.birthday ? moment(result[0].data.birthday).format('MM-DD') : ''
birthday: result[0].data.birthday ? moment(result[0].data.birthday).format('MM-DD') : '',
province: result[0].data.province,
city: result[0].data.city
});
}
... ...
... ... @@ -187,4 +187,5 @@ router.get('/family/userInfo/getCity', auth, family.getCity); // family个人信
router.get('/family/coinMall', auth, family.coinMall); // 积分商城
router.get('/family/coinMall/getList', auth, family.getList); // 积分商城-获取积分列表
router.get('/family/modify', auth, family.modify); // family修改个人信息页
router.get('/family/integralCharts', auth, family.integralCharts); // family积分商城
module.exports = router;
... ...
... ... @@ -12,7 +12,7 @@
<span class="gender {{#isEqualOr gender 1}}boy{{/isEqualOr}}{{#isEqualOr gender 2}}girl{{/isEqualOr}}"></span>
</div>
<div class="info">
<span class="city">江苏南京</span>
<span class="city">{{province}}{{city}}</span>
<span class="birthday">{{birthday}}</span>
</div>
<div class="invition">
... ... @@ -41,10 +41,10 @@
<div class="title">会员等级及权益</div>
<div class="grade-content">
{{# appList}}
<div class="content-item" data-login="{{login}}" data-name="{{sourceName}}">
<div class="content-item" data-login="{{login}}" data-name="{{nickname}}" data-code="{{code}}">
<img class="item-tag" src="{{image iconUrl 140 140}}">
<span class="name">{{sourceName}}</span>
<span class="level">黄金</span>
<span class="level">{{level}}</span>
</div>
{{/ appList}}
</div>
... ...
... ... @@ -8,7 +8,7 @@
<div class="user-info clearfix{{#if noUid}} hide{{/if}}">
<div class="base clearfix">
<div class="pic"{{#if headIco}} style="background-image:url({{image headIco 125 125}})"{{/if}}>
<div class="level-pic vip-{{level}}"></div>
<div class="level-pic {{#if showLevel}}vip-{{level}}{{/if}}"></div>
</div>
<div class="intro">
<div class="name"><span></span>您好!</div>
... ... @@ -22,7 +22,7 @@
</div>
<div class="level-process clearfix">
<div class="line-c">
<div class="line"{{#if percent}} style="width:{{percent}}%"{{/if}}></div>
<div class="line" style="width:{{percent}}%"></div>
<div class="point">
{{# vipLevelLis}}
<div class="point-item">
... ... @@ -41,24 +41,27 @@
<div class="privilege-title">
<b></b>
当前可享受特权
<a class="more">更多</a>
<a class="more" href='{{link}}'>更多</a>
</div>
{{# privilegeList}}
<a class="privilege-item">
<img class="icon" src="{{pic}}">
<img class="icon" {{#if pic}}src="{{pic}}"{{/if}} {{#if icon}}src="{{icon}}{{/if}}">
<p>
{{title}}
<span>{{description}}</span>
{{#if title}}{{title}}{{/if}}
{{#if name}}{{name}}{{/if}}
<span>{{#if description}}{{description}}{{/if}}{{#if desc}}{{desc}}{{/if}}</span>
</p>
</a>
{{/ privilegeList}}
{{# privilegeCro}}
<div class="level-item">
<img class="item-ico" src="{{image iconUrl 125 125}}">
<span class="le-name">{{sourceName}}</span>
<span class="state">已开启</span>
<div class="transverse">
{{# privileges}}
<div class="level-item">
<img class="item-ico" src="{{image icon 125 125}}">
<span class="le-name">{{name}}</span>
<span class="state">{{status}}</span>
</div>
{{/ privileges}}
</div>
{{/ privilegeCro}}
</div>
</div>
</div>
... ...
... ... @@ -32,7 +32,8 @@ class FamilyIndex extends Page {
$trendWord: $('.trend-word'),
$wordOuter: $('.word-outer'),
$bannerCenterSwiper: $('.banner-center-swiper'),
$back: $('.back')
$back: $('.back'),
$vipMore: $('more')
};
this.view = {
... ... @@ -68,9 +69,14 @@ class FamilyIndex extends Page {
// 头像
headIco() {
if (this.selector.$userAvatar.data('avatar')) {
this.selector.$userAvatar.css('background-image', 'url(' + this.selector.$userAvatar.data('avatar') + ')');
}
let myImage = new Image(),
avatar;
avatar = this.selector.$userAvatar.data('avatar');
myImage.src = avatar;
myImage.onload = () => {
this.selector.$userAvatar.css('background-image', 'url(' + avatar + ')');
};
}
// 潮流口令滚动
... ... @@ -274,7 +280,6 @@ class FamilyIndex extends Page {
downClose() {
this.selector.$downLoadDetail.addClass('hide');
}
}
... ...
... ... @@ -352,9 +352,6 @@
left: 50%;
margin-top: 180px;
margin-left: -315px;
height: 950px;
overflow-y: scroll;
overflow-x: hidden;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
... ... @@ -517,8 +514,13 @@
height: 1.75rem;
}
.transverse{
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
}
.privilege-item {
width: 690px;
clear: both;
float: left;
padding: 25px 0;
... ... @@ -527,7 +529,7 @@
margin-left: 40px;
&:last-child {
border-bottom: 0;
border-bottom: none;
}
.iconfont {
... ... @@ -540,6 +542,10 @@
}
}
.privilege-item:last-child {
border-bottom: none;
}
p {
font-size: 28px;
margin-left: 30px;
... ... @@ -555,10 +561,12 @@
}
.level-item {
width: 210px;
width: 175px;
text-align: center;
float: left;
display: inline-block;
margin-bottom: 50px;
margin-right: 40px;
vertical-align: top;
.item-ico {
width: 125px;
... ... @@ -573,6 +581,7 @@
font-size: 28px;
line-height: 36px;
color: #000;
white-space: normal;
}
.state {
... ...