Authored by 孙凯

add share review hongyong

... ... @@ -61,7 +61,7 @@ export default class Home extends Component {
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={() => this.props.onPressProduct(rowData)}
onPressProduct={this.props.onPressProduct}
/>
);
}
... ... @@ -249,21 +249,18 @@ let styles = StyleSheet.create({
width: width,
},
bannerMainTitle: {
fontFamily: 'SourceHanSansCN-Bold',
fontSize: 16,
color: '#000000',
textAlign:'center',
marginTop:12,
},
bannerSubTitle: {
fontFamily: 'SourceHanSansCN-Bold',
fontSize:12,
color: '#000000',
textAlign:'center',
marginTop:19,
},
bannerContext: {
fontFamily: ' SourceHanSansCN-Medium;',
fontSize:9,
color: '#000000',
textAlign:'center',
... ...
... ... @@ -74,7 +74,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
rank: {
fontFamily: 'SanFranciscoText-Regular',
fontSize: 18,
color: '#444444',
marginLeft: 18 * DEVICE_WIDTH_RATIO,
... ... @@ -99,7 +98,6 @@ const styles = StyleSheet.create({
paddingTop: 15 * DEVICE_WIDTH_RATIO,
},
amount: {
fontFamily: 'SanFranciscoText-Regular',
fontSize: 16,
lineHeight: 19,
color: '#444444',
... ... @@ -111,4 +109,4 @@ const styles = StyleSheet.create({
lineHeight: 17,
color: '#B0B0B0'
}
})
\ No newline at end of file
})
... ...
... ... @@ -16,13 +16,27 @@ function mapStateToProps(store) {
}
class ShareDetail extends Component {
// state = { opacity: 0 }
render() {
let productInfo = this.props.shareDetail.get('productInfo').toJS();
let { goodsList: [ goodsInfo = {} ], productPriceBo = {} } = productInfo;
let { goodsImagesList } = goodsInfo;
let {shareDetail} = this.props;
let shareDetailInfo = shareDetail ? shareDetail.toJS(): {};
let productInfo = shareDetailInfo.productInfo;
let isCollect = shareDetail.isCollect;
if (!productInfo || productInfo == {}) {
return null
}
let goodsList = productInfo.goodsList;
let productPriceBo = productInfo.productPriceBo;
let goodsInfo = goodsList ? goodsList[0] : {};
if (!goodsInfo || !productPriceBo) {
return null
}
let goodsImagesList = goodsInfo ? goodsInfo.goodsImagesList: null;
let imgList = goodsImagesList && goodsImagesList.map(item => ({src: item.imageUrl}));
imgList = Immutable.fromJS(imgList);
return (
<View style={styles.container}>
<View style={[styles.navigatorBackground]}>
... ... @@ -78,7 +92,7 @@ class ShareDetail extends Component {
<Image
style={styles.favorite}
resizeMode="center"
source={productInfo.isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} />
source={isCollect === 'Y' ? require('../../recorder/images/brand/heart_ic_h.png') : require('../../recorder/images/brand/heart_ic_n.png')} />
<Text style={styles.favText}>收藏</Text>
</TouchableOpacity>
</View>
... ... @@ -88,7 +102,7 @@ class ShareDetail extends Component {
<Text style={styles.btnText}>查看商品详情</Text>
</View>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(true)}>
<TouchableOpacity activeOpacity={0.8} onPress={() => this.props.showShareView(productInfo)}>
<View style={[styles.button, styles.center, styles.red]}>
<Text style={styles.btnText}>{'分享可赚¥' + productInfo.rebatesAmount}</Text>
</View>
... ... @@ -102,7 +116,6 @@ class ShareDetail extends Component {
changeOpacity(e) {
let opacity = 1 - (500 - e.nativeEvent.contentOffset.y) / 500;
this.setState({opacity: opacity < 0.4 ? opacity : 0.4});
console.log(e.nativeEvent.contentOffset.y);
}
}
... ... @@ -146,7 +159,6 @@ const styles = StyleSheet.create({
height: 480 * DEVICE_WIDTH_RATIO,
},
name: {
fontFamily: 'SanFranciscoText-Regular',
fontSize: 16,
color: '#444444',
lineHeight: 22,
... ... @@ -268,4 +280,4 @@ const styles = StyleSheet.create({
}
})
export default connect(mapStateToProps)(ShareDetail);
\ No newline at end of file
export default connect(mapStateToProps)(ShareDetail);
... ...
... ... @@ -21,7 +21,7 @@ export default class ProductCell extends Component {
<TouchableOpacity
yh_exposureData={yh_exposureData} activeOpacity={1} style={[styles.container]}
onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(data.get('product_skn'));
this.props.onPressProduct && this.props.onPressProduct(data);
}}>
<View style={styles.container}>
<YH_Image style={styles.prdImage} url={prdImage}/>
... ...
... ... @@ -70,7 +70,7 @@ export default class Recommend extends Component {
<ProductCell
key={'row' + rowID}
data={rowData}
onPressProduct={() => this.props.onPressProduct(rowData)}
onPressProduct={this.props.onPressProduct}
/>
);
}
... ...
... ... @@ -112,6 +112,7 @@ class HomeContainer extends Component {
}
_onPressProduct(product) {
let productSkn = product && product.get('product_skn', 0);
let product_id = product && product.get('product_id', 0);
if (!productSkn) {
... ...
import React, { Component } from 'react';
import { StyleSheet, View, NativeModules } from "react-native";
import ReactNative,{ StyleSheet, View, NativeModules ,Dimensions} from "react-native";
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Map } from 'immutable';
import queryString from 'query-string';
import * as shareDetailActions from '../reducers/shareDetail/shareDetailActions';
import ShareDetail from '../components/ShareDetail';
import ShareViewModal from '../../groupPurchase/components/ShareViewModal';
import ListSnapshootShare from '../../groupPurchase/components/ListSnapshootShare';
import { getSlicedUrl } from '../../classify/utils/Utils';
const actions = [
shareDetailActions,
... ... @@ -33,36 +32,26 @@ function mapDispatchToProps(dispatch) {
}
class ShareDetailContainer extends Component {
state = {
showShareView: false,
showSnapshootShare: false
constructor(props) {
super(props);
this.showShareView = this.showShareView.bind(this);
this._goBack = this._goBack.bind(this);
this._addFavorite = this._addFavorite.bind(this);
this._jumpWithUrl = this._jumpWithUrl.bind(this);
}
render() {
let { showShareView, showSnapshootShare } = this.state;
let { host } = this.props.app;
let qrCode = host + '/wechat/miniapp/img-check.jpg?miniQrType=15';
let { shareDetail } = this.props;
return (
<View style={{flex: 1}}>
<ShareViewModal
show={showShareView}
showShareView={this.showShareView}
shareMiniApp={this.shareMiniApp}
showSnapshootShare={this.showSnapshootShare}/>
<ListSnapshootShare
show={showSnapshootShare}
showSnapshootShare={this.showSnapshootShare}
shareSnapshootAction={this.shareSnapshootAction}
qrCode={qrCode}
/>
<View style={styles.container}>
<ShareDetail
shareDetail={shareDetail}
showShareView={this.showShareView}
goBack={this._goBack}
addFavorite={this._addFavorite}
jumpWithUrl={this._jumpWithUrl}
/>
</View>
)
}
... ... @@ -75,52 +64,41 @@ class ShareDetailContainer extends Component {
this.props.actions.addFavorite({id: this.props.product_id, type: 'product'});
}
showShareView = (show) => {
this.setState({showShareView: show});
}
shareMiniApp = () => {
// let {
// activityId,
// resource,
// shareCodeInfo,
// } = this.props.groupPurchase;
// if (!resource) {
// return;
// }
// let miniProgramPath = '/pages/groupPurchase/groupPurchase?activity_id=' + activityId;
// let fromPage = 'GroupPurchase';
// let bigImage = shareCodeInfo.get('bigImage');
// let productIcon = bigImage ? getSlicedUrl(bigImage,150*DEVICE_WIDTH_RATIO, 120*DEVICE_WIDTH_RATIO, 2) : '';
// this.props.actions.showShareView(false);
// let param = {
// title: shareCodeInfo.get('title'),
// image: productIcon,
// shareUrl: '',
// miniProgramPath,
// fromPage,
// }
// ReactNative.NativeModules.YH_CommonHelper.shareWXMiniProgram(param);
}
showSnapshootShare = (show) => {
this.setState({
showShareView: false,
showSnapshootShare: show
});
}
shareSnapshootAction = (shareType,url) => {
let fromPage = '';
let param = {
shareType,
imageUrl: url,
fromPage,
showShareView = (productInfo) => {
let { host } = this.props.app;
let goodsList = productInfo.goodsList;
let productPriceBo = productInfo.productPriceBo;
let goodsInfo = goodsList ? goodsList[0] : {};
let productSkn = productPriceBo.productSkn;
let unionType = ReactNative.NativeModules.YH_CommonHelper.unionType();
let qrCode;
if (unionType) {
let params = {
productSkn,
union_type: unionType,
}
let paramsString = queryString.stringify(params, {encode: true});
qrCode = host + '/wechat/miniapp/img-check.jpg?param=' + paramsString + '&miniQrType=7';
}else {
qrCode = host + '/wechat/miniapp/img-check.jpg?param=' + productSkn + '&miniQrType=7';
}
let shareParam = {
title: productInfo.productName ? productInfo.productName : '',
content: productInfo.phrase ? productInfo.phrase : '',
image: goodsInfo.colorImage,
url: '',
miniProgramPath: 'pages/goodsDetail/goodsDetail?productSkn=' + productSkn,
miniProgramQCodeUrl: qrCode,
product_name: productInfo.productName ? productInfo.productName : '',
sales_price: productPriceBo.originalSalesPrice,
productDefaultImage: goodsInfo.colorImage,
fromType: 'productDetail',
};
ReactNative.NativeModules.YH_CommonHelper.shareInfoWithParam(shareParam);
ReactNative.NativeModules.YH_CommonHelper.shareImageToWXMini(param);
this.setState({showSnapshootShare: false});
}
}
_goBack = () => {
NativeModules.YH_CommonHelper.goBack();
... ... @@ -132,10 +110,11 @@ class ShareDetailContainer extends Component {
}
}
const DEVICE_WIDTH_RATIO = Dimensions.get('window').width / 375;
const styles = StyleSheet.create({
container: {
flex: 1,
}
})
export default connect(mapStateToProps, mapDispatchToProps)(ShareDetailContainer)
\ No newline at end of file
export default connect(mapStateToProps, mapDispatchToProps)(ShareDetailContainer)
... ...
... ... @@ -38,13 +38,14 @@ export function shareDetailFailue(error) {
export function fetchShareDetail(params) {
return async (dispatch, getState) => {
let { app: { host } } = getState();
let data;
try {
data = await new Service(host).fetchShareDetail(params);
} catch(error) {
dispatch(shareDetailFailue(error));
}
dispatch(shareDetailSuccess(data));
dispatch(shareDetailRequest());
return new Service(host).fetchShareDetail(params)
.then(json => {
dispatch(shareDetailSuccess(json));
})
.catch(error => {
dispatch(shareDetailFailue(error));
});
}
}
... ... @@ -123,4 +124,4 @@ export function fetchFavoriteInfo(params) {
}
dispatch(addFavoriteSuccess(data ? 'Y' : 'N'));
}
}
\ No newline at end of file
}
... ...
... ... @@ -5,9 +5,8 @@ import {List, Map, Record} from 'immutable';
let InitialState = Record({
isFetching: false,
error: '',
productInfo: new (Record({
goodsList: List()
})),
productInfo: {},
isCollect: 'N',
});
export default InitialState;
... ...
... ... @@ -32,7 +32,7 @@ export default function appReducer(state = initialState, action) {
return state.set('isFetching', true);
case ADD_FAVORITE_SUCCESS:
return state.set('isFetching', false)
.setIn(['productInfo', 'isCollect'], action.payload);
.set('isCollect', action.payload);
case ADD_FAVORITE_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
... ...
... ... @@ -67,4 +67,4 @@ export default class Service {
throw(error);
});
}
}
\ No newline at end of file
}
... ...