fix(order): 防止订单详情页重复加载或未加载
- 在onShow中增加state.orderInfo.id存在性检查,防止无效调用 - 在onLoad中完成id赋值后主动调用getOrderDetail,确保数据加载 - 通过条件判断避免onShow与onLoad同时触发导致的重复请求pull/167/head
parent
50549b8064
commit
7a3be392d6
|
|
@ -428,7 +428,10 @@
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
// onShow中获取订单列表,保证跳转后页面为最新状态
|
// onShow中获取订单列表,保证跳转后页面为最新状态
|
||||||
await getOrderDetail(state.orderInfo.id);
|
// 有几率在onLoad完成state.orderInfo.id赋值前进入onShow
|
||||||
|
if (state.orderInfo.id) {
|
||||||
|
await getOrderDetail(state.orderInfo.id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
|
@ -447,6 +450,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.orderInfo.id = id;
|
state.orderInfo.id = id;
|
||||||
|
// 完成state.orderInfo.id赋值后加载一次detail,但有几率与onShow重复可能导致detail会加载两次。
|
||||||
|
await getOrderDetail(state.orderInfo.id);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue