Authored by shuiling.wang@yoho.cn

3.0

... ... @@ -295,6 +295,11 @@ const component = {
res.render('privilege', Object.assign(result, responseData));
}).catch(next);
},
favoriteNum(req, res, next) {
homeModel.favoriteNum(req.user.uid).then(result => {
res.json(result);
}).catch(next);
}
};
... ...
... ... @@ -4,6 +4,8 @@ const serviceAPI = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const config = global.yoho.config;
const singleAPI = global.yoho.SingleAPI;
/**
* 查询用户信息
... ... @@ -438,3 +440,12 @@ exports.getPreferential = (params) => {
});
};
// 收藏数量接口
exports.favoriteNum = (uid) => {
return singleAPI.get('favorite', {
method: 'app.favorite.getFavoriteCount',
uid: uid
}, {
code: 200
});
};
\ No newline at end of file
... ...
... ... @@ -46,6 +46,7 @@ router.post('/me/save-feedback', auth, home.saveFeedback); // 个人中心-提
router.get('/me/collection', auth, favorite.favorite); // 个人中心 - 收藏
router.get('/me/collection/favpaging', auth, favorite.favpaging); // 个人中心 - 收藏商品/品牌/资讯(翻页)
router.post('/me/del-favdel', auth, favorite.deletefav); // 个人中心 - 收藏商品/品牌/资讯(刪除)
router.get('/me/favoriteNum', auth, home.favoriteNum);// 收藏个数
// 退换货
router.get('/me/return', auth, refund.refundOrders); // 退换货 - 订单列表
... ... @@ -96,4 +97,5 @@ router.get('/me/grade', auth, home.grade);
router.get('/me/gradeData', home.gradeData);
router.get('/me/privilege', auth, home.preferential);
module.exports = router;
... ...
... ... @@ -6,14 +6,14 @@ module.exports = () => {
const token = req.cookies._YOHOTOKEN;
const key = `-_-!!!${uid}!!!-_-`;
console.log(uid)
console.log(uid);
if (md5(key) === token) {
req.user.uid = uid;
delete req.cookies._YOHOUID;
}
req.user.uid = 51477204; // todo modify wsl
req.user.uid = 51477204; // todo modify wsl
next();
};
... ...
... ... @@ -40,7 +40,7 @@ const yoho = {
* 判断是否是 登录
*/
isLogin() {
return true; //todo del wsl
return true; // todo del wsl
return cookie.get('_YOHOUID');
},
... ...
<template>
<resources :content-code.sync="contentCode"></resources>
<div v-infinite-scroll="getNewsList()">
<div v-for="editorial in editorialList" class="editorial-box">
<div class="img">
<a href='{{"/editorial/" + editorial.id + ".html"}}'>
<img v-bind:src="editorial.src | resize 750 469" alt="" />
</a>
</div>
<div class="title">
<a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a>
</div>
<div class="editorial-des">
<p class="line-clamp-2">{{editorial.intro}}</p>
</div>
<hr>
<div class="bottom clearfix">
<span class="icon icon-timeshare"></span>
<span class="time">{{editorial.publish_time}}</span>
<span class="icon icon-share share" @click="share(editorial.title, editorial.intro, editorial.src, editorial.id)"></span>
</div>
</div>
</div>
<div v-if="!scrollDisabled" class="is-loading">loading...</div>
</template>
<style>
.editorial-box {
background: #f6f6f6;
border-bottom: #eee 1px solid;
padding-top: 30px;
.img {
width: 100%;
height: 470px;
overflow: hidden;
img {
width: 100%;
}
}
.title {
background: #fff;
font-size: 42px;
line-height: 1.2;
font-weight: 700;
padding: 30px;
}
.editorial-des {
background: #fff;
padding: 0 30px 30px;
color: #b0b0b0;
font-size: 28px;
line-height: 32px;
}
hr {
margin: 0 30px;
border: #eee 1px solid;
border-bottom: 0;
}
.bottom {
padding: 10px 30px;
background: #fff;
color: #b0b0b0;
font-size: 24px;
height: 78px;
span {
display: inline-block;
padding: 12px 0;
}
.share {
float: right;
padding-top: 16px;
}
}
}
.is-loading {
font-size: 32px;
text-align: center;
padding: 16px 0;
}
</style>
<script>
const util = require('common/util');
const contentCode = require('content-code');
const resources = require('component/resources/index.vue');
const qs = require('yoho-qs');
const $ = require('jquery');
const tip = require('common/tip');
const yoho = require('yoho');
module.exports = {
data() {
return {
contentCode: contentCode.editorial.all,
editorialList: [],
page: 1,
scrollDisabled: false,
channel: qs.channel
};
},
watch: {
channel() {
this.getNewsList();
}
},
methods: {
/* 获取资讯列表数据 */
getNewsList() {
if (this.scrollDisabled) {
return;
}
this.scrollDisabled = true;
$.get({
url: '/editorial/list.json',
data: {
page: this.page,
channel: this.channel
}
}).done(result => {
if (result.code === 200 && result.data.list.length > 0) {
if (this.editorialList.length > 0 && result.data.list.length > 0) {
this.$set('editorialList', this.editorialList.concat(result.data.list));
} else if (result.data.list.length > 0) {
this.editorialList = result.data.list;
}
// 如果未加载完,继续翻页加载
if (result.data.list.length > 0) {
this.page++;
this.scrollDisabled = false;
}
} else {
tip('没有了...');
}
}).fail(() => {
this.scrollDisabled = false;
});
},
/* 分享资讯 */
share(title, des, img, id) {
title = title.length > 15 ? title.substr(0, 15) + '...' : title;
img = location.protocol + util.getImgUrl(img, 300, 300, 2);
yoho.goShare({
title: title,
des: des,
img: img,
url: `${location.origin}/editorial/${id}.html?shareTitle=${title}`
});
}
},
components: {
resources
},
created() {
this.getNewsList();
}
};
</script>
... ...
... ... @@ -5,48 +5,47 @@
<div class="img">
<a href='{{"/editorial/" + editorial.id + ".html"}}'>
<img v-bind:src="editorial.src | resize 750 469" alt="" />
<p class="title">{{editorial.title}}</p>
<p class="type">搭配</p>
</a>
</div>
<div class="title">
<a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a>
</div>
<div class="editorial-des">
<p class="line-clamp-2">{{editorial.intro}}</p>
</div>
<hr>
<div class="bottom clearfix">
<span class="icon icon-timeshare"></span>
<span class="time">{{editorial.publish_time}}</span>
<span class="icon icon-share share" @click="share(editorial.title, editorial.intro, editorial.src, editorial.id)"></span>
</div>
</div>
</div>
<div v-if="!scrollDisabled" class="is-loading">loading...</div>
</template>
<style>
.editorial-box {
background: #f6f6f6;
border-bottom: #eee 1px solid;
padding-top: 30px;
.img {
width: 100%;
height: 470px;
overflow: hidden;
position: relative;
img {
width: 100%;
}
}
.title {
background: #fff;
font-size: 42px;
line-height: 1.2;
font-weight: 700;
padding: 30px;
}
.title {
width: 580px;
position: absolute;
bottom: 100px;
text-align: center;
color: #fff;
font-size: 34px;
line-height: 34px;
left: 50%;
margin-left: -290px;
}
.type {
width: 100%;
color: #fff;
font-size: 24px;
position: absolute;
bottom: 45px;
text-align: center;
}
}
.editorial-des {
background: #fff;
padding: 0 30px 30px;
... ...
... ... @@ -19,11 +19,11 @@
</a>
<div class="group-list">
<div class="user-count">
<a class="auth uc-item" href="">
<a class="auth uc-item" href="/me/collection">
<p class="num">{{productNum}}</p>
<p class="label">商品收藏</p>
</a>
<a class="auth uc-item" href="">
<a class="auth uc-item" href="/me/collection?tab=article">
<p class="num">{{editorialNum}}</p>
<p class="label">资讯收藏</p>
</a>
... ... @@ -68,7 +68,7 @@
</a>
</div>
</div>
<div class="group-list">
<!--<div class="group-list">
<a class="glist-item auth" href="/me/collection">
我的收藏
<span class="num">商品/品牌/资讯 <span class="icon icon-right"></span></span>
... ... @@ -77,18 +77,23 @@
浏览记录
<span class="num">{{recordNum}}<span class="icon icon-right"></span></span>
</a>
</div>
</div>-->
<!--<div class="group-list">
<a class="glist-item auth" href="/me/mycurrency">
有货币
<span class="num">{{data.yoho_coin_num}} <span class="icon icon-right"></span></span>
</a>
</div>-->
<div class="group-list">
<a class="glist-item auth" id="address">
<div class="group-list address-item">
<a class="glist-item auth" id="address" v-if="data.nickName">
地址管理
<span class="num">{{data.address_num}} <span class="icon icon-right"></span></span>
</a>
<p class="glist-item" v-else>
地址管理
</p>
</div>
<div class="group-list">
<a class="glist-item" href="/help">
帮助中心
<span class="num"><span class="icon icon-right"></span></span>
... ... @@ -132,9 +137,9 @@
return {
data: {},
headIco: '',
recordNum: 0,
productNum: 0,
editorialNum: 0
recordNum: '',
productNum: '',
editorialNum: ''
};
},
components: {
... ... @@ -151,15 +156,22 @@
$('.auth').removeClass('no-intercept');
if (yoho.isLogin()) {
$.ajax({
url: '/me/userdata'
}).then(result => {
this.data = result || {};
if (this.data.headIco) {
this.headIco = this.data.headIco;
this.headIco = this.data.headIco || 0;
}
});
$.ajax({
url: '/me/favoriteNum'
}).then(result => {
this.productNum = result.data.product_favorite_total;
});
$('#address').on('click', this.addressClick);
// 之前是否有访客浏览
... ... @@ -178,6 +190,9 @@
this.data = {
nickName: false
};
this.productNum = 0;
this.editorialNum = 0;
this.recordNum = 0;
this.setEmptyimg();
$('.auth').addClass('no-intercept');
... ... @@ -360,7 +375,7 @@
}
.username {
width: 330px;
width: 326px;
display: inline-block;
text-align: left;
text-overflow: ellipsis;
... ... @@ -502,10 +517,9 @@
position: absolute;
left: 0;
bottom: 0;
width: 92%;
width: 100%;
height: 0;
border-top: 1px solid #eee;
margin-left: 28px;
}
&:last-child:after {
... ... @@ -531,6 +545,11 @@
}
}
.address-item {
margin-bottom: 0;
border-bottom: none;
}
.change-channel {
height: 88px;
width: 100%;
... ... @@ -555,10 +574,11 @@
.user-count {
padding: 0 60px;
background: #fff;
text-align: center;
.uc-item {
display: inline-block;
margin: 24px 54px;
margin: 24px 44px;
text-align: center;
.num {
... ...
... ... @@ -27,13 +27,13 @@
</span>
</label>
</li>
<li>
<!--<li>
<label>会员等级
<a class="grade" href="/me/grade">
<span class="icon icon-right"></span>
</a>
</label>
</li>
</li>-->
</ul>
</template>
... ...