场景

  • 移动端上
  • 从A页面跳转到B页面
  • 需要带很多参数,敏感或不敏感
  • A、B无相同接口

实现

  1. // A页面编码
  2. const pointPayload = {
  3. flowId,
  4. goodsSn: pageGoodsSn,
  5. skuSn: pageSkuSn,
  6. productId: pageGoodsBizNo,
  7. courseType,
  8. isCamp: Number(hasOpenTrainingCamp) || 0,
  9. };
  10. const encodePointPayload = btoa(encodeURIComponent(JSON.stringify(pointPayload)));
  11. window.location.href = `/finance/course/change/term?editSource=pay&skuSn=${pageSkuSn}&pointPayload=${encodePointPayload}`;
  12. // B页面解码
  13. const defaultPointPayload = {
  14. courseType: '',
  15. flowId: '',
  16. goodsSn: '',
  17. isCamp: 0,
  18. productId: '',
  19. skuSn: '',
  20. };
  21. const decodePointPayload = pointPayload ? JSON.parse(decodeURIComponent(atob(pointPayload))) : defaultPointPayload;