<template>
  <view class="orderlist">
    <view class="ordertab">
      <orderTap tabtittle="全部,待付款,待收货,待评价" v-on:tabchange="change1" :tap="state"></orderTap>
    </view>

    <view class="orders" v-if="state==3">
      <!-- <view class="orderitem" v-for="(i,j) in orderlist" :key="j"> -->
        <orderItem
          :orderno="i.order_no"
          num="3"
          money="146"
          :state="i.state"
          class="orderitem"
          :shops="orderlist"
        ></orderItem>
      <!-- </view> -->
      <!-- <view class="orderitem">
        <orderItem
          orderno="TH70900175"
          shopname="养车定制T1汽车LED大灯 无损改装替换H7 6000K一对装 白光（不可用券）"
          shoppic="../../static/img/ordershop.png"
          num="3"
          money="146"
          class="orderitem"
          state="4"
        ></orderItem>
      </view>
      <view class="orderitem">
        <orderItem
          orderno="TH70900175"
          shopname="养车定制T1汽车LED大灯 无损改装替换H7 6000K一对装 白光（不可用券）"
          shoppic="../../static/img/ordershop.png"
          num="3"
          money="146"
          state="2"
          class="orderitem"
        ></orderItem>
      </view> -->
    </view>
    <view class="orders" v-if="state==0">
      <!-- <view class="orderitem" v-for="(i,j) in orderlist0" :key="j"> -->
        <orderItem
          :orderno="i.order_no"
          num="3"
          money="146"
          :state="i.state"
          class="orderitem"
          :shops="orderlist0"
        ></orderItem>
      <!-- </view> -->
    </view>
    <view class="orders" v-if="state==1">
     <!-- <view class="orderitem" v-for="(i,j) in orderlist1" :key="j"> -->
        <orderItem
          :orderno="i.order_no"
          num="3"
          money="146"
          :state="i.state"
          class="orderitem"
          :shops="orderlist1"
        ></orderItem>
      <!-- </view> -->
  </view>
  <view class="orders" v-if="state==2">
      <!-- <view class="orderitem" v-for="(i,j) in orderlist2" :key="j"> -->
        <orderItem
          :orderno="i.order_no"
          num="3"
          money="146"
          :state="i.state"
          class="orderitem"
          :shops="orderlist2"
          @shouhuo="shouhuo"
        ></orderItem>
      <!-- </view> -->
    </view>
  </view>
</template>

<script>
import orderTap from "../../components/order/order-tab";
import offerList from "../../components/offer/offer-list";
import orderItem from "../../components/order/orderitem";
import requestP from "../../static/js/request.js";
export default {
  data() {
    return {
      ifnull: true,
      state: 3,
      orderlist:[],
      orderlist0:[],
      orderlist1:[],
      orderlist2:[],

    };
  },
  onLoad(e){
    this.state=e.kind
    console.log(this.state)
    requestP.requestP({
      url:"order/get_order_list",
    }).then((res)=>{
      console.log(res.data.data)
      this.orderlist=res.data.data  
    })
     requestP.requestP({
      url:"order/get_order_list",
      data:{
        type:0
      }
    }).then((res)=>{
      console.log(res.data.data)
      this.orderlist0=res.data.data  
    })
    requestP.requestP({
      url:"order/get_order_list",
      data:{
        type:1
      }
    }).then((res)=>{
      console.log(res.data.data)
      this.orderlist1=res.data.data  
    })
    requestP.requestP({
      url:"order/get_order_list",
      data:{
        type:2
      }
    }).then((res)=>{
      console.log(res.data.data)
      this.orderlist2=res.data.data  
    })
  },
  components: {
    orderTap,
    offerList,
    orderItem
  },
  methods: {
    change1(data) {
      console.log(data, 42);
      this.state = data;
    },
    shouhuo(e){
      console.log(e)
    }
  }
};
</script>

<style lang="scss">
page {
  background-color: #eeeeee;
}
.orderlist {
  .ordertab {
    background-color: white;
    position: relative;
    z-index: 999;
  }
  .ordernull {
    position: absolute;
    top: 0;
  }
  .orderitem {
    margin-top: 21upx;
  }
}
</style>