| | |
| | | import { newsPage,saveShareRecord } from '../../api/index' |
| | | import { |
| | | newsPage, |
| | | saveShareRecord |
| | | } from '../../api/index' |
| | | import moment from "moment"; |
| | | Page({ |
| | | |
| | |
| | | this.getList() |
| | | }, |
| | | getList() { |
| | | newsPage({capacity:this.data.capacity, |
| | | newsPage({ |
| | | capacity: this.data.capacity, |
| | | page:this.data.page, |
| | | model:{type:0}}) |
| | | model: { |
| | | type: 0 |
| | | } |
| | | }) |
| | | .then(res =>{ |
| | | wx.stopPullDownRefresh() |
| | | if(this.data.page ==1){ |
| | | this.setData({list:[]}) |
| | | 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}) |
| | | this.setData({ |
| | | list: [...this.data.list, ...res.data.records || []], |
| | | total: res.data.total |
| | | }) |
| | | } |
| | | console.log(this.data) |
| | | }) |
| | |
| | | }, |
| | | onReachBottom() { |
| | | console.log('触底事件'); |
| | | const { total, list, page } = this.data |
| | | const { |
| | | total, |
| | | list, |
| | | page |
| | | } = this.data |
| | | if(total > list.length){ |
| | | this.setData({ page: page + 1 }) |
| | | this.setData({ |
| | | page: page + 1 |
| | | }) |
| | | this.getList() |
| | | }else{ |
| | | wx.showToast({ |
| | |
| | | downloadImageFileDo(files,title){ |
| | | wx.showLoading({ |
| | | title: '正在下载', |
| | | mask: true |
| | | }) |
| | | let temp = 0; |
| | | let count = 0; |
| | | if(files.length){ |
| | | for(let i = 0;i<files.length;i++){ |
| | | let filePath = wx.env.USER_DATA_PATH + '/' + new Date().valueOf()+i + '.jpg' ; |
| | |
| | | filePath: tempFp, |
| | | success(result) { |
| | | temp ++; |
| | | console.log(result) |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | if(temp == files.length){ |
| | | wx.hideLoading(); |
| | | wx.setClipboardData({ |
| | | data: title, |
| | | success: function (res) { |
| | |
| | | } |
| | | }) |
| | | } |
| | | }, fail(err) { |
| | | }, |
| | | fail(err) { |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | wx.showToast({ |
| | | title: '图片下载失败哦' |
| | | }) |
| | | } |
| | | }) |
| | | } , fail(err) { |
| | | }, |
| | | fail(err) { |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | wx.showToast({ |
| | | title: '图片下载失败哦' |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }else{ |
| | | wx.showToast({ |
| | | title: '该资讯暂无可分享的图片或视频', |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | }, |
| | | downloadVideoFileDo(files,title){ |
| | | wx.showLoading({ |
| | | title: '正在下载', |
| | | mask: true |
| | | }) |
| | | let count = 0; |
| | | if(files.length){ |
| | | let filePath = wx.env.USER_DATA_PATH + '/' + new Date().valueOf() + '0.mp4'; |
| | | wx.downloadFile({ |
| | |
| | | wx.saveVideoToPhotosAlbum({ |
| | | filePath: tempFp, |
| | | success(result) { |
| | | console.log(result) |
| | | wx.hideLoading(); |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | wx.setClipboardData({ |
| | | data: title, |
| | | success: function (res) { |
| | |
| | | }) |
| | | } |
| | | }) |
| | | }, fail(err) { |
| | | }, |
| | | fail(err) { |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | wx.showToast({ |
| | | title: '视频下载失败哦' |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | fail(err) { |
| | | count++; |
| | | if (count == files.length) { |
| | | wx.hideLoading() |
| | | } |
| | | wx.showToast({ |
| | | title: '视频下载失败哦' |
| | | }) |
| | | } |
| | | }) |
| | | }else{ |
| | | wx.showToast({ |
| | | title: '该资讯暂无可分享的图片或视频', |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | }, |
| | |
| | | */ |
| | | onPullDownRefresh() { |
| | | console.log('下拉刷新') |
| | | this.setData({ page: 1 }) |
| | | this.setData({ |
| | | page: 1 |
| | | }) |
| | | this.getList() |
| | | }, |
| | | |