Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
梁志锋
8 years ago
Commit
7564052cff839a08b3a7a1b5ce494113fa07cd54
2 parents
6ac21cd1
554e5d93
Merge branch 'feature-orderlist-opt' into release/wap-optim
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
10 deletions
apps/home/controllers/order.js
apps/home/views/action/order.hbs
public/js/home/order.page.js
apps/home/controllers/order.js
View file @
7564052
...
...
@@ -24,7 +24,19 @@ exports.order = (req, res, next) => {
uid
:
req
.
user
.
uid
};
orderModel
.
order
(
params
).
then
(
result
=>
{
// 获取第一页数据做服务端渲染
let
initialData
=
{
type
:
1
,
page
:
1
,
gender
:
req
.
query
.
gender
||
'1,3'
,
yh_channel
:
req
.
query
.
channel
||
1
,
uid
:
req
.
user
.
uid
};
return
Promise
.
all
([
orderModel
.
order
(
params
),
orderModel
.
getOrders
(
initialData
)
]).
then
(
result
=>
{
res
.
render
(
'order'
,
{
module
:
'home'
,
page
:
'order'
,
...
...
@@ -33,9 +45,11 @@ exports.order = (req, res, next) => {
}),
title
:
'Yoho!Buy 有货'
,
pageFooter
:
true
,
order
:
result
order
:
result
[
0
]
||
[],
firstPageOrdersList
:
result
[
1
]
||
[]
});
}).
catch
(
next
);
};
/**
...
...
@@ -45,13 +59,20 @@ exports.order = (req, res, next) => {
* @param next
*/
exports
.
getOrders
=
(
req
,
res
,
next
)
=>
{
orderModel
.
getOrders
({
let
start
=
req
.
query
.
start
||
0
;
let
params
=
{
type
:
req
.
query
.
type
||
1
,
page
:
req
.
query
.
page
||
1
,
gender
:
req
.
query
.
gender
||
'1,3'
,
yh_channel
:
req
.
query
.
channel
||
1
,
uid
:
req
.
user
.
uid
}).
then
(
result
=>
{
};
orderModel
.
getOrders
(
params
).
then
(
result
=>
{
if
(
result
&&
parseInt
(
params
.
page
,
10
)
===
1
&&
parseInt
(
start
,
10
)
>
0
)
{
result
=
result
.
slice
(
start
||
0
);
}
res
.
render
(
'order-content'
,
{
layout
:
false
,
orders
:
result
...
...
apps/home/views/action/order.hbs
View file @
7564052
...
...
@@ -9,6 +9,21 @@
</ul>
<div
id=
"order-container"
class=
"order-container"
>
{{#if
walkwayUrl
}}
<div
class=
"no-order"
>
<div
class=
"icon"
></div>
<span>
你还没有订单!
</span>
<a
class=
"walk-way"
href=
"
{{
walkwayUrl
}}
"
>
随便逛逛
</a>
</div>
{{^}}
<div
class=
"firstscreen-orders"
>
{{#
each
@root
.
firstPageOrdersList
}}
{{>
order
/
order
}}
{{/
each
}}
</div>
{{/if}}
{{#
each
navs
}}
<div
class=
"orders
{{#
unless
active
}}
hide
{{/
unless
}}
"
></div>
{{/
each
}}
...
...
public/js/home/order.page.js
View file @
7564052
...
...
@@ -20,7 +20,7 @@ var winH = $(window).height();
var
activeType
=
$navLi
.
filter
(
'.active'
).
data
(
'type'
);
// 当前active的项的index
var
order
=
{
page
:
0
,
page
:
1
,
end
:
false
};
...
...
@@ -34,6 +34,9 @@ var orderHammer,
$reaMask
=
$
(
'.reason-mask'
),
reasonSwiper
;
// 首屏加载标志
var
firstScreen
=
$
(
'.firstscreen-orders'
).
children
().
size
()
>
0
;
require
(
'../common'
);
// 减少计时
...
...
@@ -58,8 +61,8 @@ function downCount(item) {
seconds
;
// calculate dates
hours
=
Math
.
floor
((
difference
%
_day
)
/
_hour
),
minutes
=
Math
.
floor
((
difference
%
_hour
)
/
_minute
),
hours
=
Math
.
floor
((
difference
%
_day
)
/
_hour
);
minutes
=
Math
.
floor
((
difference
%
_hour
)
/
_minute
);
seconds
=
Math
.
floor
((
difference
%
_minute
)
/
_second
);
// fix dates so that it will show two digets
...
...
@@ -106,6 +109,11 @@ function getOrders(option) {
page
:
order
.
page
+
1
};
if
(
firstScreen
)
{
// 如果首屏加载了,则去掉10条记录
opt
.
start
=
10
;
}
var
show
=
option
&&
!
option
.
noLoadingMask
;
if
(
inAjax
)
{
...
...
@@ -154,6 +162,9 @@ function getOrders(option) {
setTime
();
}
});
// 还原参数
firstScreen
=
false
;
}
lazyLoad
({
...
...
@@ -265,7 +276,7 @@ $(window).scroll(function() {
});
// 初始化请求第一页数据
getOrders
();
//
getOrders();
$
(
function
()
{
reasonSwiper
=
new
Swiper
(
'.box-main'
,
{
...
...
@@ -273,7 +284,7 @@ $(function() {
slidesPerView
:
5
,
centeredSlides
:
true
,
initialSlide
:
0
,
onSlideChangeStart
:
function
(
reasonSwiper
)
{
onSlideChangeStart
:
function
(
reasonSwiper
)
{
//eslint-disable-line
var
activeIndex
=
reasonSwiper
.
activeIndex
,
slides
=
reasonSwiper
.
slides
,
i
=
0
;
...
...
@@ -301,7 +312,7 @@ $(function() {
});
});
$reaMask
.
find
(
'.box-cmp'
).
on
(
'touchend'
,
function
(
e
)
{
$reaMask
.
find
(
'.box-cmp'
).
on
(
'touchend'
,
function
()
{
var
selSolid
=
reasonSwiper
.
slides
[
reasonSwiper
.
activeIndex
],
reason
=
$
(
selSolid
).
text
(),
reasonId
=
$
(
selSolid
).
data
(
'reasonId'
);
...
...
Please
register
or
login
to post a comment