Authored by 张丽霞

红人店铺模块化, review by Redding

... ... @@ -42,6 +42,7 @@ export default class DoubleImage extends React.Component {
let data1 = list?list[0]:null;
let backgroundImage1 = data1.pic;
let linkType1 = data1.linkType;
let showProductInfo1 = data1.showProductInfo;
let product1 = data1.product;
let salePrice1 = product1?parseFloat(product1.sales_price):0;
let originPrice1 = product1?parseFloat(product1.market_price):0;
... ... @@ -54,6 +55,7 @@ export default class DoubleImage extends React.Component {
let data2 = list?list[1]:null;
let backgroundImage2 = data2.pic;
let linkType2 = data2.linkType;
let showProductInfo2 = data2.showProductInfo;
let product2 = data2.product;
let salePrice2 = product2?parseFloat(product2.sales_price):0;
let originPrice2 = product2?parseFloat(product2.market_price):0;
... ... @@ -70,7 +72,7 @@ export default class DoubleImage extends React.Component {
url={backgroundImage1}
style={styles.thumbnail}
></YH_Image>
{linkType1=='1'?<View style={styles.titleView}>
{linkType1=='1'&& showProductInfo1 ?<View style={styles.titleView}>
<Text style={styles.title} numberOfLines={1}>{name1}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble1?'red':'white',}}>{price1}</Text>
... ... @@ -84,7 +86,7 @@ export default class DoubleImage extends React.Component {
url={backgroundImage2}
style={styles.thumbnail}
></YH_Image>
{linkType2=='1'?<View style={styles.titleView}>
{linkType2=='1' && showProductInfo2 ?<View style={styles.titleView}>
<Text style={styles.title} numberOfLines={1}>{name2}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble2?'red':'white',}}>{price2}</Text>
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
Image,
View,
StyleSheet,
Dimensions,
Text,
ListView,
TouchableOpacity,
Platform,
} = ReactNative;
import DeviceInfo from 'react-native-device-info';
import Immutable, {Map} from 'immutable';
export default class Recommend extends React.Component {
constructor(props) {
super (props);
this.renderRow = this.renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
renderRow(rowData, sectionID, rowID, highlightRow) {
let rowContainerHeight = itemWidth + 20;
let {resource} = this.props;
let list = resource.get('module_data').get('data').toArray();
let bottomStyle ={};
if (rowID < list.length - 4) {
rowContainerHeight += 1;
}else {
bottomStyle ={borderBottomWidth: 0}
}
if (rowData.get('linkType') == 1 && !rowData.get('showProductInfo')) {
rowContainerHeight -= 20;
}
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(rowData.get('linkType'), rowData.get('resource'));
}}>
<View style={[styles.rowContainer, bottomStyle,{height: rowContainerHeight}]}>
<Image
source={{uri: rowData.get('pic')}}
style={styles.thumbnail}
>
</Image>
{rowData.get('linkType') == 1 && rowData.get('showProductInfo')?
<View style={styles.itemTitle}>
<Text style={styles.itemText} numberOfLines={1}>{rowData.get('text')}</Text>
</View>
:null
}
</View>
</TouchableOpacity>
);
}
render() {
let {resource} = this.props;
let list = resource.get('module_data').get('data').toArray();
if (!list || list.length == 0) {
return null;
}
let backgroundWidth = width;
let backgroundHeight = 40 + Math.ceil(list.length / 4) * itemWidth + 15;
return (
<View style={{width: backgroundWidth, height:backgroundHeight, backgroundColor:'#f0f0f0'}}>
<ListView
contentContainerStyle={styles.contentContainer}
dataSource={this.dataSource.cloneWithRows(list)}
renderRow={this.renderRow}
enableEmptySections={true}
pageSize={Math.ceil(list.length/4)}
scrollEnabled={false}
scrollsToTop={false}
/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let itemWidth = (width - 4)/4;
const styles = StyleSheet.create({
contentContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
backgroundColor: 'white',
alignItems:'flex-start',
},
header: {
},
rowContainer: {
width: itemWidth + 1,
height: itemWidth + 20,
borderRightWidth: 1,
borderBottomWidth: 1,
borderColor: '#e5e5e5',
backgroundColor: 'white',
},
thumbnail: {
width: itemWidth,
height: itemWidth,
},
itemTitle: {
height: 20,
width: itemWidth,
},
itemText: {
fontWeight: 'bold',
textAlign: 'center',
color: 'gray',
fontSize: 9,
},
text: {
textAlign: 'center',
fontSize: 16,
fontWeight: 'bold',
color: '#444',
},
});
... ...
... ... @@ -99,7 +99,7 @@ export default class Header extends React.Component {
}
render() {
let {resource,launchProfile} = this.props;
let {resource,launchProfile,showShopBanner} = this.props;
if (!resource) {
return null;
}
... ... @@ -123,8 +123,12 @@ export default class Header extends React.Component {
let favImage = isFav?require('../../image/btn_gz_h.png'):require('../../image/btn_gz_n.png');
//下拉图标
let sourceIcon = launchProfile?require('../../image/arrow_ic_up.png'):require('../../image/arrow_ic.png');
let realContentHeight = launchProfile ? this.state.realContentHeight + 20 : 60;
if (!showShopBanner) {
realContentHeight = 0;
}
//计算控件高度,图片+标题+简介+下拉图标+20空白
let cellHeight = launchProfile ? (imageHeigth + titleHeigth + this.state.realContentHeight + 20 + 20) : (imageHeigth + titleHeigth + 60 + 20);
let cellHeight = launchProfile ? (imageHeigth + titleHeigth + realContentHeight + 20) : (imageHeigth + titleHeigth + realContentHeight + 20);
//获取字体
let fontFamilyStyle = {};
if (Platform.OS === 'ios') {
... ... @@ -159,6 +163,7 @@ export default class Header extends React.Component {
url={brandIcon}
style={styles.brandIcon}
/>
{showShopBanner?
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressLaunchProfile && this.props.onPressLaunchProfile(!launchProfile);
}}>
... ... @@ -179,6 +184,9 @@ export default class Header extends React.Component {
<Image source={sourceIcon} style={styles.pullDown}/>
</View>
</TouchableOpacity>
:null
}
</View>
);
}
... ...
... ... @@ -12,7 +12,7 @@ import {
TouchableOpacity,
} from 'react-native';
import {Map} from 'immutable';
import Immutable,{Map,Record} from 'immutable';
import Header from './Header';
import RedBrandStoreFilter from './RedBrandStoreFilter';
import Title from './Title';
... ... @@ -29,6 +29,9 @@ import BrandProductListCell from '../../../common/components/ListCell/ProductLis
import BrandProductFilter from '../../../brandStore/components/brandStore/brandStoreSubView/Cells/BrandProductFilter';
import CouponCell from '../../../brandStore/components/brandStore/brandStoreSubView/Cells/CouponCell';
import Prompt from '../../../coupon/components/coupon/Prompt';
import FourImages from './FourImages';
import GoodsGroupList from '../../../guang/components/detail/GoodsGroupList';
export default class RedBrand extends Component {
constructor(props) {
... ... @@ -74,6 +77,7 @@ export default class RedBrand extends Component {
let {fliter} = this.props;
switch(sectionID) {
case 'newProductList':
case 'brandReource': {
return(<RedBrandStoreFilter resource={fliter} onPressStoreFilter={this._onPressFilter}/>);
}
... ... @@ -90,7 +94,10 @@ export default class RedBrand extends Component {
}
return (
<View style={styles.brandFilterContainer} onLayout={(evt) => {yPosition = evt.nativeEvent.layout.y;}}>
{this.props.fliter == '2' ?
<RedBrandStoreFilter resource={fliter} onPressStoreFilter={this._onPressFilter}/>
:null
}
<BrandProductFilter
onPressFilter={this._onPressProductFilter}
lastSelected={this.props.productList.isFilter}
... ... @@ -108,8 +115,16 @@ export default class RedBrand extends Component {
renderRow(rowData, sectionID, rowID, highlightRow) {
if (sectionID == 'ShopBanner') {
let {launchProfile} = this.props;
return(<Header resource={rowData} launchProfile={launchProfile} onPressLaunchProfile={this._onPressLaunchProfile} onPressCollection={this.props.onPressCollection} onPressLink={this.props.onPressLink}/>);
let {launchProfile, shopsdecorator} = this.props;
let resList = shopsdecorator.modules?shopsdecorator.modules.toArray():[];
let showShopBanner = false;
resList.map((item, index) => {
if (item.get('module_type') == 'ShopBanner') {
let data = item.get('module_data').get('data').toArray();
showShopBanner = data[0].get('showShopInfo');
}
});
return(<Header resource={rowData} launchProfile={launchProfile} showShopBanner={showShopBanner} onPressLaunchProfile={this._onPressLaunchProfile} onPressCollection={this.props.onPressCollection} onPressLink={this.props.onPressLink}/>);
} else if(sectionID == 'brandReource'){
if (rowData.get('module_type') == 'coupon') {
return(<CouponCell resource={rowData} onPressCoupon={this.props.onPressCoupon}/>);
... ... @@ -125,8 +140,12 @@ export default class RedBrand extends Component {
return(<Video resource={rowData} videoCounts={videoCounts} onPressVideo={this.props.onPressVideo}/>);
}else if (rowData.get('module_type') == 'TripleImage') {
return(<TripleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
}else if (rowData.get('module_type') == 'FourImage') {
return(<FourImages resource={rowData} onPressProduct={this.props.onPressProduct}/>);
}else if (rowData.get('module_type') == 'AppRecommendProduct') {
return(<GoodsGroupList resource={rowData} onPressProduct={this.props.onPressProductCell}/>);
}
} else if (sectionID == 'productList') {
} else if (sectionID == 'productList' || sectionID == 'newProductList') {
let similarIndex = this.props.similarIndex;
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
... ... @@ -188,6 +207,7 @@ export default class RedBrand extends Component {
let {
productList,
launchProfile,
productListForNew,
fliter,
categoryFilterList,
filterCategoryDetailFilterList,
... ... @@ -209,10 +229,16 @@ export default class RedBrand extends Component {
dataSource = {
ShopBanner: [shopIntro],
brandReource: resList,
productList: productList.list.toArray(),
};
} else if (fliter == 1) {
dataSource = {
ShopBanner: [shopIntro],
newProductList: productListForNew.list.toArray(),
};
} else if (fliter == 2) {
dataSource = {
ShopBanner: [shopIntro],
productList: productList.list.toArray(),
};
}
... ...
... ... @@ -31,8 +31,11 @@ export default class RedBrandStoreFilter extends React.Component {
key: 'home',
name: '首页',
isSelect: false,
},
{
},{
key: 'new',
name: '新品',
isSelect: false,
},{
key: 'all',
name: '全部商品',
isSelect: false,
... ... @@ -102,6 +105,7 @@ let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
marginLeft: -1,
marginRight: -0.5,
width: width + 2,
height: 44,
backgroundColor:'white',
... ... @@ -113,7 +117,7 @@ let styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
width: Math.ceil(width / 2),
width: Math.ceil(width / 3),
height: 43,
backgroundColor:'white',
},
... ...
... ... @@ -39,9 +39,12 @@ export default class SingleImage extends React.Component {
let data = list?list[0]:null;
let backgroundImage = data.pic;
let linkType = data.linkType;
let showProductInfo = data.showProductInfo;
let properties = resource.get('module_data').get('properties').toJS();
let imageW = properties.width;
let imageH = properties.height;
imageW = imageW ? imageW : width;
imageH = imageH ? imageH : 200
let isModuleMargin = properties.isModuleMargin;
let imageHeight = (imageH*width)/(imageW==0?1:imageW);//根据返回信息计算出高度
let backgroundHeight =isModuleMargin?((imageH*width)/(imageW==0?1:imageW)+10):(imageH*width)/(imageW==0?1:imageW);
... ... @@ -63,7 +66,7 @@ export default class SingleImage extends React.Component {
url={backgroundImage}
style={{width: backgroundWidth, height: imageHeight}}
/>
{linkType=='1'?<View style={{ width: width, height: 35,position: 'absolute',backgroundColor: 'rgba(0,0,0,0.3)',top: imageHeight-35,flexDirection: 'row',alignItems: 'center',justifyContent: 'space-around'}}>
{linkType=='1' && showProductInfo?<View style={{ width: width, height: 35,position: 'absolute',backgroundColor: 'rgba(0,0,0,0.3)',top: imageHeight-35,flexDirection: 'row',alignItems: 'center',justifyContent: 'space-around'}}>
<Text style={styles.text1}>{name}</Text>
<Text style={{marginRight: 10,fontSize: 15,backgroundColor: 'transparent',color: saleAble?'red':'white'}}>{price}</Text>
{saleAble?<Text style={styles.deleteSale}>{sale}</Text>:null}
... ...
... ... @@ -31,6 +31,7 @@ export default class RedPersonPicThree extends Component{
let data1 = list?list[0]:null;
let backgroundImage1 = data1?data1.pic:'';
let linkType1 = data1.linkType;
let showProductInfo1 = data1.showProductInfo;
let product1 = data1.product;
let salePrice1 = product1?parseFloat(product1.sales_price):0;
let originPrice1 = product1?parseFloat(product1.market_price):0;
... ... @@ -43,6 +44,7 @@ export default class RedPersonPicThree extends Component{
let data2 = list?list[1]:null;
let backgroundImage2 = data2.pic;
let linkType2 = data2.linkType;
let showProductInfo2 = data2.showProductInfo;
let product2 = data2.product;
let salePrice2 = product2?parseFloat(product2.sales_price):0;
let originPrice2 = product2?parseFloat(product2.market_price):0;
... ... @@ -55,6 +57,7 @@ export default class RedPersonPicThree extends Component{
let data3 = list?list[2]:null;
let backgroundImage3 = data3.pic;
let linkType3 = data3.linkType;
let showProductInfo3 = data3.showProductInfo;
let product3 = data3.product;
let salePrice3 = product3?parseFloat(product3.sales_price):0;
let originPrice3= product3?parseFloat(product3.market_price):0;
... ... @@ -70,7 +73,7 @@ export default class RedPersonPicThree extends Component{
<View style={{flexDirection: 'row',width:width,height: isModuleMargin=='1'?containerHeigth4+nullHeigth:containerHeigth4,backgroundColor: 'white'}}>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType1,linkReource1)}} >
<YH_Image url={backgroundImage1} style={styles.imagetype4}/>
{linkType1=='1'?<View style={styles.maskContainer4}>
{linkType1=='1' && showProductInfo1 ?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name1}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble1?'red':'white',}}>{price1}</Text>
... ... @@ -80,7 +83,7 @@ export default class RedPersonPicThree extends Component{
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType2,linkReource2)}} >
<YH_Image url={backgroundImage2} style={styles.imagetype4}/>
{linkType2=='1'?<View style={styles.maskContainer4}>
{linkType2=='1' && showProductInfo2?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name2}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble2?'red':'white',}}>{price2}</Text>
... ... @@ -90,7 +93,7 @@ export default class RedPersonPicThree extends Component{
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType3,linkReource3)}} >
<YH_Image url={backgroundImage3} style={styles.imagetype4}/>
{linkType3=='1'?<View style={styles.maskContainer4}>
{linkType3=='1' && showProductInfo3?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name3}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble3?'red':'white',}}>{price3}</Text>
... ...
... ... @@ -18,6 +18,10 @@ export default keyMirror({
PRODUCT_LIST_FAILURE: null,
PRODUCT_FILTER_ACTION: null,
PRODUCT_LIST_FOR_NEW_REQUEST: null,
PRODUCT_LIST_FOR_NEW_SUCCESS: null,
PRODUCT_LIST_FOR_NEW_FAILURE: null,
FILTER_LIST_VIEW: null,
FILTER_MORE_VIEW: null,
SET_PRODUCT_LIST_FILTER: null,
... ...
... ... @@ -63,6 +63,7 @@ class RedPersonBrandContainer extends Component {
this.props.actions.getIntro();
this.props.actions.getRedBrandDecorator();
this.props.actions.getProductList(true);
this.props.actions.getProductListForNew(true);
this.props.actions.getShopCouponList();
this.props.actions.getFavoriteCount();
this.props.actions.getFavoriteState();
... ... @@ -204,6 +205,7 @@ class RedPersonBrandContainer extends Component {
shopIntro,
shopsdecorator,
productList,
productListForNew,
filterFactors,
filterNameFactors,
receiveCouponResult,
... ... @@ -216,6 +218,7 @@ class RedPersonBrandContainer extends Component {
<RedBrand
similarIndex = {similarIndex}
productList={productList}
productListForNew={productListForNew}
launchProfile={launchProfile}
fliter={fliter}
receiveCouponResult={receiveCouponResult}
... ...
... ... @@ -15,6 +15,9 @@ const {
PRODUCT_LIST_REQUEST,
PRODUCT_LIST_SUCCESS,
PRODUCT_LIST_FAILURE,
PRODUCT_LIST_FOR_NEW_REQUEST,
PRODUCT_LIST_FOR_NEW_SUCCESS,
PRODUCT_LIST_FOR_NEW_FAILURE,
PRODUCT_FILTER_ACTION,
FILTER_LIST_VIEW,
FILTER_MORE_VIEW,
... ... @@ -153,6 +156,26 @@ export function productListFailure(error) {
payload: error
}
}
export function productListForNewRequest() {
return {
type: PRODUCT_LIST_FOR_NEW_REQUEST,
};
}
export function productListForNewSuccess(json) {
return {
type: PRODUCT_LIST_FOR_NEW_SUCCESS,
payload: json
}
}
export function productListForNewFailure(error) {
return {
type: PRODUCT_LIST_FOR_NEW_FAILURE,
payload: error
}
}
/*
* 筛选
*/
... ... @@ -248,6 +271,41 @@ export function getProductList(reload=false) {
};
}
export function getProductListForNew(reload=false) {
return (dispatch, getState) => {
let {app, redBrand} = getState();
let {shopId, productListForNew} = redBrand;
if (reload) {
} else {
if (productListForNew.isFetching || productListForNew.endReached || productListForNew.error) {
return;
}
}
let order = productListForNew.order;
let page = productListForNew.currentPage + 1;
let pageSize = productListForNew.pageSize;
let channel = app.channel;
dispatch(productListForNewRequest());
return new RedBrandService(app.host).productList(shopId, channel, order, page, pageSize)
.then(json => {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount || payload.list.length < pageSize;
if (payload.currentPage > 1) {
let oldList = productList.list.toJS();
let list = [...oldList, ...payload.list];
payload.list = list;
}
dispatch(productListForNewSuccess(payload));
})
.catch(error => {
dispatch(productListForNewFailure(error));
});
};
}
function parseProductList(json) {
let currentPage = json && json.page ? json.page : 1;
let pageCount = json && json.page_total ? json.page_total : 0;
... ... @@ -568,7 +626,10 @@ export function getRedBrandDecorator() {
if (rooms) {
dispatch(getVideoLiveCount(rooms));
}
console.log('---->>>>>floor');
console.log(payload);
dispatch(getProduct(payload));
dispatch(getRedBrandDecoratorSuccess(payload));
})
.catch(error => {
... ... @@ -626,6 +687,60 @@ export function productFailure(error) {
}
}
export function appRecommendProduct(dataSource) {
return (dispatch, getState) => {
let {app, redBrand} = getState();
let {shopId} = redBrand;
let channel = app.channel;
let {shopBanner,json} = dataSource;
let originJson = json;
let list = originJson.modules;
let moduleData = [];
list.map((item, i) => {
if (item.module_type == 'AppRecommendProduct') {
moduleData = item.module_data.data[0];
if (item.module_data.properties.displayType == 1) {
let sknList = moduleData.sknList;
let SKNs = '';
sknList.map((item, i) => {
if (i == 0) {
SKNs = item;
}else {
SKNs = SKNs + ',' + item;
}
});
return new RedBrandService(app.host).searchProductBySkn(SKNs)
.then(json => {
let product_list = json.product_list;
console.log('----<<<<<<<<product_list');
console.log(product_list);
item.list = product_list;
dispatch(productSuccess(dataSource));
})
.catch(error => {
});
}else if (item.module_data.properties.displayType == 0) {
let pageSize = 2 * moduleData.lineNumber;
let order = moduleData.order;
return new RedBrandService(app.host).productList(shopId, channel, order, 1, pageSize)
.then(json => {
let product_list = json.product_list;
console.log('----------111111');
console.log(product_list);
item.list = product_list;
dispatch(productSuccess(dataSource));
})
.catch(error => {
});
}
}
});
};
}
export function getProduct(dataSource) {
return (dispatch, getState) => {
let {app, redBrand} = getState();
... ... @@ -633,6 +748,10 @@ export function getProduct(dataSource) {
let originJson = json;
let list = originJson.modules;
let sknList = [];
console.log('----originJson');
console.log(originJson);
list.map((item, i) => {
if (item.module_type == 'SknList') {
sknList = item.module_data.data;
... ... @@ -646,11 +765,17 @@ export function getProduct(dataSource) {
SKNs = SKNs + ',' + item;
}
});
console.log(SKNs);
console.log('SKNs');
dispatch(productRequest());
return new RedBrandService(app.host).searchProductBySkn(SKNs)
.then(json => {
let product_list = json.product_list;
console.log(json);
console.log('json');
console.log(list);
list.map((item, i) => {
let data = item.module_data.data;
data.map((m, i) => {
... ... @@ -665,9 +790,13 @@ export function getProduct(dataSource) {
});
let payload = parseRource(originJson);
dispatch(productSuccess(payload));
dispatch(appRecommendProduct(payload));
})
.catch(error => {
dispatch(productFailure(error));
let payload = parseRource(originJson);
dispatch(appRecommendProduct(payload));
});
};
}
... ...
... ... @@ -50,6 +50,18 @@ let InitialState = Record({
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
productListForNew: new (Record({
isFetching: false,
error: null,
list: List(),
order: 's_t_desc',
currentPage: 0,
pageCount: 0,
pageSize: 60,//60,
total: 0,
endReached: false,
sourceType: 0, // 0 - 默认,1 - 购,全球2 - 奥莱
})),
filterFactors: new (Record({
gender: '', //性别
color: '', //颜色
... ...
... ... @@ -16,6 +16,10 @@ const {
PRODUCT_LIST_FAILURE,
PRODUCT_FILTER_ACTION,
PRODUCT_LIST_FOR_NEW_REQUEST,
PRODUCT_LIST_FOR_NEW_SUCCESS,
PRODUCT_LIST_FOR_NEW_FAILURE,
FILTER_LIST_VIEW,
FILTER_MORE_VIEW,
SET_PRODUCT_LIST_FILTER,
... ... @@ -121,6 +125,32 @@ export default function redBrandReducer(state=initialState, action) {
return newState;
}
case PRODUCT_LIST_FOR_NEW_REQUEST: {
return state.setIn(['productListForNew', 'isFetching'], true)
.setIn(['productListForNew', 'error'], null);
}
case PRODUCT_LIST_FOR_NEW_SUCCESS: {
let {
list,
currentPage,
pageCount,
total,
endReached,
} = action.payload;
let newState = state.setIn(['productListForNew', 'isFetching'], false)
.setIn(['productListForNew', 'error'], null)
.setIn(['productListForNew', 'list'], Immutable.fromJS(list))
.setIn(['productListForNew', 'currentPage'], currentPage)
.setIn(['productListForNew', 'pageCount'], pageCount)
.setIn(['productListForNew', 'total'], total)
.setIn(['productListForNew', 'endReached'], endReached)
return newState;
}
case PRODUCT_LIST_FOR_NEW_FAILURE: {
return state.setIn(['productListForNew', 'isFetching'], false)
.setIn(['productListForNew', 'error'], action.payload);
}
case FILTER_LIST_VIEW: {
return state.setIn(['productList', 'isFilter'], action.payload);
}
... ...