Authored by 李犇

个人中心预加载不上报猜你喜欢数据——review by 于良

... ... @@ -133,7 +133,7 @@ export default class MineList extends React.Component {
globalOrderData
} = this.props;
let dataSource = productListForMineCenter.list.toArray();
let dataSource = productListForMineCenter.product_list.toArray();
return (
<View style={styles.container}>
... ... @@ -156,6 +156,7 @@ export default class MineList extends React.Component {
onScrollEndDrag={(event) => {
if (profile.uid != '0' && Platform.OS === 'ios' && event.nativeEvent.contentOffset.y < -60) {
this.props.onMineCenterRefresh && this.props.onMineCenterRefresh();
this.props.getProductListForMineCenter && this.props.getProductListForMineCenter();
}
}}
/>
... ...
... ... @@ -6,6 +6,7 @@ export default keyMirror({
SET_SERVICE_HOST: null,
SET_CHANNEL:null,
SET_IS_NEED_SHOW_XSRZ:null,
SET_IS_MINEVIEW_APPEARED:null,
MINECENTER_PRODUCT_REQUEST:null,
MINECENTER_PRODUCT_SUCCESS:null,
... ...
... ... @@ -67,6 +67,7 @@ class MineContainer extends Component {
this.subscription3 = NativeAppEventEmitter.addListener(
'ChannelDidChangeEvent',
(reminder) => {
this.props.actions.setIsMineViewAppeared(false);
this.props.actions.getProductListForMineCenter();
}
);
... ... @@ -100,6 +101,15 @@ class MineContainer extends Component {
}
}
);
this.subscription7 = NativeAppEventEmitter.addListener(
'MineViewDidAppearEvent',
(reminder) => {
let {productListForMineCenter} = this.props.mine.open;
this.props.actions.setIsMineViewAppeared(true);
productListForMineCenter && this.props.actions.reportFavoriteDataNotJudgeViewAppear(productListForMineCenter.toJS());
}
);
}
componentDidMount() {
... ... @@ -117,6 +127,7 @@ class MineContainer extends Component {
this.subscription4 && this.subscription4.remove();
this.subscription5 && this.subscription5.remove();
this.subscription6 && this.subscription6.remove();
this.subscription7 && this.subscription7.remove();
}
_onPressItem(viewId, data) {
... ... @@ -387,6 +398,7 @@ class MineContainer extends Component {
onPressItem={this._onPressItem}
onPressProductListProduct={this._onPressProductListProduct}
onMineCenterRefresh={this._onMineCenterRefresh}
getProductListForMineCenter={this.props.actions.getProductListForMineCenter}
onLongPressProduct={this._onLongPressProduct}
onPressFindSimilar={this._onPressFindSimilar}
onPressFloorItem={this._onPressFloorItem}
... ...
... ... @@ -9,6 +9,7 @@ const {
SET_PLATFORM,
SET_IS_NEED_SHOW_XSRZ,
SET_IS_MINEVIEW_APPEARED,
MINECENTER_PRODUCT_REQUEST,
MINECENTER_PRODUCT_SUCCESS,
... ... @@ -102,6 +103,13 @@ export function setIsNeedShowXsrz(json) {
}
}
export function setIsMineViewAppeared(json) {
return {
type: SET_IS_MINEVIEW_APPEARED,
payload: json,
}
}
export function productListForMineCenterRequest() {
return {
type: MINECENTER_PRODUCT_REQUEST,
... ... @@ -336,7 +344,7 @@ export function getProductListForMineCenter() {
} finally {
}
dispatch(productListForMineCenterSuccess(res));
dispatch(reportFavoriteData(res));
dispatch(reportFavoriteDataJudgeViewAppear(res));
})
.catch(error => {
dispatch(productListForMineCenterFailure());
... ... @@ -388,7 +396,26 @@ function exposePruductListData(json,channel) {
return res;
}
function reportFavoriteData(payload) {
/** 判断界面是否在前台显示再上报 */
export function reportFavoriteDataJudgeViewAppear(payload) {
return (dispatch, getState) => {
let {app, mine} = getState();
let isMineViewAppeared = mine.isMineViewAppeared;
if (isMineViewAppeared) {
dispatch(reportFavoriteData(payload));
}
}
}
/** 不判断界面是否在前台显示,直接上报 */
export function reportFavoriteDataNotJudgeViewAppear(payload) {
return (dispatch, getState) => {
dispatch(reportFavoriteData(payload));
}
}
/** 上报猜你喜欢埋点数据 */
export function reportFavoriteData(payload) {
return (dispatch, getState) => {
try {
let productList = payload.product_list;
... ... @@ -396,7 +423,6 @@ function reportFavoriteData(payload) {
let total = payload.page_size;
let rec_pos = '100004';
let productIDS = ''
if (productList.length > 0) {
let product = productList[0];
... ... @@ -413,7 +439,7 @@ function reportFavoriteData(payload) {
'PRD_NUM': total,
'REC_POSE': rec_pos,
'ACTION_ID': 0,
'REC_ID': rec_id?rec_id:''
'REC_ID': rec_id ? rec_id : ''
};
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CHOOSE_FOR_YOU', param);
... ...
... ... @@ -5,11 +5,13 @@ import {Record, List, Map} from 'immutable';
let InitialState = Record({
isFetching: false,
isNeedShowXsrz:true,
isMineViewAppeared:false,
open: new (Record({
productListForMineCenter: new (Record({
list: List(),
product_list: List(),
similarIndex: -1,
rec_id:'',
page_size:0,
})),
mineCenterInfo: '',
})),
... ...
... ... @@ -6,6 +6,7 @@ import Immutable, {Map} from 'immutable';
const {
SET_PLATFORM,
SET_IS_NEED_SHOW_XSRZ,
SET_IS_MINEVIEW_APPEARED,
MINECENTER_PRODUCT_REQUEST,
MINECENTER_PRODUCT_SUCCESS,
... ... @@ -82,14 +83,21 @@ export default function appReducer(state = initialState, action) {
return state.set('isNeedShowXsrz', isNeedShowXsrz);
}
case SET_IS_MINEVIEW_APPEARED:{
let isMineViewAppeared = action.payload;
return state.set('isMineViewAppeared', isMineViewAppeared);
}
case MINECENTER_PRODUCT_SUCCESS: {
let {
product_list,
rec_id,
page_size,
} = action.payload;
return state.setIn(['open', 'productListForMineCenter', 'list'], Immutable.fromJS(product_list))
.setIn(['open', 'productListForMineCenter', 'rec_id'], rec_id);
return state.setIn(['open', 'productListForMineCenter', 'product_list'], Immutable.fromJS(product_list))
.setIn(['open', 'productListForMineCenter', 'rec_id'], rec_id)
.setIn(['open', 'productListForMineCenter', 'page_size'], page_size);
}
case SET_SIMILAR_PRODUCT_INDEX: {
... ...