Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
biao
9 years ago
Commit
e439ecbf990c8c5ea057944d94d7ca4a395179a5
1 parent
80fa412a
update for pagination
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
7 deletions
apps/me/controllers/order.js
apps/me/models/order.js
apps/me/views/partial/order/table-body.hbs
public/js/me/order.page.js
public/scss/me/order/_table.css
apps/me/controllers/order.js
View file @
e439ecb
...
...
@@ -38,7 +38,8 @@ const getOrderList = (req, res) => {
layout
:
false
,
page
:
'order'
,
isMe
:
true
,
orderList
:
result
.
order
.
orderList
orderList
:
result
.
order
.
orderList
,
paginationOpts
:
result
.
order
.
paginationOpts
});
});
};
...
...
apps/me/models/order.js
View file @
e439ecb
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
camelCase
=
global
.
yoho
.
camelCase
;
...
...
@@ -9,9 +11,21 @@ const _getUserOrder = (type, page) => {
page
:
page
||
1
,
limit
:
10
}).
then
(
result
=>
{
const
orderList
=
result
&&
result
.
data
&&
result
.
data
.
order_list
||
[];
let
orderList
=
[];
let
total
=
false
;
let
curPage
=
1
;
if
(
result
&&
result
.
data
)
{
orderList
=
result
.
data
.
order_list
;
total
=
result
.
data
.
total
;
curPage
=
result
.
data
.
page
;
}
return
camelCase
(
orderList
);
return
{
orderList
:
camelCase
(
orderList
),
total
:
total
,
curPage
:
curPage
};
});
};
...
...
@@ -41,11 +55,19 @@ const getOrderData = (type, page) => {
};
const
order
=
Object
.
assign
(
fakeData
,
{
orderList
:
result
.
length
&&
resul
t
||
false
orderList
:
result
.
orderList
.
length
&&
result
.
orderLis
t
||
false
},
navBar
);
const
paginationOpts
=
{
paginationOpts
:
{
total
:
result
.
total
,
page
:
result
.
curPage
,
limit
:
10
}
};
return
{
order
:
order
order
:
Object
.
assign
(
order
,
paginationOpts
)
};
});
};
...
...
apps/me/views/partial/order/table-body.hbs
View file @
e439ecb
...
...
@@ -54,6 +54,7 @@
</div>
</div>
{{/
orderList
}}
{{{
pagination
paginationOpts
}}}
{{^}}
<div
class=
"bg"
></div>
<div
class=
"msg"
>
...
...
public/js/me/order.page.js
View file @
e439ecb
...
...
@@ -29,12 +29,12 @@ function getOrderList(type, page) {
}
}).
done
(
function
(
res
)
{
tableOperation
.
appendBody
(
res
);
bindPaginationClick
();
// eslint-disable-line
}).
fail
(
function
(
err
)
{
console
.
log
(
err
);
});
}
function
getQueryString
()
{
var
queryArr
=
location
.
search
.
substr
(
1
).
split
(
'&'
);
var
query
=
{};
...
...
@@ -49,6 +49,24 @@ function getQueryString() {
return
query
;
}
function
bindPaginationClick
()
{
$
(
'.blk-pagination li'
).
off
(
'click'
).
on
(
'click'
,
function
(
e
)
{
var
$this
=
$
(
this
);
var
page
=
$this
.
find
(
'a'
).
attr
(
'href'
).
split
(
'='
)[
1
];
var
type
=
getQueryString
().
type
;
e
.
preventDefault
();
if
(
!
$this
.
hasClass
(
'active'
))
{
$
(
'.blk-pagination li.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
getOrderList
(
type
,
page
);
}
});
}
$
(
'.tabs li'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
var
typeMap
=
{
...
...
@@ -62,7 +80,11 @@ $('.tabs li').on('click', function() {
if
(
!
$this
.
hasClass
(
'active'
))
{
$
(
'.tabs li.active'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
getOrderList
(
type
,
page
);
}
getOrderList
(
type
,
page
);
});
bindPaginationClick
();
...
...
public/scss/me/order/_table.css
View file @
e439ecb
...
...
@@ -207,5 +207,10 @@
}
}
}
.blk-pagination
{
margin
:
$
bigSpace
auto
-
$
bigSpace
;
text-align
:
center
;
}
}
...
...
Please
register
or
login
to post a comment