floorParser.js 22.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
'use strict';

import ReactNative from 'react-native';

const {
    Dimensions,
} = ReactNative;

function calcluateFloorHeight(payload) {
	if (!payload) {
		return {};
	}

	let allFloorHeight = 0;

	if (!payload.list) {
		payload.floorHeight = allFloorHeight;
		return payload;
	}

	let i = 0;
	let count = payload.list.length;
	for(i; i < count; i++) {
		let item = payload.list[i];
		if (!item) {
			continue;
		}

		let templateName = item.template_name;
		let data = item.data;
		if (!templateName || !data) {
			continue;
		}

		let floorHeight = heightForFloor(item);

		item.floorHeight = floorHeight;
		allFloorHeight = allFloorHeight + floorHeight;
	}

	payload.floorHeight = allFloorHeight;
	return payload;
}

function heightForFloor(item, immutable=false) {

	if (!item) {
		return 0;
	}

	let templateName;
	let data;

	if (immutable) {
		templateName = item.get('template_name');
		data = item.get('data').toJS();
	} else {
		templateName = item.template_name;
		data = item.data;
	}

	if (!templateName || !data) {
		return 0;
	}

	const {width, height} = Dimensions.get('window');
	const DEVICE_WIDTH_RATIO = width / 320;
	const DEVICE_WIDTH_RATIO_6 = width / 375;

	let floorHeight = 0;
	let headerHeight = 40;

	switch(templateName) {
		case 'focus': {
			floorHeight = Math.ceil(155 * DEVICE_WIDTH_RATIO);
			break;
		}
		case 'app_icon_list': {
			let count = parseInt(item.number);
			count = count > 0 ? count : 5;
	        let tail = (data.length % count != 0) ? 1 : 0;
	        let lineNumber = data.length/count + tail;

	        let padding5 = (width - 42*5)/12;
			let padding4 = (width - 51*4)/10;
	        let padding = count == 4 ? padding4 : padding5;
			floorHeight = (count == 4 ? 84 : 75) * lineNumber +  padding * (lineNumber - 1) + 12;
			break;
		}
		case 'app_hot_brands': {
			let listLength = data.list.length;
			let lineNumber = parseInt((listLength + 3) / 4);
	        if (listLength % 4 == 0) {
	            lineNumber += 1;
	        }
	        let imageHeight = Math.floor(87 * DEVICE_WIDTH_RATIO);
	        let listHeight = Math.ceil(lineNumber * imageHeight);
	        floorHeight = headerHeight + listHeight;
			break;
        }
        case 'announcement': {
            floorHeight = Math.ceil(35 * DEVICE_WIDTH_RATIO);
			break;
        }
        case 'single_image': {
            floorHeight = Math.ceil(100 * DEVICE_WIDTH_RATIO);
			break;
        }
        case 'single_name_image': {
            floorHeight = headerHeight + Math.ceil(100 * DEVICE_WIDTH_RATIO);
			break;
        }
        case 'recommend_content_one': {
        	let bannerHeight = Math.ceil(200 * DEVICE_WIDTH_RATIO);
			let listHeight = Math.ceil(190 * DEVICE_WIDTH_RATIO);
			floorHeight = headerHeight + bannerHeight + listHeight;
			break;
        }
        case 'recommend_content_two': {
            let bannerHeight = Math.ceil(200 * DEVICE_WIDTH_RATIO);
			let listHeight = Math.ceil(190 * DEVICE_WIDTH_RATIO);
			floorHeight = headerHeight + bannerHeight + listHeight;
			break;
        }
        case 'recommend_content_three': {
        	let imageHeight = Math.floor(87 * DEVICE_WIDTH_RATIO);
        	let lineNumber = parseInt((data.list.length + 3) / 4);
	        let listHeight = Math.floor(lineNumber * imageHeight);
	        let bannerHeight = Math.ceil(100 * DEVICE_WIDTH_RATIO);
	        floorHeight = bannerHeight + listHeight
			break;
        }
        case 'recommend_content_five': {
        	let imageHeight = Math.floor(87 * DEVICE_WIDTH_RATIO);
        	let lineNumber = parseInt((data.list.length + 3) / 4);
        	let listHeight = Math.floor(lineNumber * imageHeight);
        	floorHeight = listHeight + headerHeight;
			break;
        }
        case 'trendsetter_collocation': {
        	let topCellWidth = (width - 45) / 2;
        	let cellWidth =  Math.floor(82 * width / 375);
			floorHeight = headerHeight + topCellWidth + 15 * 2 + headerHeight + cellWidth;
			break;
        }
        case 'trendgoods_topic': {
        	let imageHeight = Math.ceil(182 * DEVICE_WIDTH_RATIO);
			let pageHeight = imageHeight + 15 + 16 + 9 + 12 + 30;
			floorHeight = headerHeight + 15 + pageHeight;
			break;
        }
        case 'custom_brands': {
        	let imageHeight = Math.ceil(55 * DEVICE_WIDTH_RATIO);
			let marginTop = 15;
			floorHeight = headerHeight + imageHeight + marginTop * 3;
			break;
        }
        case 'kids_brands':{
        	let itemWidth = width / 4 - 0.5;
			let itemHeight = itemWidth + 20;
			floorHeight = headerHeight + itemHeight * 2 + 0.5;
			break;
        }
        case 'small_pic': {
            floorHeight = Math.ceil(80 * (width - 45) / 2 / 137.5);
			break;
        }
        case 'divideImage': {
            floorHeight = 15;
			break;
        }
        case 'NewProductFloor': {
        	let leftBigImageWidth = width * 315 / 750;
			let leftBigImageHeight = leftBigImageWidth * 420 / 315;
			floorHeight = headerHeight + leftBigImageHeight;
			break;
        }
        case 'popular_single_product': {
        	let bannerHeight = Math.ceil(width * 234 / 750);
			floorHeight = headerHeight + bannerHeight + 192;
			break;
        }
        case 'shopRecommend': {
        	let storeHeight = Math.ceil(239 * DEVICE_WIDTH_RATIO_6 + 10);
			floorHeight = headerHeight + storeHeight;
			break;
        }
        case 'sixLinesFloor': {
        	let imageWidth = Math.floor(width / 2);
			let imageHeight = Math.floor(imageWidth * 180 / 375);
            let lineNumber = Math.floor((data.list.length + 1)/2);
    		floorHeight = headerHeight + lineNumber * imageHeight;
			break;
        }
        case 'livePicture': {
        	let imageWidth = Math.ceil((width - 64) / 3);
			let imageHeight = Math.ceil(imageWidth * 86 / 64);
            floorHeight = headerHeight + imageHeight;
			break;
        }
        case 'sale-1t-1l-4r': {
        	let bannerHeight = Math.floor(width / 3);
        	let leftBigImageWidth = width * 310 / 740;
			let leftBigImageHeight = leftBigImageWidth * 422 / 310;
			let containerHeight = headerHeight + leftBigImageHeight;
	        if(data.big_image.length > 0){
	            containerHeight = containerHeight + bannerHeight;
	        }
            floorHeight = containerHeight;
			break;
        }
        case 'vipUse': {
        	let bannerHeight = Math.ceil((234 / 750) * width);
			let cellHeight = 210;
            floorHeight = headerHeight + bannerHeight + cellHeight;
			break;
        }
        case 'activityProductFloor': {
        	//1 VIP 专享 2 新人专享 3 学生专享 4 新品到着
			const TYPE_VIP = 1;
			const TYPE_NEW_USER = 2;
			const TYPE_STUDENT = 3;
			const TYPE_NEW_PRODUCT = 4;

			let type = item.type;

        	let bannerHeight = Math.ceil((234 / 750) * width);
			let sectionHeight = Math.ceil((419 / 750) * width);
			let cellWidth = 90;
			let cellHeight = 210;
			let cellH = 0;
			if (type == TYPE_VIP || type == TYPE_STUDENT) {
				cellH = cellHeight;
			} else {
				cellH = cellHeight - 20;
			}
    		floorHeight = cellH + headerHeight + bannerHeight;
			break;
        }
        case 'hot_category_individualization': {
        	let cellWidth = width / 4;
			let imageWidth = cellWidth - 14 * 2;
			let imageHeight = imageWidth * 168 / 126;
			let cellHeight = imageHeight + 20;
	        let lineNumber = parseInt((data.list.length + 3) / 4);
	        let listHeight = Math.floor(lineNumber * cellHeight);
	        let containerHeight = listHeight + headerHeight;
            floorHeight = containerHeight;
			break;
        }
        case 'new_user_floor': {
        	let leftBigImageWidth = width * 315 / 750;
			let leftBigImageHeight = leftBigImageWidth * 420 / 315;
			let containerHeight = headerHeight + leftBigImageHeight;
            floorHeight = containerHeight;
			break;
        }
	}

	return floorHeight;
}



