Authored by 孙凯

接正式数据 review by hongmo

... ... @@ -42,18 +42,24 @@ export default class DoubleImage extends React.Component {
let data1 = list?list[0]:null;
let backgroundImage1 = data1.pic;
let linkType1 = data1.linkType;
let saleAble1 = false;
let name1 = 'CREAMY CHEEK STICK';
let price1 = '¥'+'299.00';
let sale1 = '¥'+'299.00';
let product1 = data1.product;
let salePrice1 = product1?parseFloat(product1.sales_price):0;
let originPrice1 = product1?parseFloat(product1.market_price):0;
let name1 = product2?product1.product_name:'';
let price1 = '¥' + salePrice1.toFixed(2);
let sale1 = '¥' + originPrice1.toFixed(2);
let saleAble1 = salePrice1>0?true:false;
let data2 = list?list[1]:null;
let backgroundImage2 = data2.pic;
let linkType2 = data2.linkType;
let saleAble2 = true;
let name2 = 'CREAMY CHEEK STICK';
let price2 = '¥'+'299.00';
let sale2 = '¥'+'299.00';
let product2 = data2.product;
let salePrice2 = product2?parseFloat(product2.sales_price):0;
let originPrice2 = product2?parseFloat(product2.market_price):0;
let name2 = product2?product2.product_name:'';
let price2 = '¥' + salePrice2.toFixed(2);
let sale2 = '¥' + originPrice2.toFixed(2);
let saleAble2 = salePrice2>0?true:false;
return(
<View style={{flexDirection: 'row',width: width,height: backgroundHeight,backgroundColor: 'white',}}>
... ...
... ... @@ -73,7 +73,7 @@ export default class Header extends React.Component {
}
shouldComponentUpdate(nextProps,nextState){
if (Immutable.is(nextProps.resource, this.props.resource) && nextState.realContentHeight==this.state.realContentHeight) {
if (Immutable.is(nextProps.resource, this.props.resource) && nextProps.launchProfile==this.props.launchProfile && nextState.realContentHeight == this.state.realContentHeight) {
return false;
} else {
return true;
... ... @@ -93,8 +93,7 @@ export default class Header extends React.Component {
return null;
}
let data = resource.toJS();
// console.log(data);
let text = '<a href="http://www.w3school.com.cn">W3School</a>';
let text = data.shop_intro;
text = '<html><style type="text/css">img {max-width: 100%;}</style><body>' + text + '</body></html>';
let brandName = data.is_show_shop_name?data.shop_name:'';
let num = data.favoriteCount;
... ... @@ -139,7 +138,7 @@ export default class Header extends React.Component {
style={styles.brandIcon}
/>
{!launchProfile ? <Text style={[styles.text, fontFamilyStyle]} numberOfLines={2}>好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好好</Text>:null}
{!launchProfile ? <Text style={[styles.text, fontFamilyStyle]} numberOfLines={2}>{text}</Text>:null}
{launchProfile ?<View style={{width: width,height: this.state.realContentHeight,backgroundColor: 'white'}}>
<WebView style={{width: width-40,height: this.state.realContentHeight,backgroundColor: 'white',marginRight: 20,marginLeft: 20}}
source= {{html: codeInject(text)}}
... ...
... ... @@ -37,6 +37,7 @@ export default class RedBrand extends Component {
this.renderSectionHeader = this.renderSectionHeader.bind(this);
this.renderRow = this.renderRow.bind(this);
this._onPressProductFilter = this._onPressProductFilter.bind(this);
this._onPressLaunchProfile = this._onPressLaunchProfile.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
... ... @@ -44,6 +45,11 @@ export default class RedBrand extends Component {
});
}
_onPressLaunchProfile(value){
this.refs.redBrandList && this.refs.redBrandList.scrollTo({x: 0, y: 0, animated: false});
this.props.onPressLaunchProfile && this.props.onPressLaunchProfile(value);
}
_onPressProductFilter(value){
if(value === 'filter'){
... ... @@ -101,7 +107,7 @@ 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.props.onPressLaunchProfile} onPressCollection={this.props.onPressCollection}/>);
return(<Header resource={rowData} launchProfile={launchProfile} onPressLaunchProfile={this._onPressLaunchProfile} onPressCollection={this.props.onPressCollection}/>);
} else if (sectionID == 'productList') {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
... ... @@ -128,26 +134,6 @@ export default class RedBrand extends Component {
}else if (rowData.get('module_type') == 'TripleImage') {
return(<TripleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
}
// if (rowData == 1) {
// }else if (rowData == 2) {
// return(<SingleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
// }else if (rowData == 3) {
// return(<DoubleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
// }else if (rowData == 4) {
// return(<TripleImage resource={rowData} onPressProduct={this.props.onPressProduct}/>);
// }else if (rowData == 5) {
// return null;
// return(
// <CouponCell
// resource={rowData}
// onPressCoupon={this.props.onPressCoupon}
// />
// );
// }else if (rowData == 6) {
// return(<Title resource={rowData} onPressMore={this.props.onPressMore}/>);
// }else if (rowData == 7) {
// return(<Video resource={rowData} onPressVideo={this.props.onPressVideo}/>);
// }
}
return null;
}
... ...
... ... @@ -45,9 +45,13 @@ export default class SingleImage extends React.Component {
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);
let name = 'CREAMY CHEEK STICK';
let price = '¥'+'299.00';
let product = data.product;
let salePrice = product?parseFloat(product.sales_price):0;
let originPrice = product?parseFloat(product.market_price):0;
let name = product?product.product_name:'';
let price = '¥' + salePrice.toFixed(2);
let sale = '¥' + originPrice.toFixed(2);
let saleAble = salePrice>0?true:false;
return (
<TouchableOpacity activeOpacity={0.5} style={{width: backgroundWidth, height:backgroundHeight,backgroundColor: 'white'}} onPress={() => {
... ... @@ -60,7 +64,8 @@ export default class SingleImage extends React.Component {
/>
{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'}}>
<Text style={styles.text1}>{name}</Text>
<Text style={styles.text2}>{price}</Text>
<Text style={{marginRight: 10,fontSize: 15,backgroundColor: 'transparent',color: saleAble?'red':'white'}}>{price}</Text>
{saleAble?<Text style={styles.deleteSale}>{price}</Text>:null}
</View>:null}
</View>
</TouchableOpacity>
... ... @@ -84,5 +89,12 @@ let styles = StyleSheet.create({
fontSize: 15,
backgroundColor: 'transparent',
color: 'white',
}
},
deleteSale: {
marginRight: 10,
fontSize: 12,
backgroundColor: 'transparent',
color: 'white',
textDecorationLine: 'line-through',
}
});
... ...
... ... @@ -127,13 +127,11 @@ export default function redBrandReducer(state=initialState, action) {
return state.setIn(['coupon', 'isFetching'], true)
.setIn(['coupon', 'error'], null);
}
case SHOP_COUPON_LIST_SUCCESS: {
return state.setIn(['coupon', 'isFetching'], false)
.setIn(['coupon', 'error'], null)
.setIn(['coupon', 'list'], Immutable.fromJS(action.payload));
}
case SHOP_COUPON_LIST_FAILURE: {
return state.setIn(['coupon', 'isFetching'], false)
.setIn(['coupon', 'error'], action.payload);
... ... @@ -155,18 +153,15 @@ export default function redBrandReducer(state=initialState, action) {
case ADD_FAVORITE_SUCCESS: {
return state.setIn(['shopIntro', 'is_addFav'], action.payload);
}
case ADD_FAVORITE_FAILURE: {
if (action.payload.code == 413) {
return state.setIn(['shopIntro', 'is_addFav'], true);
}
return state.setIn(['shopIntro', 'is_addFav'], false);
}
case CANCEL_FAVORITE_SUCCESS: {
return state.setIn(['shopIntro', 'is_addFav'], action.payload);
}
case GET_FAVORITE_COUNT_SUCCESS: {
return state.setIn(['shopIntro', 'favoriteCount'], action.payload);
}
... ... @@ -235,6 +230,36 @@ export default function redBrandReducer(state=initialState, action) {
case GET_INTRO_FAILURE: {
return state.setIn(['shopIntro', 'error'], action.payload);
}
case PRODUCT_SUCCESS: {
let {
shopBanner,
json,
} = action.payload;
let {
isFetching,
error,
app_type,
shop_id,
template_id,
template_type,
modules,
} = json;
let newState = state.setIn(['shopsdecorator', 'isFetching'], false)
.setIn(['shopsdecorator', 'error'], null)
.setIn(['shopsdecorator', 'app_type'], app_type)
.setIn(['shopsdecorator', 'shop_id'], shop_id)
.setIn(['shopsdecorator', 'template_id'], template_id)
.setIn(['shopsdecorator', 'template_type'], template_type)
.setIn(['shopsdecorator', 'modules'], Immutable.fromJS(modules))
.setIn(['shopIntro', 'shopBanner'], Immutable.fromJS(shopBanner))
return newState;
}
case PRODUCT_FAILURE: {
return state.setIn(['shopsdecorator', 'isFetching'], false);
}
}
return state;
}
... ...