<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="#7451DE"
          lineWidth="48rpx"
          lineHeight="4rpx"
          :activeStyle="{
            'font-family': 'PingFang SC',
            'font-weight': 500,
            'font-size': '32rpx',
            'line-height': 1.4,
            'color': '#7451DE',
          }" 
          :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" 
          @pay="onPay(item)"
          @applyService="onApplyService(item)"
          @statusChange="getData"
        ></orderCard>
      </view>

    </view>

    <payPopup ref="payPopup" @submitted="getData"></payPopup>
    <serviceSelectPopup ref="serviceSelectPopup"></serviceSelectPopup>

  </view>
  
</template>

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

  import orderCard from './orderCard.vue'
  import payPopup from '@/pages_order/order/payPopup.vue'
  import serviceSelectPopup from '@/pages_order/applyService/serviceSelectPopup.vue'

  export default {
		mixins: [mixinsList],
    components: {
      orderCard,
      payPopup,
      serviceSelectPopup,
    },
    data() {
      return {
        tabs: [
          { name: '全部' },
          { name: '待支付' },
          { name: '待发货' },
          { name: '待收货' },
          { name: '待评价' },
        ],
        // todo
				mixinsListApi: '',
        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()
			},
      // todo: delete
			getData() {
        console.log('getData')
				this.list = [
          {
						id: '001',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 4,
          },
          {
						id: '002',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 3,
          },
          {
						id: '003',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 0,
          },
          {
						id: '004',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 1,
          },
          {
						id: '005',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 2,
          },
          {
						id: '006',
						url: '/pages_order/static/index/recommend-pic.png', 
						title: '月度装定制营养包',
						amount: 688,
            productList: [
              {
                id: '0011',
    						url: '/pages_order/static/index/medicine-1.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                customized: true,
              },
              {
                id: '0012',
    						url: '/pages_order/static/index/medicine-2.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
              {
                id: '0013',
    						url: '/pages_order/static/index/medicine-3.png', 
                name: '月度装定制营养包',
                type: '保健品',
                content: '控糖精华萃 x30颗、膳食纤维 ×30颗',
                price: 688.00,
                count: 1,
                countDesc: '1月装',
                free: true,
              },
            ],
            userName: '周小艺',
            phone: '15558661691',
            createTime: '2025-04-28 08:14',
            status: 5,
          },
        ]
				this.total = this.list.length
			},
      onPay(data) {

        const {
          id,
          title,
          amount
        } = data

        
        const obj = {
          title,
          orderId: id,
          amount,
        }

        this.$refs.payPopup.open(obj)
      },
      onApplyService(data) {

        const {
          id,
          productList,
        } = data

        
        const obj = {
          id,
          productList,
        }

        this.$refs.serviceSelectPopup.open(obj)
      },
    },
  }
</script>

<style scoped lang="scss">
  .page__view {
		width: 100vw;
		min-height: 100vh;
		background-color: $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;
        bottom: 0;
      }

    }
	}

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

</style>