import track from '@apis/track';
import { getUrlParameter } from '@js/utils';

export function interceptBack(cb) {
  pushHistory();
  window.addEventListener('popstate', cb, false);
  function pushHistory() {
    var state = {
      url: '#',
      title: 'title'
    };
    window.history.pushState(state, 'title', '#');
  }
}

export function goApp(url) {
  track(9, {
    share_source: getUrlParameter('share_source')
  });
  setTimeout(() => {
    location.href = url || 'http://a.app.qq.com/o/simple.jsp?pkgname=com.youtui&ckey=CK1409589132989';
  }, 200);
}
