riku
2024-11-12 befd1f21839939b54254bd316bbd158b136fcd15
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import dayjs from "dayjs";
import { useLoading } from '../../behaviors/loading';
import { useOptions } from '../home/options-proxy.js';
import { useInsepction } from '../home/inspection-proxy.js';
// import { useSupervision } from '../home/supervision-proxy.js';
// import { useNotice } from '../home/notice-proxy.js';
// import { useNews } from '../home/news-proxy.js';
import { useProblemChangeList } from '../inspection/ranking/problem-change-list.js';
import { useStatistic } from '../inspection/ranking/statistic.js';
import { useSortOptions } from '../inspection/ranking/sort-options.js';
 
const app = getApp();
 
Page({
  behaviors: [
    useLoading,
    useOptions,
    useInsepction,
    // useSupervision,
    // useNotice,
    // useNews,
    useStatistic,
    useSortOptions,
    useProblemChangeList,
  ],
  data: {
    placeholder: '搜索企业详情',
    userName: app.globalData.userInfo.name,
  },
 
  onLoad(options) {
    this.setData({ userName: app.globalData.userInfo.name });
  },
 
  onShow() {
    // this.getTabBar().init();
  },
 
  onPullDownRefresh() {
    this._startLoad();
  },
 
  onReachBottom() {
    this._loadMore();
  },
 
  /**
   * 初始加载
   * 当所有筛选条件都获取到初始值后,执行一次初始化加载
   * 包括场景类型、区域、时间三个选项,全部获取初始值后,执行加载
   */
  optionsCount: 0,
  init() {
    this.optionsCount++;
    if (this.optionsCount == 3) this._startLoad();
  },
 
  _fetchData(page) {
    const array = [];
    // // 执法动态
    // const f3 = this._enforcementNews(page);
    // array.push(f3);
    if (page == 1) {
      // // 线上监管
      // this.fetchSupervision(page);
      // 现场巡查
      this.fetchInspection(page);
      const params = this.getParam();
      const f1 = this.fetchSceneProSummary(params, page);
      array.push(f1);
      const f2 = this.fetchProblems(params, page);
      array.push(f2);
      // // 工作提醒
      // const f1 = this._fetchNotice(page);
      // array.push(f1);
      // const f4 = this._fetchUnReadNoticeNum(page);
      // array.push(f4);
      // // 守法培训
      // const f2 = this._complianceTraining(page);
      // array.push(f2);
    }
    return Promise.all(array).then(res => {
      return res[0];
    });
  },
 
  // 排序切换后的加载函数
  _startSortLoad() {
    const params = this.getParam();
    this.setData({ pageLoading: true });
    this.fetchSceneProSummary(params, 1).finally(() => this.setData({ pageLoading: false }));
  },
 
  getParam() {
    const { provinceCode, cityCode, districtCode, townCode, sceneTypeValue, time, sort, sortBy } =
      this.data;
    const params = {
      provincecode: provinceCode,
      // provincename: provinceName,
      citycode: cityCode,
      // cityname: cityName,
      districtcode: districtCode,
      // districtname: districtName,
      towncode: townCode,
      // townname: townName,
      scensetypeid: sceneTypeValue[0],
      sort: sort,
      sortBy: sortBy,
    };
    const t = dayjs(time);
    params.starttime = t.startOf('month').format('YYYY-MM-DD HH:mm:ss');
    params.endtime = t.endOf('month').format('YYYY-MM-DD HH:mm:ss');
 
    return params;
  },
 
  navToSearchPage() {
    wx.navigateTo({
      url: '/pages/enterprise/search/index',
      success: result => {},
      fail: res => {},
      complete: res => {},
    });
  },
});