Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
YH_RNComponent
·
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
Email Patches
Plain Diff
Browse Files
Authored by
shixiang
8 years ago
Commit
5bc2977d1e274b4db676216b0352d73f06c85427
1 parent
4b22a2f9
分期开通界面 未添加事件处理 review 于良
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
176 additions
and
11 deletions
js/installment/Installment.js
js/installment/components/installment/Installment.js
js/installment/constants/actionTypes.js
js/installment/containers/InstallmentContainer.js
js/installment/reducers/installment/installmentActions.js
js/installment/reducers/installment/installmentInitialState.js
js/installment/reducers/installment/installmentReducer.js
js/installment/services/InstallmentService.js
js/installment/Installment.js
View file @
5bc2977
...
...
@@ -41,6 +41,7 @@ export default function native(platform) {
store
.
dispatch
(
setPlatform
(
platform
));
let
channel
=
this
.
props
.
channel
;
channel
&&
store
.
dispatch
(
setChannel
(
channel
));
console
.
log
(
channel
);
return
(
<
Provider
store
=
{
store
}
>
<
InstallmentContainer
/>
...
...
js/installment/components/installment/Installment.js
View file @
5bc2977
...
...
@@ -12,37 +12,85 @@ import ReactNative, {
}
from
'react-native'
;
import
Immutable
,
{
Map
}
from
'immutable'
;
import
ProductListCell
from
'../../../common/components/ListCell/ProductListCell'
;
import
OpenInstallmentTop
from
'./OpenInstallmentTop'
;
export
default
class
Installment
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
_renderRow
=
this
.
_renderRow
.
bind
(
this
);
this
.
_renderHeader
=
this
.
_renderHeader
.
bind
(
this
);
this
.
dataSource
=
new
ListView
.
DataSource
({
rowHasChanged
:
(
r1
,
r2
)
=>
!
Immutable
.
is
(
r1
,
r2
),
});
}
renderRow
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
_renderRow
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
let
paddingLeft
=
rowID
%
2
==
1
?
rowMarginHorizontal
/
2
:
rowMarginHorizontal
;
let
customStyle
=
rowID
==
0
||
rowID
==
1
?
{
paddingLeft
}
:
{
paddingLeft
};
return
(
<
ProductListCell
style
=
{[
styles
.
listContainer
,
customStyle
]}
key
=
{
'row'
+
rowID
}
rowID
=
{
rowID
}
data
=
{
rowData
}
onPressProduct
=
{
this
.
props
.
onPressProductListProduct
}
/
>
);
}
renderTop
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
_renderHeader
()
{
return
(
<
OpenInstallmentTop
/
>
);
}
render
()
{
let
{
isFetching
,
productListForInstallment
,
installmentInfo
,
}
=
this
.
props
;
let
dataSource
=
null
;
dataSource
=
productListForInstallment
.
list
.
toArray
();
console
.
log
(
'========'
);
console
.
log
(
dataSource
);
console
.
log
(
'========'
);
return
(
<
View
style
=
{
styles
.
container
}
>
<
ListView
contentContainerStyle
=
{
styles
.
contentContainer
}
enableEmptySections
=
{
true
}
dataSource
=
{
this
.
dataSource
.
cloneWithRowsAndSections
(
dataSource
)}
renderRow
=
{
this
.
renderRow
}
dataSource
=
{
this
.
dataSource
.
cloneWithRows
(
dataSource
)}
renderRow
=
{
this
.
_renderRow
}
renderHeader
=
{
this
.
_renderHeader
}
onEndReached
=
{()
=>
{
if
(
productListForInstallment
&&
productListForInstallment
.
list
&&
productListForInstallment
.
list
.
size
>
0
)
{
this
.
props
.
onEndReached
&&
this
.
props
.
onEndReached
();
}
}}
/
>
<
/View
>
);
}
};
let
{
width
,
height
}
=
Dimensions
.
get
(
'window'
);
let
rowWidth
=
Math
.
ceil
(
137.5
*
width
/
320
);
let
rowHeight
=
Math
.
ceil
(
254
*
width
/
320
);
let
rowMarginTop
=
Math
.
ceil
(
10
*
width
/
320
);
let
rowMarginHorizontal
=
(
width
-
rowWidth
*
2
)
/
3
;
let
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
backgroundColor
:
'white'
,
},
contentContainer
:{
flexDirection
:
'row'
,
flexWrap
:
'wrap'
,
},
listContainer
:
{
width
:
width
/
2
,
},
});
\ No newline at end of file
...
...
js/installment/constants/actionTypes.js
View file @
5bc2977
...
...
@@ -4,4 +4,7 @@ export default keyMirror({
SET_PLATFORM
:
null
,
SET_CHANNEL
:
null
,
INSTALLMENT_PRODUCT_REQUEST
:
null
,
INSTALLMENT_PRODUCT_SUCCESS
:
null
,
INSTALLMENT_PRODUCT_FAILURE
:
null
,
});
...
...
js/installment/containers/InstallmentContainer.js
View file @
5bc2977
...
...
@@ -40,9 +40,19 @@ class InstallmentContainer extends Component {
constructor
(
props
)
{
super
(
props
);
}
render
()
{
componentDidMount
()
{
this
.
props
.
actions
.
productListForInstallment
();
}
render
()
{
let
{
isFetching
,
open
}
=
this
.
props
.
installment
;
console
.
log
(
open
);
console
.
log
(
open
.
productListForInstallment
);
return
(
<
Installment
isFetching
=
{
open
.
isFetching
}
productListForInstallment
=
{
open
.
productListForInstallment
}
installmentInfo
=
{
open
.
installmentInfo
}
/
>
);
}
...
...
js/installment/reducers/installment/installmentActions.js
View file @
5bc2977
'use strict'
;
import
ReactNative
from
'react-native'
;
import
InstallmentService
from
'../../services/InstallmentService'
;
const
{
SET_PLATFORM
,
INSTALLMENT_PRODUCT_REQUEST
,
INSTALLMENT_PRODUCT_SUCCESS
,
INSTALLMENT_PRODUCT_FAILURE
,
}
=
require
(
'../../constants/actionTypes'
).
default
;
export
function
productListForInstallmentRequest
(){
return
{
type
:
INSTALLMENT_PRODUCT_REQUEST
,
}
}
export
function
productListForInstallmentSuccess
(
json
){
return
{
type
:
INSTALLMENT_PRODUCT_SUCCESS
,
payload
:
json
,
}
}
export
function
productListForInstallmentFailure
(){
return
{
type
:
INSTALLMENT_PRODUCT_FAILURE
,
}
}
export
function
productListForInstallment
()
{
return
(
dispatch
,
getState
)
=>
{
let
{
app
,
installment
}
=
getState
();
let
{
isFetching
,
open
}
=
installment
;
if
(
isFetching
){
return
}
console
.
log
(
'----productListForInstallment-----'
);
dispatch
(
productListForInstallmentRequest
());
return
new
InstallmentService
(
app
.
host
).
fetchInstallmentProductList
()
.
then
(
json
=>
{
console
.
log
(
json
);
let
payload
=
json
;
//product_list
if
(
payload
.
page
>
1
)
{
let
oldList
=
open
.
fetchInstallmentProductList
.
list
.
toJS
();
let
list
=
[...
oldList
,
...
payload
.
list
];
payload
.
product_list
=
list
;
}
dispatch
(
productListForInstallmentSuccess
(
payload
));
})
.
catch
(
error
=>
{
console
.
log
(
error
);
dispatch
(
productListForInstallmentFailure
());
});
}
}
...
...
js/installment/reducers/installment/installmentInitialState.js
View file @
5bc2977
...
...
@@ -3,7 +3,15 @@
import
{
Record
,
List
,
Map
}
from
'immutable'
;
let
InitialState
=
Record
({
isFetching
:
false
,
open
:
new
(
Record
({
productListForInstallment
:
new
(
Record
({
list
:
List
(),
page
:
1
,
totalPage
:
1
,
})),
installmentInfo
:
''
,
})),
});
export
default
InitialState
;
\ No newline at end of file
...
...
js/installment/reducers/installment/installmentReducer.js
View file @
5bc2977
'use strict'
;
import
InitialState
from
'./installmentInitialState'
;
import
Immutable
,
{
Map
}
from
'immutable'
;
const
{
SET_PLATFORM
,
SET_PLATFORM
,
INSTALLMENT_PRODUCT_REQUEST
,
INSTALLMENT_PRODUCT_SUCCESS
,
INSTALLMENT_PRODUCT_FAILURE
,
}
=
require
(
'../../constants/actionTypes'
).
default
;
const
initialState
=
new
InitialState
;
...
...
@@ -12,7 +17,19 @@ export default function appReducer(state = initialState, action) {
if
(
!
(
state
instanceof
InitialState
))
return
initialState
.
merge
(
state
);
switch
(
action
.
type
)
{
case
INSTALLMENT_PRODUCT_SUCCESS
:
{
let
{
page
,
page_total
,
product_list
,
}
=
action
.
payload
;
let
productListForInstallment
=
state
.
open
.
productListForInstallment
.
set
(
'list'
,
Immutable
.
fromJS
(
product_list
))
.
set
(
'page'
,
page
)
.
set
(
'totalPage'
,
page_total
);
return
state
.
setIn
([
'open'
,
'productListForInstallment'
],
productListForInstallment
);
}
}
return
state
;
...
...
js/installment/services/InstallmentService.js
View file @
5bc2977
...
...
@@ -10,4 +10,28 @@ export default class InstallmentService {
}
this
.
api
=
new
Request
(
baseURL
);
}
async
fetchInstallmentProductList
(
yh_channel
=
1
,
order
=
's_n_asc'
,
page
=
1
,
limit
=
60
,
brand
=
''
,
v
=
7
)
{
return
await
this
.
api
.
get
({
url
:
''
,
body
:
{
method
:
'app.search.li'
,
yh_channel
,
order
,
page
,
limit
,
status
:
1
,
sales
:
'Y'
,
stocknumber
:
1
,
attribute_not
:
2
,
v
,
brand
,
}
})
.
then
((
json
)
=>
{
return
json
;
})
.
catch
((
error
)
=>
{
throw
(
error
);
});
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment