Fix bug on good goods recommend. reviewed by Boss Yin.
Showing
7 changed files
with
55 additions
and
13 deletions
@@ -45,8 +45,16 @@ export default class Detail extends Component { | @@ -45,8 +45,16 @@ export default class Detail extends Component { | ||
45 | </View> | 45 | </View> |
46 | <Text style={styles.phrase}> {data.get('phrase')}</Text> | 46 | <Text style={styles.phrase}> {data.get('phrase')}</Text> |
47 | <View style={styles.tagPannel} onLayout={this.onLayout.bind(this)} > | 47 | <View style={styles.tagPannel} onLayout={this.onLayout.bind(this)} > |
48 | - <Text style={styles.tag}> {data.get('brand_info').get('brand_domain')}</Text> | ||
49 | - <Text style={styles.tag}>{data.get('middle_sort_name')} </Text> | 48 | + <Text |
49 | + onPress={()=>{this.props.onPressTag&&this.props.onPressTag(data.get('brand_info').get('brand_domain'))}} | ||
50 | + style={styles.tag}> | ||
51 | + {data.get('brand_info').get('brand_domain')} | ||
52 | + </Text> | ||
53 | + <Text | ||
54 | + onPress={()=>{this.props.onPressTag&&this.props.onPressTag(data.get('middle_sort_name'))}} | ||
55 | + style={styles.tag}> | ||
56 | + {data.get('middle_sort_name')} | ||
57 | + </Text> | ||
50 | </View> | 58 | </View> |
51 | </View> | 59 | </View> |
52 | ); | 60 | ); |
@@ -63,7 +63,7 @@ export default class Detail extends Component { | @@ -63,7 +63,7 @@ export default class Detail extends Component { | ||
63 | } | 63 | } |
64 | break; | 64 | break; |
65 | case 'content': { | 65 | case 'content': { |
66 | - return <ContentCell data={rowData}/> | 66 | + return <ContentCell data={rowData} onPressTag={this.props.onPressTag}/> |
67 | } | 67 | } |
68 | break; | 68 | break; |
69 | case 'similarTitle': { | 69 | case 'similarTitle': { |
@@ -72,7 +72,11 @@ export default class List extends Component { | @@ -72,7 +72,11 @@ export default class List extends Component { | ||
72 | showsVerticalScrollIndicator={false} | 72 | showsVerticalScrollIndicator={false} |
73 | dataSource={this.dataSource.cloneWithRowsAndSections(dataBlob)} | 73 | dataSource={this.dataSource.cloneWithRowsAndSections(dataBlob)} |
74 | renderRow={this.renderRow} | 74 | renderRow={this.renderRow} |
75 | - | 75 | + enablePullToRefresh={true} |
76 | + isOnPullToRefresh={isFetching} | ||
77 | + onRefreshData={() => { | ||
78 | + this.onRefresh && this.props.onRefresh(); | ||
79 | + }} | ||
76 | onEndReached={() => { | 80 | onEndReached={() => { |
77 | if (list && list.length) { | 81 | if (list && list.length) { |
78 | this.props.onEndReached && this.props.onEndReached(); | 82 | this.props.onEndReached && this.props.onEndReached(); |
@@ -48,6 +48,7 @@ class DetailContainer extends Component { | @@ -48,6 +48,7 @@ class DetailContainer extends Component { | ||
48 | super(props); | 48 | super(props); |
49 | this._onPressProduct = this._onPressProduct.bind(this); | 49 | this._onPressProduct = this._onPressProduct.bind(this); |
50 | this._onPressFavorite = this._onPressFavorite.bind(this); | 50 | this._onPressFavorite = this._onPressFavorite.bind(this); |
51 | + this._onPressTag = this._onPressTag.bind(this); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | componentDidMount() { | 54 | componentDidMount() { |
@@ -69,6 +70,12 @@ class DetailContainer extends Component { | @@ -69,6 +70,12 @@ class DetailContainer extends Component { | ||
69 | ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); | 70 | ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); |
70 | } | 71 | } |
71 | 72 | ||
73 | + _onPressTag(tag) { | ||
74 | + if (!tag) { | ||
75 | + return; | ||
76 | + } | ||
77 | + ReactNative.NativeModules.YH_CommonHelper.hotSearchWithKeyword(tag); | ||
78 | + } | ||
72 | _onPressFavorite(favorite) { | 79 | _onPressFavorite(favorite) { |
73 | this.props.actions.changeFavoriteStatus(favorite); | 80 | this.props.actions.changeFavoriteStatus(favorite); |
74 | } | 81 | } |
@@ -80,6 +87,7 @@ class DetailContainer extends Component { | @@ -80,6 +87,7 @@ class DetailContainer extends Component { | ||
80 | resource={detail} | 87 | resource={detail} |
81 | onPressProduct={this._onPressProduct} | 88 | onPressProduct={this._onPressProduct} |
82 | onPressFavorite={this._onPressFavorite} | 89 | onPressFavorite={this._onPressFavorite} |
90 | + onPressTag={this._onPressTag} | ||
83 | /> | 91 | /> |
84 | ); | 92 | ); |
85 | } | 93 | } |
@@ -49,6 +49,7 @@ class ListContainer extends Component { | @@ -49,6 +49,7 @@ class ListContainer extends Component { | ||
49 | this._onPressDetail = this._onPressDetail.bind(this); | 49 | this._onPressDetail = this._onPressDetail.bind(this); |
50 | this._onPressBanner = this._onPressBanner.bind(this); | 50 | this._onPressBanner = this._onPressBanner.bind(this); |
51 | this._onEndReached = this._onEndReached.bind(this); | 51 | this._onEndReached = this._onEndReached.bind(this); |
52 | + this._onRefresh = this._onRefresh.bind(this); | ||
52 | } | 53 | } |
53 | 54 | ||
54 | componentDidMount() { | 55 | componentDidMount() { |
@@ -60,6 +61,11 @@ class ListContainer extends Component { | @@ -60,6 +61,11 @@ class ListContainer extends Component { | ||
60 | 61 | ||
61 | } | 62 | } |
62 | 63 | ||
64 | + _onRefresh() { | ||
65 | + this.props.actions.fetchBanner(); | ||
66 | + this.props.actions.getProductList(true); | ||
67 | + } | ||
68 | + | ||
63 | _onPressDetail(product_skn) { | 69 | _onPressDetail(product_skn) { |
64 | if (!product_skn) { | 70 | if (!product_skn) { |
65 | return; | 71 | return; |
@@ -88,6 +94,7 @@ class ListContainer extends Component { | @@ -88,6 +94,7 @@ class ListContainer extends Component { | ||
88 | onPressDetail={this._onPressDetail} | 94 | onPressDetail={this._onPressDetail} |
89 | onEndReached={this._onEndReached} | 95 | onEndReached={this._onEndReached} |
90 | onPressBanner={this._onPressBanner} | 96 | onPressBanner={this._onPressBanner} |
97 | + onRefresh={this._onRefresh} | ||
91 | /> | 98 | /> |
92 | ); | 99 | ); |
93 | } | 100 | } |
@@ -54,13 +54,28 @@ export function changeFavoriteStatus(favorite) { | @@ -54,13 +54,28 @@ export function changeFavoriteStatus(favorite) { | ||
54 | return (dispatch, getState) => { | 54 | return (dispatch, getState) => { |
55 | let {app, detail} = getState(); | 55 | let {app, detail} = getState(); |
56 | let product_id = detail.get('product').get('data').get('product_id'); | 56 | let product_id = detail.get('product').get('data').get('product_id'); |
57 | - if (product_id && favorite) { | ||
58 | - new DetailService(app.host).cancelFavorite(product_id); | 57 | + let favRequest = (product_id, favorite) => { |
58 | + if (product_id && favorite) { | ||
59 | + new DetailService(app.host).cancelFavorite(product_id); | ||
60 | + } | ||
61 | + if (product_id && !favorite) { | ||
62 | + new DetailService(app.host).addFavorite(product_id); | ||
63 | + } | ||
64 | + dispatch(setFavoriteStatus(!favorite)); | ||
59 | } | 65 | } |
60 | - if (product_id && !favorite) { | ||
61 | - new DetailService(app.host).addFavorite(product_id); | ||
62 | - } | ||
63 | - dispatch(setFavoriteStatus(!favorite)); | 66 | + ReactNative.NativeModules.YH_CommonHelper.uid() |
67 | + .then(uid => { | ||
68 | + favRequest(product_id, favorite); | ||
69 | + }) | ||
70 | + .catch(error => { | ||
71 | + ReactNative.NativeModules.YH_CommonHelper.login() | ||
72 | + .then(uid => { | ||
73 | + favRequest(product_id, favorite); | ||
74 | + }) | ||
75 | + .catch(error => { | ||
76 | + | ||
77 | + }); | ||
78 | + }); | ||
64 | } | 79 | } |
65 | } | 80 | } |
66 | 81 |
@@ -14,7 +14,7 @@ const { | @@ -14,7 +14,7 @@ const { | ||
14 | FETCH_BANNER_FAILURE, | 14 | FETCH_BANNER_FAILURE, |
15 | } = require('../../constants/actionTypes').default; | 15 | } = require('../../constants/actionTypes').default; |
16 | 16 | ||
17 | -export function getProductList() { | 17 | +export function getProductList(reload = false) { |
18 | return (dispatch, getState) => { | 18 | return (dispatch, getState) => { |
19 | let {app, list} = getState(); | 19 | let {app, list} = getState(); |
20 | let {products} = list; | 20 | let {products} = list; |
@@ -30,7 +30,7 @@ export function getProductList() { | @@ -30,7 +30,7 @@ export function getProductList() { | ||
30 | let payload = parseProductList(json); | 30 | let payload = parseProductList(json); |
31 | payload.endReached = payload.currentPage == payload.pageCount; | 31 | payload.endReached = payload.currentPage == payload.pageCount; |
32 | 32 | ||
33 | - if (payload.currentPage > 1) { | 33 | + if (payload.currentPage > 1 && !reload) { |
34 | let oldList = products.list.toJS(); | 34 | let oldList = products.list.toJS(); |
35 | let list = [...oldList, ...payload.list]; | 35 | let list = [...oldList, ...payload.list]; |
36 | payload.list = list; | 36 | payload.list = list; |
@@ -45,7 +45,7 @@ export function getProductList() { | @@ -45,7 +45,7 @@ export function getProductList() { | ||
45 | let channel = app.channel; | 45 | let channel = app.channel; |
46 | let gender = ''; | 46 | let gender = ''; |
47 | let uid = 0; | 47 | let uid = 0; |
48 | - let page = products.currentPage + 1; | 48 | + let page = reload? 1: products.currentPage + 1; |
49 | let pageSize = products.pageSize; | 49 | let pageSize = products.pageSize; |
50 | 50 | ||
51 | Promise.all([ | 51 | Promise.all([ |
-
Please register or login to post a comment