function homeDataParse(data, channel) {
	let {list, cached, isFetching, isFirstLoad, endReached, favorite, bottomBanner, hotList, newList, selectIndex} = data;
	let floorList = list.size > 0 ? list.toArray() : cached.get('list').toArray();
	let dataSource = {};
	if (channel == '4') {
		let favlist = selectIndex == 0 ? newList : hotList;
		if (endReached) {
			dataSource = {
				floor: floorList,
				lifeStyleFav:favlist.toArray(),
				footer: ['1']
			}
		}else {
			dataSource = {
				floor: floorList,
			}
		}
	} else {
		let favoriteList = favorite.get('list');
		let bottomBannerList = bottomBanner.get('list');
		if (favoriteList.size == 0) {
			dataSource = {
			   floor: floorList,
			}
		}else {
			if (favoriteList.size > 0 && endReached) {
				dataSource = {
				   floor: floorList,
				   favoriteHeader: ['1'],
				   favorite: favoriteList.toArray(),
				   bottomBanner: [bottomBannerList],
				   footer: ['1']
				}
				if (channel == 3) {
					dataSource = {
					   floor: floorList,
					   favoriteHeader: ['1'],
					   favorite: favoriteList.toArray(),
					   footer: ['1']
					}
				}
			}else {
				dataSource = {
				   floor: floorList,
				   favoriteHeader: ['1'],
				   favorite: favoriteList.toArray()
				}
			}
		}
	}

	return dataSource;
}

