<template>
	<view class="page__view">

		<navbar title="订单管理" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />

		<view class="main">

      
      <view class="tabs">
        <uv-tabs 
          :list="tabs" 
          :current="current"
          :scrollable="false" 
          lineColor="#00A9FF"
          lineWidth="48rpx"
          lineHeight="4rpx"
          :activeStyle="{
            'font-family': 'PingFang SC',
            'font-weight': 500,
            'font-size': '32rpx',
            'line-height': 1.4,
            'color': '#00A9FF',
          }" 
          :inactiveStyle="{
            'font-family': 'PingFang SC',
            'font-weight': 400,
            'font-size': '32rpx',
            'line-height': 1.4,
            'color': '#181818',
          }" 
          @click="clickTabs"
        ></uv-tabs>
      </view>

      <view class="card" v-for="item in list" :key="item.id">
        <orderCard 
          :data="item" 
          @comment="onComment(item.id, item)"
          @applyService="onApplyService"
          @contatcMentor="onContactMentor"
          @statusChange="getData"
        ></orderCard>
      </view>

    </view>

    <contactMentorPopup ref="contactMentorPopup" ></contactMentorPopup>

    <commentPopup ref="commentPopup" @submitted="getData"></commentPopup>

    <servicePopup ref="servicePopup"></servicePopup>

  </view>
  
</template>

<script>
	import mixinsList from '@/mixins/list.js'

  import orderCard from './orderCard.vue'
  import contactMentorPopup from '@/pages_order/order/components/contactMentorPopup.vue'
  import commentPopup from '@/pages_order/comment/commentPopup.vue'
	import servicePopup from '@/components/base/servicePopup.vue'

  export default {
		mixins: [mixinsList],
    components: {
      orderCard,
      contactMentorPopup,
      commentPopup,
      servicePopup,
    },
    data() {
      return {
        // 订单状态 0待支付 1已支付 2已完成 // 售后 → isService：0-否 1-是
        tabs: [
          { name: '全部' },
          { name: '待支付' },
          { name: '已支付' },
          { name: '已完成' },
          { name: '售后' },
        ],
				mixinsListApi: 'queryOrderList',
        current: 0,
      }
    },
    onShow() {
      console.log('onShow')
    },
    onLoad(arg) {
      this.clickTabs({ index: arg.index || 0 })
    },
    methods: {
			//点击tab栏
			clickTabs({ index }) {
        console.log('clickTabs')
        this.current = index

				if (index == 0) {
					delete this.queryParams.status
				} else {
					this.queryParams.status = index - 1
				}
				this.getData()
			},
      onComment(id, detail) {
        this.$refs.commentPopup.open(id, detail)
      },
      onApplyService() {
        this.$refs.servicePopup.open()
      },
      onContactMentor(teacherPhone) {
        this.$refs.contactMentorPopup.open(teacherPhone)
      },
    },
  }
</script>

<style scoped lang="scss">
  .page__view {
		width: 100vw;
		min-height: 100vh;
		background: $uni-bg-color;
		position: relative;

    /deep/ .nav-bar__view {
      position: fixed;
      top: 0;
      left: 0;
    }
  }

  .main {
    padding: calc(var(--status-bar-height) + 244rpx) 32rpx 40rpx 32rpx;

    .tabs {
      position: fixed;
      top: calc(var(--status-bar-height) + 120rpx);
      left: 0;
      width: 100%;
      height: 84rpx;
      background: #FFFFFF;
      z-index: 1;

      /deep/ .uv-tabs__wrapper__nav__line {
        border-radius: 2rpx;
      }

    }
	}

  .card {
    & + & {
      margin-top: 40rpx;
    }
  }

</style>