<template>

	<view class="app">
		<view class="" v-if="myFollowUpdata.length>0">
			<view class="body" v-for="(item,index) in myFollowUpdata" :key="index"
				@tap="changefollow(item)">
				<view class="follow">
					随访时间：<span class="time">{{item.followDate?item.followDate:'暂无'}}</span>
				</view>
				<view class="follow">
					<span></span>
					随访方式：
					<span class="time">
						{{item.taskNodeType=='PHONE_OUTBOUND'?'电话外呼':''}}
						{{item.taskNodeType=='QUESTIONNAIRE_SCALE'?'问卷量表':''}}
						<!-- {{item.taskNodeType=='PROPAGANDA_ARTICLE'?'宣教文章':''}} -->
						<!-- {{item.taskNodeType=='TEXT_REMIND'?'文字提醒':''}} -->
					<!-- 	{{item.taskNodeType=='ARTIFICIAL_FOLLOW_UP'?'人工随访':''}} -->
					</span>
				</view>
				<view class="follow">
					随访名称：<span class="time">{{item.followName?item.followName:'暂无'}}</span>
				</view>
			</view>

		</view>
		<view class="noorder" v-else>
			<u-empty mode="data" icon-size='220' text='暂无内容'></u-empty>
		</view>

	</view>
</template>

<script>
	import {
		myFollowUp
	} from '@/api/follow/follow.js'
	export default {
		data() {
			return {
				myFollowUpdata: [], //随访列表
				query: {
					num: 1,
					size: 10,
					residentId: '',
				},
				total: 0,

			}
		},
		onLoad() {

			if(uni.getStorageSync('patientId')){
				this.query.residentId=uni.getStorageSync('patientId')
				this.myFollowUplist()

			}

			console.log(this.myFollowUpdata)

		},
		methods: {
			myFollowUplist() {
				myFollowUp(this.query).then(res => {
					this.myFollowUpdata = res.rows
					this.total = res.total
				})
			},
			changefollow(item) {
				console.log(item, 'item')
				// 电话外呼
				if (item.taskNodeType == 'PHONE_OUTBOUND') {
					uni.navigateTo({
						url: `/pages/consulting/consulting?item=${JSON.stringify(item)}`
					})

				}
				// 详情及答案
				else if (item.taskNodeType == 'QUESTIONNAIRE_SCALE') {
					// 问卷量表
					uni.navigateTo({
						url: `/pages/questionnairedetail/questionnairedetail?item=${JSON.stringify(item)}`
					})

				}
			},
			onReachBottom() { //下滑加载
				// console.log(this.myFollowUpdata, '000000000')
				if (this.myFollowUpdata.length >= this.total) {} else {
					this.query.num++;
					myFollowUp(this.query).then(res => {
						if (res.rows) {
							res.rows.forEach(e => {
								this.myFollowUpdata.push(e)
							})
						}
					})
				}
			},
			onPullDownRefresh() { //下拉刷新
				this.myFollowUpdata = [];
				this.query.num = 1;
				this.myFollowUplist();
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},


		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F5F5;
	}

	::v-deep .u-empty {
		margin-top: 100rpx !important;
	}

	.app {
		// padding: 20rpx 0 0 0;
		// overflow: scroll;
		// font-size: 28rpx;

		.noorder {
			margin-top: 20%;
		}

		.bodys {
			width: 95%;
			height: 320rpx;
			background: #E8E5E5;
			margin: 40rpx auto;
			padding-top: 15rpx;
			box-shadow: 0px 4px 15px 4px rgba(0, 0, 0, 0.03);
			border-radius: 2px;

			.follow {
				margin-top: 10rpx;
				padding: 20rpx 0 0 100rpx;

				.time {
					display: inline-block;
					width: 200rpx;
					height: 55rpx;
					line-height: 55rpx;
					padding-left: 20rpx;
					padding-right: 20rpx;
					border: 1px solid #CFCECE;
				}

				;
			}

		}

		.body {
			width: 95%;
			height: 320rpx;
			background: #fff;
			margin: 40rpx auto;
			padding-top: 15rpx;
			box-shadow: 0px 4px 15px 4px rgba(0, 0, 0, 0.03);
			border-radius: 2px;

			.follow {
				margin-top: 10rpx;
				padding: 20rpx 0 0 100rpx;

				.time {
					display: inline-block;
					width: 200rpx;
					height: 55rpx;
					line-height: 55rpx;
					padding-left: 20rpx;
					padding-right: 20rpx;
					// background: #F6F6F6;
					border: 1px solid #CFCECE;
				}

				;
			}

		}
	}
</style>
