|
|
import React, { Component } from 'react';
|
|
|
import { Dimensions, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
|
import { Dimensions, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View,ListView } from 'react-native';
|
|
|
import { connect } from 'react-redux';
|
|
|
import Immutable, { List } from 'immutable';
|
|
|
|
|
|
import Focus from './floor/Focus';
|
|
|
import ProductCell from './recommend/ProductCell';
|
|
|
|
|
|
const { width } = Dimensions.get('window');
|
|
|
const DEVICE_WIDTH_RATIO = width / 375;
|
|
|
|
|
|
function mapStateToProps(store) {
|
|
|
const { shareDetail } = store;
|
|
|
return {
|
|
|
shareDetail
|
|
|
export default class ShareDetail extends Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
this._renderHeader = this._renderHeader.bind(this);
|
|
|
this._renderBottom = this._renderBottom.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class ShareDetail extends Component {
|
|
|
render() {
|
|
|
_renderBottom(productInfo,isCollect) {
|
|
|
return (
|
|
|
<View style={styles.bottomBar}>
|
|
|
<View style={[styles.favContainer, styles.center]}>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.addFavorite()} style={[styles.center]}>
|
|
|
<Image
|
|
|
style={styles.favorite}
|
|
|
resizeMode="contain"
|
|
|
source={isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} />
|
|
|
<Text style={styles.favText}>收藏</Text>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
<View style={styles.buttonContainer}>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.jumpWithUrl()}>
|
|
|
<View style={[styles.button, styles.center]}>
|
|
|
<Text style={styles.btnText}>查看商品详情</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(productInfo)}>
|
|
|
<View style={[styles.button, styles.center, styles.red]}>
|
|
|
<Text style={styles.btnText}>{'分享可赚¥' + productInfo.rebatesAmount}</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
switch (sectionID) {
|
|
|
case 'productList': {
|
|
|
return (
|
|
|
<ProductCell
|
|
|
style={styles.listContainer}
|
|
|
key={'row' + rowID}
|
|
|
rowID={rowID}
|
|
|
data={rowData}
|
|
|
onPressProduct={this.props.onPressProduct}
|
|
|
/>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_renderHeader() {
|
|
|
|
|
|
let {shareDetail} = this.props;
|
|
|
let shareDetailInfo = shareDetail ? shareDetail.toJS(): {};
|
|
|
let productInfo = shareDetailInfo.productInfo;
|
|
|
|
|
|
let isCollect = shareDetail.isCollect;
|
|
|
if (!productInfo || productInfo == {}) {
|
|
|
return null
|
|
|
}
|
|
|
let goodsList = productInfo.goodsList;
|
|
|
let productPriceBo = productInfo.productPriceBo;
|
|
|
let goodsInfo = goodsList ? goodsList[0] : {};
|
|
|
|
|
|
if (!goodsInfo || !productPriceBo) {
|
|
|
return null
|
|
|
}
|
|
|
|
|
|
let goodsImagesList = goodsInfo ? goodsInfo.goodsImagesList: null;
|
|
|
let imgList = goodsImagesList && goodsImagesList.map(item => ({src: item.imageUrl}));
|
|
|
imgList = Immutable.fromJS(imgList);
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<View style={[styles.navigatorBackground]}>
|
|
|
<View>
|
|
|
<View style={[styles.imgContainer]}>
|
|
|
<Focus
|
|
|
data={imgList}
|
|
|
height={480}
|
|
|
resourceJumpWithUrl={this.props.resourceJumpWithUrl}
|
|
|
/>
|
|
|
</View>
|
|
|
{/*<View style={styles.navigatorContainer}>
|
|
|
<View style={[styles.navigatorBtn, styles.center]} >
|
|
|
<TouchableOpacity onPress={() => this.props.goBack()}>
|
|
|
<Image source={require('../images/home_drawer_back.png')} />
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
<View style={styles.navigatorBtnRightContainer}>
|
|
|
<View style={[styles.navigatorBtn,styles.navigatorBtnRight]}>
|
|
|
<TouchableOpacity onPress={() => null}>
|
|
|
<Image source={require('../images/yh_prd_more_icon.png')} />
|
|
|
</TouchableOpacity>
|
|
|
<View style={styles.infoContainer}>
|
|
|
<Text style={styles.name}>{productInfo.productName}</Text>
|
|
|
<View style={styles.priceContainer}>
|
|
|
<View style={styles.alignBottom}>
|
|
|
<Text style={styles.priceUnit}>¥</Text>
|
|
|
<Text style={styles.price}>{productPriceBo.salesPrice}</Text>
|
|
|
<Text style={styles.origpriceUnit}>¥</Text>
|
|
|
<Text style={styles.origPrice}>{productPriceBo.marketPrice}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>*/}
|
|
|
<ScrollView
|
|
|
style={styles.container}
|
|
|
showsVerticalScrollIndicator={false}>
|
|
|
<View style={[styles.imgContainer]}>
|
|
|
<Focus
|
|
|
data={imgList}
|
|
|
height={480}
|
|
|
resourceJumpWithUrl={this.props.resourceJumpWithUrl}
|
|
|
/>
|
|
|
</View>
|
|
|
<View style={styles.infoContainer}>
|
|
|
<Text style={styles.name}>{productInfo.productName}</Text>
|
|
|
<View style={styles.priceContainer}>
|
|
|
<View style={styles.alignBottom}>
|
|
|
<Text style={styles.priceUnit}>¥</Text>
|
|
|
<Text style={styles.price}>{productPriceBo.salesPrice}</Text>
|
|
|
<Text style={styles.origpriceUnit}>¥</Text>
|
|
|
<Text style={styles.origPrice}>{productPriceBo.marketPrice}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
<View style={styles.divider} />
|
|
|
<View style={styles.promContainer}>
|
|
|
<Text style={styles.proDesc}>{productInfo.phrase}</Text>
|
|
|
</View>
|
|
|
<View style={styles.recommendContainer}>
|
|
|
<View style={styles.solid} />
|
|
|
<Text style={styles.recommendText}>查看其它推荐商品</Text>
|
|
|
<View style={styles.solid} />
|
|
|
</View>
|
|
|
</ScrollView>
|
|
|
<View style={styles.bottomBar}>
|
|
|
<View style={[styles.favContainer, styles.center]}>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.addFavorite()} style={[styles.center]}>
|
|
|
<Image
|
|
|
style={styles.favorite}
|
|
|
resizeMode="contain"
|
|
|
source={isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} />
|
|
|
<Text style={styles.favText}>收藏</Text>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
<View style={styles.buttonContainer}>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.jumpWithUrl()}>
|
|
|
<View style={[styles.button, styles.center]}>
|
|
|
<Text style={styles.btnText}>查看商品详情</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(productInfo)}>
|
|
|
<View style={[styles.button, styles.center, styles.red]}>
|
|
|
<Text style={styles.btnText}>{'分享可赚¥' + productInfo.rebatesAmount}</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
</View>
|
|
|
<View style={styles.divider} />
|
|
|
<View style={styles.promContainer}>
|
|
|
<Text style={styles.proDesc}>{productInfo.phrase}</Text>
|
|
|
</View>
|
|
|
<View style={styles.recommendContainer}>
|
|
|
<View style={styles.solid} />
|
|
|
<Text style={styles.recommendText}>查看其它推荐商品</Text>
|
|
|
<View style={styles.solid} />
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
changeOpacity(e) {
|
|
|
let opacity = 1 - (500 - e.nativeEvent.contentOffset.y) / 500;
|
|
|
this.setState({opacity: opacity < 0.4 ? opacity : 0.4});
|
|
|
render() {
|
|
|
let {shareDetail} = this.props;
|
|
|
let shareDetailInfo = shareDetail ? shareDetail.toJS(): {};
|
|
|
let productInfo = shareDetailInfo.productInfo;
|
|
|
let isCollect = shareDetail.isCollect;
|
|
|
let productList = shareDetail.productList;
|
|
|
let product_List = productList.product_list ? productList.product_list.toArray() : [];
|
|
|
let dataSource = {
|
|
|
productList: product_List,
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<ListView
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
enableEmptySections={true}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderHeader={this._renderHeader}
|
|
|
onEndReached={() => {
|
|
|
if (product_List.size !== 0) {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
|
|
}
|
|
|
}}
|
|
|
/>
|
|
|
{this._renderBottom(productInfo,isCollect)}
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -123,33 +152,10 @@ const styles = StyleSheet.create({ |
|
|
container: {
|
|
|
flex: 1,
|
|
|
},
|
|
|
navigatorBackground: {
|
|
|
height: 44 * DEVICE_WIDTH_RATIO,
|
|
|
width,
|
|
|
position: 'absolute',
|
|
|
top: 0,
|
|
|
},
|
|
|
navigatorContainer: {
|
|
|
backgroundColor: 'transparent',
|
|
|
height: 44 * DEVICE_WIDTH_RATIO,
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
},
|
|
|
navigatorBtn: {
|
|
|
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
|
height: 32 * DEVICE_WIDTH_RATIO,
|
|
|
width: 32 * DEVICE_WIDTH_RATIO,
|
|
|
overflow: 'hidden',
|
|
|
borderRadius: 16 * DEVICE_WIDTH_RATIO,
|
|
|
marginLeft: 9 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
|
|
navigatorBtnRightContainer: {
|
|
|
flex: 1,
|
|
|
alignItems: 'flex-end',
|
|
|
},
|
|
|
navigatorBtnRight: {
|
|
|
marginLeft: 0,
|
|
|
marginRight: 9 * DEVICE_WIDTH_RATIO,
|
|
|
contentContainer: {
|
|
|
flexDirection: 'row',
|
|
|
flexWrap: 'wrap',
|
|
|
backgroundColor: 'white'
|
|
|
},
|
|
|
center: {
|
|
|
justifyContent: 'center',
|
...
|
...
|
@@ -168,7 +174,7 @@ const styles = StyleSheet.create({ |
|
|
borderColor: '#5d5d5d'
|
|
|
},
|
|
|
infoContainer: {
|
|
|
height: 122 * DEVICE_WIDTH_RATIO,
|
|
|
height: 97 * DEVICE_WIDTH_RATIO,
|
|
|
paddingTop: 15 * DEVICE_WIDTH_RATIO,
|
|
|
paddingHorizontal: 15 * DEVICE_WIDTH_RATIO,
|
|
|
},
|
...
|
...
|
@@ -279,7 +285,8 @@ const styles = StyleSheet.create({ |
|
|
btnText: {
|
|
|
color: '#FFFFFF',
|
|
|
fontSize: 15,
|
|
|
}
|
|
|
},
|
|
|
listContainer: {
|
|
|
width: width,
|
|
|
},
|
|
|
}) |
|
|
|
|
|
export default connect(mapStateToProps)(ShareDetail); |
...
|
...
|
|