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
于良
8 years ago
Commit
3992a5c35e8881f72a8327d16fca609d9adcdf27
1 parent
f914b82e
店铺性能优化 review by 草莓
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
62 deletions
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandListCell.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandProductFilter.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandStoreFilter.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandSwiper.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/CouponCell.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/HotProducts.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/OneRowTwoColImages.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/Recommend.js
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandListCell.js
View file @
3992a5c
...
...
@@ -14,14 +14,24 @@ const {
TouchableOpacity
,
}
=
ReactNative
;
import
Immutable
,
{
Map
}
from
'immutable'
;
export
default
class
BrandListCell
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
dataSource
=
new
ListView
.
DataSource
({
rowHasChanged
:
(
r1
,
r2
)
=>
!
Immutable
.
is
(
r1
,
r2
),
});
super
(
props
);
this
.
dataSource
=
new
ListView
.
DataSource
({
rowHasChanged
:
(
r1
,
r2
)
=>
!
Immutable
.
is
(
r1
,
r2
),
});
}
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
_pressRow
(
rowData
){
this
.
props
.
onPressBrandItem
(
rowData
.
url
)
}
...
...
@@ -39,7 +49,7 @@ export default class BrandListCell extends React.Component {
resizeMode
=
{
'contain'
}
><
/Image
>
<
/View
>
<
View
style
=
{
styles
.
textV
}
>
<
View
style
=
{
styles
.
textV
}
>
<
Text
style
=
{
styles
.
text
}
numberOfLines
=
{
1
}
>
{
rowData
.
name
}
<
/Text
>
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandProductFilter.js
View file @
3992a5c
...
...
@@ -127,34 +127,36 @@ export default class BrandProductFilter extends React.Component {
}
}
return
(
<
TouchableOpacity
activeOpacity
=
{
1
}
onPress
=
{()
=>
{
let
filters
=
this
.
state
.
filters
;
let
filter
=
this
.
state
.
filters
[
rowID
];
if
(
filter
.
radio
)
{
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
filters
[
0
].
key
);
return
;
}
if
(
rowID
==
3
)
{
let
value
=
'filter'
;
<
View
style
=
{{
backgroundColor
:
'white'
}}
>
<
TouchableOpacity
style
=
{{
backgroundColor
:
'white'
,
flex
:
1
}}
onPress
=
{()
=>
{
let
filters
=
this
.
state
.
filters
;
let
filter
=
this
.
state
.
filters
[
rowID
];
if
(
filter
.
radio
)
{
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
filters
[
0
].
key
);
return
;
}
if
(
rowID
==
3
)
{
let
value
=
'filter'
;
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
value
);
return
;
}
filter
.
isAsc
=
!
filter
.
isAsc
;
filters
[
rowID
]
=
filter
;
this
.
setState
({
selectedIndex
:
rowID
,
filters
,
});
let
value
=
filter
.
isAsc
?
filter
.
value
[
'asc'
]
:
filter
.
value
[
'desc'
];
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
value
);
return
;
}
filter
.
isAsc
=
!
filter
.
isAsc
;
filters
[
rowID
]
=
filter
;
this
.
setState
({
selectedIndex
:
rowID
,
filters
,
});
let
value
=
filter
.
isAsc
?
filter
.
value
[
'asc'
]
:
filter
.
value
[
'desc'
];
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
value
);
}}
>
<
View
key
=
{
'row'
+
rowID
}
style
=
{
styles
.
rowContainer
}
>
<
Text
style
=
{[
styles
.
name
,
colorStyle
]}
>
{
rowData
.
name
}
<
/Text
>
{
this
.
_renderImage
(
rowData
,
rowID
)}
<
/View
>
<
/TouchableOpacity
>
}}
>
<
View
key
=
{
'row'
+
rowID
}
style
=
{
styles
.
rowContainer
}
>
<
Text
style
=
{[
styles
.
name
,
colorStyle
]}
>
{
rowData
.
name
}
<
/Text
>
{
this
.
_renderImage
(
rowData
,
rowID
)}
<
/View
>
<
/TouchableOpacity
>
<
/View
>
);
}
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandStoreFilter.js
View file @
3992a5c
...
...
@@ -52,32 +52,42 @@ export default class BrandStoreFilter extends React.Component {
};
}
shouldComponentUpdate
(
nextProps
){
if
(
nextProps
.
selectID
==
this
.
props
.
selectID
)
{
return
false
;
}
else
{
return
true
;
}
}
_renderRow
(
rowData
,
sectionID
,
rowID
)
{
let
colorStyle
=
rowID
==
this
.
state
.
selectedIndex
?
{
color
:
'#444444'
}
:
{
color
:
'#b0b0b0'
};
return
(
<
TouchableOpacity
onPress
=
{()
=>
{
let
filters
=
this
.
state
.
filters
;
let
filter
=
this
.
state
.
filters
[
rowID
];
if
(
this
.
state
.
selectedIndex
==
rowID
)
{
return
;
}
filter
.
isSelect
=
!
filter
.
isSelect
;
filters
[
rowID
]
=
filter
;
if
(
rowID
!=
3
)
{
this
.
setState
({
selectedIndex
:
rowID
,
filters
,
});
}
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
rowID
);
}}
>
<
View
key
=
{
'row'
+
rowID
}
style
=
{
styles
.
rowContainer
}
>
<
Text
style
=
{[
styles
.
name
,
colorStyle
]}
>
{
rowData
.
name
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
View
style
=
{{
backgroundColor
:
'white'
}}
>
<
TouchableOpacity
onPress
=
{()
=>
{
let
filters
=
this
.
state
.
filters
;
let
filter
=
this
.
state
.
filters
[
rowID
];
if
(
this
.
state
.
selectedIndex
==
rowID
)
{
return
;
}
filter
.
isSelect
=
!
filter
.
isSelect
;
filters
[
rowID
]
=
filter
;
if
(
rowID
!=
3
)
{
this
.
setState
({
selectedIndex
:
rowID
,
filters
,
});
}
this
.
props
.
onPressFilter
&&
this
.
props
.
onPressFilter
(
rowID
);
}}
>
<
View
key
=
{
'row'
+
rowID
}
style
=
{
styles
.
rowContainer
}
>
<
Text
style
=
{[
styles
.
name
,
colorStyle
]}
>
{
rowData
.
name
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
/View
>
);
}
...
...
@@ -90,12 +100,10 @@ export default class BrandStoreFilter extends React.Component {
render
()
{
let
{
style
}
=
this
.
props
;
return
(
<
View
style
=
{[
styles
.
container
,
style
]}
>
<
View
style
=
{[
styles
.
container
]}
>
<
ListView
contentContainerStyle
=
{[
styles
.
contentContainer
,
style
]}
contentContainerStyle
=
{[
styles
.
contentContainer
]}
enableEmptySections
=
{
true
}
dataSource
=
{
this
.
dataSource
.
cloneWithRows
(
this
.
state
.
filters
)}
renderRow
=
{
this
.
_renderRow
}
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/BrandSwiper.js
View file @
3992a5c
...
...
@@ -14,6 +14,8 @@ const {
Platform
,
}
=
ReactNative
;
import
Immutable
,
{
Map
}
from
'immutable'
;
export
default
class
BrandSwiper
extends
React
.
Component
{
constructor
(
props
)
{
...
...
@@ -45,6 +47,14 @@ export default class BrandSwiper extends React.Component {
/>
;
}
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
render
()
{
let
{
resource
}
=
this
.
props
;
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/CouponCell.js
View file @
3992a5c
...
...
@@ -14,6 +14,8 @@ const {
TouchableOpacity
,
}
=
ReactNative
;
import
Immutable
,
{
Map
}
from
'immutable'
;
export
default
class
CouponCell
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -25,6 +27,14 @@ export default class CouponCell extends React.Component {
};
}
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
renderRow
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
let
data
=
this
.
props
.
resource
.
toJS
();
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/HotProducts.js
View file @
3992a5c
...
...
@@ -14,7 +14,7 @@ const {
Platform
,
}
=
ReactNative
;
import
{
Map
}
from
'immutable'
;
import
Immutable
,
{
Map
}
from
'immutable'
;
import
BrandProductListCell
from
'../../../../../common/components/ListCell/ProductListCell'
;
import
DeviceInfo
from
'react-native-device-info'
;
...
...
@@ -31,8 +31,12 @@ export default class HotProducts extends React.Component {
});
}
componentDidMount
()
{
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
renderRow
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/OneRowTwoColImages.js
View file @
3992a5c
...
...
@@ -11,13 +11,20 @@ const {
TouchableOpacity
,
}
=
ReactNative
;
import
Immutable
,
{
Map
}
from
'immutable'
;
export
default
class
OneRowTwoColImages
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
}
componentDidMount
()
{
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
render
()
{
...
...
@@ -25,6 +32,7 @@ export default class OneRowTwoColImages extends React.Component {
if
(
this
.
props
.
resource
.
size
==
0
)
{
return
null
;
}
let
data
=
this
.
props
.
resource
.
toJS
();
return
(
<
View
style
=
{
styles
.
viewStyle
}
>
...
...
js/brandStore/components/brandStore/brandStoreSubView/Cells/Recommend.js
View file @
3992a5c
...
...
@@ -14,8 +14,8 @@ const {
Platform
,
}
=
ReactNative
;
import
{
Map
}
from
'immutable'
;
import
DeviceInfo
from
'react-native-device-info'
;
import
Immutable
,
{
Map
}
from
'immutable'
;
export
default
class
Recommend
extends
React
.
Component
{
...
...
@@ -30,6 +30,14 @@ export default class Recommend extends React.Component {
});
}
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
renderRow
(
rowData
,
sectionID
,
rowID
,
highlightRow
)
{
return
(
<
TouchableOpacity
activeOpacity
=
{
0.5
}
onPress
=
{()
=>
{
...
...
Please
register
or
login
to post a comment