Authored by 于良

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

@@ -119,8 +119,8 @@ export default class Browse extends Component { @@ -119,8 +119,8 @@ export default class Browse extends Component {
119 data={categoryList} 119 data={categoryList}
120 selectedCategoryIndex={selectedCategoryIndex} 120 selectedCategoryIndex={selectedCategoryIndex}
121 onPressCategory={(rowData, rowID) => { 121 onPressCategory={(rowData, rowID) => {
122 - this.props.onPressCategory && this.props.onPressCategory(rowData, rowID);  
123 this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true}); 122 this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
  123 + this.props.onPressCategory && this.props.onPressCategory(rowData, rowID);
124 }} 124 }}
125 /> 125 />
126 ); 126 );
@@ -8,7 +8,9 @@ import ReactNative, { @@ -8,7 +8,9 @@ import ReactNative, {
8 ListView, 8 ListView,
9 TouchableOpacity, 9 TouchableOpacity,
10 StyleSheet, 10 StyleSheet,
11 - Dimensions 11 + Dimensions,
  12 + Animated,
  13 + Easing
12 } from 'react-native'; 14 } from 'react-native';
13 import Immutable, {Map, List} from 'immutable'; 15 import Immutable, {Map, List} from 'immutable';
14 16
@@ -21,6 +23,10 @@ export default class ProductCell extends Component { @@ -21,6 +23,10 @@ export default class ProductCell extends Component {
21 super(props); 23 super(props);
22 24
23 this.renderReduce = this.renderReduce.bind(this); 25 this.renderReduce = this.renderReduce.bind(this);
  26 +
  27 + this.state = {
  28 + marginLeft: new Animated.Value(0)
  29 + }
24 } 30 }
25 31
26 renderReduce() { 32 renderReduce() {
@@ -48,6 +54,14 @@ export default class ProductCell extends Component { @@ -48,6 +54,14 @@ export default class ProductCell extends Component {
48 ); 54 );
49 } 55 }
50 56
  57 + // componentWillReceiveProps(nextProps) {
  58 + // if (this.props.data.isDeleting
  59 + // && this.props.data.isDeleting != nextProps.data.isDeleting) {
  60 + // this.state.currentlyOpenSwipeable && this.state.currentlyOpenSwipeable.recenter();
  61 + // this.setState({currentlyOpenSwipeable: null});
  62 + // }
  63 + // }
  64 +
