import { newsPage,saveShareRecord } from '../../api/index' import moment from "moment"; Page({ /** * 页面的初始数据 */ data: { capacity: 10, page: 1, list: [], total: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getList() }, getList() { newsPage({capacity:this.data.capacity, page:this.data.page, model:{type:0}}) .then(res =>{ wx.stopPullDownRefresh() if(this.data.page ==1){ this.setData({list:[]}) } if(this.data.page == res.data.page){ res.data.records.forEach(element => { element.createDate = moment(element.createDate).format("yyyy/MM/DD") }) this.setData({list: [...this.data.list, ...res.data.records || []], total:res.data.total}) } console.log(this.data) }) }, onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, onReachBottom() { console.log('触底事件'); const { total, list, page } = this.data if(total > list.length){ this.setData({ page: page + 1 }) this.getList() }else{ wx.showToast({ title: '暂无更多数据', icon: 'none' }) } }, downfile(e){ const item = e.currentTarget.dataset.index; saveShareRecord(item.id) const files = [] if(item.fileType ==1 && item.fileList && item.fileList.length && item.fileList[0].fileurlFull ){ files.push(item.fileList[0].fileurlFull) } if(item.fileType !=1 && item.fileList && item.fileList.length ){ item.fileList.forEach(ee => { if(ee.fileurlFull){ files.push(ee.fileurlFull) } }) } if(item.fileType ==1){ this.downloadVideoFileDo(files,item.title) }else{ this.downloadImageFileDo(files,item.title) } }, downloadImageFileDo(files,title){ wx.showLoading({ title: '正在下载', }) let temp = 0; if(files.length){ for(let i = 0;i