Authored by 孙凯

add share shortUrl review by chenling

... ... @@ -138,4 +138,8 @@ export default keyMirror({
FAVORITE_INFO_REQUEST: null,
FAVORITE_INFO_FAILURE: null,
});
\ No newline at end of file
SHARE_CODE_INFO_REQUEST: null,
SHARE_CODE_INFO_SUCCESS: null,
SHARE_CODE_INFO_FAILURE: null,
});
... ...
... ... @@ -56,6 +56,7 @@ class ShareDetailContainer extends Component {
}
componentDidMount() {
this.props.actions.fetchShareCodeInfo(this.props.product_skn);
this.props.actions.fetchShareDetail({product_skn: this.props.product_skn});
this.props.actions.fetchFavoriteInfo({id: this.props.product_id, type: 'product'})
}
... ... @@ -66,11 +67,14 @@ class ShareDetailContainer extends Component {
showShareView = (productInfo) => {
let { host } = this.props.app;
let { shareDetail } = this.props;
let shareDetailJS = shareDetail ? shareDetail.toJS(): null;
let goodsList = productInfo.goodsList;
let productPriceBo = productInfo.productPriceBo;
let goodsInfo = goodsList ? goodsList[0] : {};
let productSkn = productPriceBo.productSkn;
let productUrl = productInfo.productUrl;
let shortUrl = shareDetailJS && shareDetailJS.shareCodeInfo ? shareDetailJS.shareCodeInfo.shortUrl : '';
let unionType = ReactNative.NativeModules.YH_CommonHelper.unionType();
let qrCode;
if (unionType) {
... ... @@ -78,6 +82,7 @@ class ShareDetailContainer extends Component {
productSkn,
union_type: unionType,
}
productUrl = shortUrl;
let paramsString = encodeURIComponent(JSON.stringify(params));
qrCode = host + '/wechat/miniapp/img-check.jpg?param=' + paramsString + '&miniQrType=7';
}else {
... ... @@ -88,7 +93,7 @@ class ShareDetailContainer extends Component {
title: productInfo.productName ? productInfo.productName : '',
content: productInfo.productName ? productInfo.productName : '',
image: goodsInfo.colorImage,
url: '',
url: productUrl,
miniProgramPath: 'pages/goodsDetail/goodsDetail?productSkn=' + productSkn,
miniProgramQCodeUrl: qrCode,
product_name: productInfo.productName ? productInfo.productName : '',
... ... @@ -98,7 +103,6 @@ class ShareDetailContainer extends Component {
};
ReactNative.NativeModules.YH_CommonHelper.shareInfoWithParam(shareParam);
}
_goBack = () => {
... ...
... ... @@ -13,8 +13,55 @@ const {
FAVORITE_INFO_REQUEST,
FAVORITE_INFO_FAILURE,
SHARE_CODE_INFO_REQUEST,
SHARE_CODE_INFO_SUCCESS,
SHARE_CODE_INFO_FAILURE,
} = require('../../constants/actionTypes').default;
export function fetchShareCodeInfoRequest() {
return {
type: SHARE_CODE_INFO_REQUEST
}
}
export function fetchShareCodeInfoSuccess(json) {
return {
type: SHARE_CODE_INFO_SUCCESS,
payload: json
}
}
export function fetchShareCodeInfoFailue(error) {
return {
type: SHARE_CODE_INFO_FAILURE,
payload: error
}
}
export function fetchShareCodeInfo(skn) {
return async (dispatch, getState) => {
let { app: { host } } = getState();
let getShareCodeInfo = (unionType) => {
dispatch(fetchShareCodeInfoRequest());
return new Service(host).fetchShareCodeInfo(skn,unionType)
.then(json => {
dispatch(fetchShareCodeInfoSuccess(json));
})
.catch(error => {
dispatch(fetchShareCodeInfoFailue(error));
});
};
ReactNative.NativeModules.YH_CommonHelper.unionType()
.then(unionType => {
getShareCodeInfo(unionType)
})
.catch(error => {
getShareCodeInfo()
});
}
}
export function shareDetailRequest() {
return {
type: SHARE_DETAIL_REQUEST
... ...
... ... @@ -7,6 +7,7 @@ let InitialState = Record({
error: '',
productInfo: {},
isCollect: 'N',
shareCodeInfo: null,
});
export default InitialState;
... ...
... ... @@ -12,6 +12,11 @@ const {
ADD_FAVORITE_FAILURE,
FAVORITE_INFO_REQUEST,
FAVORITE_INFO_FAILURE,
SHARE_CODE_INFO_REQUEST,
SHARE_CODE_INFO_SUCCESS,
SHARE_CODE_INFO_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
... ... @@ -42,6 +47,14 @@ export default function appReducer(state = initialState, action) {
case ADD_FAVORITE_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
case SHARE_CODE_INFO_REQUEST:
return state.set('isFetching', true);
case SHARE_CODE_INFO_SUCCESS:
return state.set('isFetching', false)
.set('shareCodeInfo', Immutable.fromJS(action.payload));
case SHARE_CODE_INFO_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
}
return state;
... ...
... ... @@ -8,6 +8,26 @@ export default class Service {
}
this.api = new Request(baseURL);
}
async fetchShareCodeInfo(skn,unionType) {
return await this.api.get({
url: '',
body: {
method: 'app.union.shareOrder.getShareCodeInfo',
skn,
type: 1,
unionType,
}
})
.then((json) => {
return json;
})
.catch((error) => {
throw(error);
});
}
async fetchShareDetail(params) {
return await this.api.get({
url: '',
... ...