Authored by 陈林

修改小程序分享的地址。review by 孙凯。

... ... @@ -11,6 +11,8 @@ import GroupPurchase from '../components/GroupPurchase';
import ShareViewModal from '../components/ShareViewModal';
import ListSnapshootShare from '../components/ListSnapshootShare';
import {getSlicedUrl} from '../../classify/utils/Utils';
import Helper from '../utils/Helper';
const actions = [
groupPurchaseActions,
... ... @@ -56,6 +58,8 @@ class GroupPurchaseContainer extends Component {
this.props.actions.showShareView(true);
}
);
}
async componentDidMount() {
... ... @@ -114,11 +118,14 @@ class GroupPurchaseContainer extends Component {
activityId,
resource,
shareCodeInfo,
groupListParams,
} = this.props.groupPurchase;
if (!resource) {
return;
}
let miniProgramPath = '/pages/group/list?activityId=' + activityId;
miniProgramPath = Helper.joinWxProgramPath(miniProgramPath, groupListParams)
let fromPage = 'GroupPurchase';
let bigImage = shareCodeInfo.get('bigImage');
let productIcon = bigImage ? getSlicedUrl(bigImage,150*DEVICE_WIDTH_RATIO, 120*DEVICE_WIDTH_RATIO, 2) : '';
... ... @@ -153,6 +160,7 @@ class GroupPurchaseContainer extends Component {
productList,
resource,
shareCodeInfo,
groupListParams,
} = this.props.groupPurchase;
let {
... ... @@ -160,7 +168,9 @@ class GroupPurchaseContainer extends Component {
unionType,
} = this.props.app;
let groupParams = Helper.excludeParams(groupListParams, false)
let param = {
...groupParams,
activityId,
}
... ...
... ... @@ -2,6 +2,7 @@
import ReactNative from 'react-native';
import GroupPurchaseService from '../../services/GroupPurchaseService';
import Helper from '../../utils/Helper';
const Platform = require('Platform');
... ... @@ -124,7 +125,7 @@ export function getProductList(reload=false) {
dispatch(productListRequest());
//处理拼团列表参数
let listParams = excludeParams(groupListParams);
let listParams = Helper.excludeParams(groupListParams);
return new GroupPurchaseService(app.host).fetchGroupProductList(activityId, page, limit,fromPage, listParams)
.then(json => {
json.endReached = json.page == json.page_total;
... ... @@ -141,34 +142,6 @@ export function getProductList(reload=false) {
};
}
function excludeParams(groupParams){
let newParams = {};
try{
let params = groupParams.toJS();
for(let key in params){
if(params[key]){
newParams[key] = params[key]
}
}
//gender 需要进行空处理,防止原生会添加默认值
if(!newParams["gender"]){
newParams["gender"] = "";
}
//size因为字段是关键字,使用了g_size替换
if(newParams["g_size"]){
newParams["size"] = newParams["g_size"];
delete newParams["g_size"]
}
}catch(e){
}
return newParams;
}
export function shareCodeInfoRequest() {
return {
type: SHARECODEINFO_REQUEST,
... ...
'use strict';
function excludeParams(groupParams, needGender=true){
let newParams = {};
try{
let params = groupParams.toJS();
for(let key in params){
if(params[key]){
newParams[key] = params[key]
}
}
//gender 需要进行空处理,防止原生会添加默认值
if(needGender && !newParams["gender"]){
newParams["gender"] = "";
}
//size因为字段是关键字,使用了g_size替换
if(newParams["g_size"]){
newParams["size"] = newParams["g_size"];
delete newParams["g_size"]
}
}catch(e){
}
return newParams;
}
function joinWxProgramPath(wxPath, groupParams){
let params = excludeParams(groupParams, false);
for(let key in params){
wxPath = wxPath + "&" + key + "=" + params[key];
}
return wxPath;
}
module.exports = {
excludeParams,
joinWxProgramPath
};
... ...