广州矛调粤政易端
xusd
7 days ago d27794814b69d18aeb8ee96a46cae91d5613570c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * @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();