Authored by 于良

Merge branch '5.4.1' of http://git.yoho.cn/mobile/YH_RNComponent into 5.4.1

Conflicts:
	js/home/containers/HomeContainer.js
Showing 37 changed files with 1226 additions and 224 deletions
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
const {
View,
Text,
ListView,
TouchableOpacity,
Dimensions,
StyleSheet,
Platform,
} = ReactNative;
export default class ChannelSelector extends React.Component {
constructor(props) {
super (props);
this._renderRow = this._renderRow.bind(this);
this._renderSeparator = this._renderSeparator.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.id != r2.id,
});
}
shouldComponentUpdate(nextProps){
if (nextProps.onSelectdIndex == this.props.onSelectdIndex) {
return false;
} else {
return true;
}
}
_renderRow(rowData, sectionID, rowID) {
let isRowSelected = false;
let onSelectdIndex = this.props.onSelectdIndex;
let dataSource = this.props.dataSource;
isRowSelected = onSelectdIndex == rowID;
let colorStyle = isRowSelected ? {color: '#444444', fontFamily: 'HelveticaNeue', fontSize: 17} : {color: '#b0b0b0', fontFamily: 'HelveticaNeue', fontSize: 17,};
let rowWidth = width/dataSource.length;
return (
<TouchableOpacity activeOpacity={1} onPress={() => {
if (isRowSelected) {
return;
}
this.props.onClickSort && this.props.onClickSort(rowID);
}}>
<View key={'row' + rowID} style={[styles.rowContainer, {width: rowWidth}]}>
<Text style={[styles.name, colorStyle]}>{rowData}</Text>
</View>
</TouchableOpacity>
);
}
_renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return (
<View key={'sep' + rowID} style={styles.separator}>
</View>
);
}
render() {
let {dataSource} = this.props;
dataSource = dataSource ? dataSource : [];
return (
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this._renderRow}
renderSeparator={this._renderSeparator}
scrollEnabled={false}
scrollsToTop={false}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let viewHeight = 44;
let styles = StyleSheet.create({
container: {
width: width,
height: viewHeight,
borderTopColor: 'transparent',
borderBottomColor: '#e0e0e0',
borderBottomWidth: 0.5,
backgroundColor:'white',
},
contentContainer: {
flexDirection: 'row',
},
rowContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: viewHeight,
backgroundColor:'white',
},
name: {
color: '#b0b0b0',
},
separator: {
width: 0.5,
top: 14,
height: 16,
backgroundColor: '#e0e0e0',
},
});
... ...
... ... @@ -69,7 +69,7 @@ export default class ActivityProductFloor extends Component {
<Text style={styles.discountText} numberOfLines={1}>{orginPrice}</Text>
{
this._isShowVip(type) ? <Image style={{width:33,height:12,marginLeft:2}}
source={require('../../images/ic_vip_red.png')}/> : null
source={require('../../images/yh_home_vipUser_vip_icon.png')}/> : null
}
</View> : null
}
... ...
... ... @@ -44,75 +44,59 @@ export default class KidsBrandFloor extends Component {
}
}
_renderRow(rowData,sectionID,rowID,highlightRow){
let moreUrl = this.props.data.get('title').get('more_url');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), itemWidth, itemWidth, 2);
let title = rowData.get('title');
let actionUrl = rowData.get('url');
if (rowID <= 7){
if (rowID == 7){
return (
<TouchableOpacity onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(moreUrl,rowID)}}>
<View style={styles.row}>
<View style={styles.imageContainer}>
<Image
source={require('../../images/brandicon_more.png')}/>
</View>
<Text style={styles.text} numberOfLines={1}>
MORE
</Text>
</View>
</TouchableOpacity>
);
_renderRow(rowData, sectionID, rowID, highlightRow) {
let moreUrl = this.props.data.get('title').get('more_url');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), itemWidth, itemWidth, 2);
let title = rowData.get('title');
let actionUrl = rowData.get('url');
if (rowID <= 7) {
if (rowID == 7) {
return (
<TouchableOpacity
onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(moreUrl,rowID)}}>
<View style={styles.row}>
<View style={styles.imageContainer}>
<Image
source={require('../../images/brandicon_more.png')}/>
</View>
<Text style={styles.text} numberOfLines={1}>
MORE
</Text>
</View>
</TouchableOpacity>
);
} else {
return (
<TouchableOpacity style={styles.cellContainer}
activeOpacity={1}
onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(actionUrl,rowID)}}>
<YH_Image style={styles.image}
url={imgUrl}/>
<Text style={styles.text} numberOfLines={1}>
{title}
</Text>
</TouchableOpacity>
);
}
} else {
let curW,curH,mr;
if (rowID < 3){
curW = itemWidth - 0.5;
curH = itemHeight - 0.5;
mr = 0.5;
} else if (rowID == 3){
curW = itemWidth;
curH = itemHeight - 0.5;
mr = 0;
} else if (rowID > 3 && rowID < 7){
curW = itemWidth - 0.5;
curH = itemHeight;
mr = 0.5;
} else {
curW = itemWidth;
curH = itemHeight;
mr = 0;
}
return (
<TouchableOpacity activeOpacity={1} onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(actionUrl,rowID)}}>
<View style={styles.row,{width:curW,height:curH,marginRight:mr}}>
<YH_Image style={styles.image}
url={imgUrl}/>
<Text style={styles.text} numberOfLines={1}>
{title}
</Text>
</View>
</TouchableOpacity>
);
return null;
}
} else {
return null;
}
}
render() {
let data = this.props.data;
let title = data.get('title').get('title');
let moreurl = data.get('title').get('more_url');
let dataList = data.get('list');
let data = this.props.data;
let title = data.get('title').get('title');
let moreurl = data.get('title').get('more_url');
let dataList = data.get('list');
let floorH = 40 + itemHeight * 2 + 0.5;
return (
<View style={styles.container}>
<View style={{backgroundColor:'white',width:width,height:floorH}}>
<HeadTitleCell title={title} moreUrl={moreurl}/>
<ListView
contentContainerStyle={styles.list}
dataSource={this.dataSource.cloneWithRows(dataList.toArray())}
initialListSize={data.length}
renderRow={this._renderRow.bind(this)}
contentContainerStyle={styles.list}
dataSource={this.dataSource.cloneWithRows(dataList.toArray())}
initialListSize={data.length}
renderRow={this._renderRow.bind(this)}
/>
</View>
);
... ... @@ -121,48 +105,48 @@ export default class KidsBrandFloor extends Component {
let {width, height} = Dimensions.get('window');
let itemWidth = width / 4;
let itemHeight = itemWidth+20;
let itemWidth = width / 4 - 0.5;
let itemHeight = itemWidth + 20;
let styles = StyleSheet.create({
container:{
backgroundColor:'white'
},
list: {
backgroundColor: '#7f808080',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent:'space-around',
alignItems:'flex-start',
},
cell: {
marginLeft: 0,
width: itemWidth,
height: itemWidth + 20,
backgroundColor: 'white',
flexDirection:'column'
},
image:{
width:itemWidth,
height:itemWidth,
},
text:{
width:itemWidth,
height:20,
backgroundColor:'white',
color: 'gray',
textAlign:'center',
fontSize:12,
},
imageContainer:{
width:itemWidth,
height:itemWidth,
backgroundColor:'white',
justifyContent:'center',
alignItems:'center'
},
row:{
width:itemWidth,
height:itemHeight,
backgroundColor:'white'
},
list: {
backgroundColor: '#7f808080',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'flex-start',
alignItems: 'flex-start',
},
cell: {
marginLeft: 0,
width: itemWidth,
height: itemWidth + 20,
backgroundColor: 'white',
flexDirection: 'column'
},
image: {
width: itemWidth,
height: itemWidth,
},
text: {
width: itemWidth,
height: 20,
backgroundColor: 'white',
color: 'gray',
textAlign: 'center',
fontSize: 12,
},
imageContainer: {
width: itemWidth,
height: itemWidth,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center'
},
cellContainer: {
backgroundColor: 'white',
width: itemWidth,
justifyContent: 'center',
alignItems: 'center',
marginRight: 0.5,
marginBottom: 0.5
},
});
... ...
... ... @@ -76,6 +76,7 @@ let styles = StyleSheet.create({
container: {
width: width,
height: 40 + imageHeight,
},
imageContainer: {
... ...
... ... @@ -48,7 +48,7 @@ export default class NewUserFloor extends Component {
<View style={styles.buyContainer}>
<Text style={styles.buy} numberOfLines={1}>立即购买</Text>
<Image style={{width:4,height:7,marginLeft:2}}
source={require('../../images/ic_small_arrow_right.png')}/>
source={require('../../images/yh_home_new_user_arrow.png')}/>
</View>
</View>
</TouchableOpacity>);
... ... @@ -88,7 +88,7 @@ export default class NewUserFloor extends Component {
showsHorizontalScrollIndicator={false}
/>
<View style={{position:'absolute',left:0,top:12,alignItems:'center'}}>
<Image source={require('../../images/ic_newcomer_tips.png')}
<Image source={require('../../images/yh_home_new_user.png')}
style={{width:20,height:cellHeight}}/>
<Text
style={{color:'white',fontSize:11,textAlignVertical:"center",height:90,position:'absolute',left:0,top:0}}>
... ...
... ... @@ -121,6 +121,7 @@ let styles = StyleSheet.create({
container: {
width: width,
height: 40 + bannerHeight + leftBigImageHeight,
backgroundColor: "#e5e5e5",
},
... ... @@ -202,7 +203,7 @@ let styles = StyleSheet.create({
marginTop: 2,
},
rightBottomBigImage: {
rightBottomSmallImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
... ...
... ... @@ -49,7 +49,7 @@ export default class VipUserFloor extends Component {
<View style={styles.vipContainer}>
<Text style={styles.discountText} numberOfLines={1}>{orginPrice}</Text>
<Image style={{width:33,height:12,marginLeft:2}}
source={require('../../images/ic_vip_red.png')}/>
source={require('../../images/yh_home_vipUser_vip_icon.png')}/>
</View>
</TouchableOpacity>);
}
... ... @@ -102,6 +102,8 @@ let cellHeight = 210;
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
width:width,
height:40+bannerHeight+cellHeight
},
listContianer: {
width:width,
... ...
... ... @@ -16,8 +16,9 @@ import ReactNative, {
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import YH_SortView from '../../../common/components/YH_SortView';
import HeadTitleCell from '../cell/HeadTitleCell';
import channelTransfer from '../../../common/utils/channelTransfer';
import floorParser from '../../utils/floorParser';
import Focus from '../floor/Focus';
import AppIconList from '../floor/AppIconList';
... ... @@ -56,6 +57,7 @@ export default class Home extends Component {
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
this._floorCellRender = this._floorCellRender.bind(this);
this._currentChannelData = this._currentChannelData.bind(this);
this._renderSectionHeader = this._renderSectionHeader.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
... ... @@ -133,8 +135,19 @@ export default class Home extends Component {
);
}
case 'lifeStyleFav': {
return null;
}
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal*1.5 : rowMarginHorizontal*2;
let customStyle = {paddingLeft};
return (
<View style={[styles.product,]}>
<ProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={this.props.onPressProductListProduct}
/>
</View>
); }
break;
default:
{
... ... @@ -377,8 +390,10 @@ export default class Home extends Component {
_renderFooter() {
let data = this._currentChannelData();
let {isFetching, endReached, list} = data;
let isLoadingMore = !endReached && list.size != 0;
let {isFetching, endReached, list, cached} = data;
let floorList = list.size > 0 ? list.toArray() : cached.get('list').toArray();
let isLoadingMore = !endReached && floorList.size != 0;
return (
<LoadMoreIndicator
isVisible={isLoadingMore}
... ... @@ -388,12 +403,17 @@ export default class Home extends Component {
}
_renderSectionHeader(sectionData, sectionID) {
let floor = [];
if (sectionID == 'floor') {
floor = sectionData;
}
if (sectionID == 'lifeStyleFav') {
let data = this._currentChannelData();
let selectIndex = data.selectIndex;
selectIndex = parseInt(selectIndex);
return (
<YH_SortView
dataSource={['新品到着', '人气单品']}
onSelectdIndex={selectIndex}
onClickSort={this.props.onClickSort}
/>
);
}else {
return null
}
... ... @@ -402,43 +422,8 @@ export default class Home extends Component {
render() {
let channel = this.props.channel;
let data = this._currentChannelData();
let {list, cached, isFetching, isFirstLoad, endReached, favorite, bottomBanner, hotList, newList} = data;
let floorList = list.size > 0 ? list.toArray() : cached.get('list').toArray();
let dataSource = {};
if (channel == 4) {
dataSource = {
floor: floorList,
lifeStyleFav:{
hotList,
newList
}
}
} 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']
}
}else {
dataSource = {
floor: floorList,
favoriteHeader: ['1'],
favorite: favoriteList.toArray()
}
}
}
}
let {isFetching} = data;
let dataSource = floorParser.homeDataParse(data, channel);
let isPullToRefresh = isFetching;
... ...
... ... @@ -9,7 +9,7 @@ export default keyMirror({
HOME_RESET_STATE_WHEN_REFRESH: null,
HOME_FLOOR_DATA_HAS_NOT_CHANGE: null,
LOAD_CHANNEL_CACHED_DATA: null,
HOME_FLOOR_REQUEST: null,
... ... @@ -28,6 +28,8 @@ export default keyMirror({
HOME_LIFESTYLE_FAVORITE_SUCCESS: null,
HOME_LIFESTYLE_FAVORITE_FAILURE: null,
HOME_LIFESTYLE_FAVORITE_SET_INDEX: null,
HOME_SHOP_INFO_REQUEST: null,
HOME_SHOP_INFO_SUCCESS: null,
HOME_SHOP_INFO_FAILURE: null,
... ...
... ... @@ -62,13 +62,13 @@ class HomeContainer extends Component {
this.onPressTrendTopicItem = this.onPressTrendTopicItem.bind(this);
this.onPressBrandItem = this.onPressBrandItem.bind(this);
this.onPressVipBannerItem = this.onPressVipBannerItem.bind(this);
this.onPressVipBuy = this.onPressVipBuy.bind(this);
this.onPressVipProduct = this.onPressVipProduct.bind(this);
this.onPressAppIconItem = this.onPressAppIconItem.bind(this);
this.onPressHotBrandItem = this.onPressHotBrandItem.bind(this);
this.onPressShopRecommendItem = this.onPressShopRecommendItem.bind(this);
this.onPressShopFavorite = this.onPressShopFavorite.bind(this);
this.onPressTitleMore = this.onPressTitleMore.bind(this);
this.onClickSort = this.onClickSort.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
'ChannelDidChangeEvent',
... ... @@ -178,18 +178,19 @@ class HomeContainer extends Component {
this.jumpWithUrl(url);
}
onPressVipBuy() {
}
onPressVipProduct(productId,productName) {
console.log('productId=' + productId + " productName=" + productName);
onPressVipProduct(productId,productSkn) {
ReactNative.NativeModules.YH_CommonHelper.jumpToProductDetail(productId.toString(), productSkn.toString());
}
onPressTitleMore(url, index) {
this.jumpWithUrl(url);
}
onClickSort(index) {
this.props.actions.selecLifeStyleProductIndex(index);
}
render() {
let {app, home} = this.props;
return (
... ... @@ -214,13 +215,13 @@ class HomeContainer extends Component {
onPressTrendTopicItem={this.onPressTrendTopicItem}
onPressBrandItem={this.onPressBrandItem}
onPressVipBannerItem={this.onPressVipBannerItem}
onPressVipBuy={this.onPressVipBuy}
onPressVipProduct={this.onPressVipProduct}
onPressAppIconItem={this.onPressAppIconItem}
onPressHotBrandItem={this.onPressHotBrandItem}
onPressShopRecommendItem={this.onPressShopRecommendItem}
onPressShopFavorite={this.onPressShopFavorite}
onPressTitleMore={this.onPressTitleMore}
onClickSort={this.onClickSort}
/>
</View>
);
... ...
... ... @@ -27,6 +27,8 @@ const {
HOME_LIFESTYLE_FAVORITE_SUCCESS,
HOME_LIFESTYLE_FAVORITE_FAILURE,
HOME_LIFESTYLE_FAVORITE_SET_INDEX,
HOME_SHOP_INFO_REQUEST,
HOME_SHOP_INFO_SUCCESS,
HOME_SHOP_INFO_FAILURE,
... ... @@ -164,7 +166,7 @@ export function fetchBoyGirlFavoriteList() {
if (currentChannelData.favorite.isFetching
|| currentChannelData.endReached
|| currentChannelData.list.size == 0) {
|| (currentChannelData.list.size == 0 && currentChannelData.cached.get('list').size == 0)) {
return;
}
... ... @@ -230,7 +232,7 @@ export function fetchKidsFavoriteList() {
let {kid} = home;
if (kid.favorite.isFetching
|| kid.endReached
|| kid.list.size == 0) {
|| (kid.list.size == 0 && kid.cached.get('list').size == 0)) {
return;
}
... ... @@ -244,7 +246,7 @@ export function fetchKidsFavoriteList() {
.then(json =>{
let payload = floorParser.parseKidsFavorite(json);
if (payload.currentPage > 1) {
let oldList = kid.favorite.list.toJS();
let oldList = kid.favorite.get('list').toJS();
let newList = [...oldList, ...payload.list];
payload.list = newList;
}
... ... @@ -283,8 +285,7 @@ function fetchLifeStyleFavoriteList(fromPage) {
let {lifeStyle} = home;
if (lifeStyle.isListFetching
|| lifeStyle.endReached
|| lifeStyle.list.size == 0) {
|| (lifeStyle.list.size == 0 && lifeStyle.cached.get('list').size == 0)) {
return;
}
... ... @@ -316,6 +317,19 @@ function fetchLifeStyleFavoriteList(fromPage) {
}
}
export function selecLifeStyleProductIndex(index) {
return (dispatch) => {
dispatch(selectLifeStyleIndex(index));
}
}
function selectLifeStyleIndex(index) {
return {
type: HOME_LIFESTYLE_FAVORITE_SET_INDEX,
payload: index
}
}
/**
** 男女频道底部banner
**/
... ...
... ... @@ -60,6 +60,8 @@ let lifeStyle = new (Record({
listError: null,
hotList: List(), //创意生活频道 人气单品商品列表
newList: List(), //创意生活频道 新品到着商品列表
selectIndex: 0,
content_code: '',
}));
... ...
... ... @@ -15,7 +15,7 @@ const {
HOME_FAVORITE_REQUEST,
HOME_FAVORITE_SUCCESS,
HOME_FAVORITE_FAILURE,
HOME_KIDS_FAVORITE_REQUEST,
HOME_KIDS_FAVORITE_SUCCESS,
HOME_KIDS_FAVORITE_FAILURE,
... ... @@ -24,6 +24,8 @@ const {
HOME_LIFESTYLE_FAVORITE_SUCCESS,
HOME_LIFESTYLE_FAVORITE_FAILURE,
HOME_LIFESTYLE_FAVORITE_SET_INDEX,
HOME_SHOP_INFO_REQUEST,
HOME_SHOP_INFO_SUCCESS,
HOME_SHOP_INFO_FAILURE,
... ... @@ -73,11 +75,13 @@ export default function homeReducer(state=initialState, action) {
*** 猜你喜欢列表
*****************************/
case HOME_FAVORITE_REQUEST:
case HOME_KIDS_FAVORITE_REQUEST:
case HOME_LIFESTYLE_FAVORITE_REQUEST:{
case HOME_KIDS_FAVORITE_REQUEST:{
let channelStr = action.payload;
return state.setIn([channelStr, 'favorite', 'isFetching'], true);
}
case HOME_LIFESTYLE_FAVORITE_REQUEST:{
return state.setIn(['lifeStyle', 'isListFetching'], true);
}
case HOME_FAVORITE_SUCCESS:
case HOME_KIDS_FAVORITE_SUCCESS:{
let {channelStr, json} = action.payload;
... ... @@ -95,22 +99,24 @@ export default function homeReducer(state=initialState, action) {
.setIn([channelStr, 'favorite', 'error'], error);
}
case HOME_LIFESTYLE_FAVORITE_SUCCESS:{
let {channelStr, json} = action.payload;
return state.setIn([channelStr, 'hotList'], Immutable.fromJS(json.hotList))
.setIn([channelStr, 'newList'], Immutable.fromJS(json.newList))
.setIn([channelStr, 'isFetching'], false)
.setIn([channelStr, 'isFirstLoad'], false)
.setIn([channelStr, 'isListFetching'], false)
.setIn([channelStr, 'endReached'], true);
}
case HOME_LIFESTYLE_FAVORITE_FAILURE:{
let {channelStr, error} = action.payload;
return state.setIn([channelStr, 'isFetching'], false)
.setIn([channelStr, 'listError'], error);
}
case HOME_LIFESTYLE_FAVORITE_SET_INDEX:{
return state.setIn(['lifeStyle', 'selectIndex'], action.payload);
}
/****************************
*** 底部banner
... ... @@ -137,7 +143,7 @@ export default function homeReducer(state=initialState, action) {
let channelStr = action.payload;
return state.setIn([channelStr, 'shop', 'isFetching'], true);
}
case HOME_SHOP_INFO_SUCCESS:{
let {channelStr, json} = action.payload;
return state.setIn([channelStr, 'shop', 'isFetching'], false)
... ... @@ -176,7 +182,7 @@ export default function homeReducer(state=initialState, action) {
.setIn([channelStr, 'cached', 'md5'], data.md5)
.setIn([channelStr, 'cached', 'content_code'], data.content_code);
}
case HOME_FLOOR_DATA_HAS_NOT_CHANGE:{
let channelStr = action.payload;
return state.setIn([channelStr, 'isFetching'], false);
... ...
'use strict';
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;
}
... ... @@ -75,6 +129,7 @@ function parseShopInfo(json) {
}
module.exports = {
homeDataParse,
channelCacheKey,
parseHomeFloor,
parseBoyGirlFavorite,
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import AlreadyOpenedHeader from './AlreadyOpenedHeader';
import AlreadyOpenedFooter from './AlreadyOpenedFooter';
import ProductListCell from '../../../common/components/ListCell/ProductListCell';
export default class AlreadyOpened extends React.Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this._renderFooter = this._renderFooter.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
componentDidMount() {
this.props.getAlreadyPageInfo();
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
return (
<ProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={this.props.onPressProductListProduct}
/>
);
}
_renderHeader() {
let {alreadyOpenedPageInfo} = this.props;
return (
<AlreadyOpenedHeader
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressTabBtn={this.props.onPressTabBtn}
onPressMoreProducts={this.props.onPressMoreProducts}
onPressProtocol={this.props.onPressProtocol}
/>
)
}
_renderFooter() {
let {alreadyOpenedPageInfo} = this.props;
return (
<AlreadyOpenedFooter
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressMoreProducts={this.props.onPressMoreProducts}
/>
)
}
render() {
let {alreadyOpenedPageInfo} = this.props;
let {tabFocusIndex,goods} = alreadyOpenedPageInfo;
let dataSource=[];
if (tabFocusIndex == 2) {
dataSource = alreadyOpenedPageInfo.goods.toArray();
}
return(
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
renderFooter={this._renderFooter}
onEndReached={() => {
if (goods && goods.size > 0) {
this.props.onEndReached && this.props.onEndReached();
}
}}
/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let rowWidth = Math.ceil(137.5 * width / 320);
let rowHeight = Math.ceil(254 * width / 320);
let rowMarginTop = Math.ceil(10 * width / 320);
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
const DEVICE_WIDTH_RATIO = width / 320;
let tabBtnWidth = (width - 30) / 2;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
tabBarContainer: {
width: width,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: 'black',
flexDirection: 'row',
},
tabBtnFocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
tabBtnUnfocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: '#b0b0b0',
},
listContainer: {
width: width / 2,
},
});
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
Platform,
DeviceInfo,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class AlreadyOpenedFooter extends React.Component {
constructor(props) {
super(props);
}
render() {
let {tabFocusIndex,creditInfo,goods,installmentInfo} = this.props.alreadyOpenedPageInfo;
return(
<View style={styles.container}>
{tabFocusIndex==1?
<View style={styles.bottomCellsContainer}>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.monthRepay && this.props.monthRepay();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>本月待还金额:</Text>
<View style={styles.cellLeftContainer}>
<Text style={styles.cellPrice}>¥{installmentInfo.get('monthAmt')}</Text>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.totalRepayCell && this.props.totalRepayCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>待还总金额:</Text>
<View style={styles.cellLeftContainer}>
<Text style={styles.cellPrice}>¥{installmentInfo.get('totalAmt')}</Text>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.repayRecordCell && this.props.repayRecordCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>还款记录:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
marginLeft: 15 * DEVICE_WIDTH_RATIO,
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.installmentOrderCell && this.props.installmentOrderCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>分期订单:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.installmentAccountCell && this.props.installmentAccountCell();
}}>
<View style={styles.cellContainer}>
<Text style={styles.cellTitle}>账户管理:</Text>
<View style={styles.cellLeftContainer}>
<Image source={require("../../image/category_b_arrow.png")}/>
</View>
</View>
</TouchableOpacity>
</View>
:<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressMoreProducts && this.props.onPressMoreProducts(this.props.moreUrl);
}}>
<View style={styles.moreBtnContainer}>
<Text style={styles.moreProductBtn}>
查看更多可分期商品
</Text>
</View>
</TouchableOpacity>
}
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let containerHeight = 74 * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
flex: 1,
width: width,
backgroundColor: '#e5e5e5',
},
bottomCellsContainer: {
backgroundColor: 'white',
},
moreBtnContainer: {
borderRadius: 5,
margin: 15 * DEVICE_WIDTH_RATIO,
height: 44 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
backgroundColor: '#444444',
},
moreProductBtn: {
width: width,
fontSize: 13 * DEVICE_WIDTH_RATIO,
textAlign: 'center',
height: 44 * DEVICE_WIDTH_RATIO,
lineHeight: 29 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
cellContainer: {
width: width,
flexDirection: 'row',
justifyContent: 'space-between',
height: 40 * DEVICE_WIDTH_RATIO,
},
cellTitle: {
marginLeft: 15 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
lineHeight: 26 * DEVICE_WIDTH_RATIO,
},
cellPrice: {
color: '#b0b0b0',
marginRight: 5 * DEVICE_WIDTH_RATIO,
},
cellLeftContainer: {
marginRight: 15 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
alignItems: 'center',
}
});
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
Platform,
DeviceInfo,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class AlreadyOpenedHeader extends React.Component {
constructor(props) {
super(props);
}
render() {
let {tabFocusIndex,creditInfo,goods,installmentInfo,isOverdue} = this.props.alreadyOpenedPageInfo;
if (tabFocusIndex == 2 && goods && goods.size > 0) {
containerHeight = (44 + 175 + 15 + 42 + 0.5) * DEVICE_WIDTH_RATIO;
}else {
containerHeight = (44 + 175) * DEVICE_WIDTH_RATIO;
}
return(
<View style={[styles.container,{height: containerHeight}]}>
<View style={styles.tabBarContainer}>
<TouchableOpacity activeOpacity={1} onPress={() => {this.props.onPressTabBtn &&this.props.onPressTabBtn(1)}} >
{tabFocusIndex==1?
<Text style={styles.tabBtnFocus}>
待还款金额
</Text>
:<Text style={styles.tabBtnUnfocus}>
待还款金额
</Text>
}
</TouchableOpacity>
<View style={{width: 0.5,height:23*DEVICE_WIDTH_RATIO,marginTop:10*DEVICE_WIDTH_RATIO,backgroundColor:'white'}} />
<TouchableOpacity activeOpacity={1} onPress={() => {this.props.onPressTabBtn &&this.props.onPressTabBtn(2)}} >
{tabFocusIndex==1?
<Text style={styles.tabBtnUnfocus}>
可用额度
</Text>
:<Text style={styles.tabBtnFocus}>
可用额度
</Text>
}
</TouchableOpacity>
</View>
{tabFocusIndex==1?
<View style={styles.imageContainer}>
<Image style={styles.bgImage} source={require("../../image/header_bg.png")}/>
<Text style={[styles.imageText,styles.text1]}>近七日待还款</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginTop:5*DEVICE_WIDTH_RATIO,marginBottom:5*DEVICE_WIDTH_RATIO}]}>¥
<Text style={[styles.imageText,styles.text2]}>
{installmentInfo.get('dayAmt')}
</Text>
</Text>
{isOverdue?
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginBottom:15*DEVICE_WIDTH_RATIO}]}>您有¥{creditInfo.get('initCreditLimit')}已逾期,点击
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressOverdue && this.props.onPressOverdue();
}}>
<View style={{borderColor:'white',borderBottomWidth:0.5*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText]}>查看详情</Text>
</View>
</TouchableOpacity>
</Text>
:null
}
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressProtocol && this.props.onPressProtocol();
}}>
<View style={{width:95*DEVICE_WIDTH_RATIO,height:30*DEVICE_WIDTH_RATIO,borderRadius:15*DEVICE_WIDTH_RATIO,alignItems:'center',backgroundColor:'rgba(69, 74, 76, 0.5)',marginTop:15*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText,{lineHeight:20*DEVICE_WIDTH_RATIO}]}>明细</Text>
</View>
</TouchableOpacity>
</View>
:<View style={styles.imageContainer}>
<Image style={styles.bgImage} source={require("../../image/header_bg.png")}/>
<Text style={[styles.imageText,styles.text1]}>可用额度</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginTop:5*DEVICE_WIDTH_RATIO,marginBottom:5*DEVICE_WIDTH_RATIO}]}>¥
<Text style={[styles.imageText,styles.text2]}>
{creditInfo.get('currCreditLimit')}
</Text>
</Text>
<Text style={[styles.imageText,{fontSize:12*DEVICE_WIDTH_RATIO,marginBottom:15*DEVICE_WIDTH_RATIO}]}>总额度:¥{creditInfo.get('initCreditLimit')}</Text>
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressProtocol && this.props.onPressProtocol();
}}>
<View style={{borderColor:'white',borderBottomWidth:0.5*DEVICE_WIDTH_RATIO}}>
<Text style={[styles.imageText]}>服务条款</Text>
</View>
</TouchableOpacity>
</View>
}
{tabFocusIndex==2&&goods&&goods.size>0?
<View style={styles.installmentOnlyHeader}>
<View style={{
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
<View style={styles.titleContainer}>
<Text style={styles.productText}>分期专享</Text>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressMoreProducts && this.props.onPressMoreProducts(this.props.moreUrl);
}}>
<Image
source={require('../../image/btn_more_p.png')}
style={{width: 22*DEVICE_WIDTH_RATIO, height: 4*DEVICE_WIDTH_RATIO,backgroundColor:'white',marginRight:15*DEVICE_WIDTH_RATIO,marginTop:21*DEVICE_WIDTH_RATIO,}}
resizeMode={'contain'}
/>
</TouchableOpacity>
</View>
<View style={{
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
</View>
:null
}
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let tabBtnWidth = (width - 30) / 2;
let imageContainerWidth = width - 52 * DEVICE_WIDTH_RATIO;
let containerHeight = (44 + 175) * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
flex: 1,
width:width,
height: containerHeight,
backgroundColor: 'white',
},
tabBarContainer: {
width: width,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: 'black',
flexDirection: 'row',
},
tabBtnFocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: 'white',
},
tabBtnUnfocus: {
textAlign: 'center',
width: tabBtnWidth,
height: 44 * DEVICE_WIDTH_RATIO,
fontSize: 17 * DEVICE_WIDTH_RATIO,
lineHeight: 31 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
color: '#b0b0b0',
},
imageContainer: {
width: width,
height: 175 * DEVICE_WIDTH_RATIO,
position: 'relative',
alignItems: 'center',
},
bgImage: {
position: 'absolute',
width: width,
height: 175 * DEVICE_WIDTH_RATIO,
resizeMode: 'cover',
},
imageText: {
backgroundColor: 'transparent',
color: 'white',
},
text1: {
marginTop: 25 * DEVICE_WIDTH_RATIO,
fontSize: 12 *DEVICE_WIDTH_RATIO,
},
text2: {
marginTop: 15 * DEVICE_WIDTH_RATIO,
fontSize: 24 * DEVICE_WIDTH_RATIO,
marginBottom: 5 * DEVICE_WIDTH_RATIO,
},
titleContainer: {
width: width,
flexDirection: 'row',
justifyContent: 'space-between',
height: 42 * DEVICE_WIDTH_RATIO,
},
productText:{
width: imageContainerWidth,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
justifyContent: 'center',
height: 42 * DEVICE_WIDTH_RATIO,
fontSize: 16 * DEVICE_WIDTH_RATIO,
lineHeight: 29 * DEVICE_WIDTH_RATIO,
textAlign:'center',
textAlignVertical:'center',
backgroundColor: 'white',
},
});
... ...
... ... @@ -25,6 +25,10 @@ export default class Installment extends React.Component {
});
}
componentDidMount() {
this.props.getNewUserPageInfo();
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
... ... @@ -88,8 +92,8 @@ let styles = StyleSheet.create({
contentContainer:{
flexDirection: 'row',
flexWrap: 'wrap',
},
},
listContainer: {
width: width / 2,
},
});
\ No newline at end of file
},
});
... ...
... ... @@ -25,4 +25,13 @@ export default keyMirror({
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO: null,
SET_INSTALLMENT_STATUS_PAGE_GOODS: null,
SET_STATUS_PAGE_ADVERTISEMENT: null,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX: null,
SET_ALREADY_PAGE_GOODS: null,
SET_ALREADY_PAGE_CONTENT: null,
SET_ALREADY_PAGE_NOTICE: null,
SET_ALREADY_PAGE_AMT_INFO: null,
SET_ALREADY_PAGE_OVERDUE_STATUS: null,
SET_ALREADY_PAGE_CREDIT_INFO: null,
});
... ...
... ... @@ -16,6 +16,9 @@ import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import Installment from '../components/installment/Installment';
import AlreadyOpened from '../components/installment/AlreadyOpened';
import InstallmentStatus from '../components/installment/InstallmentStatus';
const actions = [
installmentActions,
];
... ... @@ -41,11 +44,24 @@ class InstallmentContainer extends Component {
super(props);
this._onPressOpenInstallment = this._onPressOpenInstallment.bind(this);
this._onPressMoreProducts = this._onPressMoreProducts.bind(this);
this._onPressTabBtn = this._onPressTabBtn.bind(this);
this._getAlreadyPageInfo = this._getAlreadyPageInfo.bind(this);
this._getNewUserPageInfo = this._getNewUserPageInfo.bind(this);
this._onPressMoreProducts = this._onPressMoreProducts.bind(this);
this._onPressProtocol = this._onPressProtocol.bind(this);
}
componentDidMount() {
this.props.actions.getInstallmentStatus();
}
_getNewUserPageInfo() {
this.props.actions.productListForInstallment();
}
_getAlreadyPageInfo() {
this.props.actions.getAlreadyPageInfo();
}
_onPressOpenInstallment() {
this.props.actions.onPressOpenInstallment();
}
... ... @@ -54,17 +70,50 @@ class InstallmentContainer extends Component {
this.props.actions.onPressMoreProducts();
}
_onPressTabBtn(index) {
this.props.actions.setAlreadyPageTabFocusIndex(index);
}
_onPressProtocol() {
this.props.actions.onPressTabBtn();
}
render() {
let {isFetching,open,installmentStatus} = this.props.installment;
return (
<Installment
isFetching={open.isFetching}
productListForInstallment={open.productListForInstallment}
installmentInfo={open.installmentInfo}
onPressOpenInstallment={this._onPressOpenInstallment}
onPressMoreProducts={this._onPressMoreProducts}
/>
);
let {isFetching,open,alreadyOpenedPageInfo,installmentStatus,installmentStausPageInfo} = this.props.installment;
let {status} = installmentStatus;
if (status == 'New') {
return (
<Installment
getNewUserPageInfo={this._getNewUserPageInfo}
isFetching={open.isFetching}
productListForInstallment={open.productListForInstallment}
installmentInfo={open.installmentInfo}
onPressOpenInstallment={this._onPressOpenInstallment}
onPressMoreProducts={this._onPressMoreProducts}
/>
);
} else if (status == 'AlreadyOpned') {
return (
<AlreadyOpened
alreadyOpenedPageInfo={alreadyOpenedPageInfo}
onPressTabBtn={this._onPressTabBtn}
getAlreadyPageInfo={this._getAlreadyPageInfo}
onPressMoreProducts={this._onPressMoreProducts}
onPressProtocol={this._onPressProtocol}
/>
);
} else if (status == 'OpenStatus') {
let status = '5';
let failReason = '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。';
let uid = '5448919';
this.props.actions.setInstallmentStausPageParams(status,failReason,uid);
return (
<InstallmentStatus/>
)
} else {
return null;
}
}
}
let styles = StyleSheet.create({
... ...
... ... @@ -28,6 +28,15 @@ NEXT_BTN_PROCESSING_FAILURE,
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
SET_ALREADY_PAGE_GOODS,
SET_ALREADY_PAGE_CONTENT,
SET_ALREADY_PAGE_NOTICE,
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
const codeContent = {
... ... @@ -60,9 +69,10 @@ export function productListForInstallmentFailure(){
}
}
export function featchInstallmentStatusRequest() {
export function featchInstallmentStatusRequest(uid) {
return {
type: GET_INSTALLMENT_STATUS_REQUEST,
payload: uid
}
}
... ... @@ -159,6 +169,62 @@ export function setInstallmentStatusPageGoods(goods) {
}
}
export function setStatusPageAdvertisement(advertisement) {
return {
type: SET_STATUS_PAGE_ADVERTISEMENT,
payload: advertisement
}
}
export function setAlreadyPageTabFocusIndex(index) {
return {
type: SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
payload: index
}
}
export function setAlreadPageGoods(goods) {
return {
type: SET_ALREADY_PAGE_GOODS,
payload: goods
}
}
export function setAlreadPageContent(content) {
return {
type: SET_ALREADY_PAGE_CONTENT,
payload: content
}
}
export function setAlreadPageNotices(notice) {
return {
type: SET_ALREADY_PAGE_NOTICE,
payload: notice
}
}
export function setAlreadPageAmtInfo(info) {
return {
type: SET_ALREADY_PAGE_AMT_INFO,
payload: info
}
}//
export function setAlreadPageOverdueStatus(status) {
return {
type: SET_ALREADY_PAGE_OVERDUE_STATUS,
payload: status
}
}
export function setAlreadPageCreditInfo(creditInfo) {
return {
type: SET_ALREADY_PAGE_CREDIT_INFO,
payload: creditInfo,
}
}
export function productListForInstallment() {
return (dispatch, getState) => {
let {app, installment} = getState();
... ... @@ -217,14 +283,26 @@ export function getInstallmentStatus() {
let installmentStatus = (uid) => {
let {app, installment} = getState();
dispatch(featchInstallmentStatusRequest());
dispatch(featchInstallmentStatusRequest(uid));
return new InstallmentService(app.host).getStauts(uid)
.then(json => {
let status = 0;
if (json.status) {
status = json.status;
let status = 'New';
switch (json.status) {
case '0':
status = 'New';
break;
case '2':
status = 'AlreadyOpned';
break;
case '1':
case '3':
case '4':
case '5':
status = 'OpenStatus';
break;
default:
}
dispatch(productListForInstallment());
dispatch(featchInstallmentStatusSuccess(status));
})
.catch(error => {
dispatch(featchInstallmentStatusFailure(error));
... ... @@ -261,10 +339,10 @@ export function onPressOpenNext() {
let {nextBtnEnable,cellList,nextProcessing} = installment.openPageInfo;
let activateParams = {};
let newCellList = cellList;
if (!nextBtnEnable) {
return;
}
// ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('5', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
// if (!nextBtnEnable) {
// return;
// }
ReactNative.NativeModules.YH_InstallmentHelper.gotoInstallmentStatusView('2', '您的授信未通过,在有货更多的消费,增加信用度,会大大提升审核通过率奥。');
return;
cellList.map((item, i) => {
if (item.get('inputKey') != 'BankIcon') {
... ... @@ -273,11 +351,9 @@ export function onPressOpenNext() {
});
let activateService = (uid) => {
dispatch(nextBtnProcessingRequest());
console.log('----0000');
return new InstallmentService(app.host).checkVerifyCode(uid, activateParams.mobile, activateParams.snsCheckCode)
.then(json => {
if (json.result === '1') {
return new InstallmentService(app.host).activateService(activateParams)
}else {
newCellList.map((item, i) => {
... ... @@ -515,7 +591,7 @@ export function onPressCheckCode() {
if (snsCheckCodeEnable && snsCheckCodeText == '获取验证码') {
return new InstallmentService(app.host).sendVerifyCode('17705176933')
.then(json => {
let status = 0;
let snsText = '';
new Timer().startCountdown(function() {
... ... @@ -547,8 +623,6 @@ export function setInstallmentStausPageParams(statusCode, failReason, uid) {
//请求用户信用额度
return new InstallmentService(app.host).getQueryCreditInfo('5448919')
.then(json => {
console.log('---额度');
console.log(json);
status = 'success',
statusInfo = {
message: '可用额度',
... ... @@ -627,11 +701,17 @@ export function setInstallmentStausPageParams(statusCode, failReason, uid) {
export function getInstallmentProductAndAdvertisement(page) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getSearchIntallment(page)
return new InstallmentService(app.host).fetchInstallmentProductList(page)
.then(json => {
dispatch(setInstallmentStatusPageGoods(json.product_list))
console.log('goods');
console.log(json);
let content_code = codeContent['advertisement'];
return new InstallmentService(app.serviceHost).getResources(content_code)
})
.then(json => {
let advertisement = false;
if (json && json.length > 1) {
advertisement = json[0].data[0];
}
})
.catch(error => {
});
... ... @@ -650,3 +730,83 @@ export function onPressStatusPageBtn(page) {
}
};
}
function getAlreadPageGoods() {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).fetchInstallmentProductList(1)
.then(json => {
dispatch(setAlreadPageGoods(json.product_list))
})
.catch(error => {
});
};
}
function getAlreadPageResources() {
return (dispatch, getState) => {
let {app, installment} = getState();
let content_code = codeContent['openY'];
return new InstallmentService(app.serviceHost).getResources(content_code)
.then(json => {
dispatch(setAlreadPageContent(json))
})
.catch(error => {
});
};
}
function getAlreadPageNotices() {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getNotices()
.then(json => {
dispatch(setAlreadPageNotices(json))
})
.catch(error => {
});
};
}
function getAlreadPageAmtInfo(uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getAmtInfo(uid)
.then(json => {
json.dayAmt = json.s_7daysAmt;
dispatch(setAlreadPageAmtInfo(json))
})
.catch(error => {
});
};
}
function getAlreadPageCreditInfo(uid) {
return (dispatch, getState) => {
let {app, installment} = getState();
return new InstallmentService(app.host).getQueryCreditInfo(uid)
.then(json => {
dispatch(setAlreadPageCreditInfo(json))
})
.catch(error => {
});
};
}
export function getAlreadyPageInfo() {
return (dispatch, getState) => {
let {app, installment} = getState();
let {uid} = installment;
dispatch(getAlreadPageGoods());
dispatch(getAlreadPageResources());
dispatch(getAlreadPageNotices());
dispatch(getAlreadPageAmtInfo(uid));
dispatch(getAlreadPageCreditInfo(uid));
};
}
export function onPressTabBtn() {
return (dispatch, getState) => {
ReactNative.NativeModules.YH_InstallmentHelper.helpAction();
};
}
... ...
... ... @@ -44,9 +44,10 @@ let banks = ['农业银行', '中国银行', '工商银行', '建设银行', '
let InitialState = Record({
isFetching:false,
uid: '',
installmentStatus:new (Record({
isFetching:false,
status: 0,
status: '',
error: null,
})),
open:new (Record({
... ... @@ -57,6 +58,15 @@ let InitialState = Record({
})),
installmentInfo:'',
})),
alreadyOpenedPageInfo:new (Record({
tabFocusIndex: 1,
goods: List(),
isOverdue: false,
content: Map(),
notice: Map(),
installmentInfo:Map(),
creditInfo: Map(),
})),
openPageInfo:new (Record({ //开通有货分期页面数据
cellList: Immutable.fromJS(openPageParams),
agreeProtocol: true,
... ... @@ -76,6 +86,7 @@ let InitialState = Record({
jumpUrl: '',
statusInfo:Map(),
goods: List(),
advertisement: false,
})),
});
... ...
... ... @@ -28,6 +28,15 @@ const {
SET_INSTALLMENT_STATUS_PAGE_ORIGINAL_INFO,
SET_INSTALLMENT_STATUS_PAGE_GOODS,
SET_STATUS_PAGE_ADVERTISEMENT,
SET_ALREADY_PAGE_TAB_FOCUS_INDEX,
SET_ALREADY_PAGE_GOODS,
SET_ALREADY_PAGE_CONTENT,
SET_ALREADY_PAGE_NOTICE,
SET_ALREADY_PAGE_AMT_INFO,
SET_ALREADY_PAGE_OVERDUE_STATUS,
SET_ALREADY_PAGE_CREDIT_INFO,
} = require('../../constants/actionTypes').default;
... ... @@ -50,7 +59,8 @@ export default function appReducer(state = initialState, action) {
return state.setIn(['open', 'productListForInstallment'], productListForInstallment);
}
case GET_INSTALLMENT_STATUS_REQUEST:
return state.setIn(['installmentStatus', 'isFetching'], true);
return state.setIn(['installmentStatus', 'isFetching'], true)
.set('uid',action.payload);
case GET_INSTALLMENT_STATUS_SUCCESS:
return state.setIn(['installmentStatus', 'isFetching'], false)
.setIn(['installmentStatus', 'status'], action.payload);
... ... @@ -87,6 +97,22 @@ export default function appReducer(state = initialState, action) {
.setIn(['installmentStausPageInfo', 'statusInfo'], Immutable.fromJS(action.payload.statusInfo));
case SET_INSTALLMENT_STATUS_PAGE_GOODS:
return state.setIn(['installmentStausPageInfo', 'goods'], Immutable.fromJS(action.payload));
case SET_STATUS_PAGE_ADVERTISEMENT:
return state.setIn(['installmentStausPageInfo', 'advertisement'], action.payload);
case SET_ALREADY_PAGE_TAB_FOCUS_INDEX:
return state.setIn(['alreadyOpenedPageInfo', 'tabFocusIndex'], action.payload);
case SET_ALREADY_PAGE_GOODS:
return state.setIn(['alreadyOpenedPageInfo', 'goods'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_CONTENT:
return state.setIn(['alreadyOpenedPageInfo', 'content'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_NOTICE:
return state.setIn(['alreadyOpenedPageInfo', 'notice'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_AMT_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'installmentInfo'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_OVERDUE_STATUS:
return state.setIn(['alreadyOpenedPageInfo', 'isOverdue'], Immutable.fromJS(action.payload));
case SET_ALREADY_PAGE_CREDIT_INFO:
return state.setIn(['alreadyOpenedPageInfo', 'creditInfo'], Immutable.fromJS(action.payload));
}
return state;
... ...
... ... @@ -10,6 +10,8 @@ export default class InstallmentService {
}
this.api = new Request(baseURL);
}
// 分期专享推荐商品
async fetchInstallmentProductList(page=1) {
return await this.api.get({
url: '',
... ... @@ -28,6 +30,7 @@ export default class InstallmentService {
});
}
// 获取分期开通状态
async getStauts(uid) {
return await this.api.get({
url: '',
... ... @@ -44,6 +47,7 @@ export default class InstallmentService {
});
}
// 获取短信验证码
async sendVerifyCode(mobile) {
return await this.api.get({
url: '',
... ... @@ -62,6 +66,7 @@ export default class InstallmentService {
});
}
// 获取银行信息
async fentchBankInfo(cardNo,uid) {
return await this.api.get({
url: '',
... ... @@ -130,14 +135,13 @@ export default class InstallmentService {
});
}
async getSearchIntallment(page) {
// 获取用户可用额度信息
async getQueryCreditInfo(uid) {
return await this.api.get({
url: '',
body: {
method: 'app.search.instalment',
limit: '50',
order: 's_t_desc',
page: page
method: 'user.instalment.queryCreditLimit',
uid,
}
})
.then((json) => {
... ... @@ -148,11 +152,32 @@ export default class InstallmentService {
});
}
async getQueryCreditInfo(uid) {
/**
* 获取资源位数据
* @return {[array]}
*/
async getResources(content_code) {
return await this.api.get({
url: '/operations/api/v5/resource/get',
body: {
content_code,
platform: 'iphone'
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
// 获取用户待还款金额
async getAmtInfo(uid) {
return await this.api.get({
url: '',
body: {
method: 'user.instalment.queryCreditLimit',
method: 'app.order.queryAmtInfo',
uid,
}
})
... ... @@ -164,12 +189,14 @@ export default class InstallmentService {
});
}
async getResources(content_code) {
return await this.serviceAPI.get({
url: '/operations/api/v5/resource/get',
// 公告
async getNotices() {
return await this.api.get({
url: '',
body: {
content_code,
platform: 'iphone'
method: 'app.resources.getNotices',
position: 8,
client_type: 'iphone'
}
})
.then((json) => {
... ...