小程序swiper左右滑动


  
    待确认
    运输中
    待结算
    已完成
    已取消
  
  
  
    
  
  
    
  
  
    
  
  
    
  
  
    
  
   
 data: {
    currentTab: 0,
    isactive: true,
    scrollHeight: 0,
    myReceive:[],
    size: 10,
    pageEnd: false,
    state:'待确认'
  },
//滑动切换
swiperTab:function(e){
    var that = this;
    that.setData({
       currentTab: e.detail.current 
       });
    if (that.data.currentTab == 0) {
      that.data.state = '待确认'
    } else if (that.data.currentTab == 1) {
      that.data.state = '运输中'
    } else if (that.data.currentTab == 2) {
      that.data.state = '待结算'
    } else if (that.data.currentTab == 3) {
      that.data.state = '已完成'
    } else if (that.data.currentTab == 4) {
      that.data.state = '已取消'
    }
    var myReceive = {
      state: that.data.state,
      page: '1',
      size: '10'
    }
    api.getRequest(api.apiUrl.ORDERS_ACCEPTED_GET, myReceive, function (res) {
      var datas = res.data.data.items;
      console.log(datas)
      for (let i = 0; i < datas.length; i++) {
        datas[i]["limitedAt"] = tool.toDate(datas[i]["limitedAt"])
      }
      that.setData({
        myReceive: datas
      })
    })
    console.log("9ui", that.data.state)
  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
    if (that.data.currentTab == 0) {
      that.data.state = '待确认'
    } else if (that.data.currentTab == 1) {
      that.data.state = '运输中'
    } else if (that.data.currentTab == 2) {
      that.data.state = '待结算'
    } else if (that.data.currentTab == 3) {
      that.data.state = '已完成'
    } else if (that.data.currentTab == 4) {
      that.data.state = '已取消'
    }
    console.log("ffffffffffffffff" + this.data.currentTab)
    var that = this;
    var myReceive = {
      state: that.data.state,
      page: '1',
      size: '10'
    }
    api.getRequest(api.apiUrl.ORDERS_ACCEPTED_GET, myReceive, function (res) {
      var datas = res.data.data.items;
      for (let i = 0; i < datas.length; i++) {
        datas[i]["limitedAt"] = tool.toDate(datas[i]["limitedAt"])
      }
      that.setData({
        myReceive: datas
      })
      console.log("asfffff", that.data.myReceive)
    })
  },

 

之前是直接赋值了禁止左右滑动待确认.但后来要求可以滑动,我以为把禁止滑动(catchtouchmove='stopTouchMove')就可以了,但发现api里swiper current属性默认值是0,所以一直滑动不了,后来我就设置为数字了,然后通过js赋值,之前直接赋值,也没用滚动,所以只写一条数据判断不同的状态,然后显示就行了,但左右滚动数据必须在scroll-view里,有几个滚动就要写几个scroll-view,所以数据重复太多,然后我就写在模板里面引用过来了

 

你可能感兴趣的:(微信小程序笔记)