项目实训四,审计系统展示

js项目

const app = getApp()
Page({
  data: {
    showsearch:false,   //显示搜索按钮
    searchtext:'',  //搜索文字
    filterdata:{},  //筛选条件数据
    showfilter:false, //是否显示下拉筛选
    showfilterindex:null, //显示哪个筛选类目
    sortindex:0,  //一级分类索引
    sortid:null,  //一级分类id
    subsortindex:0, //二级分类索引
    subsortid:null, //二级分类id
    servicelist:[], 
    scrolltop:null, //滚动位置
    leixing:'报销审计' 
  },
  onLoad: function () { //加载数据渲染页面
    this.fetchServiceData();
    this.fetchFilterData();
  },
  fetchFilterData:function(){ //获取筛选条件
    this.setData({
      filterdata:{
        "sort": [
            {
                "id": 0,
                "title": "全部"
            },
            {
              "id": 1,
              "title": "报销审计",
              "subsort": [
                {
                    "id": 1,
                    "title": "全部"
                },
                {
                    "id": 11,
                    "title": "准备审计"
                },
                {
                    "id": 12,
                    "title": "待审批中"
                },
                {
                    "id": 13,
                    "title": "审计修改"
                },
                {
                  "id": 14,
                  "title": "审计成功"
              },
              ]
            },
            {
              "id": 2,
              "title": "全程跟踪审计",
              "subsort": [
                {
                    "id": 2,
                    "title": "全部"
                },
                {
                  "id": 21,
                  "title": "准备审计"
              },
              {
                  "id": 22,
                  "title": "待审批中"
              },
              {
                  "id": 23,
                  "title": "审计修改"
              },
              {
                "id": 24,
                "title": "审计成功"
            },
              ]
            },
            
      
        ],
      
      }
    })
  },
  fetchServiceData:function(){  
    let _this = this;
    var that =  this;
    wx.showToast({
      title: '加载中',
      icon: 'loading'
    })
    const newlist = [];
    wx.request({
      url: app.globalData.globalReqUrl +'/api/my_affair', 
 
      method: 'get',
      header: {
        'content-type': 'application/json' ,
        'token':app.globalData.token
        },
      success(res) {
        console.log(res.data.content[0])
   
        for (var i = 0; i < res.data.content.length; i++) {
         if(res.data.content[i].kind==21)
         { 
          that.setData({
              leixing:"全程跟踪审计"
          })
         }
         else{
          that.setData({
            leixing:"报销审计"
        })
         }
         
          newlist.push({
            "i": i,
            "id":res.data.content[i].id,
            "name":res.data.content[i].name,
            "tag": that.data.leixing,
            
          })
        }
        
      }
    })
   
    setTimeout(()=>{
      _this.setData({
        servicelist:_this.data.servicelist.concat(newlist)
      })
    },1500)
  },
  inputSearch:function(e){  //输入搜索文字
    this.setData({
      showsearch:e.detail.cursor>0,
      searchtext:e.detail.value
    })
  },
  submitSearch:function(){  //提交搜索
    console.log(this.data.searchtext);
    this.fetchServiceData();
  },
  setFilterPanel: function(e){ //展开筛选面板
    const d = this.data;
    const i = e.currentTarget.dataset.findex;
    if(d.showfilterindex == i){
      this.setData({
        showfilter: false,
        showfilterindex: null
      })
    }else{    
      this.setData({
        showfilter: true,
        showfilterindex:i,
      })
    }
    console.log(d.showfilterindex);
  },
  setSortIndex:function(e){ //服务类别一级索引
    const d= this.data;
    const dataset = e.currentTarget.dataset;
    this.setData({
      sortindex:dataset.sortindex,
      sortid:dataset.sortid,
      subsortindex: d.sortindex==dataset.sortindex ? d.subsortindex:0
    })
    console.log('服务类别id:一级--'+this.data.sortid+',二级--'+this.data.subsortid);
  },
  setSubsortIndex:function(e){ //服务类别二级索引
    const dataset = e.currentTarget.dataset;
    this.setData({
      subsortindex:dataset.subsortindex,
      subsortid:dataset.subsortid,
    })
    console.log('服务类别id:一级--'+this.data.sortid+',二级--'+this.data.subsortid);
  },
  
  hideFilter: function(){ //关闭筛选面板
    this.setData({
      showfilter: false,
      showfilterindex: null
    })
  },
  scrollHandle:function(e){ //滚动事件
    this.setData({
      scrolltop:e.detail.scrollTop
    })
  },
  goToTop:function(){ //回到顶部
    this.setData({
      scrolltop:0
    })
  },
  scrollLoading:function(){ //滚动加载
   
  },
  onPullDownRefresh:function(){ //下拉刷新
    this.setData({
    
      servicelist:[]
    })
    this.fetchServiceData();
    this.fetchFilterData();
    setTimeout(()=>{
      wx.stopPullDownRefresh()
    },1000)
  }
})

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值