/* * @Company: hugeInfo * @Author: ldh * @Date: 2022-08-18 16:35:06 * @LastEditTime: 2023-02-18 19:36:37 * @LastEditors: lwh * @Version: 1.0.0 * @Description: 路由传参状态类,刷新数据会重置,只适合保存不影响页面操作的数据 */ class routerStatus { constructor() { // 路由传递的参数 this.state = {}; // 记录虚拟滚动的滚动条位置,返回时设置 this.scrollTop = {}; // 设置当前页面列表List的滚动位置 this.pageScrollTop = 0; // 记录缓存路由当需要返回更新页面 this.spinPage = {}; // 防止MyList触底加载多次触发 this.loadBottom = false; } // 设置路由传参 setState(key, value) { this.state[key] = value; } // 清除路由参数 clearState(key) { delete this.state[key]; } // 保存当前页面的scrollTop setPageScrollTop(key, value) { this.scrollTop[key] = value; } // 设置列表滚动 setPageScrollTopNow(key) { this.pageScrollTop = this.scrollTop[key]; } // 设置横向滚动 setPageScrollLeftNow(key) { this.pageScrollLeft = this.scrollLeft[key]; } // 设置列表滚动 clearPageScrollTopNow() { this.pageScrollTop = 1; } // 设置列表滚动 clearPageScrollLeftNow() { this.pageScrollLeft = 1; } // 设置返回路由页面需刷新 setSpinPage(key) { this.spinPage[key] = true; } // 清除路由页面需刷新数据 clearSpinPage(key) { delete this.spinPage[key]; } // 设置触底加载状态 setLoadBottomStatus(visible) { this.loadBottom = visible; } } export default new routerStatus();