首页进一步实现分类展示、分类导航,将所有的问题按照发布者的学校、学院和问题已解决还是为解决分类,因为问答数据库Qes-info设计的时候我们就只设计了问题内容、收藏的人数、发布者学校学院这些数据。
data: {
input: null,
//问题信息
userSchool: null,
userFaculty: null,
details: null,
},
main.js
if (that.data.filterVal == 1) { //本学校筛选
qesInfo.where({
userSchool: that.data.userSchool,
}).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
success: res => {
//console.log(res)
wx.hideLoading()
let oldData = that.data.fileCollection
that.setData({
fileCollection: oldData.concat(res.data)
})
that.pageData.skip = that.pageData.skip + 20;
},
fail: err => {
console.error(err)
}
})
} else if (that.data.filterVal == 2) { //本学院筛选
qesInfo.where({
userSchool: that.data.userSchool,
userFaculty: that.data.userFaculty,
}).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
success: res => {
//console.log(res)
wx.hideLoading()
let oldData = that.data.fileCollection
that.setData({
fileCollection: oldData.concat(res.data)
})
that.pageData.skip = that.pageData.skip + 20;
},
fail: err => {
console.error(err)
}
})
} else if (that.data.filterVal == 3) { //已解决筛选
qesInfo.where({
fileId: db.command.not(db.command.size(0)), //数组长度不为0
}).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
success: res => {
//console.log(res)
wx.hideLoading()
let oldData = that.data.fileCollection
that.setData({
fileCollection: oldData.concat(res.data)
})
that.pageData.skip = that.pageData.skip + 20;
},
fail: err => {
console.error(err)
}
})
} else if (that.data.filterVal == 4) { //未解决筛选
qesInfo.where({
fileId: [],
}).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
success: res => {
//console.log(res)
wx.hideLoading()
let oldData = that.data.fileCollection
that.setData({
fileCollection: oldData.concat(res.data)
})
that.pageData.skip = that.pageData.skip + 20;
},
fail: err => {
console.error(err)
}
})
} else { //无筛选
qesInfo.skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
success: res => {
//console.log(res)
wx.hideLoading()
let oldData = that.data.fileCollection
that.setData({
fileCollection: oldData.concat(res.data)
})
that.pageData.skip = that.pageData.skip + 20;
},
fail: err => {
console.error(err)
}
})
}
main.wxml
<view class="filter">
<view class="manage {{filterVal==null?'hover':''}}" bindtap="all">全部</view>
<view class="manage {{filterVal==1?'hover':''}}" bindtap="mySchool">本学校</view>
<view class="manage {{filterVal==2?'hover':''}}" bindtap="myFaculty">本学院</view>
<view class="manage {{filterVal==3?'hover':''}}" bindtap="solved">已解决</view>
<view class="manage {{filterVal==4?'hover':''}}" bindtap="unSolved">未解决</view>
<view class="total">共 {{total}} 项</view>
</view>