<template>
	<view class="app">
		<view class="inputs">
			<i class="icon"></i>
			<input type="text" name="" id="" class="input" placeholder="请输入医生姓名">
		</view>
		<view class="list">
			<view class="item" v-for="item in doctorlist" @tap='emitdata(item)'>
				<image src="../../static/docHead.png" mode=""></image>
				<view class="name">
					{{item.realname?item.realname:''}}
				</view>
				<view class="address">
					{{item.teamName?item.teamName:''}}
				</view>
				<view class="title">
					{{item.teamMemberTypeName?item.teamMemberTypeName:''}}
				</view>
				<view class="zixunbtn">
					选TA
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getDoctorList
	} from '@/api/pagesC/choosedoctor/index.js'
	export default {
		data() {
			return {
				orgNo: null,
				doctorlist: [],
				doctortotal: 0,
				pageNum: 1,
			};
		},
		methods: {
			getDoctorListinfo() {
				getDoctorList(this.pageNum, this.orgNo, '1').then(res => {
					this.doctorlist = res.rows
					this.doctortotal = res.total
				})
			},
			emitdata(item) {
				uni.$emit('doctordata', {
					data: JSON.stringify(item),
				})
				uni.navigateBack({
					delta: 1
				});
			},
		},
		onLoad(options) {
			this.orgNo = options.orgNo
			this.getDoctorListinfo();
		},
		onReachBottom() { //上滑加载
			if (this.doctorlist.length >= this.doctortotal) {} else {
				this.pageNum++;
				getDoctorList(this.pageNum, this.orgNo, '1').then(res => {
					res.rows.forEach(e => {
						this.doctorlist.push(e)
					})
					this.doctortotal = res.total
				})
			}
		},
		onPullDownRefresh() { //下拉刷新
			this.pageNum = 1;
			this.getDoctorListinfo()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style lang="scss">
	@import './choosedoctor.scss';
</style>
