const { httpRequest } = getApp(); import { imageBasUrl } from '../../utils/config' Page({ data: { discoverList: [], noDataFlag: false, page: 1, imageBasUrl, }, getFindIndex(page, show, refresh) { const discoverList = this.data.discoverList; if (!show) { my.showLoading({ content: '加载中...', }); } const paramenter = { path: '/findindex', method: 'POST', body: { page } } httpRequest(paramenter).then(res => { my.hideLoading(); if (refresh) { my.stopPullDownRefresh(); } if (res.status == 1 && Array.isArray(res.data.module1)) { const module1 = res.data.module1; let ls = []; let noDataFlag = false; if (module1.length == 0) { noDataFlag = true; } if (page == 1) { ls = module1; } else { ls = [...discoverList, ...module1]; } this.setData({ discoverList: ls, page, noDataFlag, }) } }) }, onShow() { this.getFindIndex(1) }, onReachBottom() { const page = this.data.page; const noDataFlag = this.data.noDataFlag; if (!noDataFlag) { this.getFindIndex(page + 1) } }, onPullDownRefresh() { this.getFindIndex(1, false, true) }, chaseCollection(ev) { let params = {}; const item = ev.currentTarget.dataset.item; const idx = ev.currentTarget.dataset.idx; const discoverList = this.data.discoverList; if (item.collection === 0) { params = { path: '/addkeep', method: 'POST', body: { sid: item.id } } } else { params = { path: '/chasingdramadel', method: 'POST', body: { ids: item.id, sid: item.id } } } discoverList[idx].collection = item.collection === 0 ? 1 : 0; discoverList[idx].num = item.collection === 0 ? item.num + 1 : item.num - 1; httpRequest(params).then((res) => { this.setData({ discoverList }) }); }, toPathVideo(event) { const data = event.target.dataset.item; const systemInfo = getApp().globalData.systemInfo; if (systemInfo.platform == 'android' || systemInfo.platform == 'Android') { my.navigateTo({ url: `/pages/videoAndroid/videoAndroid?sid=${data.id}`, }); } else { my.navigateTo({ url: `/pages/video/video?sid=${data.id}` }); } }, })