import wx from '../utils/wx';
import {stringify} from '../vendors/query-stringify';

const appData = {
  yohobuy: {
    appId: 'wx084ab813d88c594b',
    page: {
      productDetail: '/pages/goodsDetail/goodsDetail',
      brandDetail: '/pages/goodsList/brand',
      guangDetail: 'pages/guang/detail'
    }
  },
  anotherApp: {
    appId: 'wx084ab813d88c594b',
    page: {
      home: '/pages/goodsDetail/goodsDetail'
    }
  },
};

export default function(params) {
  let navigateToMiniParams = {
    appId: appData[params.app].appId,
    path: params.path || `${appData[params.app].page[params.page]}?${stringify(params.data)}`
  };

  return wx.navigateToMiniProgram(navigateToMiniParams);
}