<template>
	<view class="msilde">
		<view class="left">
			<view :class="{ active: index == current }" v-for="(item, index) in list" :key="index" class="item" @click="selected(item, index)">{{ item.deptName }}</view>
		</view>
		<view class="right">
			<view class="list" v-if="doctor_list.length > 0">
				<view v-for="(item, index) in doctor_list" :key="index" class="item" @click="go('/pages/doctor/detail?id=' + item.id)">
					<image :src="item.avatar ? ip + item.avatar : '../../static/head.png'" mode="scaleToFill" class="avatar"></image>
					<view class="con">
						<view class="name">{{ item.name }}</view>
						<view class="brief ellip">{{ item.brief }}</view>
					</view>
				</view>
			</view>
			<u-empty v-else></u-empty>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			current: 0,
			ip: this.http.ip,
			doctor_list: {},
			list: []
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/department/list',
				success: (res) => {
					this.list = res.data.data;
					this.selected(this.list[0], 0);
				}
			});
		},
		selected(item, index) {
			this.current = index;
			this.http.request({
				url: '/app/doctor/list',
				data: { deptId: item.deptId },
				success: (res) => {
					this.doctor_list = res.data.data;
				}
			});
		},
		go(url) {
			uni.navigateTo({ url: url });
		}
	}
};
</script>

<style lang="scss"></style>
