<template>
	<view class="technician-select-list">
		<mNavbar title="选择技师" :leftClick="leftClick"></mNavbar>
		<view class="technician-list">
			<selectTechnicianCompoents 
			v-if="loading"
			: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: [],
				loading: false,
				finished: false
			}
		},
		onLoad() {
			this.getProjectDetail()
		},
		methods: {
			//获取项目详情
			getProjectDetail() {
				
				let queryParams = {
					id: this.$route.query.serviceId
				}
				
				if(this.$store.state.selectArea.id){
					queryParams.county = this.$store.state.selectArea.id
				}
				
				this.$api('getProjectDetail', queryParams, res => {
					this.loading = true
					if (res.code == 200) {
						this.technicianList = res.result.tenPageList;
					}
				})
			},
			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) {
				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>