首页分类导航进一步优化

首页进一步实现分类展示、分类导航,将所有的问题按照发布者的学校、学院和问题已解决还是为解决分类,因为问答数据库Qes-info设计的时候我们就只设计了问题内容、收藏的人数、发布者学校学院这些数据。

 data: {
    input: null,
    //问题信息
    userSchool: null,
    userFaculty: null,
    details: null,
  },

qes-info 数据库

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值