51 render() { 65 render() {
52 66
53 let data = this.props.data; 67 let data = this.props.data;
@@ -77,62 +91,78 @@ export default class ProductCell extends Component { @@ -77,62 +91,78 @@ export default class ProductCell extends Component {
77 let {editing, editedRow, rowID} = this.props; 91 let {editing, editedRow, rowID} = this.props;
78 let showLeft = editing && editedRow != rowID; 92 let showLeft = editing && editedRow != rowID;
79 let showTail = editing && editedRow == rowID; 93 let showTail = editing && editedRow == rowID;
80 - let marginLeft = showTail?-70:0; 94 + let marginLeft = showTail
  95 + ? -70
  96 + : 0;
  97 +
  98 + Animated.timing(this.state.marginLeft, {
  99 + toValue: marginLeft,
  100 + duration: 150,
  101 + easing: Easing.linear
  102 + }).start();
81 return ( 103 return (
82 <View style={styles.fatherContainer}> 104 <View style={styles.fatherContainer}>
83 {showLeft 105 {showLeft
84 ? <TouchableOpacity activeOpacity={1} style={styles.deleteContainer} onPress={() => { 106 ? <TouchableOpacity activeOpacity={1} style={styles.deleteContainer} onPress={() => {
85 - this.props.setEditedIndex && this.props.setEditedIndex(rowID);  
86 - }}> 107 + this.props.setEditedIndex && this.props.setEditedIndex(rowID);
  108 + }}>
87 <View style={styles.deleteCircle}> 109 <View style={styles.deleteCircle}>
88 <View style={styles.deleteBar}/> 110 <View style={styles.deleteBar}/>
89 </View> 111 </View>
90 </TouchableOpacity> 112 </TouchableOpacity>
91 : null} 113 : null}
92 114
93 - <TouchableOpacity activeOpacity={1} style={[styles.container, {marginLeft}]} onPress={() => {  
94 - this.props.onPressProduct && this.props.onPressProduct(data);  
95 - }}>  
96 - <View style={styles.container}>  
97 - <View style={styles.leftContainer}>  
98 - <YH_Image style={styles.prdImage} url={prdImage}/>  
99 - <View>  
100 - <Text style={styles.prdName} numberOfLines={2}>{data.get('product_name', '')}</Text>  
101 - {this.renderReduce()}  
102 - </View>  
103 - </View>  
104 - <Image style={styles.arrow} source={require('../../images/browse/shared_next_icon.png')}/> 115 + <Animated.View style={[
  116 + styles.container, {
  117 + marginLeft: this.state.marginLeft
  118 + }
  119 + ]}>
105 120
106 - <View style={styles.priceContainer}>  
107 - <Text style={[  
108 - styles.nowPrice, {  
109 - color: salePriceColor  
110 - }  
111 - ]} numberOfLines={1}>{salePriceStr}</Text>  
112 - {showOriginPrice  
113 - ? <DeleteLineText style={styles.oldPriceContainer} textStyle={styles.oldPrice} lineStyle={styles.deleteLine} text={originPriceStr}/>  
114 - : null}  
115 - </View>  
116 - {showSoldOut  
117 - ? <View style={styles.soldOutContainer}>  
118 - <Text style={styles.soldOut}>{'已售罄'}</Text> 121 + <TouchableOpacity activeOpacity={1} style={[styles.container]} onPress={() => {
  122 + this.props.onPressProduct && this.props.onPressProduct(data);
  123 + }}>
  124 + <View style={styles.container}>
  125 + <View style={styles.leftContainer}>
  126 + <YH_Image style={styles.prdImage} url={prdImage}/>
  127 + <View>
  128 + <Text style={styles.prdName} numberOfLines={2}>{data.get('product_name', '')}</Text>
  129 + {this.renderReduce()}
119 </View> 130 </View>
120 - : null} 131 + </View>
  132 + <Image style={styles.arrow} source={require('../../images/browse/shared_next_icon.png')}/>
121 133
122 - <TouchableOpacity activeOpacity={1} style={styles.similar} onPress={() => {  
123 - this.props.onPressFindSimilar && this.props.onPressFindSimilar(data);  
124 - }}>  
125 - <Image source={require('../../images/browse/shopcart_findResemblance.png')}/>  
126 - </TouchableOpacity> 134 + <View style={styles.priceContainer}>
  135 + <Text style={[
  136 + styles.nowPrice, {
  137 + color: salePriceColor
  138 + }
  139 + ]} numberOfLines={1}>{salePriceStr}</Text>
  140 + {showOriginPrice
  141 + ? <DeleteLineText style={styles.oldPriceContainer} textStyle={styles.oldPrice} lineStyle={styles.deleteLine} text={originPriceStr}/>
  142 + : null}
  143 + </View>
  144 + {showSoldOut
  145 + ? <View style={styles.soldOutContainer}>
  146 + <Text style={styles.soldOut}>{'已售罄'}</Text>
  147 + </View>
  148 + : null}
  149 + {this.props.currentTab != 'global'
  150 + ? <TouchableOpacity activeOpacity={1} style={styles.similar} onPress={() => {
  151 + this.props.onPressFindSimilar && this.props.onPressFindSimilar(data);
  152 + }}>
  153 + <Image source={require('../../images/browse/shopcart_findResemblance.png')}/>
  154 + </TouchableOpacity>
  155 + : null}
127 156
128 - <View style={styles.separator}/>  
129 - </View>  
130 - </TouchableOpacity> 157 + <View style={styles.separator}/>
  158 + </View>
  159 + </TouchableOpacity>
  160 + </Animated.View>
131 161
132 {showTail 162 {showTail
133 ? <TouchableOpacity activeOpacity={1} style={styles.tailContainer} onPress={() => { 163 ? <TouchableOpacity activeOpacity={1} style={styles.tailContainer} onPress={() => {
134 - this.props.onPressDelete && this.props.onPressDelete(data, rowID);  
135 - }}> 164 + this.props.onPressDelete && this.props.onPressDelete(data, rowID);
  165 + }}>
136 <Text style={styles.tailText}>删除</Text> 166 <Text style={styles.tailText}>删除</Text>
137 </TouchableOpacity> 167 </TouchableOpacity>
138 : null} 168 : null}
@@ -155,27 +185,28 @@ let styles = StyleSheet.create({ @@ -155,27 +185,28 @@ let styles = StyleSheet.create({
155 fatherContainer: { 185 fatherContainer: {
156 flexDirection: 'row', 186 flexDirection: 'row',
157 alignItems: 'center', 187 alignItems: 'center',
158 - backgroundColor: 'white', 188 + backgroundColor: 'white'
159 }, 189 },
160 deleteContainer: { 190 deleteContainer: {
161 - width: 50, 191 + width: 40,
162 height: 70, 192 height: 70,
163 alignItems: 'center', 193 alignItems: 'center',
164 justifyContent: 'center', 194 justifyContent: 'center',
165 - backgroundColor : 'white', 195 + backgroundColor: 'white',
  196 + paddingLeft: 5
166 }, 197 },
167 deleteCircle: { 198 deleteCircle: {
168 - width: 15,  
169 - height: 15,  
170 - borderRadius: 7.5, 199 + width: 22,
  200 + height: 22,
  201 + borderRadius: 11,
171 backgroundColor: 'red', 202 backgroundColor: 'red',
172 flexDirection: 'row', 203 flexDirection: 'row',
173 alignItems: 'center', 204 alignItems: 'center',
174 justifyContent: 'center' 205 justifyContent: 'center'
175 }, 206 },
176 deleteBar: { 207 deleteBar: {
177 - width: 6,  
178 - height: 1, 208 + width: 11,
  209 + height: 1.5,
179 backgroundColor: 'white' 210 backgroundColor: 'white'
180 }, 211 },
181 tailContainer: { 212 tailContainer: {
@@ -58,6 +58,7 @@ export default class Product extends Component { @@ -58,6 +58,7 @@ export default class Product extends Component {
58 if (currentlyOpenSwipeable) { 58 if (currentlyOpenSwipeable) {
59 currentlyOpenSwipeable.recenter(); 59 currentlyOpenSwipeable.recenter();
60 } 60 }
  61 + this.props.setEditedIndex && this.props.setEditedIndex(-1);
61 } 62 }
62 63
63 onOpen(event, gestureState, swipeable) { 64 onOpen(event, gestureState, swipeable) {
@@ -131,6 +132,7 @@ export default class Product extends Component { @@ -131,6 +132,7 @@ export default class Product extends Component {
131 rowID={parseInt(rowID)} 132 rowID={parseInt(rowID)}
132 setEditedIndex={this.props.setEditedIndex} 133 setEditedIndex={this.props.setEditedIndex}
133 onPressDelete={this.props.onPressDelete} 134 onPressDelete={this.props.onPressDelete}
  135 + currentTab={currentTab}
134 /> 136 />
135 </Swipeable> 137 </Swipeable>
136 ); 138 );
@@ -201,8 +203,8 @@ export default class Product extends Component { @@ -201,8 +203,8 @@ export default class Product extends Component {
201 data={categoryList} 203 data={categoryList}
202 selectedCategoryIndex={selectedCategoryIndex} 204 selectedCategoryIndex={selectedCategoryIndex}
203 onPressCategory={(rowData, rowID) => { 205 onPressCategory={(rowData, rowID) => {
  206 + this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false});
204 this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); 207 this.props.onPressCategory && this.props.onPressCategory(rowData, rowID);
205 - this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});  
206 }} 208 }}
207 /> 209 />
208 ); 210 );
@@ -82,7 +82,7 @@ class BrandContainer extends Component { @@ -82,7 +82,7 @@ class BrandContainer extends Component {
82 let isGlobalProduct = product.get('is_global', 'N') == 'Y'; // 是否全球购商品 82 let isGlobalProduct = product.get('is_global', 'N') == 'Y'; // 是否全球购商品
83 let action = ''; 83 let action = '';
84 if (isGlobalProduct) { 84 if (isGlobalProduct) {
85 - 85 + action = 'go.globalpurchase';
86 } else { 86 } else {
87 action = 'go.productDetail'; 87 action = 'go.productDetail';
88 } 88 }
@@ -78,17 +78,33 @@ class ProductContainer extends Component { @@ -78,17 +78,33 @@ class ProductContainer extends Component {
78 } 78 }
79 79
80 onPressCategory(data, index) { 80 onPressCategory(data, index) {
  81 + let {editing} = this.props.product;
  82 + if (editing) {
  83 + this.props.actions.setEditedIndex(-1);
  84 + }
81 this.props.actions.setSelectedCategory(data.get('category_id'), index); 85 this.props.actions.setSelectedCategory(data.get('category_id'), index);
82 } 86 }
83 87
84 onPressProduct(data) { 88 onPressProduct(data) {
  89 + let {editing} = this.props.product;
  90 + if (editing) {
  91 + this.props.actions.setEditedIndex(-1);
  92 + return;
  93 + }
85 let productSkn = data.get('product_skn', 0); 94 let productSkn = data.get('product_skn', 0);
86 if (!productSkn) { 95 if (!productSkn) {
87 return; 96 return;
88 } 97 }
  98 + let {currentTab} = this.props.product;
  99 + if (currentTab == 'common') {
  100 + let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${productSkn}"}}`;
  101 + ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
  102 + }
  103 + if (currentTab == 'global') {
  104 + let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.globalpurchase","params":{"skn":"${productSkn}"}}`;
  105 + ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
  106 + }
89 107
90 - let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${productSkn}"}}`;  
91 - ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);  
92 } 108 }
93 109
94 onPressFindSimilar(data) { 110 onPressFindSimilar(data) {