<template>
	<view class="main">
		<view class="cu-list menu-avatar margin-sm" @click="gotoinfo(item)" v-for="(item,index) in patientList" :key="index"
		 style="border-radius: 16rpx;box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);">
			<view class="cu-item">
				<view class="cu-avatar round lg" :style="'background-image:url('+item.avatar+');'"></view>
				<view class="content">
					<view class="text-grey">{{item.name}}</view>
					<view class="text-gray text-sm flex">
						<text class="text-cut">
							{{item.sex==1?'男':'女'}}
						</text>
						<text class="text-cut margin-left-sm">
							{{item.age}}
						</text>
					</view>
				</view>
				<view class="action">
					<text class="cuIcon-roundright lg text-gray"></text>
				</view>
			</view>
		</view>
		<u-empty text="暂无档案" :show="istrue" mode="list" margin-top="300"></u-empty>
		<view class="cu-bar bg-white tabbar" style="position: fixed;bottom: 0;width: 100%;">
			<view class="submit" style="background-color: #0B73B9;color: white;" @click="addarchives">
				添加健康档案
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(options) {

		},
		onShow() {
			this.getarchives()
		},
		data() {
			return {
				patientList: [],
				istrue: false
			}
		},
		methods: {
			getarchives: async function() {
				let res = await this.$request.post("/api/v1/patient/patientList")
				console.log(res)
				if (res.status == 0) {
					this.patientList = res.data.data
					if (this.patientList.length == 0) {
						this.istrue = true
					}
				}
			},
			addarchives() {
				uni.navigateTo({
					url: "add_archives"
				})
			},
			gotoinfo(item) {
				uni.navigateTo({
					url: "archives_info?id=" + item.id
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.main {}
</style>
