import articleApi from "../../../api/articleApi" import clientConfig from "../../../config/index" Page({ data: { searchKey: '', hotArticles:[], rankType: 'all', hasMore: true, // 是否有更多数据 loading: false, // 是否正在加载 pageSize: 10, pageNum: 1, sortField: '', }, onSearch(){ this.data.hotArticles = [] this.data.pageNum = 1 this.data.hasMore = true this.fetchData() }, onLoad(options) { this.fetchData() }, onReachBottom: function () { if (this.data.hasMore) { this.fetchData(); // 触底时加载更多数据 } }, fetchData(){ if (this.data.loading) { return; // 如果正在加载,则不再加载 } articleApi.projectPage({ pageNum: this.data.pageNum, pageSize: this.data.pageSize, searchKey: this.data.searchKey, sortField: this.data.sortField, sortOrder: 'descend' }).then(res=>{ this.setData({ hotArticles: [...this.data.hotArticles, ...res.data.rows], loading: false, pageNum: this.data.pageNum + 1 }) if (res.data.rows.length < 10) { console.log(res.data.rows) this.setData({ hasMore: false }); } }) }, rank(e){ let rankType = e.currentTarget.dataset.type this.setData({rankType}) this.fetchData() }, copyUrl: function(e) { const url = e.currentTarget.dataset.url; const name = e.currentTarget.dataset.name; wx.setClipboardData({ data: name + ' 演示视频:' + url, success: () => { wx.showToast({ title: '已复制到剪贴板', icon: 'success', duration: 2000 }); } }); }, // 分享给朋友 onShareAppMessage(res) { return new Promise((resolve) => { wx.showLoading({ title: '生成分享图片...' }) // 获取页面截图 wx.createSelectorQuery() .select('.card-blank') // 选择要截图的区域,这里选择了标题区域 .fields({ size: true, scrollOffset: true }) .exec((res) => { wx.hideLoading() resolve({ title: '南音源码资源搜索', path: '/pages/tabpages/org/org', imageUrl: '' // 微信会自动使用页面截图 }) }) }) }, // 分享到朋友圈 onShareTimeline() { return { title: '南音源码资源搜索', query: '', imageUrl: '' // 微信会自动使用页面截图 } } })