// 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)
|
},
|
})
|