<template>
	<view class='waiting-method-page'>
		<view class="h-name over PfScSemibold">
			{{hospital_depart_name}}
		</view>

		<user-card v-for="(item, key) in active_visitors" :dataitem="item" @clickEvent="changeType" :index="key"></user-card>

		<view class="submit">
			<view class="bot primary btn btn2 submitbtn PfScMedium" hover-class="hover" @click="submitWaitType">
				确认候诊方式
			</view>
		</view>

	</view>
</template>

<script>
	import userCard from '@/components/userCard.vue';
	
	export default {
		data() {
			return {
				cssUrl:this.cssUrl,
				depart_id:0,
				active_visitors:[],
				hospital_depart_name:'',
				visitorList:[
					{name:'张三',type:1},
					{name:'李四', type:1},
				]
			}
		},
		components:{
			userCard
		},
		onLoad(option) {
			// 来自 确认报道页面选中的就诊人
			var active_visitors = JSON.parse(uni.getStorageSync('active_visitors'));
			this.active_visitors = active_visitors;
			var depart_info = uni.getStorageSync('depart');
			if(depart_info) {
				depart_info = JSON.parse(depart_info)
				this.hospital_depart_name = depart_info.hospital_name + ' ' + depart_info.depart_name
			}

			this.getVisitors()
			this.depart_id = uni.getStorageSync('depart_id')
			if(!this.depart_id) {
				this.$pop.modelShow('请先选择要预约的医院科室', '/pages/index/index')
				return
			}
		},
		onReady() {
		},
		methods: {

			getVisitors() {
				this.$http.req('user/get_visitors', {}, 'POST').then(data=>{
					this.visitUsers = data;
					this.visitUsers = [...this.visitUsers]
					this.popMsgs = []
					var popmsgIndex = 0
					for (var i = 0; i < this.visitUsers.length; i++) {
						this.visitUsers[i].select = false
					}
				});
			},
			changeType(info) {
				console.log(info)
				// 存储每一项的候诊方式
				this.active_visitors[info.key].type = info.type;
			},
			submitWaitType(){
				// 跳转就诊记录待完成
				// this.active_visitors待完成
				// jiekou 更新数据----待完成
				
				this.$http.req('user/get_visitors', {}, 'POST').then(data=>{
					
					uni.navigateTo({
						url:'/pages/prebook_list/prebook_list'
					})
				});
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.waiting-method-page{
	overflow: hidden;
	.h-name{
		padding: 36rpx 24rpx;
		box-sizing: border-box;
		width: 100%;
		height: 116rpx;
		margin-bottom: 20rpx;
		background: white;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		color: #000000;
	}
	.title-wrap{
		width: 100%;
		height: 100rpx;
	}
	.submit{
		position: fixed;
		width: 100%;
		top: 82.41%;
		.submitbtn{
			width: 666rpx;
			margin: 0 auto;
		}
		.tip{
			text-align: center;
			font-size: 28rpx;
			color: #B3B4BC;
			margin-top: 33rpx;
		}
	}
}
</style>
