<template>
	<view class="container">
		<VNavigationBar titleColor="rgba(0,0,0,0.9)" backgroundColor="transparent" title="我的预约">
		</VNavigationBar>
		<view class="body">
			<scroll-view style="height: 100%;" scroll-y="true">
				<view class="orderList">
					<reservationOrderVue v-for="(item, index) in orderList" :key="index" :orderInfo="item">
					</reservationOrderVue>
				</view>
        <view class="no-data" v-if="orderList.length==0">
          <image class=""  src="@/static/images/nothing.png" ></image>
        </view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import VNavigationBar from '@/components/VNavigationBar.vue'
	import tabBarVue from '@/components/tabBar/tabBar.vue'
	import reservationOrderVue from '../../components/reservationOrder/reservationOrder.vue'
  import request from "@/utils/request";
  import {getToken} from '@/utils/auth.js'

	export default {
		components: {
			tabBarVue,
			VNavigationBar,
			reservationOrderVue
		},
		data() {
			return {
				// orderList: [{
				// 		title: '顺捷汽车维修搭电救援补胎中心',
				// 		status: '1',
				// 		address: '济南市历下区福瑞达历下护理院东南门旁',
				// 		phone: '15726506879',
				// 		busiTypeStr: '汽车维修'
				// 	},
				// 	{
				// 		title: '顺捷汽车维修搭电救援补胎中心',
				// 		status: '1',
				// 		address: '济南市历下区福瑞达历下护理院东南门旁',
				// 		phone: '15726506879',
				// 		busiTypeStr: '汽车维修'
				// 	}
				// ]
        orderList:[]
			}
		},
    onShow() {
      if(!getToken()){
        uni.reLaunch({
          url: '/pages/login/login'
        })
      }else{
        console.log("已登录")
      }
      this.getBookingPage()
    },
		methods: {
      async getBookingPage(){
        const res = await request({
          url: "/userClient/repair/booking/page",
          method: "get",
          params:{
            pageNo: 1,
            pageSize: 10
          }
        })
        const data = res.data.records
        const ids = data.map(item => item.id)
        const response = await request({
          url: "/userClient/repair/booking/map?ids=" + ids,
          method: "get",
        })
        const list = response.data
        this.orderList = list.map(item => {
          return {
            ...item,
            title: item.company.corpName,
            address: item.company.address,
            phone: item.company.mobilePhone,
            busiTypeStr: item.servicePackage.name,
            status: item.bookingStatus
          }
        })
      }
		}
	}
</script>

<style scoped lang="less">
	.container {
		height: 100%;
		background: #F3F5F7;
		background: linear-gradient(180deg, #C1DEFF 0%, rgba(#F3F5F7, 0) 100%);
		background-size: 100% 600rpx;
		background-repeat: no-repeat;
		display: flex;
		flex-direction: column;
		color: #333333;

		.body {
			flex: 1;
			height: 0;
			padding: 16rpx 0 30rpx;
			overflow: auto;
		}

		.orderList {
			width: 686rpx;
			margin: 0 auto;
			display: flex;
			flex-direction: column;
			row-gap: 20rpx;
		}
    .no-data{
      text-align: center;
    }
	}
</style>
