/** * 快应用宿主环境下的下拉刷新 → 原生 webview.reload() 转发 mixin * * 在已启用 enablePullDownRefresh 的 uniapp 页面 mixin 链中加入本文件, * 当用户在原生快应用 webview 内下拉刷新时,会通过 this.$util.requestQuickAppReload() * 把指令发回快应用 shell(对应 hello.ux onMessage 中的 'reload' 处理); * 其余平台走默认的 uni.stopPullDownRefresh 即可。 * * 用法: * import pullReload from '@/common/js/mixins/quickapp-pull-refresh.js'; * export default { mixins: [..., pullReload] } * * 注意: * - 请确保对应的 pages.json style 块中开启 "enablePullDownRefresh": true * - 不要在本文件里覆盖 onPullDownRefresh,否则会被本页/上游 mixin 拦截失效 */ export default { onPullDownRefresh() { try { if (this.$util && typeof this.$util.requestQuickAppReload === 'function' && this.$util.requestQuickAppReload()) { // 原生侧 webview.reload() 会把整个 H5 页面替换掉,这里只是兜底停动画 setTimeout(() => { try { uni.stopPullDownRefresh(); } catch (_) { /* swallow */ } }, 800); return; } } catch (e) { console.error('[quickapp-pull-refresh] crashed:', e); } try { uni.stopPullDownRefresh(); } catch (_) { /* swallow */ } } }