个人中心预加载不上报猜你喜欢数据——review by 于良
Showing
6 changed files
with
58 additions
and
8 deletions
@@ -133,7 +133,7 @@ export default class MineList extends React.Component { | @@ -133,7 +133,7 @@ export default class MineList extends React.Component { | ||
133 | globalOrderData | 133 | globalOrderData |
134 | } = this.props; | 134 | } = this.props; |
135 | 135 | ||
136 | - let dataSource = productListForMineCenter.list.toArray(); | 136 | + let dataSource = productListForMineCenter.product_list.toArray(); |
137 | 137 | ||
138 | return ( | 138 | return ( |
139 | <View style={styles.container}> | 139 | <View style={styles.container}> |
@@ -156,6 +156,7 @@ export default class MineList extends React.Component { | @@ -156,6 +156,7 @@ export default class MineList extends React.Component { | ||
156 | onScrollEndDrag={(event) => { | 156 | onScrollEndDrag={(event) => { |
157 | if (profile.uid != '0' && Platform.OS === 'ios' && event.nativeEvent.contentOffset.y < -60) { | 157 | if (profile.uid != '0' && Platform.OS === 'ios' && event.nativeEvent.contentOffset.y < -60) { |
158 | this.props.onMineCenterRefresh && this.props.onMineCenterRefresh(); | 158 | this.props.onMineCenterRefresh && this.props.onMineCenterRefresh(); |
159 | + this.props.getProductListForMineCenter && this.props.getProductListForMineCenter(); | ||
159 | } | 160 | } |
160 | }} | 161 | }} |
161 | /> | 162 | /> |
@@ -6,6 +6,7 @@ export default keyMirror({ | @@ -6,6 +6,7 @@ export default keyMirror({ | ||
6 | SET_SERVICE_HOST: null, | 6 | SET_SERVICE_HOST: null, |
7 | SET_CHANNEL:null, | 7 | SET_CHANNEL:null, |
8 | SET_IS_NEED_SHOW_XSRZ:null, | 8 | SET_IS_NEED_SHOW_XSRZ:null, |
9 | + SET_IS_MINEVIEW_APPEARED:null, | ||
9 | 10 | ||
10 | MINECENTER_PRODUCT_REQUEST:null, | 11 | MINECENTER_PRODUCT_REQUEST:null, |
11 | MINECENTER_PRODUCT_SUCCESS:null, | 12 | MINECENTER_PRODUCT_SUCCESS:null, |
@@ -67,6 +67,7 @@ class MineContainer extends Component { | @@ -67,6 +67,7 @@ class MineContainer extends Component { | ||
67 | this.subscription3 = NativeAppEventEmitter.addListener( | 67 | this.subscription3 = NativeAppEventEmitter.addListener( |
68 | 'ChannelDidChangeEvent', | 68 | 'ChannelDidChangeEvent', |
69 | (reminder) => { | 69 | (reminder) => { |
70 | + this.props.actions.setIsMineViewAppeared(false); | ||
70 | this.props.actions.getProductListForMineCenter(); | 71 | this.props.actions.getProductListForMineCenter(); |
71 | } | 72 | } |
72 | ); | 73 | ); |
@@ -100,6 +101,15 @@ class MineContainer extends Component { | @@ -100,6 +101,15 @@ class MineContainer extends Component { | ||
100 | } | 101 | } |
101 | } | 102 | } |
102 | ); | 103 | ); |
104 | + | ||
105 | + this.subscription7 = NativeAppEventEmitter.addListener( | ||
106 | + 'MineViewDidAppearEvent', | ||
107 | + (reminder) => { | ||
108 | + let {productListForMineCenter} = this.props.mine.open; | ||
109 | + this.props.actions.setIsMineViewAppeared(true); | ||
110 | + productListForMineCenter && this.props.actions.reportFavoriteDataNotJudgeViewAppear(productListForMineCenter.toJS()); | ||
111 | + } | ||
112 | + ); | ||
103 | } | 113 | } |
104 | 114 | ||
105 | componentDidMount() { | 115 | componentDidMount() { |
@@ -117,6 +127,7 @@ class MineContainer extends Component { | @@ -117,6 +127,7 @@ class MineContainer extends Component { | ||
117 | this.subscription4 && this.subscription4.remove(); | 127 | this.subscription4 && this.subscription4.remove(); |
118 | this.subscription5 && this.subscription5.remove(); | 128 | this.subscription5 && this.subscription5.remove(); |
119 | this.subscription6 && this.subscription6.remove(); | 129 | this.subscription6 && this.subscription6.remove(); |
130 | + this.subscription7 && this.subscription7.remove(); | ||
120 | } | 131 | } |
121 | 132 | ||
122 | _onPressItem(viewId, data) { | 133 | _onPressItem(viewId, data) { |
@@ -387,6 +398,7 @@ class MineContainer extends Component { | @@ -387,6 +398,7 @@ class MineContainer extends Component { | ||
387 | onPressItem={this._onPressItem} | 398 | onPressItem={this._onPressItem} |
388 | onPressProductListProduct={this._onPressProductListProduct} | 399 | onPressProductListProduct={this._onPressProductListProduct} |
389 | onMineCenterRefresh={this._onMineCenterRefresh} | 400 | onMineCenterRefresh={this._onMineCenterRefresh} |
401 | + getProductListForMineCenter={this.props.actions.getProductListForMineCenter} | ||
390 | onLongPressProduct={this._onLongPressProduct} | 402 | onLongPressProduct={this._onLongPressProduct} |
391 | onPressFindSimilar={this._onPressFindSimilar} | 403 | onPressFindSimilar={this._onPressFindSimilar} |
392 | onPressFloorItem={this._onPressFloorItem} | 404 | onPressFloorItem={this._onPressFloorItem} |
@@ -9,6 +9,7 @@ const { | @@ -9,6 +9,7 @@ const { | ||
9 | 9 | ||
10 | SET_PLATFORM, | 10 | SET_PLATFORM, |
11 | SET_IS_NEED_SHOW_XSRZ, | 11 | SET_IS_NEED_SHOW_XSRZ, |
12 | + SET_IS_MINEVIEW_APPEARED, | ||
12 | 13 | ||
13 | MINECENTER_PRODUCT_REQUEST, | 14 | MINECENTER_PRODUCT_REQUEST, |
14 | MINECENTER_PRODUCT_SUCCESS, | 15 | MINECENTER_PRODUCT_SUCCESS, |
@@ -102,6 +103,13 @@ export function setIsNeedShowXsrz(json) { | @@ -102,6 +103,13 @@ export function setIsNeedShowXsrz(json) { | ||
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
106 | +export function setIsMineViewAppeared(json) { | ||
107 | + return { | ||
108 | + type: SET_IS_MINEVIEW_APPEARED, | ||
109 | + payload: json, | ||
110 | + } | ||
111 | +} | ||
112 | + | ||
105 | export function productListForMineCenterRequest() { | 113 | export function productListForMineCenterRequest() { |
106 | return { | 114 | return { |
107 | type: MINECENTER_PRODUCT_REQUEST, | 115 | type: MINECENTER_PRODUCT_REQUEST, |
@@ -336,7 +344,7 @@ export function getProductListForMineCenter() { | @@ -336,7 +344,7 @@ export function getProductListForMineCenter() { | ||
336 | } finally { | 344 | } finally { |
337 | } | 345 | } |
338 | dispatch(productListForMineCenterSuccess(res)); | 346 | dispatch(productListForMineCenterSuccess(res)); |
339 | - dispatch(reportFavoriteData(res)); | 347 | + dispatch(reportFavoriteDataJudgeViewAppear(res)); |
340 | }) | 348 | }) |
341 | .catch(error => { | 349 | .catch(error => { |
342 | dispatch(productListForMineCenterFailure()); | 350 | dispatch(productListForMineCenterFailure()); |
@@ -388,7 +396,26 @@ function exposePruductListData(json,channel) { | @@ -388,7 +396,26 @@ function exposePruductListData(json,channel) { | ||
388 | return res; | 396 | return res; |
389 | } | 397 | } |
390 | 398 | ||
391 | -function reportFavoriteData(payload) { | 399 | +/** 判断界面是否在前台显示再上报 */ |
400 | +export function reportFavoriteDataJudgeViewAppear(payload) { | ||
401 | + return (dispatch, getState) => { | ||
402 | + let {app, mine} = getState(); | ||
403 | + let isMineViewAppeared = mine.isMineViewAppeared; | ||
404 | + if (isMineViewAppeared) { | ||
405 | + dispatch(reportFavoriteData(payload)); | ||
406 | + } | ||
407 | + } | ||
408 | +} | ||
409 | + | ||
410 | +/** 不判断界面是否在前台显示,直接上报 */ | ||
411 | +export function reportFavoriteDataNotJudgeViewAppear(payload) { | ||
412 | + return (dispatch, getState) => { | ||
413 | + dispatch(reportFavoriteData(payload)); | ||
414 | + } | ||
415 | +} | ||
416 | + | ||
417 | +/** 上报猜你喜欢埋点数据 */ | ||
418 | +export function reportFavoriteData(payload) { | ||
392 | return (dispatch, getState) => { | 419 | return (dispatch, getState) => { |
393 | try { | 420 | try { |
394 | let productList = payload.product_list; | 421 | let productList = payload.product_list; |
@@ -396,7 +423,6 @@ function reportFavoriteData(payload) { | @@ -396,7 +423,6 @@ function reportFavoriteData(payload) { | ||
396 | let total = payload.page_size; | 423 | let total = payload.page_size; |
397 | 424 | ||
398 | let rec_pos = '100004'; | 425 | let rec_pos = '100004'; |
399 | - | ||
400 | let productIDS = '' | 426 | let productIDS = '' |
401 | if (productList.length > 0) { | 427 | if (productList.length > 0) { |
402 | let product = productList[0]; | 428 | let product = productList[0]; |
@@ -413,7 +439,7 @@ function reportFavoriteData(payload) { | @@ -413,7 +439,7 @@ function reportFavoriteData(payload) { | ||
413 | 'PRD_NUM': total, | 439 | 'PRD_NUM': total, |
414 | 'REC_POSE': rec_pos, | 440 | 'REC_POSE': rec_pos, |
415 | 'ACTION_ID': 0, | 441 | 'ACTION_ID': 0, |
416 | - 'REC_ID': rec_id?rec_id:'' | 442 | + 'REC_ID': rec_id ? rec_id : '' |
417 | }; | 443 | }; |
418 | ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CHOOSE_FOR_YOU', param); | 444 | ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CHOOSE_FOR_YOU', param); |
419 | 445 |
@@ -5,11 +5,13 @@ import {Record, List, Map} from 'immutable'; | @@ -5,11 +5,13 @@ import {Record, List, Map} from 'immutable'; | ||
5 | let InitialState = Record({ | 5 | let InitialState = Record({ |
6 | isFetching: false, | 6 | isFetching: false, |
7 | isNeedShowXsrz:true, | 7 | isNeedShowXsrz:true, |
8 | + isMineViewAppeared:false, | ||
8 | open: new (Record({ | 9 | open: new (Record({ |
9 | productListForMineCenter: new (Record({ | 10 | productListForMineCenter: new (Record({ |
10 | - list: List(), | 11 | + product_list: List(), |
11 | similarIndex: -1, | 12 | similarIndex: -1, |
12 | rec_id:'', | 13 | rec_id:'', |
14 | + page_size:0, | ||
13 | })), | 15 | })), |
14 | mineCenterInfo: '', | 16 | mineCenterInfo: '', |
15 | })), | 17 | })), |
@@ -6,6 +6,7 @@ import Immutable, {Map} from 'immutable'; | @@ -6,6 +6,7 @@ import Immutable, {Map} from 'immutable'; | ||
6 | const { | 6 | const { |
7 | SET_PLATFORM, | 7 | SET_PLATFORM, |
8 | SET_IS_NEED_SHOW_XSRZ, | 8 | SET_IS_NEED_SHOW_XSRZ, |
9 | + SET_IS_MINEVIEW_APPEARED, | ||
9 | 10 | ||
10 | MINECENTER_PRODUCT_REQUEST, | 11 | MINECENTER_PRODUCT_REQUEST, |
11 | MINECENTER_PRODUCT_SUCCESS, | 12 | MINECENTER_PRODUCT_SUCCESS, |
@@ -82,14 +83,21 @@ export default function appReducer(state = initialState, action) { | @@ -82,14 +83,21 @@ export default function appReducer(state = initialState, action) { | ||
82 | return state.set('isNeedShowXsrz', isNeedShowXsrz); | 83 | return state.set('isNeedShowXsrz', isNeedShowXsrz); |
83 | } | 84 | } |
84 | 85 | ||
86 | + case SET_IS_MINEVIEW_APPEARED:{ | ||
87 | + let isMineViewAppeared = action.payload; | ||
88 | + return state.set('isMineViewAppeared', isMineViewAppeared); | ||
89 | + } | ||
90 | + | ||
85 | case MINECENTER_PRODUCT_SUCCESS: { | 91 | case MINECENTER_PRODUCT_SUCCESS: { |
86 | let { | 92 | let { |
87 | product_list, | 93 | product_list, |
88 | rec_id, | 94 | rec_id, |
95 | + page_size, | ||
89 | } = action.payload; | 96 | } = action.payload; |
90 | 97 | ||
91 | - return state.setIn(['open', 'productListForMineCenter', 'list'], Immutable.fromJS(product_list)) | ||
92 | - .setIn(['open', 'productListForMineCenter', 'rec_id'], rec_id); | 98 | + return state.setIn(['open', 'productListForMineCenter', 'product_list'], Immutable.fromJS(product_list)) |
99 | + .setIn(['open', 'productListForMineCenter', 'rec_id'], rec_id) | ||
100 | + .setIn(['open', 'productListForMineCenter', 'page_size'], page_size); | ||
93 | } | 101 | } |
94 | 102 | ||
95 | case SET_SIMILAR_PRODUCT_INDEX: { | 103 | case SET_SIMILAR_PRODUCT_INDEX: { |
-
Please register or login to post a comment