riku
2022-10-10 437144f41c74505d362a5214a18cec3d01b3ce4b
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
const b_loadingStatus = require("../../../base/behaviors/b_loadingStatus")
const lawservice = require("../../../service/lawservice")
const moment = require('../../../utils/moment.min')
const app = getApp()
 
/**
 * 获取守法培训材料
 */
module.exports = Behavior({
  behaviors: [b_loadingStatus],
  data: {
    //搜索结果
    results: []
  },
  methods: {
    loadmore(cPage) {
      this.getResources({cPage: ++cPage})
    },
 
    /**
     * 根据筛选条件获取守法学习材料
     * @param fileType 文件类型,包括[1:office文档,2:网址,3:音频,4:视频],不填写时表示查询所有类型
     */
    getResources({cPage = 1, fileType}) {
      this.setData({loading: true})
      const t = setTimeout(() => { this.setData({loading: false}) }, 10000);
      var that = this
      const user = app.globalData.userInfo
      const condition = {
        sceneTypeId: user.extension2
      }
      if (fileType) {
        condition.fileType = fileType
      }
      lawservice.getLawRegulations(user.guid, cPage, condition, {
        onHead(header) {
          that.setData({
            cPage: parseInt(header.currentPage),
            tPage: parseInt(header.totalPage)
          })
        },
        success(data) {
          let results = that.data.results
          data.forEach(d => {
            d.views = parseInt(Math.random() * 1000 + 10)
            d.lrPublishdate = moment(d.lrPublishdate).format('YYYY年MM月DD日')
          });
          results = results.concat(data)
          that.setData({
            results
          })
        },
        complete() {
          that.setData({loading: false})
          clearTimeout(t)
        }
      }, app.globalData.perPage)
    },
  }
})