Showing
9 changed files
with
247 additions
and
43 deletions
@@ -295,6 +295,11 @@ const component = { | @@ -295,6 +295,11 @@ const component = { | ||
295 | res.render('privilege', Object.assign(result, responseData)); | 295 | res.render('privilege', Object.assign(result, responseData)); |
296 | }).catch(next); | 296 | }).catch(next); |
297 | 297 | ||
298 | + }, | ||
299 | + favoriteNum(req, res, next) { | ||
300 | + homeModel.favoriteNum(req.user.uid).then(result => { | ||
301 | + res.json(result); | ||
302 | + }).catch(next); | ||
298 | } | 303 | } |
299 | }; | 304 | }; |
300 | 305 |
@@ -4,6 +4,8 @@ const serviceAPI = global.yoho.ServiceAPI; | @@ -4,6 +4,8 @@ const serviceAPI = global.yoho.ServiceAPI; | ||
4 | const helpers = global.yoho.helpers; | 4 | const helpers = global.yoho.helpers; |
5 | const _ = require('lodash'); | 5 | const _ = require('lodash'); |
6 | const config = global.yoho.config; | 6 | const config = global.yoho.config; |
7 | +const singleAPI = global.yoho.SingleAPI; | ||
8 | + | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * 查询用户信息 | 11 | * 查询用户信息 |
@@ -438,3 +440,12 @@ exports.getPreferential = (params) => { | @@ -438,3 +440,12 @@ exports.getPreferential = (params) => { | ||
438 | }); | 440 | }); |
439 | }; | 441 | }; |
440 | 442 | ||
443 | +// 收藏数量接口 | ||
444 | +exports.favoriteNum = (uid) => { | ||
445 | + return singleAPI.get('favorite', { | ||
446 | + method: 'app.favorite.getFavoriteCount', | ||
447 | + uid: uid | ||
448 | + }, { | ||
449 | + code: 200 | ||
450 | + }); | ||
451 | +}; |
@@ -46,6 +46,7 @@ router.post('/me/save-feedback', auth, home.saveFeedback); // 个人中心-提 | @@ -46,6 +46,7 @@ router.post('/me/save-feedback', auth, home.saveFeedback); // 个人中心-提 | ||
46 | router.get('/me/collection', auth, favorite.favorite); // 个人中心 - 收藏 | 46 | router.get('/me/collection', auth, favorite.favorite); // 个人中心 - 收藏 |
47 | router.get('/me/collection/favpaging', auth, favorite.favpaging); // 个人中心 - 收藏商品/品牌/资讯(翻页) | 47 | router.get('/me/collection/favpaging', auth, favorite.favpaging); // 个人中心 - 收藏商品/品牌/资讯(翻页) |
48 | router.post('/me/del-favdel', auth, favorite.deletefav); // 个人中心 - 收藏商品/品牌/资讯(刪除) | 48 | router.post('/me/del-favdel', auth, favorite.deletefav); // 个人中心 - 收藏商品/品牌/资讯(刪除) |
49 | +router.get('/me/favoriteNum', auth, home.favoriteNum);// 收藏个数 | ||
49 | 50 | ||
50 | // 退换货 | 51 | // 退换货 |
51 | router.get('/me/return', auth, refund.refundOrders); // 退换货 - 订单列表 | 52 | router.get('/me/return', auth, refund.refundOrders); // 退换货 - 订单列表 |
@@ -96,4 +97,5 @@ router.get('/me/grade', auth, home.grade); | @@ -96,4 +97,5 @@ router.get('/me/grade', auth, home.grade); | ||
96 | router.get('/me/gradeData', home.gradeData); | 97 | router.get('/me/gradeData', home.gradeData); |
97 | router.get('/me/privilege', auth, home.preferential); | 98 | router.get('/me/privilege', auth, home.preferential); |
98 | 99 | ||
100 | + | ||
99 | module.exports = router; | 101 | module.exports = router; |
@@ -6,14 +6,14 @@ module.exports = () => { | @@ -6,14 +6,14 @@ module.exports = () => { | ||
6 | const token = req.cookies._YOHOTOKEN; | 6 | const token = req.cookies._YOHOTOKEN; |
7 | const key = `-_-!!!${uid}!!!-_-`; | 7 | const key = `-_-!!!${uid}!!!-_-`; |
8 | 8 | ||
9 | - console.log(uid) | 9 | + console.log(uid); |
10 | 10 | ||
11 | if (md5(key) === token) { | 11 | if (md5(key) === token) { |
12 | req.user.uid = uid; | 12 | req.user.uid = uid; |
13 | delete req.cookies._YOHOUID; | 13 | delete req.cookies._YOHOUID; |
14 | } | 14 | } |
15 | 15 | ||
16 | - req.user.uid = 51477204; // todo modify wsl | 16 | + req.user.uid = 51477204; // todo modify wsl |
17 | 17 | ||
18 | next(); | 18 | next(); |
19 | }; | 19 | }; |
public/vue/editorial/index-box.1.vue
0 → 100644
1 | +<template> | ||
2 | + <resources :content-code.sync="contentCode"></resources> | ||
3 | + <div v-infinite-scroll="getNewsList()"> | ||
4 | + <div v-for="editorial in editorialList" class="editorial-box"> | ||
5 | + <div class="img"> | ||
6 | + <a href='{{"/editorial/" + editorial.id + ".html"}}'> | ||
7 | + <img v-bind:src="editorial.src | resize 750 469" alt="" /> | ||
8 | + </a> | ||
9 | + </div> | ||
10 | + <div class="title"> | ||
11 | + <a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a> | ||
12 | + </div> | ||
13 | + <div class="editorial-des"> | ||
14 | + <p class="line-clamp-2">{{editorial.intro}}</p> | ||
15 | + </div> | ||
16 | + <hr> | ||
17 | + <div class="bottom clearfix"> | ||
18 | + <span class="icon icon-timeshare"></span> | ||
19 | + <span class="time">{{editorial.publish_time}}</span> | ||
20 | + <span class="icon icon-share share" @click="share(editorial.title, editorial.intro, editorial.src, editorial.id)"></span> | ||
21 | + </div> | ||
22 | + </div> | ||
23 | + </div> | ||
24 | + <div v-if="!scrollDisabled" class="is-loading">loading...</div> | ||
25 | +</template> | ||
26 | +<style> | ||
27 | + .editorial-box { | ||
28 | + background: #f6f6f6; | ||
29 | + border-bottom: #eee 1px solid; | ||
30 | + padding-top: 30px; | ||
31 | + | ||
32 | + .img { | ||
33 | + width: 100%; | ||
34 | + height: 470px; | ||
35 | + overflow: hidden; | ||
36 | + | ||
37 | + img { | ||
38 | + width: 100%; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + .title { | ||
43 | + background: #fff; | ||
44 | + font-size: 42px; | ||
45 | + line-height: 1.2; | ||
46 | + font-weight: 700; | ||
47 | + padding: 30px; | ||
48 | + } | ||
49 | + | ||
50 | + .editorial-des { | ||
51 | + background: #fff; | ||
52 | + padding: 0 30px 30px; | ||
53 | + color: #b0b0b0; | ||
54 | + font-size: 28px; | ||
55 | + line-height: 32px; | ||
56 | + } | ||
57 | + | ||
58 | + hr { | ||
59 | + margin: 0 30px; | ||
60 | + border: #eee 1px solid; | ||
61 | + border-bottom: 0; | ||
62 | + } | ||
63 | + | ||
64 | + .bottom { | ||
65 | + padding: 10px 30px; | ||
66 | + background: #fff; | ||
67 | + color: #b0b0b0; | ||
68 | + font-size: 24px; | ||
69 | + height: 78px; | ||
70 | + | ||
71 | + span { | ||
72 | + display: inline-block; | ||
73 | + padding: 12px 0; | ||
74 | + } | ||
75 | + | ||
76 | + .share { | ||
77 | + float: right; | ||
78 | + padding-top: 16px; | ||
79 | + } | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + .is-loading { | ||
84 | + font-size: 32px; | ||
85 | + text-align: center; | ||
86 | + padding: 16px 0; | ||
87 | + } | ||
88 | +</style> | ||
89 | +<script> | ||
90 | + const util = require('common/util'); | ||
91 | + const contentCode = require('content-code'); | ||
92 | + const resources = require('component/resources/index.vue'); | ||
93 | + const qs = require('yoho-qs'); | ||
94 | + const $ = require('jquery'); | ||
95 | + const tip = require('common/tip'); | ||
96 | + const yoho = require('yoho'); | ||
97 | + | ||
98 | + module.exports = { | ||
99 | + data() { | ||
100 | + return { | ||
101 | + contentCode: contentCode.editorial.all, | ||
102 | + editorialList: [], | ||
103 | + page: 1, | ||
104 | + scrollDisabled: false, | ||
105 | + channel: qs.channel | ||
106 | + }; | ||
107 | + }, | ||
108 | + watch: { | ||
109 | + channel() { | ||
110 | + this.getNewsList(); | ||
111 | + } | ||
112 | + }, | ||
113 | + methods: { | ||
114 | + | ||
115 | + /* 获取资讯列表数据 */ | ||
116 | + getNewsList() { | ||
117 | + if (this.scrollDisabled) { | ||
118 | + return; | ||
119 | + } | ||
120 | + this.scrollDisabled = true; | ||
121 | + $.get({ | ||
122 | + url: '/editorial/list.json', | ||
123 | + data: { | ||
124 | + page: this.page, | ||
125 | + channel: this.channel | ||
126 | + } | ||
127 | + }).done(result => { | ||
128 | + if (result.code === 200 && result.data.list.length > 0) { | ||
129 | + if (this.editorialList.length > 0 && result.data.list.length > 0) { | ||
130 | + this.$set('editorialList', this.editorialList.concat(result.data.list)); | ||
131 | + } else if (result.data.list.length > 0) { | ||
132 | + this.editorialList = result.data.list; | ||
133 | + } | ||
134 | + | ||
135 | + // 如果未加载完,继续翻页加载 | ||
136 | + if (result.data.list.length > 0) { | ||
137 | + this.page++; | ||
138 | + this.scrollDisabled = false; | ||
139 | + } | ||
140 | + } else { | ||
141 | + tip('没有了...'); | ||
142 | + } | ||
143 | + }).fail(() => { | ||
144 | + this.scrollDisabled = false; | ||
145 | + }); | ||
146 | + }, | ||
147 | + | ||
148 | + /* 分享资讯 */ | ||
149 | + share(title, des, img, id) { | ||
150 | + title = title.length > 15 ? title.substr(0, 15) + '...' : title; | ||
151 | + img = location.protocol + util.getImgUrl(img, 300, 300, 2); | ||
152 | + yoho.goShare({ | ||
153 | + title: title, | ||
154 | + des: des, | ||
155 | + img: img, | ||
156 | + url: `${location.origin}/editorial/${id}.html?shareTitle=${title}` | ||
157 | + }); | ||
158 | + } | ||
159 | + }, | ||
160 | + components: { | ||
161 | + resources | ||
162 | + }, | ||
163 | + created() { | ||
164 | + this.getNewsList(); | ||
165 | + } | ||
166 | + }; | ||
167 | +</script> |
@@ -5,48 +5,47 @@ | @@ -5,48 +5,47 @@ | ||
5 | <div class="img"> | 5 | <div class="img"> |
6 | <a href='{{"/editorial/" + editorial.id + ".html"}}'> | 6 | <a href='{{"/editorial/" + editorial.id + ".html"}}'> |
7 | <img v-bind:src="editorial.src | resize 750 469" alt="" /> | 7 | <img v-bind:src="editorial.src | resize 750 469" alt="" /> |
8 | + <p class="title">{{editorial.title}}</p> | ||
9 | + <p class="type">搭配</p> | ||
8 | </a> | 10 | </a> |
9 | </div> | 11 | </div> |
10 | - <div class="title"> | ||
11 | - <a class="line-clamp-2" href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a> | ||
12 | - </div> | ||
13 | - <div class="editorial-des"> | ||
14 | - <p class="line-clamp-2">{{editorial.intro}}</p> | ||
15 | - </div> | ||
16 | - <hr> | ||
17 | - <div class="bottom clearfix"> | ||
18 | - <span class="icon icon-timeshare"></span> | ||
19 | - <span class="time">{{editorial.publish_time}}</span> | ||
20 | - <span class="icon icon-share share" @click="share(editorial.title, editorial.intro, editorial.src, editorial.id)"></span> | ||
21 | - </div> | ||
22 | </div> | 12 | </div> |
23 | </div> | 13 | </div> |
24 | <div v-if="!scrollDisabled" class="is-loading">loading...</div> | 14 | <div v-if="!scrollDisabled" class="is-loading">loading...</div> |
25 | </template> | 15 | </template> |
26 | <style> | 16 | <style> |
27 | .editorial-box { | 17 | .editorial-box { |
28 | - background: #f6f6f6; | ||
29 | - border-bottom: #eee 1px solid; | ||
30 | - padding-top: 30px; | ||
31 | - | ||
32 | .img { | 18 | .img { |
33 | width: 100%; | 19 | width: 100%; |
34 | height: 470px; | 20 | height: 470px; |
35 | overflow: hidden; | 21 | overflow: hidden; |
22 | + position: relative; | ||
36 | 23 | ||
37 | img { | 24 | img { |
38 | width: 100%; | 25 | width: 100%; |
39 | } | 26 | } |
40 | - } | ||
41 | 27 | ||
42 | - .title { | ||
43 | - background: #fff; | ||
44 | - font-size: 42px; | ||
45 | - line-height: 1.2; | ||
46 | - font-weight: 700; | ||
47 | - padding: 30px; | ||
48 | - } | 28 | + .title { |
29 | + width: 580px; | ||
30 | + position: absolute; | ||
31 | + bottom: 100px; | ||
32 | + text-align: center; | ||
33 | + color: #fff; | ||
34 | + font-size: 34px; | ||
35 | + line-height: 34px; | ||
36 | + left: 50%; | ||
37 | + margin-left: -290px; | ||
38 | + } | ||
49 | 39 | ||
40 | + .type { | ||
41 | + width: 100%; | ||
42 | + color: #fff; | ||
43 | + font-size: 24px; | ||
44 | + position: absolute; | ||
45 | + bottom: 45px; | ||
46 | + text-align: center; | ||
47 | + } | ||
48 | + } | ||
50 | .editorial-des { | 49 | .editorial-des { |
51 | background: #fff; | 50 | background: #fff; |
52 | padding: 0 30px 30px; | 51 | padding: 0 30px 30px; |
@@ -19,11 +19,11 @@ | @@ -19,11 +19,11 @@ | ||
19 | </a> | 19 | </a> |
20 | <div class="group-list"> | 20 | <div class="group-list"> |
21 | <div class="user-count"> | 21 | <div class="user-count"> |
22 | - <a class="auth uc-item" href=""> | 22 | + <a class="auth uc-item" href="/me/collection"> |
23 | <p class="num">{{productNum}}</p> | 23 | <p class="num">{{productNum}}</p> |
24 | <p class="label">商品收藏</p> | 24 | <p class="label">商品收藏</p> |
25 | </a> | 25 | </a> |
26 | - <a class="auth uc-item" href=""> | 26 | + <a class="auth uc-item" href="/me/collection?tab=article"> |
27 | <p class="num">{{editorialNum}}</p> | 27 | <p class="num">{{editorialNum}}</p> |
28 | <p class="label">资讯收藏</p> | 28 | <p class="label">资讯收藏</p> |
29 | </a> | 29 | </a> |
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | </a> | 68 | </a> |
69 | </div> | 69 | </div> |
70 | </div> | 70 | </div> |
71 | - <div class="group-list"> | 71 | + <!--<div class="group-list"> |
72 | <a class="glist-item auth" href="/me/collection"> | 72 | <a class="glist-item auth" href="/me/collection"> |
73 | 我的收藏 | 73 | 我的收藏 |
74 | <span class="num">商品/品牌/资讯 <span class="icon icon-right"></span></span> | 74 | <span class="num">商品/品牌/资讯 <span class="icon icon-right"></span></span> |
@@ -77,18 +77,23 @@ | @@ -77,18 +77,23 @@ | ||
77 | 浏览记录 | 77 | 浏览记录 |
78 | <span class="num">{{recordNum}}<span class="icon icon-right"></span></span> | 78 | <span class="num">{{recordNum}}<span class="icon icon-right"></span></span> |
79 | </a> | 79 | </a> |
80 | - </div> | 80 | + </div>--> |
81 | <!--<div class="group-list"> | 81 | <!--<div class="group-list"> |
82 | <a class="glist-item auth" href="/me/mycurrency"> | 82 | <a class="glist-item auth" href="/me/mycurrency"> |
83 | 有货币 | 83 | 有货币 |
84 | <span class="num">{{data.yoho_coin_num}} <span class="icon icon-right"></span></span> | 84 | <span class="num">{{data.yoho_coin_num}} <span class="icon icon-right"></span></span> |
85 | </a> | 85 | </a> |
86 | </div>--> | 86 | </div>--> |
87 | - <div class="group-list"> | ||
88 | - <a class="glist-item auth" id="address"> | 87 | + <div class="group-list address-item"> |
88 | + <a class="glist-item auth" id="address" v-if="data.nickName"> | ||
89 | 地址管理 | 89 | 地址管理 |
90 | <span class="num">{{data.address_num}} <span class="icon icon-right"></span></span> | 90 | <span class="num">{{data.address_num}} <span class="icon icon-right"></span></span> |
91 | </a> | 91 | </a> |
92 | + <p class="glist-item" v-else> | ||
93 | + 地址管理 | ||
94 | + </p> | ||
95 | + </div> | ||
96 | + <div class="group-list"> | ||
92 | <a class="glist-item" href="/help"> | 97 | <a class="glist-item" href="/help"> |
93 | 帮助中心 | 98 | 帮助中心 |
94 | <span class="num"><span class="icon icon-right"></span></span> | 99 | <span class="num"><span class="icon icon-right"></span></span> |
@@ -132,9 +137,9 @@ | @@ -132,9 +137,9 @@ | ||
132 | return { | 137 | return { |
133 | data: {}, | 138 | data: {}, |
134 | headIco: '', | 139 | headIco: '', |
135 | - recordNum: 0, | ||
136 | - productNum: 0, | ||
137 | - editorialNum: 0 | 140 | + recordNum: '', |
141 | + productNum: '', | ||
142 | + editorialNum: '' | ||
138 | }; | 143 | }; |
139 | }, | 144 | }, |
140 | components: { | 145 | components: { |
@@ -151,15 +156,22 @@ | @@ -151,15 +156,22 @@ | ||
151 | $('.auth').removeClass('no-intercept'); | 156 | $('.auth').removeClass('no-intercept'); |
152 | 157 | ||
153 | if (yoho.isLogin()) { | 158 | if (yoho.isLogin()) { |
159 | + | ||
154 | $.ajax({ | 160 | $.ajax({ |
155 | url: '/me/userdata' | 161 | url: '/me/userdata' |
156 | }).then(result => { | 162 | }).then(result => { |
157 | this.data = result || {}; | 163 | this.data = result || {}; |
158 | if (this.data.headIco) { | 164 | if (this.data.headIco) { |
159 | - this.headIco = this.data.headIco; | 165 | + this.headIco = this.data.headIco || 0; |
160 | } | 166 | } |
161 | }); | 167 | }); |
162 | 168 | ||
169 | + $.ajax({ | ||
170 | + url: '/me/favoriteNum' | ||
171 | + }).then(result => { | ||
172 | + this.productNum = result.data.product_favorite_total; | ||
173 | + }); | ||
174 | + | ||
163 | $('#address').on('click', this.addressClick); | 175 | $('#address').on('click', this.addressClick); |
164 | 176 | ||
165 | // 之前是否有访客浏览 | 177 | // 之前是否有访客浏览 |
@@ -178,6 +190,9 @@ | @@ -178,6 +190,9 @@ | ||
178 | this.data = { | 190 | this.data = { |
179 | nickName: false | 191 | nickName: false |
180 | }; | 192 | }; |
193 | + this.productNum = 0; | ||
194 | + this.editorialNum = 0; | ||
195 | + this.recordNum = 0; | ||
181 | this.setEmptyimg(); | 196 | this.setEmptyimg(); |
182 | 197 | ||
183 | $('.auth').addClass('no-intercept'); | 198 | $('.auth').addClass('no-intercept'); |
@@ -360,7 +375,7 @@ | @@ -360,7 +375,7 @@ | ||
360 | } | 375 | } |
361 | 376 | ||
362 | .username { | 377 | .username { |
363 | - width: 330px; | 378 | + width: 326px; |
364 | display: inline-block; | 379 | display: inline-block; |
365 | text-align: left; | 380 | text-align: left; |
366 | text-overflow: ellipsis; | 381 | text-overflow: ellipsis; |
@@ -502,10 +517,9 @@ | @@ -502,10 +517,9 @@ | ||
502 | position: absolute; | 517 | position: absolute; |
503 | left: 0; | 518 | left: 0; |
504 | bottom: 0; | 519 | bottom: 0; |
505 | - width: 92%; | 520 | + width: 100%; |
506 | height: 0; | 521 | height: 0; |
507 | border-top: 1px solid #eee; | 522 | border-top: 1px solid #eee; |
508 | - margin-left: 28px; | ||
509 | } | 523 | } |
510 | 524 | ||
511 | &:last-child:after { | 525 | &:last-child:after { |
@@ -531,6 +545,11 @@ | @@ -531,6 +545,11 @@ | ||
531 | } | 545 | } |
532 | } | 546 | } |
533 | 547 | ||
548 | + .address-item { | ||
549 | + margin-bottom: 0; | ||
550 | + border-bottom: none; | ||
551 | + } | ||
552 | + | ||
534 | .change-channel { | 553 | .change-channel { |
535 | height: 88px; | 554 | height: 88px; |
536 | width: 100%; | 555 | width: 100%; |
@@ -555,10 +574,11 @@ | @@ -555,10 +574,11 @@ | ||
555 | .user-count { | 574 | .user-count { |
556 | padding: 0 60px; | 575 | padding: 0 60px; |
557 | background: #fff; | 576 | background: #fff; |
577 | + text-align: center; | ||
558 | 578 | ||
559 | .uc-item { | 579 | .uc-item { |
560 | display: inline-block; | 580 | display: inline-block; |
561 | - margin: 24px 54px; | 581 | + margin: 24px 44px; |
562 | text-align: center; | 582 | text-align: center; |
563 | 583 | ||
564 | .num { | 584 | .num { |
@@ -27,13 +27,13 @@ | @@ -27,13 +27,13 @@ | ||
27 | </span> | 27 | </span> |
28 | </label> | 28 | </label> |
29 | </li> | 29 | </li> |
30 | - <li> | 30 | + <!--<li> |
31 | <label>会员等级 | 31 | <label>会员等级 |
32 | <a class="grade" href="/me/grade"> | 32 | <a class="grade" href="/me/grade"> |
33 | <span class="icon icon-right"></span> | 33 | <span class="icon icon-right"></span> |
34 | </a> | 34 | </a> |
35 | </label> | 35 | </label> |
36 | - </li> | 36 | + </li>--> |
37 | </ul> | 37 | </ul> |
38 | </template> | 38 | </template> |
39 | 39 |
-
Please register or login to post a comment