function channelCacheKey(channelKey) {
	return 'YH_RNCacheTypeHomeChannel' + channelKey;
}

function parseHomeFloor(json) {
	let data = json && json.data ? json.data : {};
	let md5 = json && json.md5 ? json.md5 : '';
	let list = data && data.list ? data.list : [];
	let content_code = data && data.content_code ? data.content_code : '';
	return {
		md5,
		list,
		content_code,
	};
}

function parseBoyGirlFavorite(json) {
	let currentPage = json && json.page ? json.page : 1;
	let pageCount = json && json.page_total ? json.page_total : 0;
	let total = json && json.total ? json.total : 0;

	let list = json && json.product_list ? json.product_list : [];
    let rec_id = json && json.rec_id ? json.rec_id : '';

	return {
		currentPage,
		pageCount,
		total,
		list,
        rec_id
	}
}

function parseKidsFavorite(json) {
	let currentPage = json && json.page ? json.page : 1;
	let pageCount = json && json.page_total ? json.page_total : 0;
	let total = json && json.total ? json.total : 0;

	let list = json && json.product_list ? json.product_list : [];

	return {
		currentPage,
		pageCount,
		total,
		list
	}
}

function parseLifeStyleFavorite(json) {
	let product_list = json && json.product_list ? json.product_list : {};
	let newList = product_list && product_list.new ? product_list.new : [];
	let hotList = product_list && product_list.top ? product_list.top : [];
	return {
		newList,
		hotList
	}
}

