<template>
	<view class="technician-select-list">
		<mNavbar title="选择技师" :leftClick="leftClick"></mNavbar>
		<view class="technician-list">
			<selectTechnicianCompoents :technicianList="technicianList" :select="toPayOrder" />
		</view>
	</view>
</template>

<script>
	import mNavbar from '../../components/base/m-navbar.vue'
	import selectTechnicianCompoents from "../../components/selectTechnicianCompoents.vue"
	export default {
		components: {
			mNavbar,
			selectTechnicianCompoents
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
					title: ''
				},
				technicianList: sessionStorage.getItem('technicianList') ? JSON.parse(sessionStorage.getItem(
					'technicianList')) : [],
				loading: false,
				finished: false
			}
		},
		methods: {
			onLoad() {

			},
			leftClick() {
				let { current , active } = this.$route.query
				if(current && active > -2){
					return uni.reLaunch({
					  url: `/pages/index/order?active=${active}`
					})
				}
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			toPayOrder(item) {
				if (item.bookable != 'Y') {
					return uni.showToast({
						title: '技师未开启接单',
						icon: 'none'
					})
				}
				this.$api('createVipOrder', {
					projectId: this.$route.query.serviceId,
					technicianId: item.id
				}, res => {
					if (res.code == 200) {
						uni.navigateTo({
							url: `/pages/order/payOrder?orderId=${res.result.id}&distance=${item.setKmOpen == 'Y' ? item.setKm : item.km}&setKmOpen=${item.setKmOpen}`
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.technician-select-list {
		background: #F5F5F5;
		min-height: 100vh;
		width: 750rpx;
		margin: 0rpx auto;
		box-sizing: border-box;
	}
</style>