Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
htoooth
8 years ago
Commit
138aadd0f6b2a861e087068949db3c1a22654451
1 parent
779527ca
ok
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
198 additions
and
51 deletions
apps/home/controllers/Favorite.js
apps/home/models/favorite-api.js
apps/home/models/favorite-service.js
apps/home/router.js
apps/home/views/action/favorite.hbs
apps/home/views/action/home/favorite/reduction.hbs
apps/home/views/partial/favorite/price-notice.hbs
public/hbs/home/favorite/new-notify.hbs
public/img/sprite.home.png
public/scss/home/_favorite.css
apps/home/controllers/Favorite.js
View file @
138aadd
...
...
@@ -49,10 +49,10 @@ const index = (req, res, next)=> {
switch
(
type
)
{
case
TABS
.
brand
:
data
.
favBrands
=
yield
favoriteService
.
favoriteBrandListAsync
(
uid
,
page
,
limit
);
data
.
favBrands
=
yield
favoriteService
.
favoriteBrandListAsync
(
uid
,
page
,
limit
,
type
);
break
;
case
TABS
.
article
:
data
.
favArticles
=
yield
favoriteService
.
favoriteArticleListAsync
(
uid
,
udid
,
page
,
limit
);
data
.
favArticles
=
yield
favoriteService
.
favoriteArticleListAsync
(
uid
,
udid
,
page
,
limit
,
type
);
break
;
default
:
data
.
favProducts
=
yield
favoriteService
.
favoriteProductListAsync
(
...
...
@@ -97,16 +97,56 @@ const reduction = (req, res, next) => {
let
type
=
req
.
query
.
type
||
''
;
let
limit
=
10
;
favoriteService
.
reduction
(
uid
,
page
,
limit
,
type
,
0
,
'Y'
).
then
((
result
)
=>
{
favoriteService
.
reduction
Async
(
uid
,
page
,
limit
,
type
,
0
,
'Y'
).
then
((
result
)
=>
{
return
res
.
render
(
'home/favorite/reduction'
,
result
);
}).
catch
(
next
);
};
const
notice
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
id
=
req
.
query
.
id
;
let
mobile
=
req
.
query
.
mobile
;
favoriteService
.
enableNoticeAsync
(
uid
,
mobile
,
id
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
cancelNotice
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
id
=
req
.
query
.
id
;
favoriteService
.
disableNoticeAsync
(
uid
,
id
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
cancel
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
id
=
req
.
query
.
id
;
let
type
=
req
.
query
.
type
||
'product'
;
if
(
!
uid
||
!
id
)
{
return
res
.
json
({
code
:
400
,
message
:
'缺少参数'
});
}
favoriteService
.
cancelAsync
(
uid
,
id
,
type
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
module
.
exports
=
{
index
,
newProduct
,
reduction
,
notice
,
cancelNotice
,
cancel
,
udidRequired
};
...
...
apps/home/models/favorite-api.js
View file @
138aadd
...
...
@@ -2,12 +2,12 @@
const
api
=
global
.
yoho
.
API
;
const
service
=
global
.
yoho
.
ServiceAPI
;
const
_
=
require
(
'lodash'
);
const
URL_PRODUCT_FAVORITE
=
'shops/service/v1/favorite/'
;
const
URL_ARTICLE_FAVORITE
=
'/guang/api/v1/favorite/'
;
const
URL_ARTICLE_FAVORITE_BRAND
=
'/guang/service/v2/favorite/toggleBrand'
;
// apiS.get(self::URL_ARTICLE_FAVORITE. 'getUserFavArticleList',{})
/**
* 根据uid和商品的id查询是否被用户收藏
* @param int $uid
...
...
@@ -38,6 +38,13 @@ const favoriteArticleData = (uid, udid, page, limit)=> {
return
service
.
get
(
URL_ARTICLE_FAVORITE
+
'getUserFavArticleList'
,
options
);
};
const
cancelArticle
=
(
uid
,
id
)
=>
{
return
service
.
get
(
URL_ARTICLE_FAVORITE
+
'cancelFavorite'
,
{
uid
:
uid
,
article_id
:
id
});
}
const
getFavoriteProductList
=
(
uid
,
page
,
limit
)
=>
{
let
options
=
{
method
:
'web.favorite.product'
,
...
...
@@ -65,10 +72,44 @@ const favoriteBrandData = (uid, page, limit) => {
});
};
const
redutionAdd
=
(
uid
,
mobile
,
pid
)
=>
{
return
api
.
get
(
''
,
{
method
:
'web.redution.add'
,
uid
:
uid
,
mobile
:
mobile
,
productId
:
pid
});
};
const
redutionCancel
=
(
uid
,
pid
)
=>
{
return
api
.
get
(
''
,
{
method
:
'web.redution.cancel'
,
uid
:
uid
,
productIds
:
pid
});
};
const
_cancel
=
(
type
,
uid
,
ids
)
=>
{
return
api
.
get
(
''
,
{
method
:
'web.favorite.cancel'
,
favIds
:
ids
,
uid
:
uid
,
type
:
type
});
};
module
.
exports
=
{
getUidProductFav
,
getFavoriteProductList
,
favoriteArticleData
,
favoriteBrandData
,
redutionCount
redutionCount
,
redutionAdd
,
redutionCancel
,
cancel
:
{
product
:
_
.
partial
(
_cancel
,
'product'
,
_
,
_
),
shop
:
_
.
partial
(
_cancel
,
'shop'
,
_
,
_
),
brand
:
_
.
partial
(
_cancel
,
'brand'
,
_
,
_
),
article
:
cancelArticle
}
};
...
...
apps/home/models/favorite-service.js
View file @
138aadd
...
...
@@ -5,9 +5,7 @@ const co = Promise.coroutine;
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
path
=
require
(
'path'
);
const
pager
=
require
(
'./pager'
).
handlePagerData
;
const
favoriteApi
=
require
(
'./favorite-api'
);
const
TABS
=
[
...
...
@@ -54,7 +52,7 @@ const _getSortInfo = (categoryList, sort)=> {
return
result
;
};
const
_getPager
=
(
page
,
total
,
totalPage
,
size
,
type
)
=>
{
const
_getPager
=
(
page
,
total
,
totalPage
)
=>
{
let
result
=
{};
if
(
page
&&
total
&&
totalPage
)
{
...
...
@@ -205,7 +203,7 @@ const favoriteProductListAsync = (uid, page, limit, selectedSort, subscribe, red
})();
};
const
favoriteBrandListAsync
=
(
uid
,
page
,
limit
)
=>
{
const
favoriteBrandListAsync
=
(
uid
,
page
,
limit
,
type
)
=>
{
return
co
(
function
*
()
{
let
result
=
{
brands
:
{
...
...
@@ -237,15 +235,14 @@ const favoriteBrandListAsync = (uid, page, limit)=> {
});
let
total
=
brand
.
data
.
total
||
0
;
let
pageTotal
=
brand
.
data
.
page_total
||
0
;
page
=
brand
.
data
.
page
||
0
;
result
.
pager
=
_getPager
(
page
,
total
,
pageTotal
);
result
.
pager
=
pager
(
total
,
{
page
,
limit
,
type
}
);
return
result
;
})();
};
const
favoriteArticleListAsync
=
(
uid
,
udid
,
page
,
limit
)
=>
{
const
favoriteArticleListAsync
=
(
uid
,
udid
,
page
,
limit
,
type
)
=>
{
return
co
(
function
*
()
{
let
result
=
{};
...
...
@@ -262,10 +259,8 @@ const favoriteArticleListAsync = (uid, udid, page, limit)=> {
});
let
total
=
articles
.
data
.
total
||
0
;
let
pageTotal
=
articles
.
data
.
totalPage
||
0
;
let
pageNum
=
articles
.
data
.
page
||
0
;
result
.
pager
=
_getPager
(
pageNum
,
total
,
pageTotal
);
result
.
pager
=
pager
(
total
,
{
page
,
limit
,
type
}
);
if
(
_
.
isEmpty
(
result
.
articles
))
{
result
.
articles
=
{
...
...
@@ -305,14 +300,83 @@ const newProductAsync = (uid, page, limit, id) => {
})();
};
const
reduction
=
(
uid
,
page
,
limit
,
type
)
=>
{
const
reductionAsync
=
(
uid
,
page
,
limit
)
=>
{
let
result
=
{};
result
.
tabs
=
getFavoriteTabs
(
'product'
);
return
favoriteProductListAsync
(
uid
,
page
,
limit
,
0
,
'Y'
).
then
((
products
)
=>
{
result
.
goods
=
products
.
goods
;
result
.
reductionUrl
=
helpers
.
urlFormat
(
'/home/fovorite'
);
return
{
meFavoritePage
:
true
,
meFavorite
:
result
};
});
};
const
enableNoticeAsync
=
(
uid
,
mobile
,
id
)
=>
{
return
co
(
function
*
()
{
let
result
=
{
code
:
400
,
message
:
'订阅失败'
};
if
(
!
uid
||
!
mobile
||
!
id
)
{
return
result
;
}
let
data
=
yield
favoriteApi
.
redutionAdd
(
uid
,
mobile
,
id
);
if
(
data
.
code
===
200
)
{
result
.
code
=
200
;
return
data
;
}
}
if
(
data
.
code
===
500
)
{
result
.
code
=
500
;
switch
(
data
.
message
)
{
case
'count must be lt 5'
:
result
.
message
=
'您的订阅数已经到达上限'
;
break
;
case
'mobile must bu not null'
:
result
.
message
=
'请填写手机号'
;
break
;
default
:
result
.
message
=
'订阅失败'
;
break
;
}
}
return
result
;
})();
};
const
disableNoticeAsync
=
(
uid
,
id
)
=>
{
return
co
(
function
*
()
{
if
(
!
uid
||
!
id
)
{
return
{
code
:
400
,
message
:
'取消失败'
};
}
return
yield
favoriteApi
.
redutionCancel
(
uid
,
id
);
})();
};
const
cancelAsync
=
(
uid
,
id
,
type
)
=>
{
return
favoriteApi
.
cancel
[
type
](
uid
,
id
);
};
module
.
exports
=
{
getFavoriteTabs
,
favoriteBrandListAsync
,
favoriteProductListAsync
,
favoriteArticleListAsync
,
newProductAsync
newProductAsync
,
reductionAsync
,
enableNoticeAsync
,
disableNoticeAsync
,
cancelAsync
};
...
...
apps/home/router.js
View file @
138aadd
...
...
@@ -43,7 +43,7 @@ const homeNav = (req) => {
title
:
'交易管理'
,
subNav
:
[
{
name
:
'我的订单'
,
href
:
'/home/orders'
,
catchs
:
[
'/home/orders'
,
'/home/index'
]},
{
name
:
'我的收藏'
,
href
:
'/home/favorite'
},
{
name
:
'我的收藏'
,
href
:
'/home/favorite'
,
catchs
:
[
'/home/favorite/reduction'
]
},
{
name
:
'我的有货币'
,
href
:
'/home/currency'
},
{
name
:
'我的红包'
,
href
:
'/home/redenvelopes'
},
{
name
:
'我的优惠券'
,
href
:
'/home/coupons'
},
...
...
@@ -233,7 +233,12 @@ router.get('/favorite', [getCommonHeader, getHomeNav],
// 品牌页新品到着
router
.
get
(
'/favorite/newproduct'
,
favoriteController
.
newProduct
);
router
.
get
(
'/favorite/reduction'
,
favoriteController
.
reduction
);
router
.
get
(
'/favorite/reduction'
,
[
getCommonHeader
,
getHomeNav
],
favoriteController
.
reduction
);
router
.
get
(
'/favorite/notice'
,
favoriteController
.
notice
);
router
.
get
(
'/favorite/cancelnotice'
,
favoriteController
.
cancelNotice
);
router
.
get
(
'/favorite/cancel'
,
favoriteController
.
cancel
);
// router.get('/coupons', CouponsController.index);
...
...
apps/home/views/action/favorite.hbs
View file @
138aadd
...
...
@@ -20,7 +20,5 @@
{{>
help-us
}}
</div>
{{#if
favProducts
}}
{{>
favorite
/
price-notice
}}
{{/if}}
{{>
favorite
/
price-notice
}}
</div>
...
...
apps/home/views/action/home/favorite/reduction.hbs
View file @
138aadd
{{>
layout
/
header
}}
<div
class=
"me-favorite-page me-page yoho-page clearfix"
>
{{>
path
}}
{{>
navigation
}}
{{#
meFavorite
}}
{{>
path
}}
{{>
navigation
}}
<div
class=
"me-main"
>
<div
class=
"favorite fav-products block"
>
<h2
class=
"title"
></h2>
...
...
@@ -44,8 +41,6 @@
{{>
help-us
}}
</div>
{{>
favorite
/
price-notice
}}
{{/
meFavorite
}}
</div>
{{>
layout
/
footer
}}
...
...
apps/home/views/partial/favorite/price-notice.hbs
View file @
138aadd
{{!-- 降价通知弹出框 --}}
<div
id=
"price-notice"
class=
"price-notice hide"
>
<span
class=
"close"
>
<i
class=
"iconfont"
>
๠
2
;
</i>
<i
class=
"iconfont"
>
๠
d
;
</i>
关闭
</span>
<div
class=
"content"
>
...
...
@@ -17,7 +17,7 @@
<div
class=
"success hide"
>
<p>
<span
class=
"iconfont"
>
æ
1f
;
</span>
<span
class=
"iconfont"
>
æ
38
;
</span>
<em
class=
"subscribe-or-cancel"
>
订阅成功
</em>
!
</p>
...
...
@@ -29,10 +29,10 @@
</div>
<div
class=
"cue"
>
<p>
<span
class=
"iconfont"
>
æ
2d
;
</span>
<span
class=
"iconfont"
>
æ
1c
;
</span>
<em
class=
"error-message"
>
您的订阅数已经到达上限
</em>
!
</p>
</div>
<span
class=
"price-notice-sure"
>
确定
</span>
</div>
\ No newline at end of file
</div>
...
...
public/hbs/home/favorite/new-notify.hbs
View file @
138aadd
{{#if
naGoods
}}
<span
class=
"na-pre hidden"
>
<i
class=
"iconfont"
>
æ
22
;
</i>
<i
class=
"iconfont"
>
æ
18
;
</i>
</span>
<div
class=
"na-goods"
>
<ul
class=
"na-goods-ul clearfix"
>
...
...
@@ -22,7 +22,7 @@
</ul>
</div>
<span
class=
"na-next hidden"
>
<i
class=
"iconfont"
>
æ
21
;
</i>
<i
class=
"iconfont"
>
æ
19
;
</i>
</span>
{{^}}
<p
class=
"has-no-na"
>
暂无新产品
</p>
...
...
public/img/sprite.home.png
View file @
138aadd
45 KB
|
W:
|
H:
151 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
public/scss/home/_favorite.css
View file @
138aadd
...
...
@@ -126,7 +126,7 @@
float
:
left
;
height
:
14px
;
width
:
14px
;
background
:
resolve
(
passport
/
tip
/
error
.
png
);
background
:
url
(passport/tip/error.png)
;
margin-right
:
5px
;
margin-top
:
5px
;
}
...
...
@@ -209,10 +209,10 @@
.notice-img
{
float
:
right
;
width
:
20px
;
height
:
18px
;
background
:
url(/home/reduction-notice.jpg)
;
$
img
:
home
/
reduction-notice
.
jpg
;
width
:
width
(
$
img
);
height
:
height
(
$
img
);
background
:
resolve
(
$
img
);
}
}
...
...
@@ -493,12 +493,13 @@
.arrow
{
position
:
absolute
;
height
:
7px
;
$
height
:
height
(
home
/
activity-arrow
.
png
)
;
width
:
13px
;
width
:
width
(
home
/
activity-arrow
.
png
)
;
left
:
20px
;
top
:
calc
(
-7px
);
background
:
resolve
(
home
/
activity-arrow
.
png
)
no-repeat
;
top
:
-calc
(
$
height
);
height
:
$
height
;
background
:
url(home/activity-arrow.png)
no-repeat
;
}
}
}
...
...
@@ -592,11 +593,13 @@
.arrow
{
position
:
absolute
;
height
:
7px
;
width
:
13px
;
$
height
:
height
(
home
/
activity-arrow
.
png
);
width
:
width
(
home
/
activity-arrow
.
png
);
left
:
265px
;
top
:
calc
(
-7px
);
background
:
resolve
(
home
/
activity-arrow
.
png
)
no-repeat
;
top
:
-calc
(
$
height
);
height
:
$
height
;
background
:
url(home/activity-arrow.png)
no-repeat
;
}
}
...
...
@@ -652,15 +655,16 @@
}
}
$
goodsWith
:
660px
;
.na-goods
{
width
:
660px
;
width
:
$
goodsWith
;
height
:
165px
;
padding-top
:
20px
;
overflow
:
hidden
;
}
.na-goods-ul
{
width
:
calc
(
4
*
660
);
/*Max page:4*/
width
:
calc
(
4
*
$
goodsWith
);
/*Max page:4*/
>
li
{
float
:
left
;
...
...
Please
register
or
login
to post a comment