Authored by hongyong.zhao

bug fix -- reviewed by 孙凯

... ... @@ -25,7 +25,7 @@ import RecommendContainer from './containers/RecommendContainer';
import TalentRankContainer from './containers/TalentRankContainer';
import ShareDetailContainer from './containers/ShareDetailContainer';
import {setChannel, setHost, setPlatform, setServiceHost} from './reducers/app/appActions';
import {setChannel, setHost, setPlatform, setServiceHost, setproductPool} from './reducers/app/appActions';
import {setOrderCode, setActivityId, setSrc, setJumpUrl} from './reducers/alliance/allianceActions';
... ... @@ -117,6 +117,7 @@ export default function native(platform) {
} else if (type === 'recommendProduct') {
store.dispatch(setSrc(this.props.src));
store.dispatch(setJumpUrl(this.props.jumpUrl));
this.props.productPool && store.dispatch(setproductPool(this.props.productPool))
return (
<Provider store={store}>
<RecommendContainer/>
... ...
... ... @@ -54,7 +54,7 @@ export default class ImageFour extends React.Component {
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(item.url);
// }
// this.props.jumpWithUrl && this.props.jumpWithUrl('商品详情', 'shareDetail');
// let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"favType":"0", "type":"recommendProduct", "title":"商品", "src":"http://img10.static.yhbimg.com/yhb-img01/2018/08/08/21/01479a3a579091b1c198d2884f3a80b08c.png?imageView2/{mode}/w/{width}/h/{height}" }}`;
// let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"favType":"0", "type":"recommendProduct", "title":"商品", "src":"http://img10.static.yhbimg.com/yhb-img01/2018/08/08/21/01479a3a579091b1c198d2884f3a80b08c.png?imageView2/{mode}/w/{width}/h/{height}", "productPool":"680" }}`;
// ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
// this.props.jumpWithUrl && this.props.jumpWithUrl('商品详情', 'recommendProduct');
... ...
... ... @@ -17,6 +17,7 @@ export default keyMirror({
SET_ACTIVITY_ID: null,
SET_SRC: null,
SET_JUMP_URL: null,
SET_PRODUCT_POOL:null,
SHOW_WITHDRAW_DIALOG: null,
DISMISS_WITHDRAW_DIALOG: null,
... ...
... ... @@ -57,6 +57,7 @@ class DataContainer extends Component {
componentDidMount() {
this.props.actions.getSettlementInfo();
this.props.actions.getStatisticsInfo(1);
}
componentWillUnmount() {
... ...
... ... @@ -75,9 +75,15 @@ class HomeContainer extends Component {
}
componentDidMount() {
this.props.actions.getResourceInfo();
// this.props.actions.getTop100List();
this.props.actions.getProductList();
let self = this;
this.props.actions.getResourceInfo(function (json) {
json && json.forEach(item => {
if (item.template_name === 'recommendGoodsGroup' && item.data) {
let productPool = item.data.recommendLogic;
self.props.actions.getProductList(productPool);
}
})
});
this.props.actions.getInviteCode();
}
... ... @@ -123,11 +129,17 @@ class HomeContainer extends Component {
}
onPressCategory(data, index) {
this.props.actions.setAppSelectedCategory(data.get('sort_id'), index);
let {
productPool,
} = this.props.app;
this.props.actions.setAppSelectedCategory(productPool, data.get('sort_id'), index);
}
_onEndReached() {
this.props.actions.getProductList();
let {
productPool,
} = this.props.app;
this.props.actions.getProductList(productPool);
}
render() {
... ...
... ... @@ -47,7 +47,10 @@ class RecommendContainer extends Component {
}
componentDidMount() {
this.props.actions.getProductList();
let {
productPool,
} = this.props.app;
this.props.actions.getProductList(productPool);
}
_resourceJumpWithUrl(url) {
... ... @@ -60,7 +63,10 @@ class RecommendContainer extends Component {
onPressCategory(data, index) {
// console.log('category clicked');
// console.log(data);
this.props.actions.setAppSelectedCategory(data.get('sort_id'), index);
let {
productPool,
} = this.props.app;
this.props.actions.setAppSelectedCategory(productPool, data.get('sort_id'), index);
}
onPressProduct(data) {
... ... @@ -74,7 +80,10 @@ class RecommendContainer extends Component {
}
onEndReached() {
this.props.actions.getProductList();
let {
productPool,
} = this.props.app;
this.props.actions.getProductList(productPool);
}
render() {
... ...
... ... @@ -2,6 +2,7 @@
import ReactNative from 'react-native';
import AllianceService from '../../services/AllianceService';
import {setproductPool} from "../app/appActions";
const Platform = require('Platform');
... ... @@ -563,13 +564,21 @@ export function getAddSettlement() {
};
}
export function getResourceInfo() {
export function getResourceInfo(callback) {
return (dispatch, getState) => {
let {app} = getState();
dispatch(getResourceRequest());
return new AllianceService(app.host).fetchResourceInfo('b688fc3b15100d23f247271b7dbe1193')
.then(json => {
dispatch(getResourceSuccess(json));
callback && typeof callback === 'function' && callback(json)
json && json.forEach(item => {
if (item.template_name === 'recommendGoodsGroup' && item.data) {
let productPool = item.data.recommendLogic;
dispatch(setproductPool(productPool));
}
})
})
.catch(error => {
dispatch(getResourceFailure(error));
... ...
... ... @@ -20,6 +20,7 @@ const {
SET_ACTIVITY_ID,
SET_SRC,
SET_JUMP_URL,
SET_PRODUCT_POOL,
SETTLEMENT_INFO_REQUEST,
SETTLEMENT_INFO_SUCCESS,
... ...
... ... @@ -13,6 +13,7 @@ const {
SET_CHANNEL,
SET_HOST,
SET_SERVICE_HOST,
SET_PRODUCT_POOL,
PRODUCT_LIST_REQUEST,
PRODUCT_LIST_SUCCESS,
... ... @@ -25,14 +26,14 @@ const {
} = require('../../constants/actionTypes').default;
export function setAppSelectedCategory(sort_id, index) {
export function setAppSelectedCategory(productPool,sort_id, index) {
return (dispatch, getState) => {
dispatch({
type: APP_SET_SELECTED_CATEGORY,
payload: {index}
});
dispatch(getProductList(sort_id));
dispatch(getProductList(productPool,sort_id));
};
}
... ... @@ -64,6 +65,13 @@ export function setServiceHost(host) {
};
}
export function setproductPool(productPool) {
return {
type: SET_PRODUCT_POOL,
payload: productPool,
}
}
export function productListRequest() {
return {
type: PRODUCT_LIST_REQUEST,
... ... @@ -218,7 +226,7 @@ function exposeHtmlContent(json, callbackFun) {
}
export function getProductList(msort = 0) {
export function getProductList(product_pool = 0,msort = 0) {
return (dispatch, getState) => {
let {app} = getState();
let list = app.productList;
... ... @@ -239,7 +247,7 @@ export function getProductList(msort = 0) {
console.log(pageSize);
let fetchProductList = (uid) => {
dispatch(productListRequest());
return new AppService(app.host).fetchProductList(uid, page, pageSize, msort)
return new AppService(app.host).fetchProductList(uid, page, pageSize, msort, product_pool)
.then(json => {
let payload = json;
try {
... ...
... ... @@ -7,6 +7,7 @@ let InitialState = Record({
channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho
host: 'http://api.yoho.cn',
serviceHost: 'http://api.yoho.cn',
productPool: 0,
productList: new (Record({
isFetching: false,
... ...
... ... @@ -8,6 +8,7 @@ const {
SET_CHANNEL,
SET_HOST,
SET_SERVICE_HOST,
SET_PRODUCT_POOL,
PRODUCT_LIST_REQUEST,
PRODUCT_LIST_SUCCESS,
PRODUCT_LIST_FAILURE,
... ... @@ -31,7 +32,9 @@ export default function appReducer(state = initialState, action) {
return state.set('host', action.payload);
case SET_SERVICE_HOST:
return state.set('serviceHost', action.payload);
case SET_PRODUCT_POOL: {
return state.set('productPool', action.payload);
}
case PRODUCT_LIST_REQUEST: {
return state.setIn(['productList', 'isFetching'], true)
.setIn(['productList', 'error'], null);
... ...