<template>
  <layout>
    <uv-sticky
      bgColor="#fff"
      customNavHeight="0"
    >
      <uv-navbar
        :fixed="false"
        title="售后订单"
        @leftClick="$onClickLeft"
      />
      <uv-tabs
        :scrollable="false"
        :list="navList"
        @click="click"
        lineColor="#f56c6c"
      >
        ></uv-tabs>
    </uv-sticky>
    <view class="orderList">
      <order
        :data="item"
        v-for="(item, index) in orderListData"
        :key="actionType + '_' + index"
        @refresh="handleRefresh"
      />
    </view>
  </layout>
</template>

<script setup>
import { ref } from 'vue'
import { navigateTo, back } from '@/utils/router'
import { onLoad } from '@dcloudio/uni-app'
import { useMainStore } from '@/store/store'
import { storeAfterSalesList } from '@/api/order'

const orderListData = ref([])

const handleOrderList = async () => {
  let res = await storeAfterSalesList({
    type: actionType.value
  })
  orderListData.value = res
}


const actionType = ref(0)

const navList = ref([
  { name: "全部", value: -1, },
  { name: "售后中", value: 1, },
  { name: "已完成", value: 2, },
])


const click = (data) => {
  actionType.value = data.value
  handleOrderList()
  console.log("--> % click % data:\n", data)

}

onLoad(({ type }) => {

  if (type < 0 || !type) {
    actionType.value = -1
  } else {
    actionType.value = type
  }
  handleOrderList()
  console.log("--> % onLoad % type:\n", type)

})



</script>

<style lang="less">
.orderList {
  padding: 20rpx 0;
}
</style>
