Authored by aozhe.zhu

达人UI 收藏 修改 review by 孙凯

... ... @@ -109,7 +109,9 @@ export default function native(platform) {
} else if (type === 'shareDetail') {
return (
<Provider store={store}>
<ShareDetailContainer product_skn={this.props.product_skn}/>
<ShareDetailContainer
product_skn={this.props.product_skn}
product_id={this.props.product_id}/>
</Provider>
);
} else if (type === 'recommendProduct') {
... ...
... ... @@ -41,9 +41,9 @@ class RankItem extends PureComponent {
<View style={styles.row}>
<Text style={styles.rank}>{rankNum}</Text>
{this._renderImage(image)}
<Text style={styles.name}>{nickname}</Text>
<Text style={styles.name} numberOfLines={1}>{nickname}</Text>
<View style={styles.rightContainer}>
<Text style={styles.amount}>{amountStr}</Text>
<Text style={styles.amount} numberOfLines={1}>{amountStr}</Text>
<Text style={styles.amountName}>{`${monthRank ? '本月' : '总'}预估收入`}</Text>
</View>
</View>
... ...
... ... @@ -45,12 +45,12 @@ class TalentRank extends Component {
<View style={[styles.container, styles.leftContainer]}>
<Text style={styles.amountName}>{`${monthRank ? '本月' : '总'}预估收入`}</Text>
<View style={styles.amountContainer}>
<Text style={styles.amountUnit}></Text><Text style={styles.amount}>{amountStr}</Text>
<Text style={styles.amount}>{amountStr}</Text>
</View>
</View>
<View style={[styles.container, styles.middleContainer]}>
{this._renderImage(image)}
<Text style={styles.name}>{nickname}</Text>
<Text style={styles.name} numberOfLines={1}>{nickname}</Text>
</View>
<View style={[styles.container, styles.rightContainer]}>
<Text style={[styles.amountName, styles.textRight]}>排名</Text>
... ...
... ... @@ -133,4 +133,7 @@ export default keyMirror({
ADD_FAVORITE_REQUEST: null,
ADD_FAVORITE_SUCCESS: null,
ADD_FAVORITE_FAILURE: null,
FAVORITE_INFO_REQUEST: null,
FAVORITE_INFO_FAILURE: null,
});
\ No newline at end of file
... ...
... ... @@ -107,6 +107,7 @@ class HomeContainer extends Component {
_onPressProduct(product) {
let productSkn = product && product.get('product_skn', 0);
let product_id = product && product.get('product_id', 0);
if (!productSkn) {
return;
}
... ... @@ -116,7 +117,7 @@ class HomeContainer extends Component {
pageName = 'aFP_Alliance';
}
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"type":"shareDetail", "product_skn":"${productSkn}", "from_page_name":"${pageName}"}}`;
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"type":"shareDetail", "product_skn":"${productSkn}", "product_id": "${product_id}" ,"from_page_name":"${pageName}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
... ...
... ... @@ -68,10 +68,11 @@ class ShareDetailContainer extends Component {
componentDidMount() {
this.props.actions.fetchShareDetail({product_skn: this.props.product_skn});
this.props.actions.fetchFavoriteInfo({id: this.props.product_id, type: 'product'})
}
_addFavorite = () => {
this.props.actions.addFavorite({id: this.props.product_skn, type: 'product'});
this.props.actions.addFavorite({id: this.props.product_id, type: 'product'});
}
showShareView = (show) => {
... ...
... ... @@ -10,6 +10,8 @@ const {
ADD_FAVORITE_REQUEST,
ADD_FAVORITE_SUCCESS,
ADD_FAVORITE_FAILURE,
FAVORITE_INFO_REQUEST,
FAVORITE_INFO_FAILURE,
} = require('../../constants/actionTypes').default;
... ... @@ -87,4 +89,38 @@ export function addFavorite(params) {
}
dispatch(addFavoriteSuccess(isCollect === 'Y' ? 'N' : 'Y'));
}
}
export function favoriteInfoRequest() {
return {
type: FAVORITE_INFO_REQUEST,
}
}
export function favoriteInfoFailure(e) {
return {
type: FAVORITE_INFO_FAILURE,
payload: e,
}
}
export function fetchFavoriteInfo(params) {
return async (dispatch, getState) => {
let { app: { host } } = getState();
let uid, data;
let service = new Service(host);
dispatch(favoriteInfoRequest());
try {
uid = await ReactNative.NativeModules.YH_CommonHelper.uid();
params = {
method: 'app.favorite.isFavoriteNew',
uid,
...params
};
data = await service.fetchInfo(params);
} catch(e) {
dispatch(favoriteInfoFailure(e));
}
dispatch(addFavoriteSuccess(data ? 'Y' : 'N'));
}
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ import {List, Map, Record} from 'immutable';
let InitialState = Record({
isFetching: false,
error: '',
productInfo: new (Record({
goodsList: List()
})),
... ...
... ... @@ -10,6 +10,8 @@ const {
ADD_FAVORITE_REQUEST,
ADD_FAVORITE_SUCCESS,
ADD_FAVORITE_FAILURE,
FAVORITE_INFO_REQUEST,
FAVORITE_INFO_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -24,14 +26,22 @@ export default function appReducer(state = initialState, action) {
return state.set('isFetching', false)
.set('productInfo', Immutable.fromJS(action.payload));
case SHARE_DETAIL_FAILURE:
return state.set('isFetching', false);
return state.set('isFetching', false)
.set('error', action.payload);
case ADD_FAVORITE_REQUEST:
return state.set('isFetching', true);
case ADD_FAVORITE_SUCCESS:
return state.set('isFetching', false)
.setIn(['productInfo', 'isCollect'], action.payload);
case ADD_FAVORITE_FAILURE:
return state.set('isFetching', false);
return state.set('isFetching', false)
.set('error', action.payload);
case ADD_FAVORITE_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
case ADD_FAVORITE_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
}
return state;
... ...
... ... @@ -53,4 +53,18 @@ export default class Service {
throw(error);
});
}
async fetchInfo(params) {
return await this.api.get({
url: '',
body: {
...params
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
\ No newline at end of file
... ...