Authored by 张丽霞

为您推荐, review by 盖见秋

... ... @@ -100,7 +100,7 @@ let styles = StyleSheet.create({
imageContainer: {
width: rowWidth,
height: imageHeight,
backgroundColor: rgb(68,68,68),
backgroundColor: 'rgb(68,68,68)',
marginTop: tagHeight,
flexDirection: 'column',
alignItems: 'center',
... ...
... ... @@ -50,7 +50,7 @@ let styles = StyleSheet.create({
container: {
height: 102,
width: 83,
backgroundColor: rgb(255,244,244),
backgroundColor: 'rgb(255,244,244)',
marginLeft: 15,
marginTop: 5,
},
... ... @@ -68,7 +68,7 @@ let styles = StyleSheet.create({
width: 59,
height: 16,
borderRadius:8,
backgroundColor: rgb(153,146,146),
backgroundColor: 'rgb(153,146,146)',
flexDirection: 'row',
},
text: {
... ...
... ... @@ -199,6 +199,7 @@ export default class NewArrival extends Component {
filterCategoryDetailFilterList,
filterNameFactors,
topPart,
recommendForYou,
} = this.props;
let {
... ...
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
Text,
Image,
ListView,
StyleSheet,
Dimensions,
TouchableOpacity,
InteractionManager,
Platform,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import BrandCell from './BrandCell';
import {getSlicedUrl} from '../../../classify/utils/Utils';
export default class RecForYouIconTitleNumbCell extends Component {
constructor(props) {
super(props);
}
render() {
let {dataSource, hideNewNum} = this.props;
let newSrc = getSlicedUrl(dataSource.get('shop_logo'), width, height, 2);
let name = dataSource.get('shop_name');
let newProductNum = dataSource.get('new_product_num');
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => {
// this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.toJS());
}}>
<View style={styles.rowContainer}>
<Image
source={{uri: newSrc}}
style={styles.thumbnail}
resizeMode={'contain'}
>
</Image>
<View style={styles.itemTitle}>
<Text style={styles.itemText} numberOfLines={1}>{name}</Text>
</View>
{!hideNewNum ?
<View style={styles.newSale}>
<Text style={styles.newSaleText} numberOfLines={1}>上新{newProductNum}</Text>
<Image
source={require('../../images/arrow_small.png')}
style={styles.iconStyle}
/>
</View>
:null
}
</View>
</TouchableOpacity>
);
}
}
let width = Math.ceil((Dimensions.get('window').width - 40) / 3);
let height = width - 40;
let styles = StyleSheet.create({
thumbnail: {
width: width,
height: height,
marginLeft: 10,
marginTop: 20,
backgroundColor: 'white',
},
itemTitle: {
justifyContent: 'center',
height: 30,
width: width,
marginLeft: 10,
backgroundColor: 'white',
},
itemText: {
fontWeight: 'bold',
textAlign: 'center',
color: '#aaaaaa',
fontSize: 10,
},
rowContainer: {
backgroundColor:'white',
},
newSale: {
height: 16,
backgroundColor: '#999999',
borderRadius: 8,
flexDirection:'row',
marginLeft: 32,
marginRight: 22,
justifyContent: 'center',
},
newSaleText: {
textAlign: 'center',
fontSize: 9,
color: 'white',
marginTop: 2,
},
iconStyle: {
marginTop: 4,
marginLeft:4
},
});
... ...
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
Text,
Image,
ListView,
StyleSheet,
Dimensions,
TouchableOpacity,
InteractionManager,
Platform,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import RrecommendForYouCell from './RrecommendForYouCell'
export default class RecommendForYou extends Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
});
this._renderRow = this._renderRow.bind(this);
}
_renderRow(rowData, rowID, sectionID) {
let title = '';
switch (sectionID) {
case 'hotBrandList':
title = '热门品牌';
break;
case 'browseBrandList':
title = '浏览过的品牌';
break;
case 'newBrandList':
title = '新入驻品牌';
break;
default:
}
return (
<RrecommendForYouCell
title={title}
dataSource={rowData}
/>
)
}
_renderSeperator(){
return (
<View style={styles.seperatorView}>
</View>
);
}
_renderHeader(){
return (
<View style={styles.seperatorView}>
</View>
);
}
render() {
let {resource} = this.props;
let dataSource = {
hotBrandList: resource.get('hotBrandList').toArray(),
browseBrandList: resource.get('browseBrandList').toArray(),
newBrandList: resource.get('newBrandList').toArray(),
};
return (
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this._renderRow}
renderSeparator={this._renderSeperator}
renderHeader={this._renderHeader}
enableEmptySections={true}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
},
contentContainer: {
backgroundColor: 'white',
},
seperatorView: {
height: 15,
backgroundColor: '#f0f0f0',
},
});
... ...
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
Text,
Image,
ListView,
StyleSheet,
Dimensions,
TouchableOpacity,
InteractionManager,
Platform,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import RecForYouIconTitleNumbCell from './RecForYouIconTitleNumbCell'
export default class RecommendForYouCell extends Component {
constructor(props) {
super(props);
}
render() {
let {title, dataSource} = this.props;
let hideNewNum = false;
let footerHeight = 46;
if (title == '新入驻品牌') {
hideNewNum = true;
footerHeight = 30;
}
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.headerText}>{title}</Text>
</View>
<View style={styles.contentContainer}>
{dataSource.map((item, i) => {
return(
<RecForYouIconTitleNumbCell
key={i}
dataSource = {item}
hideNewNum={hideNewNum}
/>
)
})}
</View>
<View style={[styles.footer, {height:footerHeight}]}>
</View>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
},
header: {
backgroundColor: 'white',
width: width,
height: 40,
alignItems: 'center',
flexDirection: 'row',
},
headerText: {
fontSize: 15,
color: 'black',
width: width,
textAlign: 'center',
backgroundColor: 'white',
},
contentContainer: {
backgroundColor: 'white',
flexDirection: 'row',
flexWrap: 'wrap',
alignItems:'flex-start',
},
footer: {
height: 16,
backgroundColor: 'white',
},
cellContainer: {
}
});
... ...
... ... @@ -202,6 +202,47 @@ export function productListFailure(error) {
}
}
//为您推荐
export function recommendBrandRequest() {
return {
type: RECOMMEND_BRAND_REQUEST,
}
}
export function recommendBrandSuccess(json) {
return {
type: RECOMMEND_BRAND_SUCCESS,
payload: json,
}
}
export function recommendBrandFailure(error) {
return {
type: RECOMMEND_BRAND_FAILURE,
payload: error,
}
}
export function getRecommendBrand() {
return (dispatch, getState) => {
let {app, newArrival} = getState();
let { productList, filterFactors} = newArrival;
let channel = app.channel;
dispatch(recommendBrandRequest());
return new NewArrivalService(app.host).fetchRecommendBrand(channel)
.then(json => {
let hotBrandList = json.hot_brand_list;
let browseBrandList = json.browse_brand_list;
let newBrandList = json.new_brand_list;
dispatch(recommendBrandSuccess({hotBrandList, browseBrandList, newBrandList}));
})
.catch(error => {
dispatch(recommendBrandFailure(error));
});
};
}
function parseProductList(json) {
let currentPage = json && json.page ? json.page : 1;
let pageCount = json && json.page_total ? json.page_total : 0;
... ...
... ... @@ -46,6 +46,12 @@ let InitialState = Record({
sort: '所有品类', //品类
brand: '所有品牌', //品牌
})),
recommendForYou: new (Record({
isFetching: false,
hotBrandList: List(),
browseBrandList: List(),
newBrandList: List(),
})),
});
export default InitialState;
... ...
... ... @@ -113,7 +113,11 @@ export default function newArrivalReducer(state=initialState, action) {
return state.setIn(['productList', 'isFetching'], false)
.setIn(['productList', 'error'], action.payload);
}
case RECOMMEND_BRAND_SUCCESS: {
return state.setIn(['recommendForYou', 'hotBrandList'], Immutable.fromJS(action.payload.hotBrandList))
.setIn(['recommendForYou', 'browseBrandList'], Immutable.fromJS(action.payload.browseBrandList))
.setIn(['recommendForYou', 'newBrandList'], Immutable.fromJS(action.payload.newBrandList));
}
}
return state;
... ...
... ... @@ -34,7 +34,7 @@ export default class HomeService {
return await this.api.get({
url: '',
body: {
method: 'app.newproduct.rec.brand',
method: 'app.newproduct.recbrand',
yh_channel,
limit: 60,
page: 1,
... ...