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
e16d192c0217f991519a852f3d268a747759f9c1
1 parent
cf0f5379
add 我的优惠劵 bug review by hongmo
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
20 deletions
js/myAssets/components/coupon/Coupon.js
js/myAssets/components/coupon/CouponCell.js
js/myAssets/constants/actionTypes.js
js/myAssets/containers/CouponContainer.js
js/myAssets/image/coupon_mark_used@2x.png
js/myAssets/image/coupon_marker_invalid@2x.png
js/myAssets/reducers/coupon/couponActions.js
js/myAssets/reducers/coupon/couponReducer.js
js/myAssets/components/coupon/Coupon.js
View file @
e16d192
...
...
@@ -44,8 +44,10 @@ export default class Coupon extends Component {
}
_renderRow
(
rowData
,
sectionID
,
rowID
)
{
let
{
resource
}
=
this
.
props
;
let
fliter
=
resource
.
get
(
'fliter'
);
return
(
<
CouponCell
resource
=
{
rowData
}
onPressUseNow
=
{
this
.
props
.
onPressUseNow
}
/
>
<
CouponCell
usedType
=
{
fliter
}
index
=
{
rowID
}
resource
=
{
rowData
}
showCouponDetail
=
{
this
.
props
.
showCouponDetail
}
onPressUseNow
=
{
this
.
props
.
onPressUseNow
}
/
>
);
}
...
...
js/myAssets/components/coupon/CouponCell.js
View file @
e16d192
...
...
@@ -19,16 +19,20 @@ export default class CouponCell extends React.Component {
constructor
(
props
)
{
super
(
props
);
}
this
.
state
=
{
showDetail
:
false
,
};
shouldComponentUpdate
(
nextProps
){
if
(
Immutable
.
is
(
nextProps
.
resource
,
this
.
props
.
resource
))
{
return
false
;
}
else
{
return
true
;
}
}
render
()
{
let
resource
=
this
.
props
.
resource
?
this
.
props
.
resource
.
toJS
():
null
;
let
showDetail
=
this
.
state
.
showDetail
;
let
tipImage
=
showDetail
?
require
(
'../../image/up_tip_ic.png'
):
require
(
'../../image/down_tip_ic.png'
);
let
usedType
=
this
.
props
.
usedType
;
let
index
=
this
.
props
.
index
;
let
couponDetailInfomation
=
resource
.
couponDetailInfomation
;
let
couponValidity
=
resource
.
couponValidity
;
let
rule4ShortName
=
resource
.
rule4ShortName
;
...
...
@@ -37,6 +41,9 @@ export default class CouponCell extends React.Component {
let
isNoLimit
=
resource
.
isNoLimit
;
let
brandNameLimit
=
resource
.
brandNameLimit
;
let
sortNameLimit
=
resource
.
sortNameLimit
;
let
showDetail
=
resource
.
showDetail
?
resource
.
showDetail
:
false
;
let
tipImage
=
showDetail
?
require
(
'../../image/up_tip_ic.png'
):
require
(
'../../image/down_tip_ic.png'
);
let
bottomText
=
brandNameLimit
.
length
>
0
?
'限品牌:'
+
brandNameLimit
[
0
]
:
''
;
bottomText
=
sortNameLimit
.
length
>
0
?
bottomText
+
'限品类:'
+
sortNameLimit
[
0
]
:
bottomText
;
bottomText
=
isNoLimit
==
'true'
?
'全场通用'
:
bottomText
;
...
...
@@ -44,6 +51,7 @@ export default class CouponCell extends React.Component {
let
backgroundHeigth
=
showDetail
?
topBackgroundHeigth
+
detailBackgroundHeigth
+
20
:
topBackgroundHeigth
+
20
;
return
(
<
View
style
=
{{
width
:
width
,
height
:
backgroundHeigth
}}
>
<
View
style
=
{{
width
:
width
,
height
:
20
,
backgroundColor
:
'white'
,}}
/
>
<
Image
source
=
{
require
(
'../../image/coupon1_tip_bg.png'
)}
style
=
{
styles
.
couponBackgroundImage
}
><
/Image
>
<
View
style
=
{
styles
.
topContent
}
>
<
View
style
=
{
styles
.
topTitleView
}
>
...
...
@@ -59,24 +67,26 @@ export default class CouponCell extends React.Component {
<
View
style
=
{
styles
.
rigthDetail
}
>
<
View
style
=
{
styles
.
timeDetailTopView
}
>
<
Text
style
=
{
styles
.
timeDetailTop
}
numberOfLines
=
{
1
}
>
{
couponValidity
}
<
/Text
>
{
overState
?
<
Text
style
=
{
styles
.
timeDetail2
}
numberOfLines
=
{
1
}
>
({
overState
})
<
/Text>:null
}
{
usedType
==
0
&&
overState
?
<
Text
style
=
{
styles
.
timeDetail2
}
numberOfLines
=
{
1
}
>
({
overState
})
<
/Text>:null
}
<
/View
>
<
View
style
=
{
styles
.
timeDetailBottomView
}
>
<
TouchableOpacity
activeOpacity
=
{
1
}
style
=
{
styles
.
timeDetailBottomView
}
onPress
=
{()
=>
{
this
.
setState
({
showDetail
:
!
showDetail
});
this
.
props
.
showCouponDetail
&&
this
.
props
.
showCouponDetail
(
usedType
,
index
,
!
showDetail
)
}}
>
<
Text
style
=
{
styles
.
timeDetailSwitch
}
numberOfLines
=
{
1
}
>
详细信息
<
/Text
>
<
Image
source
=
{
tipImage
}
style
=
{
styles
.
timeDetailSwitchIcon
}
><
/Image
>
<
/TouchableOpacity
>
<
TouchableOpacity
activeOpacity
=
{
1
}
style
=
{
styles
.
button
}
onPress
=
{()
=>
{
this
.
props
.
onPressUseNow
&&
this
.
props
.
onPressUseNow
(
resource
)
}}
>
<
Image
source
=
{
require
(
'../../image/ljsy_tip_an.png'
)}
style
=
{
styles
.
button
}
><
/Image
>
<
/TouchableOpacity
>
{
usedType
==
0
?
<
TouchableOpacity
activeOpacity
=
{
1
}
style
=
{
styles
.
button
}
onPress
=
{()
=>
{
this
.
props
.
onPressUseNow
&&
this
.
props
.
onPressUseNow
(
resource
)
}}
>
<
Image
source
=
{
require
(
'../../image/ljsy_tip_an.png'
)}
style
=
{
styles
.
button
}
><
/Image
>
<
/TouchableOpacity>
:
<
Image
source
=
{
require
(
'../../image/coupon_mark_used.png'
)}
style
=
{
styles
.
usedIcon
}
><
/Image
>
}
<
/View
>
<
/View
>
<
/View
>
...
...
@@ -90,8 +100,6 @@ export default class CouponCell extends React.Component {
<
/View
>
<
/View
>
<
/View> : null
}
<
View
style
=
{{
width
:
width
,
height
:
20
,
backgroundColor
:
'white'
,}}
/
>
<
/View
>
);
}
...
...
@@ -107,6 +115,7 @@ let topBackgroundWidth = width - 50;
let
sc2
=
182
/
1035
;
//背景宽高比
let
detailBackgroundHeigth
=
sc2
*
(
width
-
50
);
let
detailBackgroundWidth
=
width
-
50
;
const
DEVICE_WIDTH_RATIO
=
width
/
320
;
let
styles
=
StyleSheet
.
create
({
...
...
@@ -204,7 +213,13 @@ let styles = StyleSheet.create({
right
:
15
,
top
:
5
,
},
usedIcon
:
{
width
:
detailBackgroundHeigth
+
8
,
height
:
detailBackgroundHeigth
+
8
,
position
:
'absolute'
,
right
:
10
,
bottom
:
-
5
,
},
bottom
:
{
width
:
detailBackgroundWidth
,
...
...
js/myAssets/constants/actionTypes.js
View file @
e16d192
...
...
@@ -40,8 +40,11 @@ export default keyMirror({
UNUSE_COUPON_LIST_SUCCESS
:
null
,
UNUSE_COUPON_LIST_FAILURE
:
null
,
RESET_DATA
:
null
,
SHOW_USED_COUPON_DETAIL
:
null
,
SHOW_UNUSED_COUPON_DETAIL
:
null
,
RESET_DATA
:
null
,
USED_COUPON_LIST_REQUEST
:
null
,
USED_COUPON_LIST_SUCCESS
:
null
,
USED_COUPON_LIST_FAILURE
:
null
,
...
...
js/myAssets/containers/CouponContainer.js
View file @
e16d192
...
...
@@ -48,6 +48,7 @@ class CouponContainer extends Component {
this
.
_onPressMore
=
this
.
_onPressMore
.
bind
(
this
);
this
.
_onEndReached
=
this
.
_onEndReached
.
bind
(
this
);
this
.
_onPressUseNow
=
this
.
_onPressUseNow
.
bind
(
this
);
this
.
_showCouponDetail
=
this
.
_showCouponDetail
.
bind
(
this
);
this
.
subscription
=
NativeAppEventEmitter
.
addListener
(
'needUpdateCoupon'
,
(
reminder
)
=>
{
...
...
@@ -59,6 +60,7 @@ class CouponContainer extends Component {
componentDidMount
()
{
this
.
props
.
actions
.
getUnuseCouponsList
();
this
.
props
.
actions
.
getUsedCouponsList
();
}
componentWillUnmount
()
{
...
...
@@ -70,7 +72,18 @@ class CouponContainer extends Component {
}
_onEndReached
()
{
this
.
props
.
actions
.
getUnuseCouponsList
();
let
{
coupon
}
=
this
.
props
;
let
fliter
=
coupon
.
get
(
'fliter'
);
if
(
fliter
==
0
)
{
this
.
props
.
actions
.
getUnuseCouponsList
();
}
else
if
(
fliter
==
1
)
{
this
.
props
.
actions
.
getUsedCouponsList
();
}
}
_showCouponDetail
(
fliter
,
index
,
isShow
){
this
.
props
.
actions
.
showCouponDetail
(
fliter
,
index
,
isShow
)
}
_onPressFilter
(
fliter
){
...
...
@@ -91,6 +104,7 @@ class CouponContainer extends Component {
onPressMore
=
{
this
.
_onPressMore
}
onEndReached
=
{
this
.
_onEndReached
}
onPressUseNow
=
{
this
.
_onPressUseNow
}
showCouponDetail
=
{
this
.
_showCouponDetail
}
/
>
<
/View
>
);
...
...
js/myAssets/image/coupon_mark_used@2x.png
0 → 100644
View file @
e16d192
11 KB
js/myAssets/image/coupon_marker_invalid@2x.png
0 → 100755
View file @
e16d192
8.69 KB
js/myAssets/reducers/coupon/couponActions.js
View file @
e16d192
...
...
@@ -14,6 +14,9 @@ const {
USED_COUPON_LIST_SUCCESS
,
USED_COUPON_LIST_FAILURE
,
SHOW_USED_COUPON_DETAIL
,
SHOW_UNUSED_COUPON_DETAIL
,
RESET_DATA
,
}
=
require
(
'../../constants/actionTypes'
).
default
;
...
...
@@ -107,6 +110,45 @@ export function usedCouponListFailure(error) {
}
}
export
function
showUsedCouponDetail
(
list
)
{
return
{
type
:
SHOW_USED_COUPON_DETAIL
,
payload
:
list
}
}
export
function
showUnusedCouponDetail
(
list
)
{
return
{
type
:
SHOW_UNUSED_COUPON_DETAIL
,
payload
:
list
}
}
export
function
showCouponDetail
(
fliter
,
index
,
isShow
)
{
return
(
dispatch
,
getState
)
=>
{
let
{
app
,
coupon
}
=
getState
();
let
couponDic
=
coupon
?
coupon
.
toJS
():
null
;
let
couponLists
=
couponDic
.
usedCoupon
.
couponList
;
if
(
fliter
==
0
)
{
couponLists
=
couponDic
.
unuseCoupon
.
couponList
;
}
let
items
=
couponLists
&&
couponLists
.
length
>
index
?
couponLists
[
index
]:
null
;
if
(
items
)
{
items
.
showDetail
=
isShow
;
}
if
(
fliter
==
0
)
{
dispatch
(
showUnusedCouponDetail
(
couponLists
));
}
else
if
(
fliter
==
1
)
{
dispatch
(
showUsedCouponDetail
(
couponLists
));
}
};
}
export
function
getUsedCouponsList
()
{
return
(
dispatch
,
getState
)
=>
{
...
...
js/myAssets/reducers/coupon/couponReducer.js
View file @
e16d192
...
...
@@ -13,6 +13,10 @@ const {
USED_COUPON_LIST_REQUEST
,
USED_COUPON_LIST_SUCCESS
,
USED_COUPON_LIST_FAILURE
,
SHOW_USED_COUPON_DETAIL
,
SHOW_UNUSED_COUPON_DETAIL
,
RESET_DATA
,
}
=
require
(
'../../constants/actionTypes'
).
default
;
...
...
@@ -66,6 +70,13 @@ export default function detailReducer(state=initialState, action) {
.
setIn
([
'unuseCoupon'
,
'couponList'
],
Immutable
.
fromJS
([]))
.
setIn
([
'unuseCoupon'
,
'error'
],
null
);
}
case
SHOW_USED_COUPON_DETAIL
:
{
return
state
.
setIn
([
'usedCoupon'
,
'couponList'
],
Immutable
.
fromJS
(
action
.
payload
))
}
case
SHOW_UNUSED_COUPON_DETAIL
:
{
return
state
.
setIn
([
'unuseCoupon'
,
'couponList'
],
Immutable
.
fromJS
(
action
.
payload
))
}
break
;
}
return
state
;
...
...
Please
register
or
login
to post a comment