Authored by chenl

增加我的个人中心不喜欢事件。review by 张亚宁。

... ... @@ -59,6 +59,7 @@ export default class MineList extends React.Component {
onPressProduct={this.props.onPressProductListProduct}
onLongPressProduct={this.props.onLongPressProduct}
onPressFindSimilar={this.props.onPressFindSimilar}
onPressDislike={this.props.onPressDislike}
showSimilarGuider={showSimilarGuider}
/>
);
... ...
... ... @@ -66,6 +66,7 @@ export default keyMirror({
SET_SIMILAR_PRODUCT_INDEX:null,
SET_SHOW_SIMILAR_GUIDER: null,
DISLIKE_SUCCESS: null,
LOGIN_IN_SUCCESS:null,
LOGIN_OUT_SUCCESS:null,
... ...
... ... @@ -44,8 +44,8 @@ class MineContainer extends Component {
this._onMineCenterRefresh = this._onMineCenterRefresh.bind(this);
this._onLongPressProduct = this._onLongPressProduct.bind(this);
this._onPressFindSimilar = this._onPressFindSimilar.bind(this);
//资源位点击楼层
this._onPressDislike = this._onPressDislike.bind(this);
//资源位点击楼层
this._onPressFloorItem = this._onPressFloorItem.bind(this);
this.subscription1 = NativeAppEventEmitter.addListener(
... ... @@ -331,6 +331,15 @@ class MineContainer extends Component {
this.props.actions.setShowSimilarGuider(false, false);
}
_onPressDislike(product, similarIndex) {
this.props.actions.setSimilarIndex(-1);
let product_skn = product && product.get('product_skn', 0);
if (!product_skn || product_skn == 0) {
return;
}
this.props.actions.fetchDislike(similarIndex, product_skn);
}
_onMineCenterRefresh() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.onMineCenterRefresh();
... ... @@ -403,6 +412,7 @@ class MineContainer extends Component {
getProductListForMineCenter={this.props.actions.getProductListForMineCenter}
onLongPressProduct={this._onLongPressProduct}
onPressFindSimilar={this._onPressFindSimilar}
onPressDislike={this._onPressDislike}
onPressFloorItem={this._onPressFloorItem}
showSimilarGuider={showSimilarGuider}
/>
... ...
... ... @@ -70,6 +70,7 @@ const {
SET_SIMILAR_PRODUCT_INDEX,
SET_SHOW_SIMILAR_GUIDER,
DISLIKE_SUCCESS,
LOGIN_IN_SUCCESS,
LOGIN_OUT_SUCCESS,
... ... @@ -323,6 +324,27 @@ export function setSimilarIndex(rowID) {
}
}
export function fetchDislike(rowID, product_skn) {
return (dispatch, getState) => {
let {app, mine} = getState();
let channel = app.channel;
return new MineService(app.host).fetchDislike(channel, product_skn)
.then(json => {
let data = json.product_list&&json.product_list.length?json.product_list[0]:{};
dispatch(fetchDislikeSuccess(rowID, data));
})
.catch(error => {
});
}
}
function fetchDislikeSuccess(rowID, json, channelStr) {
return {
type: DISLIKE_SUCCESS,
payload: {rowID, json, channelStr}
}
}
export function getMineResourceSuccess(json) {
return {
type: GET_MINERESOURCE_SUCCESS,
... ...
... ... @@ -66,6 +66,7 @@ const {
SET_SIMILAR_PRODUCT_INDEX,
SET_SHOW_SIMILAR_GUIDER,
DISLIKE_SUCCESS,
LOGIN_IN_SUCCESS,
LOGIN_OUT_SUCCESS,
... ... @@ -109,6 +110,12 @@ export default function appReducer(state = initialState, action) {
return state.set('showSimilarGuider', action.payload);
}
case DISLIKE_SUCCESS: {
let {rowID, json} = action.payload;
let newState = state.setIn(['open', 'productListForMineCenter', 'product_list', rowID], Immutable.fromJS(json));
return newState;
}
case LOGIN_IN_SUCCESS: {
let uid = action.payload;
let newProfile = state.profile.set("uid", uid);
... ...
... ... @@ -301,4 +301,24 @@ export default class MineService {
throw(error);
});
}
async fetchDislike(channel, product_skn) {
let rec_pos = '100004';
return await this.api.get({
url: '',
body: {
method: 'app.product.notLike',
yh_channel: channel,
rec_pos,
product_skn,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
\ No newline at end of file
... ...