Authored by 孙凯

修改 品牌列表页 快速选择不准的bug review by hongmo

... ... @@ -4,6 +4,7 @@ import React from 'react';
import ReactNative from 'react-native';
import {isEmptyObject} from '../../utils/Utils';
import Immutable, {Map} from 'immutable';
import * as _ from 'lodash';
const {
View,
... ... @@ -19,6 +20,10 @@ export default class IndexListView extends React.Component {
constructor(props) {
super (props);
this.onTouchMove = this.onTouchMove.bind(this);
this.state = {
list:[]
};
}
shouldComponentUpdate(nextProps){
... ... @@ -31,10 +36,25 @@ export default class IndexListView extends React.Component {
onTouchMove(e) {
let {dataSource} = this.props;
let Y = e.nativeEvent.pageY - Math.ceil((viewHeight - dataSource.length * (itemHeight+2))/2) - 8;
var index = Math.ceil(Y/(itemHeight+2))-1;
let sectionID = dataSource[index];
this.props.onLetterPress && this.props.onLetterPress(index,sectionID);
let Y = e.nativeEvent.pageY;
for (var i = 0; i < this.state.list.length; i++) {
if (Y > this.state.list[i].y && Y < this.state.list[i].y + 12) {
let name = this.state.list[i].name;
if (name == '0') {
name = '0-9';
}
this.props.onLetterPress && this.props.onLetterPress(i,name);
break;
}
}
}
onLayout(name,e) {
let {y} = e.nativeEvent.layout;
let Y = {'name':name,'y':y}
let list = this.state.list;
list.push(Y);
this.setState(list)
}
render() {
... ... @@ -52,7 +72,9 @@ export default class IndexListView extends React.Component {
if (name == '0-9') {
name = '0';
}
keyData.push(<Text key={i} style={styles.text}>{name}</Text>);
keyData.push(<View key={i} style={styles.TV} onLayout={this.onLayout.bind(this, name)}><Text style={styles.text}>{name}</Text></View>);
}
return (
... ... @@ -78,13 +100,20 @@ let styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
TV: {
width: 12,
height: 12,
backgroundColor: 'transparent',
marginTop: 2,
justifyContent: 'center',
},
text: {
justifyContent: 'center',
textAlign: 'center',
fontSize: 11,
color: 'black',
backgroundColor: 'transparent',
marginTop: 2,
fontWeight: 'bold',
},
image: {
... ...
... ... @@ -158,19 +158,27 @@ export default function redBrandReducer(state=initialState, action) {
case ADD_FAVORITE_SUCCESS: {
if (action.payload) {
return state.setIn(['shopIntro', 'is_addFav'], true)
.setIn(['receiveCouponResult', 'showMessage'], '收藏成功')
.setIn(['receiveCouponResult', 'isNeedShow'], true);
// .setIn(['shopIntro', 'favoriteCount'],parseInt(state.shopIntro.favoriteCount) +1);
}else {
return state.setIn(['shopIntro', 'is_addFav'], true);
return state.setIn(['shopIntro', 'is_addFav'], true)
}
}
case ADD_FAVORITE_FAILURE: {
if (action.payload.code == 413) {
return state.setIn(['shopIntro', 'is_addFav'], true);
return state.setIn(['shopIntro', 'is_addFav'], true)
.setIn(['receiveCouponResult', 'showMessage'], '已收藏')
.setIn(['receiveCouponResult', 'isNeedShow'], true);
}
return state.setIn(['shopIntro', 'is_addFav'], false);
return state.setIn(['shopIntro', 'is_addFav'], false)
.setIn(['receiveCouponResult', 'showMessage'], '收藏失败')
.setIn(['receiveCouponResult', 'isNeedShow'], true);
}
case CANCEL_FAVORITE_SUCCESS: {
return state.setIn(['shopIntro', 'is_addFav'], action.payload)
.setIn(['receiveCouponResult', 'showMessage'], '取消收藏成功')
.setIn(['receiveCouponResult', 'isNeedShow'], true);
// .setIn(['shopIntro', 'favoriteCount'],(parseInt(state.shopIntro.favoriteCount) -1)>0?(parseInt(state.shopIntro.favoriteCount) -1):0);
}
case GET_FAVORITE_COUNT_SUCCESS: {
... ...