You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
256 lines
6.6 KiB
256 lines
6.6 KiB
import { getTopicHotList, getHotIssueList, getHotItemList } from '../../../../api/reality'
|
|
Page({
|
|
data: {
|
|
isClick: 'topic',
|
|
showTimePicker: false,
|
|
someMonthsType: 1,
|
|
timeList: [
|
|
{ time: '最近一个月', id: 1 },
|
|
{ time: '最近三个月', id: 2 },
|
|
{ time: '最近六个月', id: 3 },
|
|
{ time: '最近一年', id: 4 }],
|
|
list: [],
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
total: 0,
|
|
loadVisible: true,
|
|
loadType: 'more',
|
|
isShow: false,
|
|
listLength: 0,
|
|
isShowLoading: true, //true 正在加载中 false 可以切换
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getTopicHotList()
|
|
},
|
|
goIndex(e: any) {
|
|
if (this.data.isClick == "topic") {
|
|
wx.navigateTo({ url: `/subpages/issue/pages/detail/topicDetail/topicDetail?Id=${e.currentTarget.dataset.id}` });
|
|
} else if (this.data.isClick == "issue") {
|
|
wx.navigateTo({ url: `/subpages/issue/pages/detail/IssueDetails/issueDetails?Id=${e.currentTarget.dataset.id}` });
|
|
} else if (this.data.isClick == "project") {
|
|
wx.navigateTo({ url: `/subpages/issue/pages/detail/projectDetails/projectDetails?Id=${e.currentTarget.dataset.id}` });
|
|
}
|
|
},
|
|
triggle(e: any) {
|
|
if (this.data.isShowLoading) {
|
|
wx.showToast({
|
|
title: '正在加载中请稍后切换', //提示的内容,
|
|
icon: 'none', //图标,
|
|
duration: 2000, //延迟时间,
|
|
mask: true, //显示透明蒙层,防止触摸穿透,
|
|
});
|
|
return
|
|
}
|
|
let { currentTarget } = e
|
|
this.setData({
|
|
list: [],//3个tab切换时,也应该把之前的内容清空
|
|
loadType: 'more',
|
|
isShow: false,
|
|
pageIndex: 1,
|
|
showTimePicker:false
|
|
})
|
|
if (currentTarget.dataset.index == "最热话题") {
|
|
this.setData({
|
|
isClick: 'topic',
|
|
})
|
|
this.getTopicHotList()
|
|
|
|
} else if (currentTarget.dataset.index == "最热议题") {
|
|
this.setData({
|
|
isClick: 'issue',
|
|
})
|
|
this.getHotIssueList()
|
|
} else if (currentTarget.dataset.index == "最热项目") {
|
|
this.setData({
|
|
isClick: 'project',
|
|
})
|
|
this.getHotItemList()
|
|
}
|
|
},
|
|
// 显示隐藏时间选择框
|
|
chooseTimePicker() {
|
|
if (this.data.isShowLoading) {
|
|
wx.showToast({
|
|
title: '正在加载中请稍后切换', //提示的内容,
|
|
icon: 'none', //图标,
|
|
duration: 2000, //延迟时间,
|
|
mask: true, //显示透明蒙层,防止触摸穿透,
|
|
});
|
|
return
|
|
}
|
|
this.setData({
|
|
showTimePicker: !this.data.showTimePicker
|
|
})
|
|
},
|
|
// 选择时间
|
|
onTimeChange(e: any) {
|
|
this.setData({
|
|
someMonthsType: e.currentTarget.dataset.time,
|
|
showTimePicker: false,
|
|
preloadVisible: true,
|
|
loadType: 'more',
|
|
isShow: false,
|
|
pageIndex: 1,
|
|
list: []//选择时间切换之前把之前的内容都清空
|
|
})
|
|
if (this.data.isClick == "topic") {
|
|
this.getTopicHotList()
|
|
} else if (this.data.isClick == "issue") {
|
|
this.getHotIssueList()
|
|
} else if (this.data.isClick == "project") {
|
|
this.getHotItemList()
|
|
}
|
|
|
|
},
|
|
/****话题**** */
|
|
async getTopicHotList() {
|
|
this.setData({
|
|
loadVisible: true,
|
|
isShowLoading: true,
|
|
})
|
|
try {
|
|
let obj = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
someMonthsType: this.data.someMonthsType
|
|
}
|
|
let res = await getTopicHotList(obj)
|
|
this.setData({
|
|
list: this.data.list.concat(res.data.list),
|
|
listLength: res.data.list.length,
|
|
isShowLoading: false,
|
|
})
|
|
if (this.data.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadType: 'none',
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
if (this.data.list.length == 0) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
} catch (err) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: true,
|
|
})
|
|
}
|
|
},
|
|
/****议题**** */
|
|
async getHotIssueList() {
|
|
this.setData({
|
|
loadVisible: true,
|
|
isShowLoading: true,
|
|
})
|
|
try {
|
|
let obj = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
someMonthsType: this.data.someMonthsType
|
|
}
|
|
let res = await getHotIssueList(obj)
|
|
this.setData({
|
|
list: this.data.list.concat(res.data.list),
|
|
listLength: res.data.list.length,
|
|
isShowLoading: false,
|
|
})
|
|
if (this.data.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadType: 'none',
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
if (this.data.list.length == 0) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
} catch (err) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
},
|
|
/****项目**** */
|
|
async getHotItemList() {
|
|
this.setData({
|
|
loadVisible: true,
|
|
isShowLoading: true,
|
|
})
|
|
try {
|
|
let obj = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
someMonthsType: this.data.someMonthsType
|
|
}
|
|
let res = await getHotItemList(obj)
|
|
this.setData({
|
|
list: this.data.list.concat(res.data.list),
|
|
listLength: res.data.list.length,
|
|
isShowLoading: false,
|
|
})
|
|
if (this.data.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadType: 'none',
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
if (this.data.list.length == 0) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: false,
|
|
})
|
|
}
|
|
} catch (err) {
|
|
this.setData({
|
|
loadVisible: false,
|
|
isShow: true,
|
|
isShowLoading: false,
|
|
})
|
|
|
|
}
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
// 判断是否需要在加载数据
|
|
if (this.data.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadType: 'none',
|
|
})
|
|
return
|
|
}
|
|
this.setData({
|
|
loadType: 'more',
|
|
})
|
|
let obj = {
|
|
pageIndex: ++this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
someMonthsType: this.data.someMonthsType
|
|
}
|
|
|
|
if (this.data.isClick == "topic") {
|
|
this.getTopicHotList()
|
|
} else if (this.data.isClick == "issue") {
|
|
this.getHotIssueList()
|
|
} else if (this.data.isClick == "project") {
|
|
this.getHotItemList()
|
|
}
|
|
},
|
|
|
|
})
|