Authored by 张丽霞

收藏arrow跳品牌页,收藏toast,review by 陈林

... ... @@ -18,6 +18,7 @@ import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import LoginTip from './LoginTip';
import InterestCell from './InterestCell';
import InterestActivityCell from './InterestActivityCell';
import Prompt from '../../../coupon/components/coupon/Prompt';
export default class Interest extends Component {
... ... @@ -108,7 +109,7 @@ export default class Interest extends Component {
render() {
let {list, ptr, isFetching, endReached, showLoginTip, cachedList} = this.props.data;
let {list, ptr, isFetching, endReached, showLoginTip, cachedList, addLikeTip} = this.props.data;
let dataSource = list.size == 0 ? cachedList.toArray() : list.toArray();
let isPullToRefresh = ptr && isFetching;
... ... @@ -155,7 +156,11 @@ export default class Interest extends Component {
renderFooter={this._renderFooter}
/>
}
{addLikeTip !== '' ? <Prompt
text={'收藏成功'}
duration={800}
onPromptHidden={this.props.interestListTipRemove}
/> : null}
</View>
);
}
... ...
... ... @@ -21,20 +21,19 @@ export default class InterestHeader extends Component {
}
render() {
let {data, rowID} = this.props;
let brandIconUrl = SlicedImage.getSlicedUrl(data.get('brand_img', ''), 150, 80, 2);
let typeText = '';
let extra = '';
let textBgColor = '#FD9E2B';
let type = data.get('brand_type', '');
if (type == 'new') {
typeText = 'NEW';
extra = ' ' + data.get('new_product_num', '');
textBgColor = '#86BF4A';
} else if (type == 'sale') {
typeText = 'SALE';
... ... @@ -74,15 +73,15 @@ export default class InterestHeader extends Component {
</View>
<View style={styles.rightContainer}>
<Text style={[styles.type, {backgroundColor: textBgColor}]}>{typeText}</Text>
<TouchableOpacity
<TouchableOpacity
style={styles.buttonContainer}
onPress={() => {
this.props.onInterestLike && this.props.onInterestLike(data, rowID);
this.props.onInterestLike && this.props.onInterestLike(data, rowID, data.get('is_fav', '') == 'Y' ? true : false);
}}
>
<Image style={styles.button} source={buttonImage} />
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
... ...
... ... @@ -20,6 +20,7 @@ export default keyMirror({
INTEREST_LIKE_REQUEST: null,
INTEREST_LIKE_SUCCESS: null,
INTEREST_LIKE_FAILURE: null,
INTEREST_LIKE_TIP_REMOVE: null,
LOAD_CACHED_INTEREST_LIST: null,
... ...
... ... @@ -54,6 +54,7 @@ class InterestContainer extends Component {
this._onPressInterestActivity = this._onPressInterestActivity.bind(this);
this._onPressInterestProduct = this._onPressInterestProduct.bind(this);
this._onInterestLogin = this._onInterestLogin.bind(this);
this._interestListTipRemove = this._interestListTipRemove.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'ChannelDidChangeEvent',
... ... @@ -103,8 +104,12 @@ class InterestContainer extends Component {
});
}
_onInterestLike(item, index) {
this.props.actions.addFavorite(item, index);
_onInterestLike(item, index, bliked = false) {
if (!bliked) {
this.props.actions.addFavorite(item, index);
} else {
NativeModules.YH_CommonHelper.jumpToBrand(item.toJS());
}
let params = {
CAT_NUM: index + 1 + '',
... ... @@ -113,7 +118,11 @@ class InterestContainer extends Component {
NativeModules.YH_CommonHelper.logEvent('YB_CATEGORY_BRAND_TAB_FAV', params);
}
_onPressInterestBrand(item, index) {
_interestListTipRemove() {
this.props.actions.interestListTipRemove();
}
_onPressInterestBrand(item, index) {
// let url = item.get('url', '');
NativeModules.YH_CommonHelper.jumpToBrand(item.toJS());
... ... @@ -167,6 +176,7 @@ class InterestContainer extends Component {
onPressProduct={this._onPressInterestProduct}
onPressActivity={this._onPressInterestActivity}
onInterestLogin={this._onInterestLogin}
interestListTipRemove={this._interestListTipRemove}
/>
</View>
);
... ...
... ... @@ -21,9 +21,10 @@ const {
INTEREST_LIKE_REQUEST,
INTEREST_LIKE_SUCCESS,
INTEREST_LIKE_FAILURE,
INTEREST_LIKE_TIP_REMOVE,
LOAD_CACHED_INTEREST_LIST,
} = require('../../constants/actionTypes').default;
export function setType(type) {
... ... @@ -48,7 +49,7 @@ export function loadCachedInterestList() {
dispatch({
type: LOAD_CACHED_INTEREST_LIST,
payload: data,
payload: data,
});
})
.catch(error => {
... ... @@ -108,6 +109,12 @@ export function interestListFailure(error) {
};
}
export function interestListTipRemove() {
return {
type: INTEREST_LIKE_TIP_REMOVE,
}
}
/*
* reload bool 是否需要强制重新请求数据,
*/
... ... @@ -140,7 +147,7 @@ export function interestList(reload=false) {
} else {
store.save(YH_RNCacheTypeInterestList, payload.list)
.then(data => {
})
.catch(error => {
... ...
... ... @@ -15,6 +15,7 @@ let InitialState = Record({
endReached: false,
sourceType: 0, // 0 - 默认,1 - 全球购,2 - 奥莱
showLoginTip: false,
addLikeTip: '',
});
export default InitialState;
... ...
... ... @@ -5,7 +5,7 @@ import Immutable, {Map} from 'immutable';
const {
SET_TYPE,
RESET_LIST_PAGE_INFO,
SHOW_LOGIN_TIP,
... ... @@ -18,6 +18,7 @@ const {
INTEREST_LIKE_REQUEST,
INTEREST_LIKE_SUCCESS,
INTEREST_LIKE_FAILURE,
INTEREST_LIKE_TIP_REMOVE,
LOAD_CACHED_INTEREST_LIST,
} = require('../../constants/actionTypes').default;
... ... @@ -35,7 +36,8 @@ export default function interestReducer(state=initialState, action) {
return state.set('currentPage', 0)
.set('pageCount', 0)
.set('total', 0)
.set('endReached', false);
.set('endReached', false)
.set('addLikeTip', '');
}
case SHOW_LOGIN_TIP: {
... ... @@ -77,7 +79,11 @@ export default function interestReducer(state=initialState, action) {
case INTEREST_LIKE_STATE_CHANGE: {
let {like, index} = action.payload;
return state.setIn(['list', index, 'is_fav'], like);
return state.setIn(['list', index, 'is_fav'], like)
.set('addLikeTip', '收藏成功');
}
case INTEREST_LIKE_TIP_REMOVE: {
return state.set('addLikeTip', '');
}
case INTEREST_LIKE_REQUEST:
... ...