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
0b693fb1f5a0f3452feaaa9ebb57def333b4c88d
1 parent
31e391d2
add hbs
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
13 deletions
apps/home/controllers/Favorite.js
apps/home/models/favorite-service.js
apps/home/router.js
public/hbs/home/favorite/new-notify.hbs
public/js/home/favorite.page.js
apps/home/controllers/Favorite.js
View file @
0b693fb
...
...
@@ -8,7 +8,6 @@ const Promise = require('bluebird');
const
co
=
Promise
.
coroutine
;
const
requestIp
=
require
(
'request-ip'
);
const
md5
=
require
(
'md5'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
favoriteService
=
require
(
'../models/favorite-service'
);
...
...
@@ -50,13 +49,13 @@ const index = (req, res, next)=> {
switch
(
type
)
{
case
TABS
.
brand
:
data
.
favBrands
=
yield
favoriteService
.
favoriteBrandList
(
uid
,
page
,
limit
);
data
.
favBrands
=
yield
favoriteService
.
favoriteBrandList
Async
(
uid
,
page
,
limit
);
break
;
case
TABS
.
article
:
data
.
favArticles
=
yield
favoriteService
.
favoriteArticleListAsync
(
uid
,
udid
,
page
,
limit
);
break
;
default
:
data
.
favProducts
=
yield
favoriteService
.
favoriteProductList
(
data
.
favProducts
=
yield
favoriteService
.
favoriteProductList
Async
(
uid
,
page
,
limit
,
selectedSort
,
'N'
,
reduction
,
promotion
,
req
.
query
);
break
;
...
...
@@ -71,7 +70,42 @@ const index = (req, res, next)=> {
}).
catch
(
next
);
};
const
newProduct
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
page
=
+
req
.
query
.
page
||
1
;
let
limit
=
+
req
.
query
.
limit
||
10
;
let
id
=
+
req
.
query
.
id
||
0
;
if
(
!
id
)
{
return
res
.
json
({
code
:
400
,
message
:
'缺少参数'
});
}
favoriteService
.
newProductAsync
(
uid
,
page
,
limit
,
id
).
then
((
result
)
=>
{
return
res
.
json
({
code
:
200
,
data
:
result
});
}).
catch
(
next
);
};
const
reduction
=
(
req
,
res
,
next
)
=>
{
let
page
=
+
req
.
query
.
page
||
1
;
let
type
=
req
.
query
.
type
||
''
;
let
limit
=
10
;
favoriteService
.
reduction
().
then
((
result
)
=>
{
return
res
.
render
(
'reduction'
,
result
);
}).
catch
(
next
);
};
module
.
exports
=
{
index
,
newProduct
,
reduction
,
udidRequired
};
...
...
apps/home/models/favorite-service.js
View file @
0b693fb
...
...
@@ -122,7 +122,7 @@ const _redutionCount = (uid)=> {
};
const
favoriteProductList
=
(
uid
,
page
,
limit
,
selectedSort
,
subscribe
,
reduction
,
promotion
,
query
)
=>
{
const
favoriteProductList
Async
=
(
uid
,
page
,
limit
,
selectedSort
,
subscribe
,
reduction
,
promotion
,
query
)
=>
{
return
co
(
function
*
()
{
let
result
=
{
sort
:
{},
...
...
@@ -205,7 +205,7 @@ const favoriteProductList = (uid, page, limit, selectedSort, subscribe, reductio
})();
};
const
favoriteBrandList
=
(
uid
,
page
,
limit
)
=>
{
const
favoriteBrandList
Async
=
(
uid
,
page
,
limit
)
=>
{
return
co
(
function
*
()
{
let
result
=
{
brands
:
{
...
...
@@ -277,14 +277,38 @@ const favoriteArticleListAsync = (uid, udid, page, limit)=> {
})();
};
const
newProductAsync
=
(
uid
,
page
,
limit
,
id
)
=>
{
return
co
(
function
*
()
{
let
products
=
yield
favoriteApi
.
favoriteBrandData
(
uid
,
page
,
limit
);
return
_
.
get
(
products
,
'data.brand_list'
,
[]).
reduce
((
total
,
cur
)
=>
{
if
(
id
!==
cur
.
brand_id
)
{
return
total
;
}
if
(
cur
.
new_product_num
===
0
)
{
return
total
;
}
total
=
_
.
concat
(
total
,
_
.
take
(
_
.
get
(
cur
,
'new_product'
,
[]),
20
).
map
((
pro
)
=>
{
return
{
img
:
pro
.
default_images
,
url
:
helpers
.
getUrlBySkc
(
pro
.
product_id
,
_
.
get
(
pro
,
'goods[0].id'
,
''
),
_
.
get
(
pro
,
'cnAlphabet'
)),
name
:
pro
.
product_name
,
salePrice
:
pro
.
sales_price
===
pro
.
market_price
?
''
:
pro
.
sales_price
,
marketPrice
:
pro
.
market_price
};
}));
return
total
;
},
[]);
})();
};
module
.
exports
=
{
getFavoriteTabs
,
favoriteBrandList
,
favoriteProductList
,
favoriteArticleListAsync
favoriteBrandListAsync
,
favoriteProductListAsync
,
favoriteArticleListAsync
,
newProductAsync
};
...
...
apps/home/router.js
View file @
0b693fb
...
...
@@ -215,7 +215,11 @@ router.get('/favorite', [getCommonHeader, getHomeNav],
favoriteController
.
index
);
//
// 品牌页新品到着
router
.
get
(
'/favorite/newproduct'
,
favoriteController
.
newProduct
);
router
.
get
(
'/favorite/reduction'
,
favoriteController
.
reduction
);
// router.get('/coupons', CouponsController.index);
router
.
get
(
'/user'
,
[
getCommonHeader
,
getHomeNav
],
UserController
.
index
);
...
...
public/hbs/home/favorite/new-notify.hbs
0 → 100644
View file @
0b693fb
{{#if
naGoods
}}
<span
class=
"na-pre hidden"
>
<i
class=
"iconfont"
>

</i>
</span>
<div
class=
"na-goods"
>
<ul
class=
"na-goods-ul clearfix"
>
{{#
naGoods
}}
<li
class=
"na-good"
>
<a
href=
"
{{
url
}}
"
>
<img
class=
"na-good-thumb"
src=
"
{{
image2
img
w
=
100
h
=
100
}}
"
>
<p
class=
"na-good-name"
>
{{
name
}}
</p>
</a>
<span
class=
"na-price
{{#if
salePrice
}}
has-sale
{{/if}}
"
>
¥
{{
marketPrice
}}
</span>
{{#if
salePrice
}}
<span
class=
"na-price"
>
¥
{{
salePrice
}}
</span>
{{/if}}
</li>
{{/
naGoods
}}
</ul>
</div>
<span
class=
"na-next hidden"
>
<i
class=
"iconfont"
>

</i>
</span>
{{^}}
<p
class=
"has-no-na"
>
暂无新产品
</p>
{{/if}}
...
...
public/js/home/favorite.page.js
View file @
0b693fb
...
...
@@ -4,8 +4,7 @@
* @date: 2016/2/23
*/
var
$
=
require
(
'yoho-jquery'
),
Handlebars
=
require
(
'yoho-handlebars'
);
var
$
=
require
(
'yoho-jquery'
);
var
phoneReg
=
require
(
'../passport/mail-phone-regx'
).
phoneRegx
[
'+86'
];
...
...
@@ -306,7 +305,7 @@ require('../common');
return
;
}
naTpl
=
Handlebars
.
compile
(
$
(
'#na-tpl'
).
html
()
);
naTpl
=
require
(
'hbs/home/favorite/new-notify.hbs'
);
// 新品到着【重要信息:最多显示20个新品到着商品】
$
(
'.na-trigger'
).
click
(
function
()
{
...
...
@@ -345,6 +344,7 @@ require('../common');
tplData
=
res
.
length
===
0
?
{}
:
{
naGoods
:
res
};
html
=
naTpl
(
tplData
);
$naList
.
removeClass
(
'hide'
).
find
(
'.na-content'
).
html
(
html
);
...
...
@@ -444,7 +444,7 @@ $('#me-del-checked').click(function() {
id
:
ids
.
join
(
','
),
type
:
favType
}
}).
then
(
function
(
data
)
{
}).
then
(
function
()
{
history
.
go
(
0
);
});
}
...
...
Please
register
or
login
to post a comment