场景
- 移动端上
- 从A页面跳转到B页面
- 需要带很多参数,敏感或不敏感
- A、B无相同接口
实现
// A页面编码
const pointPayload = {
flowId,
goodsSn: pageGoodsSn,
skuSn: pageSkuSn,
productId: pageGoodsBizNo,
courseType,
isCamp: Number(hasOpenTrainingCamp) || 0,
};
const encodePointPayload = btoa(encodeURIComponent(JSON.stringify(pointPayload)));
window.location.href = `/finance/course/change/term?editSource=pay&skuSn=${pageSkuSn}&pointPayload=${encodePointPayload}`;
// B页面解码
const defaultPointPayload = {
courseType: '',
flowId: '',
goodsSn: '',
isCamp: 0,
productId: '',
skuSn: '',
};
const decodePointPayload = pointPayload ? JSON.parse(decodeURIComponent(atob(pointPayload))) : defaultPointPayload;