Authored by 孙凯

add 限购码页面 review by hongmo

... ... @@ -2,6 +2,7 @@
import React from 'react';
import ReactNative from 'react-native';
import {getSlicedUrl} from '../../../../../classify/utils/Utils';
const {
Image,
... ... @@ -27,7 +28,7 @@ export default class ShopTopBanner extends React.Component {
if (backgroundImage === '') {
return null;
}
let icon = info&&info.shop_logo?info.shop_logo.replace('{width}', 100).replace('{height}', 100):''; // 商品缩略图
let icon = info&&info.shop_logo ? getSlicedUrl(info.shop_logo, 100, 100) : '';
let name = info.is_show_shop_name == 'Y'?info.shop_name:null;
let buttonIcon = this.props.info.is_addFav?require('../../../../image/btn_gz_p.png'):require('../../../../image/btn_gz_n.png');
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Image,
Text,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class GetPurchaseCell extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let resource = this.props.resource;
let backgroundHeigt = resource == '0' ? 40 + 20 : 40;
console.log(this.props);
return(
<View style={{alignItems: 'center',justifyContent: 'center',height: backgroundHeigt,width:width,backgroundColor: 'white'}}>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressHowToGetCodeLink && this.props.onPressHowToGetCodeLink();
}}>
<View style={styles.title}>
<Text style={styles.text}>如何获得限购码?</Text>
<Image source={require('../../image/community_enter_normal.png')} style={styles.timeThumb}></Image>
</View>
</TouchableOpacity>
{resource == '0' ? <View style={{width: width,height: 20,backgroundColor: '#e5e5e5',}}/> : null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
titleView: {
alignItems: 'center',
justifyContent: 'center',
height: 40 + 20,
width:width,
backgroundColor: 'white',
},
title: {
flexDirection: 'row',
alignItems: 'center',
marginLeft: 20,
height: 40,
width:width - 20,
justifyContent: 'space-between',
backgroundColor: 'white',
},
text: {
color: 'black',
},
timeThumb: {
height: 40,
width:40,
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Platform,
Text,
Image,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class InvalidLimitCodeTitle extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
return (
<View style={styles.container}>
<View style={{width: width/2 - 40 - 10,height: 0.5,backgroundColor: '#d0d0d0',position: 'absolute',top: 20,left: 10}}/>
<Text style={styles.text}>已失效</Text>
<View style={{width: width/2 - 40 - 10,height: 0.5,backgroundColor: '#d0d0d0',position: 'absolute',right: 10,top: 20}}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
width: width,
height: 40,
backgroundColor: '#e5e5e5',
alignItems: 'center',
justifyContent: 'center',
},
text: {
fontSize: 12,
color: 'gray',
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import YH_Image from '../../../common/components/YH_Image';
import {getSlicedUrl} from '../../../classify/utils/Utils';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Platform,
Text,
Image,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class LimitCodeProductsCell extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let {resource} = this.props;
let data = resource?resource.toJS():null;
if (!data) {
return null;
}
let defaultUrl = data.defaultUrl;
let newSrc = getSlicedUrl(defaultUrl, 100, 100);
let price = data.price;
let productName = data.productName;
let limitCode = data.limitCode;
let limitCodeTitle = '限购码: ' + limitCode;
let status = data.status;
return (
<View style={styles.container}>
{status == 1 ? <View style={{width: width,height: 20,backgroundColor: '#e5e5e5',}}/> : null}
<TouchableOpacity activeOpacity={1} style={{width: width,height: backgroundHeigth,backgroundColor: '#e5e5e5',}}
onPress={() => {
this.props.onPressLimitCodeProducts && this.props.onPressLimitCodeProducts(data)
}}
>
<View style={styles.titleView}>
<Image source={require('../../image/lp_list_icon.png')} style={styles.noLimitCodeIcon}></Image>
<Text style={styles.titleText}>{limitCodeTitle}</Text>
</View>
<View style={{width: width - 10,height: 0.5,backgroundColor: '#e5e5e5',marginLeft: 10}}/>
<View style={styles.bottomView}>
<YH_Image
url={newSrc}
style={styles.productIcon}
/>
<View style={styles.detailView}>
<Text style={styles.nameText} numberOfLines={2}>{productName}</Text>
<Text style={styles.priceText}>{price}</Text>
</View>
</View>
</TouchableOpacity>
{status == 0 ? <View style={{width: width,height: 20,backgroundColor: '#e5e5e5',}}/> : null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let backgroundHeigth = Math.ceil((200 / 640) * width);
let titleHeigth = Math.ceil((50 / 640) * width);
let iconWidth = Math.ceil((28 / 640) * width);
let iconHeigth = Math.ceil((23 / 640) * width);
let productIconWidth = backgroundHeigth - titleHeigth;
let productIconHeigth = backgroundHeigth - titleHeigth - 20;
let styles = StyleSheet.create({
container: {
width: width,
height: backgroundHeigth + 20,
backgroundColor: '#e5e5e5',
},
titleView: {
width: width,
height: titleHeigth,
alignItems: 'center',
flexDirection: 'row',
backgroundColor: 'white',
},
titleText: {
marginLeft: 3,
fontSize: 13,
color: 'black',
},
noLimitCodeIcon: {
width: iconWidth,
height: iconHeigth,
resizeMode: 'contain',
marginLeft: 10,
},
bottomView: {
width: width,
height: backgroundHeigth - titleHeigth - 1,
alignItems: 'center',
flexDirection: 'row',
backgroundColor: 'white',
},
productIcon: {
width: productIconWidth,
height: productIconHeigth,
resizeMode: 'contain',
marginLeft: 12,
},
detailView: {
width: width - productIconWidth - 30,
height: backgroundHeigth - titleHeigth - 1,
},
priceText: {
width: width - productIconWidth - 60,
marginLeft: 3,
fontSize: 13,
color: 'black',
marginTop: 15,
marginLeft: 10,
},
nameText: {
width: width - productIconWidth - 60,
marginLeft: 3,
fontSize: 13,
color: 'black',
marginTop: 12,
marginLeft: 10,
},
});
... ...
... ... @@ -2,8 +2,7 @@
import React from 'react';
import ReactNative from 'react-native';
import YH_Image from '../../../common/components/YH_Image';
import {getSlicedUrl} from '../../../classify/utils/Utils';
import GetPurchaseCell from './GetPurchaseCell';
const {
View,
... ... @@ -12,6 +11,7 @@ const {
Dimensions,
Platform,
Text,
Image,
} = ReactNative;
import Immutable, {Map} from 'immutable';
... ... @@ -33,18 +33,51 @@ export default class NoDataView extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>没有 PurchaseCode</Text>
<GetPurchaseCell resource={'0'} onPressHowToGetCodeLink={this.props.onPressHowToGetCodeLink}/>
<Image source={require('../../image/lp_mineList_empty.png')} style={styles.noLimitCodeIcon}></Image>
<Text style={styles.text}>暂无限购码</Text>
<TouchableOpacity activeOpacity={1} style={styles.button}
onPress={() => {
this.props.onPressMore && this.props.onPressMore()
}}
>
<Text style={styles.buttonText}>随便看看</Text>
</TouchableOpacity>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let iconHeight = Math.ceil((146 / 640) * width);
let iconWidth = Math.ceil((120 / 640) * width);
let iconTop = Math.ceil((200 / 640) * width);
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'red',
alignItems: 'center',
backgroundColor: 'white',
},
noLimitCodeIcon: {
width: iconWidth,
height: iconHeight,
marginTop: iconTop,
},
text: {
marginTop: 30,
fontSize: 12,
},
button: {
marginTop: 60,
width: 200,
height: 40,
backgroundColor: 'black',
alignItems: 'center',
justifyContent: 'center',
},
buttonText: {
color: 'white',
fontSize: 15,
},
});
... ...
... ... @@ -3,6 +3,10 @@
import React, {Component} from 'react';
import Immutable, {Map} from 'immutable';
import NoDataView from './NoDataView';
import GetPurchaseCell from './GetPurchaseCell';
import InvalidLimitCodeTitle from './InvalidLimitCodeTitle';
import LimitCodeProductsCell from './LimitCodeProductsCell';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import ReactNative, {
View,
... ... @@ -42,6 +46,30 @@ export default class PurchaseCode extends Component {
}
renderRow(rowData, sectionID, rowID, highlightRow) {
if (sectionID == 'howToGetCode') {
return(
<GetPurchaseCell resource={'1'} onPressHowToGetCodeLink={this.props.onPressHowToGetCodeLink}/>
);
}else if (sectionID == 'limitCodeProducts') {
return(
<LimitCodeProductsCell resource={rowData} onPressLimitCodeProducts={this.props.onPressLimitCodeProducts}/>
);
}else if (sectionID == 'invalidLimitCodeProductsTitle') {
let {resource} = this.props;
let error = resource?resource.get('error'):null;
let invalidLimitCodeProducts = resource?resource.get('invalidLimitCodeProducts'):null;
let invalidLimitCodeProductsCount = invalidLimitCodeProducts?invalidLimitCodeProducts.size:0;
if (invalidLimitCodeProductsCount == 0) {
return null;
}
return(
<InvalidLimitCodeTitle />
);
}else if (sectionID == 'invalidLimitCodeProducts') {
return(
<LimitCodeProductsCell resource={rowData} onPressLimitCodeProducts={this.props.onPressLimitCodeProducts}/>
);
}
return null;
}
... ... @@ -59,16 +87,18 @@ export default class PurchaseCode extends Component {
let limitCodeProducts = resource?resource.get('limitCodeProducts'):null;
let limitCodeProductsCount = limitCodeProducts?limitCodeProducts.size:0;
let isFetching = resource?resource.get('isFetching'):false;
let showNoContent = (error || (invalidLimitCodeProductsCount==0&&limitCodeProductsCount==0));
let showNoContent = ((error || (invalidLimitCodeProductsCount==0&&limitCodeProductsCount==0)) && !isFetching);
let dataSource = {
invalidLimitCodeProducts: invalidLimitCodeProducts?invalidLimitCodeProducts.toArray():[],
howToGetCode: [0],
limitCodeProducts: limitCodeProducts?limitCodeProducts.toArray():[],
invalidLimitCodeProductsTitle: [0],
invalidLimitCodeProducts: invalidLimitCodeProducts?invalidLimitCodeProducts.toArray():[],
}
return (
<View style={styles.container}>
{showNoContent?<NoDataView />:<ListView
{showNoContent?<NoDataView onPressHowToGetCodeLink={this.props.onPressHowToGetCodeLink} onPressMore={this.props.onPressMore}/>:<ListView
ref='PurchaseCode'
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
... ... @@ -76,6 +106,9 @@ export default class PurchaseCode extends Component {
renderRow={this.renderRow}
renderSectionHeader={this.renderSectionHeader}
/>}
<LoadingIndicator
isVisible={isFetching}
/>
</View>
);
}
... ... @@ -86,6 +119,7 @@ let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#e5e5e5',
},
contentContainer:{
flexDirection: 'row',
... ...
... ... @@ -8,6 +8,7 @@ import YohoCoinBanner from './YohoCoinBanner';
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
import DeviceInfo from 'react-native-device-info';
import Weixin from '../../../guang/components/detail/Weixin';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import ReactNative, {
View,
... ... @@ -100,6 +101,7 @@ export default class YohoCoin extends Component {
} = resource;
let list = favorite?favorite.get('list'):null;
let isFetching = favorite.get('isFetching') || yohoCoin.get('isFetching') || banner.get('isFetching')|| weixin.get('isFetching');
let dataSource = {
yohoCoin: [yohoCoin],
... ... @@ -124,6 +126,9 @@ export default class YohoCoin extends Component {
}
}}
/>
<LoadingIndicator
isVisible={isFetching}
/>
</View>
);
}
... ...
... ... @@ -64,7 +64,8 @@ export default class YohoCoinBanner extends React.Component {
}
let error = resource.error;
let data = resource.list;
if (error) {
if (error || data.length == 0) {
return null;
}
... ...
... ... @@ -44,6 +44,10 @@ function mapDispatchToProps(dispatch) {
class PurchaseCodeContainer extends Component {
constructor(props) {
super(props);
this._onPressHowToGetCodeLink = this._onPressHowToGetCodeLink.bind(this);
this._onPressMore = this._onPressMore.bind(this);
this._onPressLimitCodeProducts = this._onPressLimitCodeProducts.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'purchaseListChange',
(reminder) => {
... ... @@ -60,6 +64,18 @@ class PurchaseCodeContainer extends Component {
this.subscription && this.subscription.remove();
}
_onPressHowToGetCodeLink(){
ReactNative.NativeModules.YH_MyAssetsViewHelper.pushHowToGetLimitCodeVC();
}
_onPressMore(){
ReactNative.NativeModules.YH_MyAssetsViewHelper.lookAroundBtnTapped();
}
_onPressLimitCodeProducts(data){
ReactNative.NativeModules.YH_MyAssetsViewHelper.pushLimitPurchaseDetailVC(data.limitProductCode);
}
render() {
let {purchaseCode} = this.props;
... ... @@ -67,6 +83,9 @@ class PurchaseCodeContainer extends Component {
<View style={styles.container}>
<PurchaseCode
resource={purchaseCode}
onPressHowToGetCodeLink={this._onPressHowToGetCodeLink}
onPressMore={this._onPressMore}
onPressLimitCodeProducts={this._onPressLimitCodeProducts}
/>
</View>
);
... ...
'use strict';
import Request from '../../common/services/Request';
import Request from '../../common/services/NativeRequest';
import {
Platform,
... ...