Authored by 孙凯

add share review hongyong

@@ -61,7 +61,7 @@ export default class Home extends Component { @@ -61,7 +61,7 @@ export default class Home extends Component {
61 key={'row' + rowID} 61 key={'row' + rowID}
62 rowID={rowID} 62 rowID={rowID}
63 data={rowData} 63 data={rowData}
64 - onPressProduct={() => this.props.onPressProduct(rowData)} 64 + onPressProduct={this.props.onPressProduct}
65 /> 65 />
66 ); 66 );
67 } 67 }
@@ -249,21 +249,18 @@ let styles = StyleSheet.create({ @@ -249,21 +249,18 @@ let styles = StyleSheet.create({
249 width: width, 249 width: width,
250 }, 250 },
251 bannerMainTitle: { 251 bannerMainTitle: {
252 - fontFamily: 'SourceHanSansCN-Bold',  
253 fontSize: 16, 252 fontSize: 16,
254 color: '#000000', 253 color: '#000000',
255 textAlign:'center', 254 textAlign:'center',
256 marginTop:12, 255 marginTop:12,
257 }, 256 },
258 bannerSubTitle: { 257 bannerSubTitle: {
259 - fontFamily: 'SourceHanSansCN-Bold',  
260 fontSize:12, 258 fontSize:12,
261 color: '#000000', 259 color: '#000000',
262 textAlign:'center', 260 textAlign:'center',
263 marginTop:19, 261 marginTop:19,
264 }, 262 },
265 bannerContext: { 263 bannerContext: {
266 - fontFamily: ' SourceHanSansCN-Medium;',  
267 fontSize:9, 264 fontSize:9,
268 color: '#000000', 265 color: '#000000',
269 textAlign:'center', 266 textAlign:'center',
@@ -74,7 +74,6 @@ const styles = StyleSheet.create({ @@ -74,7 +74,6 @@ const styles = StyleSheet.create({
74 alignItems: 'center', 74 alignItems: 'center',
75 }, 75 },
76 rank: { 76 rank: {
77 - fontFamily: 'SanFranciscoText-Regular',  
78 fontSize: 18, 77 fontSize: 18,
79 color: '#444444', 78 color: '#444444',
80 marginLeft: 18 * DEVICE_WIDTH_RATIO, 79 marginLeft: 18 * DEVICE_WIDTH_RATIO,
@@ -99,7 +98,6 @@ const styles = StyleSheet.create({ @@ -99,7 +98,6 @@ const styles = StyleSheet.create({
99 paddingTop: 15 * DEVICE_WIDTH_RATIO, 98 paddingTop: 15 * DEVICE_WIDTH_RATIO,
100 }, 99 },
101 amount: { 100 amount: {
102 - fontFamily: 'SanFranciscoText-Regular',  
103 fontSize: 16, 101 fontSize: 16,
104 lineHeight: 19, 102 lineHeight: 19,
105 color: '#444444', 103 color: '#444444',
@@ -111,4 +109,4 @@ const styles = StyleSheet.create({ @@ -111,4 +109,4 @@ const styles = StyleSheet.create({
111 lineHeight: 17, 109 lineHeight: 17,
112 color: '#B0B0B0' 110 color: '#B0B0B0'
113 } 111 }
114 -})  
  112 +})
@@ -16,13 +16,27 @@ function mapStateToProps(store) { @@ -16,13 +16,27 @@ function mapStateToProps(store) {
16 } 16 }
17 17
18 class ShareDetail extends Component { 18 class ShareDetail extends Component {
19 - // state = { opacity: 0 }  
20 render() { 19 render() {
21 - let productInfo = this.props.shareDetail.get('productInfo').toJS();  
22 - let { goodsList: [ goodsInfo = {} ], productPriceBo = {} } = productInfo;  
23 - let { goodsImagesList } = goodsInfo; 20 + let {shareDetail} = this.props;
  21 + let shareDetailInfo = shareDetail ? shareDetail.toJS(): {};
  22 + let productInfo = shareDetailInfo.productInfo;
  23 +
  24 + let isCollect = shareDetail.isCollect;
  25 + if (!productInfo || productInfo == {}) {
  26 + return null
  27 + }
  28 + let goodsList = productInfo.goodsList;
  29 + let productPriceBo = productInfo.productPriceBo;
  30 + let goodsInfo = goodsList ? goodsList[0] : {};
  31 +
  32 + if (!goodsInfo || !productPriceBo) {
  33 + return null
  34 + }
  35 +
  36 + let goodsImagesList = goodsInfo ? goodsInfo.goodsImagesList: null;
24 let imgList = goodsImagesList && goodsImagesList.map(item => ({src: item.imageUrl})); 37 let imgList = goodsImagesList && goodsImagesList.map(item => ({src: item.imageUrl}));
25 imgList = Immutable.fromJS(imgList); 38 imgList = Immutable.fromJS(imgList);
  39 +
26 return ( 40 return (
27 <View style={styles.container}> 41 <View style={styles.container}>
28 <View style={[styles.navigatorBackground]}> 42 <View style={[styles.navigatorBackground]}>
@@ -78,7 +92,7 @@ class ShareDetail extends Component { @@ -78,7 +92,7 @@ class ShareDetail extends Component {
78 <Image 92 <Image
79 style={styles.favorite} 93 style={styles.favorite}
80 resizeMode="center" 94 resizeMode="center"
81 - source={productInfo.isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} /> 95 + source={isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} />
82 <Text style={styles.favText}>收藏</Text> 96 <Text style={styles.favText}>收藏</Text>
83 </TouchableOpacity> 97 </TouchableOpacity>
84 </View> 98 </View>
@@ -88,7 +102,7 @@ class ShareDetail extends Component { @@ -88,7 +102,7 @@ class ShareDetail extends Component {
88 <Text style={styles.btnText}>查看商品详情</Text> 102 <Text style={styles.btnText}>查看商品详情</Text>
89 </View> 103 </View>
90 </TouchableOpacity> 104 </TouchableOpacity>
91 - <TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(true)}> 105 + <TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(productInfo)}>
92 <View style={[styles.button, styles.center, styles.red]}> 106 <View style={[styles.button, styles.center, styles.red]}>
93 <Text style={styles.btnText}>{'分享可赚¥' + productInfo.rebatesAmount}</Text> 107 <Text style={styles.btnText}>{'分享可赚¥' + productInfo.rebatesAmount}</Text>
94 </View> 108 </View>
@@ -102,7 +116,6 @@ class ShareDetail extends Component { @@ -102,7 +116,6 @@ class ShareDetail extends Component {
102 changeOpacity(e) { 116 changeOpacity(e) {
103 let opacity = 1 - (500 - e.nativeEvent.contentOffset.y) / 500; 117 let opacity = 1 - (500 - e.nativeEvent.contentOffset.y) / 500;
104 this.setState({opacity: opacity < 0.4 ? opacity : 0.4}); 118 this.setState({opacity: opacity < 0.4 ? opacity : 0.4});
105 - console.log(e.nativeEvent.contentOffset.y);  
106 } 119 }
107 } 120 }
108 121
@@ -146,7 +159,6 @@ const styles = StyleSheet.create({ @@ -146,7 +159,6 @@ const styles = StyleSheet.create({
146 height: 480 * DEVICE_WIDTH_RATIO, 159 height: 480 * DEVICE_WIDTH_RATIO,
147 }, 160 },
148 name: { 161 name: {
149 - fontFamily: 'SanFranciscoText-Regular',  
150 fontSize: 16, 162 fontSize: 16,
151 color: '#444444', 163 color: '#444444',
152 lineHeight: 22, 164 lineHeight: 22,
@@ -268,4 +280,4 @@ const styles = StyleSheet.create({ @@ -268,4 +280,4 @@ const styles = StyleSheet.create({
268 } 280 }
269 }) 281 })
270 282
271 -export default connect(mapStateToProps)(ShareDetail);  
  283 +export default connect(mapStateToProps)(ShareDetail);
@@ -21,7 +21,7 @@ export default class ProductCell extends Component { @@ -21,7 +21,7 @@ export default class ProductCell extends Component {
21 <TouchableOpacity 21 <TouchableOpacity
22 yh_exposureData={yh_exposureData} activeOpacity={1} style={[styles.container]} 22 yh_exposureData={yh_exposureData} activeOpacity={1} style={[styles.container]}
23 onPress={() => { 23 onPress={() => {
24 - this.props.onPressProduct && this.props.onPressProduct(data.get('product_skn')); 24 + this.props.onPressProduct && this.props.onPressProduct(data);
25 }}> 25 }}>
26 <View style={styles.container}> 26 <View style={styles.container}>
27 <YH_Image style={styles.prdImage} url={prdImage}/> 27 <YH_Image style={styles.prdImage} url={prdImage}/>
@@ -70,7 +70,7 @@ export default class Recommend extends Component { @@ -70,7 +70,7 @@ export default class Recommend extends Component {
70 <ProductCell 70 <ProductCell
71 key={'row' + rowID} 71 key={'row' + rowID}
72 data={rowData} 72 data={rowData}
73 - onPressProduct={() => this.props.onPressProduct(rowData)} 73 + onPressProduct={this.props.onPressProduct}
74 /> 74 />
75 ); 75 );
76 } 76 }
@@ -112,6 +112,7 @@ class HomeContainer extends Component { @@ -112,6 +112,7 @@ class HomeContainer extends Component {
112 } 112 }
113 113
114 _onPressProduct(product) { 114 _onPressProduct(product) {
  115 +
115 let productSkn = product && product.get('product_skn', 0); 116 let productSkn = product && product.get('product_skn', 0);
116 let product_id = product && product.get('product_id', 0); 117 let product_id = product && product.get('product_id', 0);
117 if (!productSkn) { 118 if (!productSkn) {
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 -import { StyleSheet, View, NativeModules } from "react-native"; 2 +import ReactNative,{ StyleSheet, View, NativeModules ,Dimensions} from "react-native";
3 import { bindActionCreators } from 'redux'; 3 import { bindActionCreators } from 'redux';
4 import { connect } from 'react-redux'; 4 import { connect } from 'react-redux';
5 import { Map } from 'immutable'; 5 import { Map } from 'immutable';
  6 +import queryString from 'query-string';
6 7
7 import * as shareDetailActions from '../reducers/shareDetail/shareDetailActions'; 8 import * as shareDetailActions from '../reducers/shareDetail/shareDetailActions';
8 import ShareDetail from '../components/ShareDetail'; 9 import ShareDetail from '../components/ShareDetail';
9 -  
10 -import ShareViewModal from '../../groupPurchase/components/ShareViewModal';  
11 -import ListSnapshootShare from '../../groupPurchase/components/ListSnapshootShare'; 10 +import { getSlicedUrl } from '../../classify/utils/Utils';
12 11
13 const actions = [ 12 const actions = [
14 shareDetailActions, 13 shareDetailActions,
@@ -33,36 +32,26 @@ function mapDispatchToProps(dispatch) { @@ -33,36 +32,26 @@ function mapDispatchToProps(dispatch) {
33 } 32 }
34 33
35 class ShareDetailContainer extends Component { 34 class ShareDetailContainer extends Component {
36 - state = {  
37 - showShareView: false,  
38 - showSnapshootShare: false 35 + constructor(props) {
  36 + super(props);
  37 + this.showShareView = this.showShareView.bind(this);
  38 + this._goBack = this._goBack.bind(this);
  39 + this._addFavorite = this._addFavorite.bind(this);
  40 + this._jumpWithUrl = this._jumpWithUrl.bind(this);
39 } 41 }
40 42
41 render() { 43 render() {
42 - let { showShareView, showSnapshootShare } = this.state;  
43 - let { host } = this.props.app;  
44 - let qrCode = host + '/wechat/miniapp/img-check.jpg?miniQrType=15'; 44 + let { shareDetail } = this.props;
45 return ( 45 return (
46 - <View style={{flex: 1}}>  
47 - <ShareViewModal  
48 - show={showShareView}  
49 - showShareView={this.showShareView}  
50 - shareMiniApp={this.shareMiniApp}  
51 - showSnapshootShare={this.showSnapshootShare}/>  
52 - <ListSnapshootShare  
53 - show={showSnapshootShare}  
54 - showSnapshootShare={this.showSnapshootShare}  
55 - shareSnapshootAction={this.shareSnapshootAction}  
56 - qrCode={qrCode}  
57 - /> 46 + <View style={styles.container}>
58 <ShareDetail 47 <ShareDetail
  48 + shareDetail={shareDetail}
59 showShareView={this.showShareView} 49 showShareView={this.showShareView}
60 goBack={this._goBack} 50 goBack={this._goBack}
61 addFavorite={this._addFavorite} 51 addFavorite={this._addFavorite}
62 jumpWithUrl={this._jumpWithUrl} 52 jumpWithUrl={this._jumpWithUrl}
63 /> 53 />
64 </View> 54 </View>
65 -  
66 ) 55 )
67 } 56 }
68 57
@@ -75,52 +64,41 @@ class ShareDetailContainer extends Component { @@ -75,52 +64,41 @@ class ShareDetailContainer extends Component {
75 this.props.actions.addFavorite({id: this.props.product_id, type: 'product'}); 64 this.props.actions.addFavorite({id: this.props.product_id, type: 'product'});
76 } 65 }
77 66
78 - showShareView = (show) => {  
79 - this.setState({showShareView: show});  
80 - }  
81 -  
82 - shareMiniApp = () => {  
83 - // let {  
84 - // activityId,  
85 - // resource,  
86 - // shareCodeInfo,  
87 - // } = this.props.groupPurchase;  
88 - // if (!resource) {  
89 - // return;  
90 - // }  
91 - // let miniProgramPath = '/pages/groupPurchase/groupPurchase?activity_id=' + activityId;  
92 - // let fromPage = 'GroupPurchase';  
93 - // let bigImage = shareCodeInfo.get('bigImage');  
94 - // let productIcon = bigImage ? getSlicedUrl(bigImage,150*DEVICE_WIDTH_RATIO, 120*DEVICE_WIDTH_RATIO, 2) : '';  
95 - // this.props.actions.showShareView(false);  
96 - // let param = {  
97 - // title: shareCodeInfo.get('title'),  
98 - // image: productIcon,  
99 - // shareUrl: '',  
100 - // miniProgramPath,  
101 - // fromPage,  
102 - // }  
103 - // ReactNative.NativeModules.YH_CommonHelper.shareWXMiniProgram(param);  
104 - }  
105 -  
106 - showSnapshootShare = (show) => {  
107 - this.setState({  
108 - showShareView: false,  
109 - showSnapshootShare: show  
110 - });  
111 - }  
112 -  
113 - shareSnapshootAction = (shareType,url) => {  
114 - let fromPage = '';  
115 - let param = {  
116 - shareType,  
117 - imageUrl: url,  
118 - fromPage, 67 + showShareView = (productInfo) => {
  68 + let { host } = this.props.app;
  69 + let goodsList = productInfo.goodsList;
  70 + let productPriceBo = productInfo.productPriceBo;
  71 + let goodsInfo = goodsList ? goodsList[0] : {};
  72 + let productSkn = productPriceBo.productSkn;
  73 +
  74 + let unionType = ReactNative.NativeModules.YH_CommonHelper.unionType();
  75 + let qrCode;
  76 + if (unionType) {
  77 + let params = {
  78 + productSkn,
  79 + union_type: unionType,
  80 + }
  81 + let paramsString = queryString.stringify(params, {encode: true});
  82 + qrCode = host + '/wechat/miniapp/img-check.jpg?param=' + paramsString + '&miniQrType=7';
  83 + }else {
  84 + qrCode = host + '/wechat/miniapp/img-check.jpg?param=' + productSkn + '&miniQrType=7';
119 } 85 }
  86 + let shareParam = {
  87 + title: productInfo.productName ? productInfo.productName : '',
  88 + content: productInfo.phrase ? productInfo.phrase : '',
  89 + image: goodsInfo.colorImage,
  90 + url: '',
  91 + miniProgramPath: 'pages/goodsDetail/goodsDetail?productSkn=' + productSkn,
  92 + miniProgramQCodeUrl: qrCode,
  93 + product_name: productInfo.productName ? productInfo.productName : '',
  94 + sales_price: productPriceBo.originalSalesPrice,
  95 + productDefaultImage: goodsInfo.colorImage,
  96 + fromType: 'productDetail',
  97 + };
  98 +
  99 + ReactNative.NativeModules.YH_CommonHelper.shareInfoWithParam(shareParam);
120 100
121 - ReactNative.NativeModules.YH_CommonHelper.shareImageToWXMini(param);  
122 - this.setState({showSnapshootShare: false});  
123 -} 101 + }
124 102
125 _goBack = () => { 103 _goBack = () => {
126 NativeModules.YH_CommonHelper.goBack(); 104 NativeModules.YH_CommonHelper.goBack();
@@ -132,10 +110,11 @@ class ShareDetailContainer extends Component { @@ -132,10 +110,11 @@ class ShareDetailContainer extends Component {
132 } 110 }
133 } 111 }
134 112
  113 +const DEVICE_WIDTH_RATIO = Dimensions.get('window').width / 375;
135 const styles = StyleSheet.create({ 114 const styles = StyleSheet.create({
136 container: { 115 container: {
137 flex: 1, 116 flex: 1,
138 } 117 }
139 }) 118 })
140 119
141 -export default connect(mapStateToProps, mapDispatchToProps)(ShareDetailContainer)  
  120 +export default connect(mapStateToProps, mapDispatchToProps)(ShareDetailContainer)
@@ -38,13 +38,14 @@ export function shareDetailFailue(error) { @@ -38,13 +38,14 @@ export function shareDetailFailue(error) {
38 export function fetchShareDetail(params) { 38 export function fetchShareDetail(params) {
39 return async (dispatch, getState) => { 39 return async (dispatch, getState) => {
40 let { app: { host } } = getState(); 40 let { app: { host } } = getState();
41 - let data;  
42 - try {  
43 - data = await new Service(host).fetchShareDetail(params);  
44 - } catch(error) {  
45 - dispatch(shareDetailFailue(error));  
46 - }  
47 - dispatch(shareDetailSuccess(data)); 41 + dispatch(shareDetailRequest());
  42 + return new Service(host).fetchShareDetail(params)
  43 + .then(json => {
  44 + dispatch(shareDetailSuccess(json));
  45 + })
  46 + .catch(error => {
  47 + dispatch(shareDetailFailue(error));
  48 + });
48 } 49 }
49 } 50 }
50 51
@@ -123,4 +124,4 @@ export function fetchFavoriteInfo(params) { @@ -123,4 +124,4 @@ export function fetchFavoriteInfo(params) {
123 } 124 }
124 dispatch(addFavoriteSuccess(data ? 'Y' : 'N')); 125 dispatch(addFavoriteSuccess(data ? 'Y' : 'N'));
125 } 126 }
126 -}  
  127 +}
@@ -5,9 +5,8 @@ import {List, Map, Record} from 'immutable'; @@ -5,9 +5,8 @@ import {List, Map, Record} from 'immutable';
5 let InitialState = Record({ 5 let InitialState = Record({
6 isFetching: false, 6 isFetching: false,
7 error: '', 7 error: '',
8 - productInfo: new (Record({  
9 - goodsList: List()  
10 - })), 8 + productInfo: {},
  9 + isCollect: 'N',
11 }); 10 });
12 11
13 export default InitialState; 12 export default InitialState;
@@ -32,7 +32,7 @@ export default function appReducer(state = initialState, action) { @@ -32,7 +32,7 @@ export default function appReducer(state = initialState, action) {
32 return state.set('isFetching', true); 32 return state.set('isFetching', true);
33 case ADD_FAVORITE_SUCCESS: 33 case ADD_FAVORITE_SUCCESS:
34 return state.set('isFetching', false) 34 return state.set('isFetching', false)
35 - .setIn(['productInfo', 'isCollect'], action.payload); 35 + .set('isCollect', action.payload);
36 case ADD_FAVORITE_FAILURE: 36 case ADD_FAVORITE_FAILURE:
37 return state.set('isFetching', false) 37 return state.set('isFetching', false)
38 .set('error', action.payload); 38 .set('error', action.payload);
@@ -67,4 +67,4 @@ export default class Service { @@ -67,4 +67,4 @@ export default class Service {
67 throw(error); 67 throw(error);
68 }); 68 });
69 } 69 }
70 -}  
  70 +}