Authored by chenl

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

# Conflicts:
#	js/myAssets/components/purchaseCode/LimitCodeProductsCell.js
增加我的银行卡页面。
... ... @@ -114,7 +114,7 @@ export default class List extends Component {
<Text style={styles.text}>{publish_time}</Text>
<Image source={require('../../image/shared_view_icon.png')} style={styles.iconThumb}resizeMode={'contain'}></Image>
<Text style={styles.text}>{views_num}</Text>
<TouchableOpacity activeOpacity={1.0} style={styles.likeButton} onPress={()=>{this.props.onPressLike&&this.props.onPressLike(id, isLike)}}>
<TouchableOpacity activeOpacity={1.0} style={styles.likeButton} onPress={()=>{this.props.onPressLike&&this.props.onPressLike(id, isLike, this.props.rowID)}}>
<Image source={likeImg}/>
</TouchableOpacity>
<TouchableOpacity activeOpacity={1.0} style={styles.shareButton} onPress={()=>{this.props.onPressShare&&this.props.onPressShare(shareParam)}}>
... ...
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
LayoutAnimation,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import BankCardListCell from './BankCardListCell';
export default class BankCardList extends React.Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<BankCardListCell
cardNo={"656132156465465"}
cardBank={"icbc"}
/>
);
}
render() {
let cardList = ['65325165465321654','99999999999999'];
return (
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRows(cardList)}
enableEmptySections={true}
renderRow={this.renderRow}
/>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
... ...
... ... @@ -6,108 +6,72 @@ import ReactNative, {
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
Alert,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class RepayList extends React.Component {
export default class BankCardListCell extends React.Component {
constructor(props) {
super(props);
}
render() {
let{dataSource}=this.props;
dataSource = dataSource.toJS();
let checked = dataSource.isChecked;
let checkboxIcon = require('../../image/check_icon.png');
if (!checked) {
checkboxIcon = require('../../image/uncheck_icon.png');
}
return(
<View style={styles.container}>
<View style={styles.cellContainer}>
<View style={styles.cellLeftContainer}>
<TouchableOpacity onPress={() => {this.props.onPressRepaylistCellCheckbox &&this.props.onPressRepaylistCellCheckbox(dataSource)}} >
<Image style={styles.checkboxIcon} source={checkboxIcon}/>
</TouchableOpacity>
<View style={styles.priceContainer}>
<Text style={{marginLeft:5*DEVICE_WIDTH_RATIO}}>¥{dataSource.currAmt}</Text>
<Text numberOfLines={1}>【全{dataSource.stage}期】{dataSource.billInfo}</Text>
</View>
let{cardNo, cardBank} = this.props;
</View>
<TouchableOpacity onPress={() => {this.props.onPressRepaylistCellDetail &&this.props.onPressRepaylistCellDetail(dataSource)}} >
{dataSource.isOverdue?
<View style={styles.cellRightContainer}>
<Text style={{color:'#d0021b',fontSize:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}}>逾期{dataSource.day}</Text>
<TouchableOpacity style={styles.bankTip} onPress={() => Alert.alert('逾期服务费信息','如果您到期未还款:需要加收逾期利息费和延迟还款费\n逾期利息费:待还本金 *利息率*延迟还款天数,利息率=0.025%/天\n延迟还款费:逾期3天内还款免收延迟还款服务费,逾期4天,从第一天逾期开始算,500元之内,加收1元/天延迟还款服务费。每500元增加1元/天。',[
{text: '我知道了'},
])} >
<Image style={{width:12*DEVICE_WIDTH_RATIO,height:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/red_question_icon.png")}/>
</TouchableOpacity>
<Image style={{marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/category_b_arrow.png")}/>
</View>
:<View style={styles.cellRightContainer}>
<Text style={{color:'#b0b0b0',fontSize:12*DEVICE_WIDTH_RATIO,marginRight:5*DEVICE_WIDTH_RATIO}}>剩余{dataSource.day}</Text>
<Image style={{marginRight:5*DEVICE_WIDTH_RATIO}} source={require("../../image/category_b_arrow.png")}/>
</View>
}
</TouchableOpacity>
let bankImg = this.getBankImage(cardBank);
return(
<TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressCard && this.props.onPressCard()}>
<View style={styles.container} >
<Image style={styles.cardBg} source={bankImg} />
<Text style={styles.cardNo} numberOfLines={1}>
{cardNo}
</Text>
</View>
</TouchableOpacity>
);
}
<View style={{
width: width,
height: 0.5 * DEVICE_WIDTH_RATIO,
backgroundColor: '#e5e5e5',
}}/>
</View>
);
getBankImage(bank){
let bankImg;
switch(bank){
case "CITIC":
bankImg = require('../../image/bank/bank-CITIC.png');
break;
case "ICBC":
bankImg = require('../../image/bank/bank-ICBC.png');
break;
default:
bankImg = require('../../image/bank/bank-ICBC.png');
break;
}
return bankImg;
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
width: width,
height: 61 * DEVICE_WIDTH_RATIO,
},
cellContainer: {
width: width,
height: 60.5 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
justifyContent: 'space-between',
justifyContent: 'center',
},
checkboxIcon: {
width: 15 * DEVICE_WIDTH_RATIO,
height: 15 * DEVICE_WIDTH_RATIO,
marginLeft: 15 * DEVICE_WIDTH_RATIO,
},
cellLeftContainer: {
flexDirection: 'row',
width: 190 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
cardBg:{
width: 290 * DEVICE_WIDTH_RATIO,
height: 100 * DEVICE_WIDTH_RATIO,
},
priceContainer: {
width: 160 * DEVICE_WIDTH_RATIO,
height: 40 * DEVICE_WIDTH_RATIO,
marginTop: 10 * DEVICE_WIDTH_RATIO,
},
cellRightContainer: {
marginRight: 15 * DEVICE_WIDTH_RATIO,
height: 60 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
flexDirection: 'row',
cardNo:{
position: 'absolute',
top: 60,
left: 200,
}
});
... ...
... ... @@ -19,6 +19,8 @@ import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as cardListActions from '../reducers/bankCardList/cardListActions';
import ServerError from '../components/installment/ServerError';
import BankCardList from '../components/installment/BankCardList';
const actions = [
cardListActions,
... ... @@ -41,44 +43,25 @@ function mapDispatchToProps(dispatch) {
};
}
class InstallmentMyCardContainer extends Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
}
componentDidMount() {
this.props.actions.getBankCards();
}
renderRow(rowData, sectionID, rowID, highlightRow) {
// console.log(rowData)
return (
<TouchableOpacity activeOpacity={1} onPress={() => this.props.onSelectCategory && this.props.onSelectCategory(rowData.toJS(),rowID)}>
<View style={styles.cardBg} >
<Image style={styles.cardNo} source={require('../image/bank/bank-CITIC.png')} />
<Text style={styles.cardNo} numberOfLines={1}>
{rowData}
</Text>
</View>
</TouchableOpacity>
);
componentDidMount() {
// this.props.actions.getBankCards();
}
render() {
let cardList = ['65325165465321654','99999999999999'];
return (
<View style={styles.container}>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRows(cardList)}
enableEmptySections={true}
renderRow={this.renderRow}
/>
</View>
<BankCardList
style={styles.container}
cardList={cardList}
/>
);
}
}
... ... @@ -87,13 +70,6 @@ let styles = StyleSheet.create({
flex: 1,
},
cardBg:{
backgroundColor: "#00ff00",
},
cardNo:{
}
});
... ...
... ... @@ -233,7 +233,7 @@ export function productListForInstallment() {
export function onPressOpenInstallment() {
return (dispatch, getState) => {
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentOpen","params":{}}`;
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.instalmentMyCard","params":{}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
}
... ...
... ... @@ -86,7 +86,7 @@ export default class MessageList extends Component {
}
break;
case 500:
case 406:
case 307:
{
return(
<MessageListActivityCell
... ...
... ... @@ -66,8 +66,8 @@ class MineGuangContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.shareWithParam(param);
}
_onPressLike(article_id, isLike) {
this.props.actions.onPressLike(article_id, isLike);
_onPressLike(article_id,isLike,rowID) {
this.props.actions.onPressLike(article_id,rowID);
}
_onEndReached() {
... ...
... ... @@ -64,8 +64,6 @@ export function fetchUserFavArticleList() {
}
return new MineGuangService(app.serviceHost).getUserFavArticleList(params)
.then(json => {
console.log('------mine guang');
console.log(json);
if (favArticleList && favArticleList.size) {
favArticleList = favArticleList.toJS();
}
... ... @@ -75,8 +73,6 @@ export function fetchUserFavArticleList() {
dispatch(fetchSimpleArticleList(json.data))
})
.catch(error => {
console.log('------error');
console.log(error);
dispatch(fetchUserFavArticleListFailure(error));
})
}
... ... @@ -112,16 +108,10 @@ export function fetchSimpleArticleList(favArticleList) {
return new MineGuangService(app.serviceHost).getSimpleArticleList(params)
.then(json => {
//将请求到的文章相关数据合并到favArticleList
console.log('------mine guang');
console.log(json);
let newFavArticleList = mergeSimpleArticleToFavList(favArticleList,json.artList);
console.log('------merged');
console.log(newFavArticleList);
dispatch(updateUserFavArticleList(newFavArticleList));
})
.catch(error => {
console.log('------error');
console.log(error);
})
}
... ... @@ -157,28 +147,28 @@ function mergeSimpleArticleToFavList(favArticleList,simpleArticleList) {
return favArticleList;
}
export function onPressLike(article_id, isLike) {
export function onPressLike(article_id,rowID) {
return (dispatch, getState) => {
let {app, mineGuang} = getState();
let likeRequest = (article_id, uid, isLike) => {
// dispatch(likeArticle({article_id, isLike}));
//
// if (isLike) {
// return new ListService(app.serviceHost).setArticleFavorite(article_id, uid)
// }else {
// return new ListService(app.serviceHost).cancleArticleFavorite(article_id, uid)
// }
let {userFavArticleList} = mineGuang;
let {favArticleList} = userFavArticleList;
let likeRequest = (article_id, uid) => {
if (!favArticleList || favArticleList.size == 0) {
return;
}
let newFavArticleList = favArticleList.delete(rowID);
dispatch(updateUserFavArticleList(newFavArticleList));
return new MineGuangService(app.serviceHost).cancelFavorite({article_id,uid});
}
ReactNative.NativeModules.YH_CommonHelper.uid()
.then(uid => {
likeRequest(article_id, uid, isLike);
likeRequest(article_id, uid);
})
.catch(error => {
ReactNative.NativeModules.YH_CommonHelper.login()
.then(uid => {
likeRequest(article_id, uid, isLike);
likeRequest(article_id, uid);
})
.catch(error => {
... ...
... ... @@ -41,4 +41,19 @@ export default class MineGuangService {
throw(error);
});
}
async cancelFavorite(params) {
return await this.api.get({
url: '/guang/api/v1/favorite/cancelFavorite',
body: {
...params,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
}
... ...
... ... @@ -40,6 +40,8 @@ export default class LimitCodeProductsCell extends React.Component {
let defaultUrl = data.defaultUrl;
let newSrc = getSlicedUrl(defaultUrl, 100, 100);
let price = data.price;
let priceNum = price.replace('¥', '');
let priceColor = parseFloat(priceNum) > 0 ? 'black' : '#b0b0b0';
let productName = data.productName;
let limitCode = data.limitCode;
let limitCodeTitle = '限购码: ' + limitCode;
... ... @@ -65,7 +67,7 @@ export default class LimitCodeProductsCell extends React.Component {
/>
<View style={styles.detailView}>
<Text style={styles.nameText} numberOfLines={2}>{productName}</Text>
<Text style={styles.priceText}>{price}</Text>
<Text style={{width: width - productIconWidth - 60,fontSize: 13,color: priceColor,marginTop: 15,marginLeft: 10,}}>{price}</Text>
</View>
</View>
</TouchableOpacity>
... ... @@ -124,13 +126,6 @@ let styles = StyleSheet.create({
width: width - productIconWidth - 30,
height: backgroundHeigth - titleHeigth - 1,
},
priceText: {
width: width - productIconWidth - 60,
fontSize: 13,
color: 'black',
marginTop: 15,
marginLeft: 10,
},
nameText: {
width: width - productIconWidth - 60,
fontSize: 13,
... ...