riku
2022-08-26 c765c26eee1249b0a8d72d2b203b2ed124c2bbf6
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
// pages/module_common/pagevideo/pagevideo.js
const lawservice = require("../../../service/lawservice")
const moment = require('../../../utils/moment.min')
const app = getApp()
 
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    video: {},
    resources: []
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this
    this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) {
      setTimeout(() => {
        that.setData({
          video: data
        })  
      }, 500);
      
      if (data.lrResourcetitle) {
        wx.setNavigationBarTitle({
          title: data.lrResourcetitle,
        })
      }
    })
 
    this.getResources()
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
 
  },
 
  onReachBottom () {
    console.log('onReachBottom');
    if (this.cPage && this.tPage) {
      if (this.cPage < this.tPage) {
        this.getResources(this.cPage + 1)
      }
    }
  },
 
  getResources(cPage = 1) {
    var that = this
    let user = app.globalData.userInfo
    lawservice.getLawRegulations(user.guid, cPage, {
      sceneTypeId: user.extension2,
      fileType: 4
    }, {
      onHead(header) {
        that.cPage = parseInt(header.currentPage)
        that.tPage = parseInt(header.totalPage)
        console.log(`cPage:${that.cPage}, tPage:${that.tPage}`);
      },
      success(data) {
        let resources = that.data.resources
        data.forEach(d => {
          d.views = parseInt(Math.random() * 1000 + 10)
          d.lrPublishdate = moment(d.lrPublishdate).format('YYYY年MM月DD日')
        });
        resources = resources.concat(data)
        that.setData({
          resources
        })
      }
    }, 4)
  },
})