Authored by yoho-js001

Add jump navigation.

... ... @@ -49,7 +49,7 @@ function parseCategoryList(json) {
let newLifestyle=[];
//男
// for (let i in boy)
// for (let i in boy)
boy.map((item, i) => {
// let item=boy[i];
let newBoySub=[];
... ... @@ -214,6 +214,7 @@ export function jumpToCategory(value, index, channel){
}else{
channelId=4;
}
console.log(value);
ReactNative.NativeModules.YH_CommonHelper.jumpToCategory(value, parseInt(index), parseInt(channelId));
return {
type: JUMP_TO_CATEGORY,
... ... @@ -226,7 +227,7 @@ function dataExposure(json) {
if (!json) {
return;
}
let {boy, girl, kids, lifestyle} = json;
let newBoy = [];
... ... @@ -312,4 +313,3 @@ function dataExposure(json) {
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_CATEGORY', params);
};
}
... ...
... ... @@ -42,7 +42,7 @@ export default class ProductListCell extends Component {
style={[styles.container, style]}
activeOpacity={1}
onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(data, rowID);
this.props.onPressArticle && this.props.onPressArticle(url);
}}
>
<View style={{flex:1}}>
... ...
... ... @@ -17,12 +17,6 @@ const {
export default class Banner extends React.Component {
static propTypes = {
data: ImmutablePropTypes.listOf(
ImmutablePropTypes.contains({
src: React.PropTypes.string.isRequired,
url: React.PropTypes.string.isRequired,
})
),
duration: React.PropTypes.number,
width: React.PropTypes.number.isRequired,
height: React.PropTypes.number.isRequired,
... ... @@ -61,7 +55,7 @@ export default class Banner extends React.Component {
render() {
let width = this.props.width;
let height = this.props.height;
let data = this.props.data.toArray();
let data = this.props.data;
return (
<Swiper
... ... @@ -76,15 +70,22 @@ export default class Banner extends React.Component {
height={height}
>
{data.map((item, i) => {
let {
src,
url,
} = item;
if (!src) {
return null;
}
return (
<TouchableOpacity
key={i}
activeOpacity={1}
onPress={() => {
this.props.onPress && this.props.onPress(item.get('url'));
this.props.onPress && this.props.onPress(url);
}}
>
<SlicedImage source={{uri: item.get('src')}} style={{width, height}}/>
<SlicedImage source={{uri: src.replace('{width}', width).replace('{height}', height).replace('{mode}',2)}} style={{width, height}}/>
</TouchableOpacity>
);
})}
... ...
... ... @@ -23,7 +23,8 @@ import BrandProductListCell from '../../../common/components/ListCell/ProductLis
import TagsCell from './TagsCell'
import ShopCell from './ShopCell'
import ArticleCell from './ArticleCell'
import FeaturedView from './FeaturedView';
import FeaturedView from './FeaturedView'
import BannerCell from './BannerCell'
export default class NewArrival extends Component {
... ... @@ -75,10 +76,15 @@ export default class NewArrival extends Component {
_renderRow(rowData, sectionID, rowID) {
switch (sectionID) {
case 'banner': {
let {src} = rowData;
return (
<View style={{width,height:132}}>
<Image style={styles.bannerImage} source={{uri: 'http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg'}}/>
<BannerCell
style={styles.bannerImage}
width={width}
height={117}
data={rowData}
onPress={this.props.onPressBanner}
/>
<View style={styles.separator}/>
</View>
);
... ... @@ -95,25 +101,30 @@ export default class NewArrival extends Component {
}
break;
case 'featured': {
let testData = ['http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg',
'http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg',
'http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg',
'http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg',
'http://imgsrc.baidu.com/forum/pic/item/770a6d2f12d46d7f71f05d7c.jpg',
];
let data = [];
for (var i = 0; i < rowData.length; i++) {
let {src} = rowData[i];
if (src) {
src = src.replace('{width}', width).replace('{height}', height).replace('{mode}',2);
data.push(src);
}
}
return (
<View>
<View style={{
width,
height: 171,
}}>
<FeaturedView
style={styles.carouselSection}
items={testData}
items={data}
onClick={(info) => {
let item = testData[info.index];
console.log(item);
let item = rowData[info.index];
let {url} = item;
this.props.onPressCarouselItem&&this.props.onPressCarouselItem(url);
}}
/>
<View style={styles.separator}/>
</View>
)
}
break;
... ... @@ -133,18 +144,24 @@ export default class NewArrival extends Component {
if (recommend_type == 'hotSearchTerm' || recommend_type == 'seasonSort') {
return (
<TagsCell style={[styles.listContainer, customStyle]} recommend_type={recommend_type} data={data}/>
<TagsCell
style={[styles.listContainer, customStyle]}
recommend_type={recommend_type}
data={data}
onPressCategory={this.props.onPressCategory}
onPressHotSearch={this.props.onPressHotSearch}
/>
)
}
if (recommend_type == 'hotShop') {
return (
<ShopCell style={[styles.listContainer, customStyle]} data={data}/>
<ShopCell style={[styles.listContainer, customStyle]} data={data} onPressShop={this.props.onPressShop}/>
)
}
if (recommend_type == 'fashionArticle') {
return (
<ArticleCell style={[styles.listContainer, customStyle]} data={data}/>
<ArticleCell style={[styles.listContainer, customStyle]} data={data} onPressArticle={this.props.onPressArticle}/>
)
}
if (!recommend_type) {
... ... @@ -232,16 +249,17 @@ export default class NewArrival extends Component {
list,
} = productList.toJS();
let banner = topList?topList:[0];
let banner = topList&&topList.length?[topList]:[];
let latest = list?list:[0];
let recommend = [];
if (brandList&&brandList.length) {
recommend = [brandList];
}
let featured = featuredList&&featuredList.length?[featuredList]:[];
let dataSource = {
banner,
recommend,
'featured': [0],
featured,
latest,
}
let isLoadingMore = productList.isFetching && productList.currentPage > 0;
... ... @@ -341,7 +359,7 @@ let styles = StyleSheet.create({
},
carouselSection: {
width,
height: 156,
height: 166,
},
brandFilterContainer: {
marginLeft: -1,
... ...
... ... @@ -50,7 +50,7 @@ export default class ProductListCell extends Component {
人收藏
</Text>
<View style={styles.tag}>
<TouchableOpacity style={styles.button} onPress={()=>{console.log('item');}}>
<TouchableOpacity style={styles.button} onPress={()=>{this.props.onPressShop && this.props.onPressShop(data,);}}>
<Text style={styles.tagName}>进入店铺</Text>
</TouchableOpacity>
</View>
... ...
... ... @@ -64,7 +64,14 @@ export default class ProductListCell extends Component {
{tagData.map((item, i) => {
return (
<View style={styles.tag} key={i}>
<TouchableOpacity style={styles.button} onPress={()=>{console.log(item);}}>
<TouchableOpacity style={styles.button} onPress={()=>{
if (recommend_type == 'seasonSort') {
this.props.onPressCategory&&this.props.onPressCategory(data[i]);
}
if (recommend_type == 'hotSearchTerm') {
this.props.onPressHotSearch&&this.props.onPressHotSearch(data[i]);
}
}}>
<Text style={styles.tagName}>{item}</Text>
</TouchableOpacity>
</View>
... ...
... ... @@ -56,6 +56,11 @@ class NewArrivalContainer extends Component {
this._onPressShop = this._onPressShop.bind(this);
this._onPressProductListProduct = this._onPressProductListProduct.bind(this);
this._goToRecommendForYou = this._goToRecommendForYou.bind(this);
this._onPressCategory = this._onPressCategory.bind(this);
this._onPressHotSearch = this._onPressHotSearch.bind(this);
this._onPressArticle = this._onPressArticle.bind(this);
this._onPressBanner = this._onPressBanner.bind(this);
this._onPressCarouselItem = this._onPressCarouselItem.bind(this);
}
componentDidMount() {
... ... @@ -105,6 +110,47 @@ class NewArrivalContainer extends Component {
this.props.actions.setFilterMoreView(false);
}
_onPressCarouselItem(url) {
if (!url) {
return;
}
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressBanner(url) {
if (!url) {
return;
}
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressArticle(url) {
if (!url) {
return;
}
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressCategory(data) {
let {
categoryId,
categoryName,
parentId,
} = data;
if (!categoryId||!parentId) {
return;
}
let url = `http://m.yohobuy.com?openby:openby:yohobuy={"action":"go.list","params":{"msort":"${parentId}","misort":"${categoryId}","title":"${categoryName}","actiontype":"1","app_type":"0"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
_onPressHotSearch(data) {
if (!data) {
return;
}
ReactNative.NativeModules.YH_CommonHelper.hotSearchWithKeyword(data);
}
_onPressShop(data) {
let {
shop_name,
... ... @@ -163,6 +209,11 @@ class NewArrivalContainer extends Component {
onPressShop={this._onPressShop}
onPressProductListProduct={this._onPressProductListProduct}
goToRecommendForYou={this._goToRecommendForYou}
onPressCategory={this._onPressCategory}
onPressHotSearch={this._onPressHotSearch}
onPressArticle={this._onPressArticle}
onPressBanner={this._onPressBanner}
onPressCarouselItem={this._onPressCarouselItem}
/>
</View>
);
... ...
... ... @@ -30,9 +30,36 @@ export function getTopInfo() {
return (dispatch, getState) => {
let {app} = getState();
dispatch(topInfoRequest());
return new NewArrivalService('http://api-test2.yohops.com:9999').fetchRecommendShop(app.channel)
return new NewArrivalService('http://api-test3.yohops.com:9999').fetchRecommendShop(app.channel)
.then(json => {
dispatch(topInfoSuccess(json));
let {
shop_list,
ads,
} = json;
let first_part = [];
let second_part = [];
console.log('aaaaaaa');
console.log(ads);
if (ads&&ads.length) {
for (var i = 0; i < ads.length; i++) {
let {
data,
template_name,
} = ads[i];
if (data.length && template_name == 'focus') {
first_part = data;
}
if (data.length && template_name == 'single_image') {
second_part = data;
}
}
}
let newJson = {
first_part,
shop_list,
second_part,
}
dispatch(topInfoSuccess(newJson));
})
.catch(error => {
dispatch(topInfoFailure(error));
... ... @@ -66,9 +93,7 @@ export function topInfoFailure(error) {
export function getProductList(reload=false) {
return (dispatch, getState) => {
let {app, newArrival} = getState();
console.log('......');
let { productList, filterFactors} = newArrival;
console.log('00000');
if (reload) {
... ... @@ -96,7 +121,7 @@ export function getProductList(reload=false) {
}
}
dispatch(productListRequest());
return new NewArrivalService('http://api-test2.yohops.com:9999').fetchProductList(channel, order, page, pageSize, allFilterFactors)
return new NewArrivalService('http://api-test3.yohops.com:9999').fetchProductList(channel, order, page, pageSize, allFilterFactors)
.then(json => {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount || payload.list.length < pageSize;
... ...
... ... @@ -13,6 +13,23 @@ export default class HomeService {
}
async fetchRecommendShop(yh_channel) {
let contentCode = '1f2e07cb63811680154ba693c954dd62';
switch (yh_channel) {
case 1:
contentCode = '1f2e07cb63811680154ba693c954dd62';
break;
case 2:
contentCode = '375f201d1ec56f7515509249c9c66959';
break;
case 3:
contentCode = '74c62151673e7dde9fb154c90dcff3f0';
break;
case 4:
contentCode = 'b9b4bd0de670f982e1f8e7dc23980e81';
break;
default:
contentCode = '1f2e07cb63811680154ba693c954dd62';
}
return await this.api.get({
url: '',
body: {
... ... @@ -20,6 +37,7 @@ export default class HomeService {
yh_channel,
limit: 10,
page: 1,
contentCode,
}
})
.then((json) => {
... ...