jump-to-miniapp.js 1.23 KB
import wx from '../utils/wx';
import { stringify } from '../vendors/query-stringify';

const appData = {
    yohostore: {
        appId: 'wx668c1fe6f44f24c4',
        page: {}
    },
    yohobuy: {
        appId: 'wx084ab813d88c594b',
        page: {
            index: '/pages/index/index',
            productDetail: '/pages/goodsDetail/goodsDetail',
            brandDetail: '/pages/goodsList/brand',
            goodsList: '/pages/goodsList/goodsList',
            promotionList: '/pages/goodsList/PromotionList',
            guangDetail: '/page/subPackage/pages/guang/detail',
            orders: '/pages/orders/orders'
        }
    },
    limitedMiniapp: {
        appId: 'wxed31f9e8705fb8d1',
        page: {
            productDetail: '/pages/product/detail/detail'
        }
    }
};

/**
 * 跳转同公众号下其他小程序页面
 * params参数: {
        app: qs.app,
        path: `${path}?${stringify(qs)}`
    }
 */
export default function(params) {
    let navigateToMiniParams = {
        appId: appData[params.app].appId,
        path: params.path ||
            `${appData[params.app].page[params.page]}?${stringify(params.data, {encode: params.encode && true})}`
    };

    return wx.navigateToMiniProgram(navigateToMiniParams);
}