function parseBottomBanner(json) {
	let banner = json && json[0] ? json[0] : {};
	let list =  banner.data;
	return {
		list
	}
}

function parseShopInfo(json) {
	let payload = {};
	for (var i = 0; i < json.length; i++) {
		let shopItem = json[i];
		let shopId = shopItem.id;
		payload[shopId] = shopItem;
	}
	return payload;
}

function parseRecommendPop(json) {
	let product_list = json && json.product_list ? json.product_list : [];
	let rec_id = json && json.rec_id ? json.rec_id : '';
	return {
		list: product_list,
		rec_id,
	}
}

function parseReportData(list) {
    let reportData = [];
    for (var i = 0; i < list.length; i++) {
        let floorParam = {};
        let floorDataArr = [];
        let floorItem = list[i];
        floorParam.F_ID = floorItem.template_id ? floorItem.template_id : '';
        floorParam.F_NAME = floorItem.template_name ? floorItem.template_name : '';

        if (floorItem.template_name == 'focus' ||
            floorItem.template_name == 'small_pic' ||
            floorItem.template_name == 'app_icon_list' ||
            floorItem.template_name == 'single_image' ||
            floorItem.template_name == 'twoSmallPic' ||
            floorItem.template_name == 'divideImage')
        {
            let bannerList = floorItem.data ? floorItem.data : [];
            for (var j = 0; j < bannerList.length; j++) {
                let bannerItem = bannerList[j];
                let bannerParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': bannerItem&&bannerItem.src ? bannerItem.src : '',
                    'ACTION_URL': bannerItem&&bannerItem.url ? bannerItem.url : ''
                };
                floorDataArr.push(bannerParam);
            }
        } else if (floorItem.template_name == 'announcement') {
            let announceList = floorItem.data ? floorItem.data : [];
            for (var j = 0; j < announceList.length; j++) {
                let announceItem = announceList[j];
                let announceParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': floorItem&&floorItem.announcement_img ? floorItem.announcement_img : '',
                    'ACTION_URL': announceItem&&announceItem.url ? announceItem.url : ''
                };
                floorDataArr.push(announceParam);
            }
        } else if (floorItem.template_name == 'app_hot_brands' ||
                   floorItem.template_name == 'custom_brands' ||
                   floorItem.template_name == 'kids_brands')
        {
            let brandList = floorItem.data.list ? floorItem.data.list : [];
            let moreItem = floorItem.data.image;
            for (var j = 0; j < brandList.length; j++) {
                let brandItem = brandList[j];
                let brandParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': brandItem&&brandItem.src ? brandItem.src : '',
                    'ACTION_URL': brandItem&&brandItem.url ? brandItem.url : ''
                };
                floorDataArr.push(brandParam);
            }
            let moreParam = {
                'I_INDEX': brandList.length+1,
                'IMAGE_URL': moreItem&&moreItem.src ? moreItem.src : '',
                'ACTION_URL': moreItem&&moreItem.url ? moreItem.url : ''
            }
            floorDataArr.push(moreParam);
        } else if (floorItem.template_name == 'trendgoods_topic') {
            let topicList = floorItem.data.list ? floorItem.data.list : [];
            let moreItem = floorItem.data.title;
            for (var j = 0; j < topicList.length; j++) {
                let topicItem = topicList[j];
                let topicparam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': topicItem&&topicItem.src ? topicItem.src : '',
                    'ACTION_URL': topicItem&&topicItem.url ? topicItem.url : ''
                };
                floorDataArr.push(topicparam);
            }
            let moreParam = {
                'I_INDEX': 0,
                'IMAGE_URL': '',
                'ACTION_URL': moreItem.more_url ? moreItem.more_url : ''
            }
            floorDataArr.push(moreParam);
        } else if (floorItem.template_name == 'trendsetter_collocation') {
            let articalList = floorItem.data.article ? floorItem.data.article : [];
            let collectionList = floorItem.data.recommend_collocation ? floorItem.data.recommend_collocation : [];
            let moreItem = floorItem.data.title;
            let index = 0;

            for (var j = 0; j < articalList.length; j++) {
                let articalItem = articalList[j];
                let articalParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': articalItem&&articalItem.src ? articalItem.src : '',
                    'ACTION_URL': articalItem&&articalItem.url ? articalItem.url : ''
                };
                floorDataArr.push(articalParam);
                index = j+1;
            }

            for (var j = 0; j < collectionList.length; j++) {
                let collectionItem = collectionList[j];
                let collectionParam = {
                    'I_INDEX': j+1+index,
                    'IMAGE_URL': collectionItem&&collectionItem.src ? collectionItem.src : '',
                    'ACTION_URL': collectionItem&&collectionItem.url ? collectionItem.url : ''
                };
                floorDataArr.push(collectionParam);
            }
            let moreParam = {
                'I_INDEX': 0,
                'IMAGE_URL': '',
                'ACTION_URL': moreItem&&moreItem.more_url ? moreItem.more_url : ''
            };
            floorDataArr.push(moreParam);
        } else if (floorItem.template_name == 'recommend_content_one' ||
                   floorItem.template_name == 'recommend_content_two' ||
                   floorItem.template_name == 'recommend_content_three' ||
                   floorItem.template_name == 'recommend_content_five' ||
                   floorItem.template_name == 'livePicture' ||
                   floorItem.template_name == 'sixLinesFloor' ||
                   floorItem.template_name == 'hot_category_individualization')
        {
            let bannerList = floorItem.data.big_image ? floorItem.data.big_image : [];
            let recommendList = floorItem.data.list ? floorItem.data.list : [];
            let moreItem = floorItem.data.title;
            let index = 0;

            for (var j = 0; j < bannerList.length; j++) {
                let bannerItem = bannerList[j];
                let bannerParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': bannerItem&&bannerItem.src ? bannerItem.src : '',
                    'ACTION_URL': bannerItem&&bannerItem.url ? bannerItem.url : ''
                };
                floorDataArr.push(bannerParam);
                index = j+1;
            }

            for (var j = 0; j < recommendList.length; j++) {
                let recommendItem = recommendList[j];
                let recommendParam = {
                    'I_INDEX': j+1+index,
                    'IMAGE_URL': recommendItem&&recommendItem.src ? recommendItem.src : '',
                    'ACTION_URL': recommendItem&&recommendItem.url ? recommendItem.url : ''
                };
                floorDataArr.push(recommendParam);
            }

            let moreParam = {
                'I_INDEX': 0,
                'IMAGE_URL': '',
                'ACTION_URL': moreItem&&moreItem.more_url ? moreItem.more_url : ''
            };
            floorDataArr.push(moreParam);
        } else if (floorItem.template_name == 'single_name_image') {
            let adsItem = floorItem.data;
            let adsParam = {
                'I_INDEX': 1,
                'IMAGE_URL': adsItem&&adsItem.src ? adsItem.src : '',
                'ACTION_URL': adsItem&&adsItem.url ? adsItem.url : ''
            };
            floorDataArr.push(adsParam);
        } else if (floorItem.template_name == 'NL2R') {
            let index = 0;
            let leftList = floorItem.data.left ? floorItem.data.left : [];
            let rightList = floorItem.data.right? floorItem.data.right : [];

            for (var j = 0; j < leftList.length; j++) {
                let leftItem = leftList[j];
                let leftParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': leftItem&&leftItem.src ? leftItem.src : '',
                    'ACTION_URL': leftItem&&leftItem.url ? leftItem.url : ''
                };
                floorDataArr.push(leftParam);
                index = j+1;
            }

            for (var j = 0; j < leftList.length; j++) {
                let rightItem = rightList[j];
                let rightParam = {
                    'I_INDEX': j+1+index,
                    'IMAGE_URL': rightItem&&rightItem.src ? rightItem.src : '',
                    'ACTION_URL': rightItem&&rightItem.url ? rightItem.url : ''
                };
                floorDataArr.push(rightParam);
            }
        } else if (floorItem.template_name == 'popular_single_product' ||
                   floorItem.template_name == 'new_user_floor' ||
                   floorItem.template_name == 'activityProductFloor' ||
                   floorItem.template_name == 'vipUse')
        {
            let bannerList = floorItem.data.banner_image ? floorItem.data.banner_image : [];
            let productList = floorItem.data.list ? floorItem.data.list : [];
            let moreItem = floorItem.data.title;
            let index = 0;

            for (var j = 0; j < bannerList.length; j++) {
                let bannerItem = bannerList[j];
                let bannerParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': bannerItem&&bannerItem.src ? bannerItem.src : '',
                    'ACTION_URL': bannerItem&&bannerItem.url ? bannerItem.url : ''
                };
                floorDataArr.push(bannerParam);
                index = j+1;
            }

            for (var j = 0; j < productList.length; j++) {
                let product = productList[j];
                let productParam = {
                    'I_INDEX': j+1+index,
                    'IMAGE_URL': product&&product.default_images ? product.default_images : '',
                    'PRD_SKN': product&&product.product_skn ? product.product_skn : ''
                };
                floorDataArr.push(productParam);
            }

            let moreParam = {
                'I_INDEX': 0,
                'IMAGE_URL': '',
                'ACTION_URL': moreItem&&moreItem.more_url ? moreItem.more_url : ''
            };
            floorDataArr.push(moreParam);
        } else if (floorItem.template_name == 'shopRecommend') {
            let shopList = floorItem.data.list ? floorItem.data.list : [];
            let moreItem = floorItem.data.title;

            for (var j = 0; j < shopList.length; j++) {
                let shopItem = shopList[j];
                let shopParam = {
                    'I_INDEX': j+1,
                    'IMAGE_URL': shopItem&&shopItem.src ? shopItem.src : '',
                    'ACTION_URL': shopItem&&shopItem.url ? shopItem.url : ''
                };
                floorDataArr.push(shopParam);
            }

            let moreParam = {
                'I_INDEX': 0,
                'IMAGE_URL': '',
                'ACTION_URL': moreItem&&moreItem.more_url ? moreItem.more_url : ''
            };
            floorDataArr.push(moreParam);
        }

        floorParam.LIST = floorDataArr;
        reportData.push(floorParam);
    }

    return reportData;
}

function parseReportProductList(json) {
    let reportData = [];
    let productData = {};
    let productList = [];

    let list = json && json.list ? json.list : [];
    let page = json && json.currentPage ? json.currentPage : 1;

    let index = 1;
    if (page >= 1) {
        index = (page-1)*50 +1;
    }

    for (var i = 0; i < list.length; i++) {
        let product = list[i];
        let param = {
            'I_INDEX': i + index,
            'IMAGE_URL': product&&product.default_images ? product.default_images : '',
            'PRD_SKN': product&&product.product_skn ? product.product_skn : ''
        }
        productList.push(param);
    }

    productData.LIST = productList;
    reportData.push(productData);
    return reportData;
}

module.exports = {
	calcluateFloorHeight,
	heightForFloor,
	homeDataParse,
	channelCacheKey,
    parseHomeFloor,
   	parseBoyGirlFavorite,
   	parseKidsFavorite,
   	parseLifeStyleFavorite,
   	parseBottomBanner,
   	parseShopInfo,
	parseRecommendPop,
    parseReportData,
    parseReportProductList
};