const bLoadingStatus = require("../../../base/behaviors/bLoadingStatus")
|
const lawservice = require("../../../service/lawservice")
|
const moment = require('../../../utils/moment.min')
|
const app = getApp()
|
|
/**
|
* 获取守法培训材料
|
*/
|
module.exports = Behavior({
|
behaviors: [bLoadingStatus],
|
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)
|
},
|
}
|
})
|