Authored by chenl

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

@@ -48,6 +48,7 @@ export default class CategoryB extends Component { @@ -48,6 +48,7 @@ export default class CategoryB extends Component {
48 cacheSubCateData={cacheSubCateData} 48 cacheSubCateData={cacheSubCateData}
49 onSelectCategory={this.props.onSelectCategory} 49 onSelectCategory={this.props.onSelectCategory}
50 onPressBannerResourceItem={this.props.onPressBannerResourceItem} 50 onPressBannerResourceItem={this.props.onPressBannerResourceItem}
  51 + onPressCategoryBMore={this.props.onPressCategoryBMore}
51 onPressHotCategoryItem={this.props.onPressHotCategoryItem} 52 onPressHotCategoryItem={this.props.onPressHotCategoryItem}
52 onPressHotBrandItem={this.props.onPressHotBrandItem} 53 onPressHotBrandItem={this.props.onPressHotBrandItem}
53 /> 54 />
@@ -72,6 +72,7 @@ export default class CategoryBList extends Component { @@ -72,6 +72,7 @@ export default class CategoryBList extends Component {
72 <HotCategoryList 72 <HotCategoryList
73 title={hotTitle} 73 title={hotTitle}
74 data={rowData} 74 data={rowData}
  75 + onPressCategoryBMore={this.props.onPressCategoryBMore}
75 onPressHotCategoryItem={this.props.onPressHotCategoryItem}/> 76 onPressHotCategoryItem={this.props.onPressHotCategoryItem}/>
76 ); 77 );
77 case 'brandInfo': 78 case 'brandInfo':
@@ -145,6 +146,7 @@ export default class CategoryBList extends Component { @@ -145,6 +146,7 @@ export default class CategoryBList extends Component {
145 enableEmptySections={true} 146 enableEmptySections={true}
146 renderRow={this.subRenderRow} 147 renderRow={this.subRenderRow}
147 onPressBannerResourceItem={this.props.onPressBannerResourceItem} 148 onPressBannerResourceItem={this.props.onPressBannerResourceItem}
  149 + onPressCategoryBMore={this.props.onPressCategoryBMore}
148 onPressHotCategoryItem={this.props.onPressHotCategoryItem} 150 onPressHotCategoryItem={this.props.onPressHotCategoryItem}
149 onPressHotBrandItem={this.props.onPressHotBrandItem} 151 onPressHotBrandItem={this.props.onPressHotBrandItem}
150 scrollsToTop={false} 152 scrollsToTop={false}
1 'use strict'; 1 'use strict';
2 2
3 import React, {Component} from 'react'; 3 import React, {Component} from 'react';
4 -import {getSlicedUrl} from '../../utils/Utils'; 4 +import SlicedImage from '../../../common/components/SlicedImage';
5 5
6 import ReactNative, { 6 import ReactNative, {
7 View, 7 View,
@@ -53,7 +53,7 @@ export default class HotBrandList extends Component{ @@ -53,7 +53,7 @@ export default class HotBrandList extends Component{
53 return null; 53 return null;
54 } 54 }
55 55
56 - let imageUrl = getSlicedUrl(rowData.get("brand_ico"), 70, 29, 2); 56 + let imageUrl = SlicedImage.getSlicedUrl(rowData.get("brand_ico"), 70, 29, 2);
57 let brandName = rowData.get("brand_name"); 57 let brandName = rowData.get("brand_name");
58 58
59 return ( 59 return (
@@ -144,6 +144,7 @@ let styles = StyleSheet.create({ @@ -144,6 +144,7 @@ let styles = StyleSheet.create({
144 width: 70 * DEVICE_WIDTH_RATIO, 144 width: 70 * DEVICE_WIDTH_RATIO,
145 height: 50 * DEVICE_WIDTH_RATIO, 145 height: 50 * DEVICE_WIDTH_RATIO,
146 justifyContent: 'center', 146 justifyContent: 'center',
  147 + alignItems: 'center',
147 }, 148 },
148 149
149 rowThumbnail:{ 150 rowThumbnail:{
@@ -154,7 +155,7 @@ let styles = StyleSheet.create({ @@ -154,7 +155,7 @@ let styles = StyleSheet.create({
154 rowText:{ 155 rowText:{
155 width: 70 * DEVICE_WIDTH_RATIO, 156 width: 70 * DEVICE_WIDTH_RATIO,
156 height: 20 * DEVICE_WIDTH_RATIO, 157 height: 20 * DEVICE_WIDTH_RATIO,
157 - fontSize: 10 * DEVICE_WIDTH_RATIO, 158 + fontSize: 10,
158 color: '#B0B0B0', 159 color: '#B0B0B0',
159 textAlign: 'center', 160 textAlign: 'center',
160 }, 161 },
1 'use strict'; 1 'use strict';
2 2
3 import React, {Component} from 'react'; 3 import React, {Component} from 'react';
4 -import {getSlicedUrl} from '../../utils/Utils'; 4 +import SlicedImage from '../../../common/components/SlicedImage';
5 5
6 import ReactNative, { 6 import ReactNative, {
7 View, 7 View,
@@ -41,7 +41,9 @@ export default class HotCategoryList extends Component{ @@ -41,7 +41,9 @@ export default class HotCategoryList extends Component{
41 return( 41 return(
42 <View style={styles.headerContainer}> 42 <View style={styles.headerContainer}>
43 <Text style={styles.headerText}>{title}</Text> 43 <Text style={styles.headerText}>{title}</Text>
44 - <Text style={styles.headerMore}></Text> 44 + <TouchableOpacity style={styles.headerMore} activeOpacity={1} onPress={() => this.props.onPressCategoryBMore && this.props.onPressCategoryBMore()}>
  45 + <Text style={styles.headerMoreText}>more</Text>
  46 + </TouchableOpacity>
45 <View style={styles.headerLine}/> 47 <View style={styles.headerLine}/>
46 </View> 48 </View>
47 ); 49 );
@@ -55,7 +57,7 @@ export default class HotCategoryList extends Component{ @@ -55,7 +57,7 @@ export default class HotCategoryList extends Component{
55 return null; 57 return null;
56 } 58 }
57 59
58 - let imageUrl = getSlicedUrl(rowData.get("default_images"), 82, 110, 2); 60 + let imageUrl = SlicedImage.getSlicedUrl(rowData.get("default_images"), 82, 110, 2);
59 // let categoryName = rowData.get("category_name"); 61 // let categoryName = rowData.get("category_name");
60 62
61 //数据类型,纯文字型和图片型,列表中会出现纯文本的情况,比如MORE 63 //数据类型,纯文字型和图片型,列表中会出现纯文本的情况,比如MORE
@@ -71,7 +73,7 @@ export default class HotCategoryList extends Component{ @@ -71,7 +73,7 @@ export default class HotCategoryList extends Component{
71 ); 73 );
72 else{ 74 else{
73 return ( 75 return (
74 - <TouchableOpacity onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}> 76 + <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}>
75 <View style={styles.rowContainer}> 77 <View style={styles.rowContainer}>
76 <Image style={styles.rowThumbnail} source={{uri: imageUrl}}/> 78 <Image style={styles.rowThumbnail} source={{uri: imageUrl}}/>
77 <Text style={styles.rowText} numberOfLines={1}>{rowData.get("category_name")}</Text> 79 <Text style={styles.rowText} numberOfLines={1}>{rowData.get("category_name")}</Text>
@@ -137,8 +139,11 @@ let styles = StyleSheet.create({ @@ -137,8 +139,11 @@ let styles = StyleSheet.create({
137 139
138 headerMore:{ 140 headerMore:{
139 position: 'absolute', 141 position: 'absolute',
140 - right: 0, 142 + right: 5 * DEVICE_WIDTH_RATIO,
141 bottom: 11 * DEVICE_WIDTH_RATIO, 143 bottom: 11 * DEVICE_WIDTH_RATIO,
  144 + },
  145 +
  146 + headerMoreText:{
142 fontSize: 12 * DEVICE_WIDTH_RATIO, 147 fontSize: 12 * DEVICE_WIDTH_RATIO,
143 color: '#B0B0B0', 148 color: '#B0B0B0',
144 }, 149 },
@@ -50,6 +50,7 @@ class CategoryBContainer extends Component { @@ -50,6 +50,7 @@ class CategoryBContainer extends Component {
50 this._onSelectChannel = this._onSelectChannel.bind(this); 50 this._onSelectChannel = this._onSelectChannel.bind(this);
51 this._onSelectCategory = this._onSelectCategory.bind(this); 51 this._onSelectCategory = this._onSelectCategory.bind(this);
52 this._onPressBannerResourceItem = this._onPressBannerResourceItem.bind(this); 52 this._onPressBannerResourceItem = this._onPressBannerResourceItem.bind(this);
  53 + this._onPressCategoryBMore = this._onPressCategoryBMore.bind(this);
53 this._onPressHotCategoryItem = this._onPressHotCategoryItem.bind(this); 54 this._onPressHotCategoryItem = this._onPressHotCategoryItem.bind(this);
54 this._onPressHotBrandItem = this._onPressHotBrandItem.bind(this); 55 this._onPressHotBrandItem = this._onPressHotBrandItem.bind(this);
55 this.subscription = NativeAppEventEmitter.addListener( 56 this.subscription = NativeAppEventEmitter.addListener(
@@ -96,6 +97,12 @@ class CategoryBContainer extends Component { @@ -96,6 +97,12 @@ class CategoryBContainer extends Component {
96 } 97 }
97 } 98 }
98 99
  100 + _onPressCategoryBMore() {
  101 + console.log("chenlin","_onPressCategoryBMore");
  102 + let currentCateId = this.props.categoryB.currentCateId;
  103 + this.props.actions.pressCategoryBMore(currentCateId);
  104 + }
  105 +
99 _onPressHotCategoryItem(value, index) { 106 _onPressHotCategoryItem(value, index) {
100 let currentChannelId = this.props.categoryB.currentChannelId; 107 let currentChannelId = this.props.categoryB.currentChannelId;
101 this.props.actions.jumpToCategory(value, index, currentChannelId); 108 this.props.actions.jumpToCategory(value, index, currentChannelId);
@@ -131,6 +138,7 @@ class CategoryBContainer extends Component { @@ -131,6 +138,7 @@ class CategoryBContainer extends Component {
131 onSelectChannel={this._onSelectChannel} 138 onSelectChannel={this._onSelectChannel}
132 onSelectCategory={this._onSelectCategory} 139 onSelectCategory={this._onSelectCategory}
133 onPressBannerResourceItem={this._onPressBannerResourceItem} 140 onPressBannerResourceItem={this._onPressBannerResourceItem}
  141 + onPressCategoryBMore={this._onPressCategoryBMore}
134 onPressHotCategoryItem={this._onPressHotCategoryItem} 142 onPressHotCategoryItem={this._onPressHotCategoryItem}
135 onPressHotBrandItem={this._onPressHotBrandItem} 143 onPressHotBrandItem={this._onPressHotBrandItem}
136 /> 144 />
@@ -59,13 +59,47 @@ export function selectCategoryB(category){ @@ -59,13 +59,47 @@ export function selectCategoryB(category){
59 relation_parameter: category.relation_parameter, 59 relation_parameter: category.relation_parameter,
60 node_count: category.node_count, 60 node_count: category.node_count,
61 }; 61 };
62 - //设置当前的类别信息 62 + //设置当前的类别信息
63 dispatch(setCurrentCateB(categoryId, categoryValue)); 63 dispatch(setCurrentCateB(categoryId, categoryValue));
64 dispatch(jumpToCategory(all, 0, categoryB.currentChannelId)); 64 dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
65 } 65 }
66 }; 66 };
67 } 67 }
68 68
  69 +/**
  70 + * 点击More事件
  71 + **/
  72 +export function pressCategoryBMore(category_id){
  73 + return (dispatch, getState) => {
  74 + let {categoryB} = getState();
  75 +
  76 + //获取当前频道下一级分类列表信息
  77 + let categoryData = categoryB.categoryList.get(categoryB.currentChannelValue);
  78 +
  79 + //获取指定category_id分类信息
  80 + let category = null;
  81 + categoryData.map((item, i) => {
  82 + if(category_id == item.get('category_id')){
  83 + category = item;
  84 + }
  85 + });
  86 +
  87 + let all = {
  88 + category_name: "全部" + (category ? category.category_name : ""),
  89 + parent_id: category_id,
  90 + relation_parameter: category ? category.get('relation_parameter') : {},
  91 + node_count: category ? category.get('node_count') : 0,
  92 + };
  93 +
  94 + console.log("chenlin", JSON.stringify(all));
  95 +
  96 + //设置当前的类别信息
  97 + dispatch(setCurrentCateB(category_id, category.category_name));
  98 + dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
  99 +
  100 + };
  101 +}
  102 +
69 103
70 /** 104 /**
71 * 获取子分类的数据,逻辑上先判断缓存数据是否存在,不存在则从网络获取 105 * 获取子分类的数据,逻辑上先判断缓存数据是否存在,不存在则从网络获取
@@ -178,32 +212,33 @@ function parseCategoryBSubDetail(channel_id, category_id, subcategory_data, prop @@ -178,32 +212,33 @@ function parseCategoryBSubDetail(channel_id, category_id, subcategory_data, prop
178 return; 212 return;
179 } 213 }
180 214
181 - //分类信息不为空时,添加more  
182 - if(subcategory_data.sortInfo && subcategory_data.sortInfo.length > 0){ 215 + // 暂时不添加MORE,陈林修改 2017.1.13
  216 + // //分类信息不为空时,添加more
  217 + // if(subcategory_data.sortInfo && subcategory_data.sortInfo.length > 0){
183 218
184 - //获取当前频道下一级分类列表信息  
185 - let categoryData = props_data.categoryList.get(props_data.currentChannelValue); 219 + // //获取当前频道下一级分类列表信息
  220 + // let categoryData = props_data.categoryList.get(props_data.currentChannelValue);
186 221
187 - //获取指定category_id分类信息  
188 - let category = null;  
189 - categoryData.map((item, i) => {  
190 - if(category_id == item.get('category_id')){  
191 - category = item;  
192 - }  
193 - }); 222 + // //获取指定category_id分类信息
  223 + // let category = null;
  224 + // categoryData.map((item, i) => {
  225 + // if(category_id == item.get('category_id')){
  226 + // category = item;
  227 + // }
  228 + // });
194 229
195 - let more = {  
196 - show_category_name: 'MORE',  
197 - category_name: "全部" + (category ? category.get('category_name') : ''),  
198 - parent_id: category_id,  
199 - relation_parameter: category ? category.get('relation_parameter') : {},  
200 - node_count: category ? category.get('node_count') : 0,  
201 - data_type:'text',  
202 - }; 230 + // let more = {
  231 + // show_category_name: 'MORE',
  232 + // category_name: "全部" + (category ? category.get('category_name') : ''),
  233 + // parent_id: category_id,
  234 + // relation_parameter: category ? category.get('relation_parameter') : {},
  235 + // node_count: category ? category.get('node_count') : 0,
  236 + // data_type:'text',
  237 + // };
203 238
204 239
205 - subcategory_data.sortInfo.push(more);  
206 - } 240 + // subcategory_data.sortInfo.push(more);
  241 + // }
207 242
208 let key = getSubDetailCacheKey(channel_id, category_id); 243 let key = getSubDetailCacheKey(channel_id, category_id);
209 244
@@ -281,4 +316,96 @@ export function jumpToCategory(value, index, channelId){ @@ -281,4 +316,96 @@ export function jumpToCategory(value, index, channelId){
281 type: JUMP_TO_CATEGORY, 316 type: JUMP_TO_CATEGORY,
282 payload: value 317 payload: value
283 } 318 }
  319 +}
  320 +
  321 +
  322 +function dataExposure(json) {
  323 + return (dispatch, getState) => {
  324 + if (!json) {
  325 + return;
  326 + }
  327 +
  328 + let {boy, girl, kids, lifestyle} = json;
  329 +
  330 + let newBoy = [];
  331 + let newGirl = [];
  332 + let newKids = [];
  333 + let newLifestyle = [];
  334 +
  335 + boy.map((item, i) => {
  336 + let subList = [];
  337 + item.sub && item.sub.map((sub, k) => {
  338 + subList.push({
  339 + I_INDEX: k + 1,
  340 + CAT_ID: sub.category_id,
  341 + });
  342 + });
  343 +
  344 + newBoy.push({
  345 + I_INDEX: i + 1,
  346 + CAT_ID: item.category_id,
  347 + SUBLIST: subList,
  348 + });
  349 + });
  350 +
  351 + girl.map((item, i) => {
  352 + let subList = [];
  353 + item.sub && item.sub.map((sub, k) => {
  354 + subList.push({
  355 + I_INDEX: k + 1,
  356 + CAT_ID: sub.category_id,
  357 + });
  358 + });
  359 +
  360 + newGirl.push({
  361 + I_INDEX: i + 1,
  362 + CAT_ID: item.category_id,
  363 + SUBLIST: subList,
  364 + });
  365 + });
  366 +
  367 + kids.map((item, i) => {
  368 + let subList = [];
  369 + item.sub && item.sub.map((sub, k) => {
  370 + subList.push({
  371 + I_INDEX: k + 1,
  372 + CAT_ID: sub.category_id,
  373 + });
  374 + });
  375 +
  376 + newKids.push({
  377 + I_INDEX: i + 1,
  378 + CAT_ID: item.category_id,
  379 + SUBLIST: subList,
  380 + });
  381 + });
  382 +
  383 + lifestyle.map((item, i) => {
  384 + let subList = [];
  385 + item.sub && item.sub.map((sub, k) => {
  386 + subList.push({
  387 + I_INDEX: k + 1,
  388 + CAT_ID: sub.category_id,
  389 + });
  390 + });
  391 +
  392 + newLifestyle.push({
  393 + I_INDEX: i + 1,
  394 + CAT_ID: item.category_id,
  395 + SUBLIST: subList,
  396 + });
  397 + });
  398 +
  399 +
  400 + let params = {
  401 + YH_AppChannelBoy: newBoy,
  402 + YH_AppChannelGirl: newGirl,
  403 + YH_AppChannelKid: newKids,
  404 + YH_AppChannelLifeStyle: newLifestyle,
  405 + };
  406 +
  407 + // console.log(params);
  408 +
  409 + ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_CATEGORY', params);
  410 + };
284 } 411 }
@@ -27,8 +27,8 @@ export default class SlicedImage extends React.Component { @@ -27,8 +27,8 @@ export default class SlicedImage extends React.Component {
27 newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height; 27 newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height;
28 } else { 28 } else {
29 newSrc = src.replace('{mode}', mode) 29 newSrc = src.replace('{mode}', mode)
30 - .replace('{width}', width)  
31 - .replace('{height}', height); 30 + .replace(/{width}/g, width)
  31 + .replace(/{height}/g, height);
32 } 32 }
33 33
34 // __DEV__ && console.log(newSrc); 34 // __DEV__ && console.log(newSrc);