Authored by chenl

调整了more的位置,修复了图片被裁减的bug。review by shixiang。

... ... @@ -48,6 +48,7 @@ export default class CategoryB extends Component {
cacheSubCateData={cacheSubCateData}
onSelectCategory={this.props.onSelectCategory}
onPressBannerResourceItem={this.props.onPressBannerResourceItem}
onPressCategoryBMore={this.props.onPressCategoryBMore}
onPressHotCategoryItem={this.props.onPressHotCategoryItem}
onPressHotBrandItem={this.props.onPressHotBrandItem}
/>
... ...
... ... @@ -72,6 +72,7 @@ export default class CategoryBList extends Component {
<HotCategoryList
title={hotTitle}
data={rowData}
onPressCategoryBMore={this.props.onPressCategoryBMore}
onPressHotCategoryItem={this.props.onPressHotCategoryItem}/>
);
case 'brandInfo':
... ... @@ -145,6 +146,7 @@ export default class CategoryBList extends Component {
enableEmptySections={true}
renderRow={this.subRenderRow}
onPressBannerResourceItem={this.props.onPressBannerResourceItem}
onPressCategoryBMore={this.props.onPressCategoryBMore}
onPressHotCategoryItem={this.props.onPressHotCategoryItem}
onPressHotBrandItem={this.props.onPressHotBrandItem}
scrollsToTop={false}
... ...
'use strict';
import React, {Component} from 'react';
import {getSlicedUrl} from '../../utils/Utils';
import SlicedImage from '../../../common/components/SlicedImage';
import ReactNative, {
View,
... ... @@ -53,7 +53,7 @@ export default class HotBrandList extends Component{
return null;
}
let imageUrl = getSlicedUrl(rowData.get("brand_ico"), 70, 29, 2);
let imageUrl = SlicedImage.getSlicedUrl(rowData.get("brand_ico"), 70, 29, 2);
let brandName = rowData.get("brand_name");
return (
... ... @@ -144,6 +144,7 @@ let styles = StyleSheet.create({
width: 70 * DEVICE_WIDTH_RATIO,
height: 50 * DEVICE_WIDTH_RATIO,
justifyContent: 'center',
alignItems: 'center',
},
rowThumbnail:{
... ... @@ -154,7 +155,7 @@ let styles = StyleSheet.create({
rowText:{
width: 70 * DEVICE_WIDTH_RATIO,
height: 20 * DEVICE_WIDTH_RATIO,
fontSize: 10 * DEVICE_WIDTH_RATIO,
fontSize: 10,
color: '#B0B0B0',
textAlign: 'center',
},
... ...
'use strict';
import React, {Component} from 'react';
import {getSlicedUrl} from '../../utils/Utils';
import SlicedImage from '../../../common/components/SlicedImage';
import ReactNative, {
View,
... ... @@ -41,7 +41,9 @@ export default class HotCategoryList extends Component{
return(
<View style={styles.headerContainer}>
<Text style={styles.headerText}>{title}</Text>
<Text style={styles.headerMore}></Text>
<TouchableOpacity style={styles.headerMore} activeOpacity={1} onPress={() => this.props.onPressCategoryBMore && this.props.onPressCategoryBMore()}>
<Text style={styles.headerMoreText}>more</Text>
</TouchableOpacity>
<View style={styles.headerLine}/>
</View>
);
... ... @@ -55,7 +57,7 @@ export default class HotCategoryList extends Component{
return null;
}
let imageUrl = getSlicedUrl(rowData.get("default_images"), 82, 110, 2);
let imageUrl = SlicedImage.getSlicedUrl(rowData.get("default_images"), 82, 110, 2);
// let categoryName = rowData.get("category_name");
//数据类型,纯文字型和图片型,列表中会出现纯文本的情况,比如MORE
... ... @@ -71,7 +73,7 @@ export default class HotCategoryList extends Component{
);
else{
return (
<TouchableOpacity onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}>
<TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}>
<View style={styles.rowContainer}>
<Image style={styles.rowThumbnail} source={{uri: imageUrl}}/>
<Text style={styles.rowText} numberOfLines={1}>{rowData.get("category_name")}</Text>
... ... @@ -137,8 +139,11 @@ let styles = StyleSheet.create({
headerMore:{
position: 'absolute',
right: 0,
right: 5 * DEVICE_WIDTH_RATIO,
bottom: 11 * DEVICE_WIDTH_RATIO,
},
headerMoreText:{
fontSize: 12 * DEVICE_WIDTH_RATIO,
color: '#B0B0B0',
},
... ...
... ... @@ -50,6 +50,7 @@ class CategoryBContainer extends Component {
this._onSelectChannel = this._onSelectChannel.bind(this);
this._onSelectCategory = this._onSelectCategory.bind(this);
this._onPressBannerResourceItem = this._onPressBannerResourceItem.bind(this);
this._onPressCategoryBMore = this._onPressCategoryBMore.bind(this);
this._onPressHotCategoryItem = this._onPressHotCategoryItem.bind(this);
this._onPressHotBrandItem = this._onPressHotBrandItem.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
... ... @@ -96,6 +97,12 @@ class CategoryBContainer extends Component {
}
}
_onPressCategoryBMore() {
console.log("chenlin","_onPressCategoryBMore");
let currentCateId = this.props.categoryB.currentCateId;
this.props.actions.pressCategoryBMore(currentCateId);
}
_onPressHotCategoryItem(value, index) {
let currentChannelId = this.props.categoryB.currentChannelId;
this.props.actions.jumpToCategory(value, index, currentChannelId);
... ... @@ -131,6 +138,7 @@ class CategoryBContainer extends Component {
onSelectChannel={this._onSelectChannel}
onSelectCategory={this._onSelectCategory}
onPressBannerResourceItem={this._onPressBannerResourceItem}
onPressCategoryBMore={this._onPressCategoryBMore}
onPressHotCategoryItem={this._onPressHotCategoryItem}
onPressHotBrandItem={this._onPressHotBrandItem}
/>
... ...
... ... @@ -59,13 +59,47 @@ export function selectCategoryB(category){
relation_parameter: category.relation_parameter,
node_count: category.node_count,
};
//设置当前的类别信息
//设置当前的类别信息
dispatch(setCurrentCateB(categoryId, categoryValue));
dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
}
};
}
/**
* 点击More事件
**/
export function pressCategoryBMore(category_id){
return (dispatch, getState) => {
let {categoryB} = getState();
//获取当前频道下一级分类列表信息
let categoryData = categoryB.categoryList.get(categoryB.currentChannelValue);
//获取指定category_id分类信息
let category = null;
categoryData.map((item, i) => {
if(category_id == item.get('category_id')){
category = item;
}
});
let all = {
category_name: "全部" + (category ? category.category_name : ""),
parent_id: category_id,
relation_parameter: category ? category.get('relation_parameter') : {},
node_count: category ? category.get('node_count') : 0,
};
console.log("chenlin", JSON.stringify(all));
//设置当前的类别信息
dispatch(setCurrentCateB(category_id, category.category_name));
dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
};
}
/**
* 获取子分类的数据,逻辑上先判断缓存数据是否存在,不存在则从网络获取
... ... @@ -178,32 +212,33 @@ function parseCategoryBSubDetail(channel_id, category_id, subcategory_data, prop
return;
}
//分类信息不为空时,添加more
if(subcategory_data.sortInfo && subcategory_data.sortInfo.length > 0){
// 暂时不添加MORE,陈林修改 2017.1.13
// //分类信息不为空时,添加more
// if(subcategory_data.sortInfo && subcategory_data.sortInfo.length > 0){
//获取当前频道下一级分类列表信息
let categoryData = props_data.categoryList.get(props_data.currentChannelValue);
// //获取当前频道下一级分类列表信息
// let categoryData = props_data.categoryList.get(props_data.currentChannelValue);
//获取指定category_id分类信息
let category = null;
categoryData.map((item, i) => {
if(category_id == item.get('category_id')){
category = item;
}
});
// //获取指定category_id分类信息
// let category = null;
// categoryData.map((item, i) => {
// if(category_id == item.get('category_id')){
// category = item;
// }
// });
let more = {
show_category_name: 'MORE',
category_name: "全部" + (category ? category.get('category_name') : ''),
parent_id: category_id,
relation_parameter: category ? category.get('relation_parameter') : {},
node_count: category ? category.get('node_count') : 0,
data_type:'text',
};
// let more = {
// show_category_name: 'MORE',
// category_name: "全部" + (category ? category.get('category_name') : ''),
// parent_id: category_id,
// relation_parameter: category ? category.get('relation_parameter') : {},
// node_count: category ? category.get('node_count') : 0,
// data_type:'text',
// };
subcategory_data.sortInfo.push(more);
}
// subcategory_data.sortInfo.push(more);
// }
let key = getSubDetailCacheKey(channel_id, category_id);
... ... @@ -281,4 +316,96 @@ export function jumpToCategory(value, index, channelId){
type: JUMP_TO_CATEGORY,
payload: value
}
}
function dataExposure(json) {
return (dispatch, getState) => {
if (!json) {
return;
}
let {boy, girl, kids, lifestyle} = json;
let newBoy = [];
let newGirl = [];
let newKids = [];
let newLifestyle = [];
boy.map((item, i) => {
let subList = [];
item.sub && item.sub.map((sub, k) => {
subList.push({
I_INDEX: k + 1,
CAT_ID: sub.category_id,
});
});
newBoy.push({
I_INDEX: i + 1,
CAT_ID: item.category_id,
SUBLIST: subList,
});
});
girl.map((item, i) => {
let subList = [];
item.sub && item.sub.map((sub, k) => {
subList.push({
I_INDEX: k + 1,
CAT_ID: sub.category_id,
});
});
newGirl.push({
I_INDEX: i + 1,
CAT_ID: item.category_id,
SUBLIST: subList,
});
});
kids.map((item, i) => {
let subList = [];
item.sub && item.sub.map((sub, k) => {
subList.push({
I_INDEX: k + 1,
CAT_ID: sub.category_id,
});
});
newKids.push({
I_INDEX: i + 1,
CAT_ID: item.category_id,
SUBLIST: subList,
});
});
lifestyle.map((item, i) => {
let subList = [];
item.sub && item.sub.map((sub, k) => {
subList.push({
I_INDEX: k + 1,
CAT_ID: sub.category_id,
});
});
newLifestyle.push({
I_INDEX: i + 1,
CAT_ID: item.category_id,
SUBLIST: subList,
});
});
let params = {
YH_AppChannelBoy: newBoy,
YH_AppChannelGirl: newGirl,
YH_AppChannelKid: newKids,
YH_AppChannelLifeStyle: newLifestyle,
};
// console.log(params);
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_CATEGORY', params);
};
}
\ No newline at end of file
... ...
... ... @@ -27,8 +27,8 @@ export default class SlicedImage extends React.Component {
newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height;
} else {
newSrc = src.replace('{mode}', mode)
.replace('{width}', width)
.replace('{height}', height);
.replace(/{width}/g, width)
.replace(/{height}/g, height);
}
// __DEV__ && console.log(newSrc);
... ...