|
|
import {stringify} from 'query-string';
|
|
|
import router from '../router/index';
|
|
|
|
|
|
const GO_LIST = 'go.list';
|
|
|
const GO_PRODUCTPOOL = 'go.poollist';
|
|
|
const GO_SHOP = 'go.shop';
|
|
|
const GO_BRAND = 'go.brand';
|
|
|
const GO_CATEGORY = 'go.category';
|
|
|
const GO_DETAIL = 'go.productDetail';
|
|
|
const GO_COUPON = 'go.coupon';
|
|
|
const GO_MINE = 'go.mine';
|
|
|
const GO_NEW = 'go.new';
|
|
|
const GO_SHOPCART = 'go.shopcart';
|
|
|
const GO_H5 = 'go.h5';
|
|
|
const GO_ACTIVITY = 'go.activitytemplate';
|
|
|
const GO_MINIAPP = 'go.miniapp';
|
|
|
const GO_ZEROSELL = 'go.zerosell';
|
|
|
const GO_COLLAGEHOME = 'go.collagehome';//拼团购首页
|
|
|
|
|
|
const MINI_APP_DOMAIN = 'miniapp.yohobuy.com';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
jumpByUrl(jumpUrl, pageName) {
|
|
|
if (!jumpUrl) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 跳小程序
|
|
|
if (jumpUrl.indexOf(MINI_APP_DOMAIN)>=0) {
|
|
|
router.goUrl(jumpUrl);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let url = "";
|
|
|
let startIndex = jumpUrl.indexOf('openby:yohobuy=');
|
|
|
if (startIndex < 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let jsonRule = jumpUrl.substring(startIndex + 'openby:yohobuy='.length);
|
|
|
let json = JSON.parse(jsonRule);
|
|
|
let action = json.action;
|
|
|
|
|
|
let path = '';
|
|
|
|
|
|
if (GO_LIST === action) {
|
|
|
let actionType = json.params.actiontype;
|
|
|
if (1 == actionType) {
|
|
|
path = "../goodsList/goodsList";
|
|
|
} else if (2 == actionType) {
|
|
|
path = "../goodsList/activtyDetail";
|
|
|
}
|
|
|
} else if (GO_BRAND === action) {
|
|
|
path = "../goodsList/brand";
|
|
|
} else if (GO_PRODUCTPOOL === action) {
|
|
|
path = "../goodsList/productPool";
|
|
|
} else if (GO_SHOP === action) {
|
|
|
path = "../goodsList/brandStore";
|
|
|
} else if (GO_DETAIL === action) {
|
|
|
let actionType = '';
|
|
|
if (json.params && json.params.activity_type){
|
|
|
actionType = json.params.activity_type;
|
|
|
}
|
|
|
if (actionType && actionType == 'groupPurchase'){
|
|
|
path = "/pages/groupPurchase/groupPurchaseDetail"
|
|
|
}else{
|
|
|
path = "../goodsDetail/goodsDetail";
|
|
|
}
|
|
|
} else if (GO_COUPON === action) {
|
|
|
path = "../page/subPackage/pages/couponList/couponList";
|
|
|
}else if (GO_NEW === action) {
|
|
|
path = "../goodsList/newArrival";
|
|
|
} else if (GO_ZEROSELL == action) {
|
|
|
path = "/page/subPackage/pages/zeroSell/index";
|
|
|
} else if (GO_SHOPCART === action) {
|
|
|
Taro.switchTab({
|
|
|
url: "/pages/shopCart/shopCart"
|
|
|
})
|
|
|
return;
|
|
|
}else if (GO_CATEGORY === action) {
|
|
|
Taro.switchTab({
|
|
|
url: "/pages/classify/category"
|
|
|
})
|
|
|
return;
|
|
|
}else if (GO_MINE === action) {
|
|
|
Taro.switchTab({
|
|
|
url: "/pages/userCenter/userCenter"
|
|
|
})
|
|
|
return;
|
|
|
} else if (GO_H5 === action) {
|
|
|
path = "/pages/webview/webview";
|
|
|
} else if (GO_ACTIVITY === action) {
|
|
|
let actionType;
|
|
|
if (json.params && json.params.type){
|
|
|
actionType = json.params.type;
|
|
|
}
|
|
|
if (actionType == 2) {
|
|
|
path = "../groupPurchase/groupPurchase";
|
|
|
} else if (actionType == 3) {
|
|
|
path = "../assist/assist";
|
|
|
}
|
|
|
}else if (GO_MINIAPP === action){
|
|
|
//跳转到小程序必须有appid和path
|
|
|
if(!json.params||!json.params.appId||!json.params.path ||json.params.appId.length===0 ||json.params.path.length===0){return}
|
|
|
let app_id = json.params.appId;
|
|
|
let target_path = json.params.path;
|
|
|
//如果appid的值为miniapp则表示要跳转到当前小程序中给定的path界面
|
|
|
if (app_id && 'miniapp' == app_id && target_path){
|
|
|
if (target_path.indexOf(0) != '/'){
|
|
|
target_path = '/' + target_path;
|
|
|
}
|
|
|
Taro.navigateTo({
|
|
|
url: target_path,
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
let navigateToMiniParams = {
|
|
|
appId: json.params.appId,
|
|
|
path: json.params.path
|
|
|
};
|
|
|
Taro.navigateToMiniProgram(navigateToMiniParams);
|
|
|
return
|
|
|
} else if (GO_COLLAGEHOME == action){
|
|
|
path = "/pages/groupPurchase/groupPurchaseHome"
|
|
|
}
|
|
|
|
|
|
let params = stringify(json.params, false);
|
|
|
console.log(path)
|
|
|
url = path + "?page_name=" + pageName + "&" + params;
|
|
|
console.log(url)
|
|
|
if (!path) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (url) {
|
|
|
Taro.navigateTo({
|
|
|
url: url,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |