|
|
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) |
...
|
...
|
|