Authored by 盖剑秋

Fix bug on good goods recommend. reviewed by Boss Yin.

... ... @@ -45,8 +45,16 @@ export default class Detail extends Component {
</View>
<Text style={styles.phrase}> {data.get('phrase')}</Text>
<View style={styles.tagPannel} onLayout={this.onLayout.bind(this)} >
<Text style={styles.tag}> {data.get('brand_info').get('brand_domain')}</Text>
<Text style={styles.tag}>{data.get('middle_sort_name')} </Text>
<Text
onPress={()=>{this.props.onPressTag&&this.props.onPressTag(data.get('brand_info').get('brand_domain'))}}
style={styles.tag}>
{data.get('brand_info').get('brand_domain')}
</Text>
<Text
onPress={()=>{this.props.onPressTag&&this.props.onPressTag(data.get('middle_sort_name'))}}
style={styles.tag}>
{data.get('middle_sort_name')}
</Text>
</View>
</View>
);
... ...
... ... @@ -63,7 +63,7 @@ export default class Detail extends Component {
}
break;
case 'content': {
return <ContentCell data={rowData}/>
return <ContentCell data={rowData} onPressTag={this.props.onPressTag}/>
}
break;
case 'similarTitle': {
... ...
... ... @@ -72,7 +72,11 @@ export default class List extends Component {
showsVerticalScrollIndicator={false}
dataSource={this.dataSource.cloneWithRowsAndSections(dataBlob)}
renderRow={this.renderRow}
enablePullToRefresh={true}
isOnPullToRefresh={isFetching}
onRefreshData={() => {
this.onRefresh && this.props.onRefresh();
}}
onEndReached={() => {
if (list && list.length) {
this.props.onEndReached && this.props.onEndReached();
... ...
... ... @@ -48,6 +48,7 @@ class DetailContainer extends Component {
super(props);
this._onPressProduct = this._onPressProduct.bind(this);
this._onPressFavorite = this._onPressFavorite.bind(this);
this._onPressTag = this._onPressTag.bind(this);
}
componentDidMount() {
... ... @@ -69,6 +70,12 @@ class DetailContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressTag(tag) {
if (!tag) {
return;
}
ReactNative.NativeModules.YH_CommonHelper.hotSearchWithKeyword(tag);
}
_onPressFavorite(favorite) {
this.props.actions.changeFavoriteStatus(favorite);
}
... ... @@ -80,6 +87,7 @@ class DetailContainer extends Component {
resource={detail}
onPressProduct={this._onPressProduct}
onPressFavorite={this._onPressFavorite}
onPressTag={this._onPressTag}
/>
);
}
... ...
... ... @@ -49,6 +49,7 @@ class ListContainer extends Component {
this._onPressDetail = this._onPressDetail.bind(this);
this._onPressBanner = this._onPressBanner.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this._onRefresh = this._onRefresh.bind(this);
}
componentDidMount() {
... ... @@ -60,6 +61,11 @@ class ListContainer extends Component {
}
_onRefresh() {
this.props.actions.fetchBanner();
this.props.actions.getProductList(true);
}
_onPressDetail(product_skn) {
if (!product_skn) {
return;
... ... @@ -88,6 +94,7 @@ class ListContainer extends Component {
onPressDetail={this._onPressDetail}
onEndReached={this._onEndReached}
onPressBanner={this._onPressBanner}
onRefresh={this._onRefresh}
/>
);
}
... ...
... ... @@ -54,13 +54,28 @@ export function changeFavoriteStatus(favorite) {
return (dispatch, getState) => {
let {app, detail} = getState();
let product_id = detail.get('product').get('data').get('product_id');
if (product_id && favorite) {
new DetailService(app.host).cancelFavorite(product_id);
let favRequest = (product_id, favorite) => {
if (product_id && favorite) {
new DetailService(app.host).cancelFavorite(product_id);
}
if (product_id && !favorite) {
new DetailService(app.host).addFavorite(product_id);
}
dispatch(setFavoriteStatus(!favorite));
}
if (product_id && !favorite) {
new DetailService(app.host).addFavorite(product_id);
}
dispatch(setFavoriteStatus(!favorite));
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
favRequest(product_id, favorite);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
favRequest(product_id, favorite);
})
.catch(error => {
});
});
}
}
... ...
... ... @@ -14,7 +14,7 @@ const {
FETCH_BANNER_FAILURE,
} = require('../../constants/actionTypes').default;
export function getProductList() {
export function getProductList(reload = false) {
return (dispatch, getState) => {
let {app, list} = getState();
let {products} = list;
... ... @@ -30,7 +30,7 @@ export function getProductList() {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount;
if (payload.currentPage > 1) {
if (payload.currentPage > 1 && !reload) {
let oldList = products.list.toJS();
let list = [...oldList, ...payload.list];
payload.list = list;
... ... @@ -45,7 +45,7 @@ export function getProductList() {
let channel = app.channel;
let gender = '';
let uid = 0;
let page = products.currentPage + 1;
let page = reload? 1: products.currentPage + 1;
let pageSize = products.pageSize;
Promise.all([
... ...