<template>
	<view class="content">
		<view class="grxx">
			<view class="grxxTitle">个人信息</view>
			<view class="grxxItem">
				<view class="ygxm">姓名：{{userData.name}}</view>
				<view class="sfzhm">
					<text>身份证</text>
					<text>{{userData.idcard}}</text>
				</view>
				<view class="sfzhm">
					<text>手机号</text>
					<text>{{userData.phone}}</text>
				</view>
				<view class="sfzhm">
					<picker @change="bindPickerChangeGzdd" :value="value" :range="areaList" range-key="label">
						<view class="gzdd">
							<text>工作地点</text>
							<input type="text" :disabled="true" placeholder="请选择>>" :value="areaName" />
						</view>
					</picker>
				</view>
			</view>
		</view>
		<view class="grxx">
			<view class="grxxTitle">1.身体是否出现以下异常</view>
			<view class="grxxItem">
				<view class="sfzhm">
					发烧、四肢无力、喉咙痛、流鼻涕、出血、眼眶发红、红疹等
				</view>
				<view class="xx">
					<button class="xx1" :class="abnormalBody==1?'xx3':''" @click="abnormalBody=1">是</button>
					<button class="xx2" :class="abnormalBody==0?'xx3':''" @click="abnormalBody=0">否</button>
				</view>
				<view v-if="abnormalBody==1" class="sfzhm">
					<text>体温</text>
					<input type="number" v-model="animalHeat" placeholder="请输入摄氏度温度" />
				</view>
			</view>
		</view>
		<view  class="footer">
			<button type="default" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		postRequest,
		getRequest,
		baseURL,
		baseURL1
	} from '../../api/api.js'
	export default {
		data() {
			return {
				abnormalBody: null,
				animalHeat: '', //温度
				userData: {},
				areaType: '',
				areaName: '',
				areaList: [{
					id: 1,
					name: '金山'
				}, {
					id: 2,
					name: '市区'
				}],
				id: '0', //地域选择id
				num:''

			}
		},
		onLoad: function(option) {
			this.num=option.num || ''
			getRequest('/loginVerify/findByOpenIdInfo', {}).then(res => {
				if (res.code == '200') {
					this.userData = res.data;
					if (this.userData.areaType != null) {
						this.areaName = this.candidates[this.userData.areaType - 1].name;
						this.areaType = this.userData.areaType;
					}
				} 
			});
			//获取工作地点字典列表
			postRequest('/sys-dict/findDictByType', {"type": "area_type"}).then(res => {
				if (res.code == '200') {
					this.areaList = res.data;
				} 
			});
			getRequest('/covidDailyRegister/isDailyRegister', {}).then(res => {
				if (res.code == '200') {
					if (res.data == 1) {
						uni.navigateTo({
							url: '/pages/txz/txz'
						})
					} else {
						if(option.icon){
							uni.showModal({
								title: '提示',
								content: '您今日无排班记录',
								success: function(res) {
									uni.navigateTo({
										url: '/pages/sy/sy'
									})
								}
							})
						}else{
							getRequest('/loginVerify/findByOpenIdInfo', {}).then(res => {
								if (res.code == '200') {
									this.userData = res.data;
									 /* if (this.userData.areaType != null) {
										this.areaType=this.userData.areaType
										this.areaName = this.areaList[this.userData.areaType - 1].name;
									} */
								} else {
									uni.showModal({
										title: '提示',
										content: '您今日无排班记录',
										success: function(res) {
											uni.navigateTo({
												url: '/pages/404/404'
											})
										}
									})
								}
							});
						}
						
					}
				}
			}) 

		},
		methods: {
			bindPickerChangeGzdd: function(e) {
				this.areaType = this.areaList[e.target.value].value;
				this.areaName = this.areaList[e.target.value].label;
			},
			submit() {
				if(this.abnormalBody==1 && this.animalHeat==''){
					uni.showModal({
						title: '提示',
						showCancel: false,
						content: '温度必填',
						success: function(res) {
							
						}
					})
				}else{
					let that = this;
					uni.showModal({
						title: '《疫情防控承诺书》',
						showCancel: false,
						content: '本人同意上海市公共卫生临床中心（下简称机构）在疫情防控时期对本人身体状况定期跟踪，如遇发烧、咳嗽等相关情况，采取强制离岗措施。本人承诺积极配合机构的防疫相关工作，真实有效的上报自身身体状况和旅居史。如因瞒报、谎报身体状况或高风险旅居史导致疫情出现社群性传染情况，本人愿承担相应法律责任，并赔偿相应损失。',
						success: function(res) {
							if (res.confirm) {
								that.save()
							}
						}
					});
				}
			},
			save() {
				let data = {
					abnormalBody: this.abnormalBody,
					animalHeat: this.animalHeat || '',
					areaType: this.areaType,
					idcard: this.userData.idcard,
					name: this.userData.name,
					officeId: this.userData.officeId,
					phone: this.userData.phone,
					userId: this.userData.id,
					userType: this.userData.userType,
					num:this.num
				}
				postRequest('/dailyReport/insertDailyReport', data).then((res) => {
					if (res.code == '200') {
						uni.showModal({
							title: '提示',
							showCancel: false,
							content: res.data.msg,
							success: function(res) {
								if (res.confirm) {
									uni.navigateTo({
										url: '/pages/txz/txz?status=0'
									})
								}
							}
						})
					} else {
						uni.showModal({
							title: '提示',
							showCancel: false,
							content: res.msg,
							success: function(res) {

							}
						})
					}
				})
			}
		}
	}
</script>

<style>
	page {
		position: relative;
	}

	.content {
		padding: 0 10px;
	}

	.content .grxxTitle {
		padding: 5% 0;
		font-size: 14px;
	}

	.grxxItem {
		border-radius: 5px;
		box-shadow: 0px 0px 15px 3px rgba(0, 0, 0, 0.1);
	}

	.grxxItem .ygxm {
		padding: 10px;
		background-color: #3297ff;
		color: white;
	}

	.contextdqs {
		position: fixed;
		z-index: 100;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.3);
	}


	.contextdq {
		width: 80%;
		height: 50%;
		margin: 0 auto;
		transform: translateY(44%);
		background-color: white;
		overflow-y: scroll;
		padding: 5%;
		border-radius: 5px;
		font-size: 14px;
	}

	.xcmphoto {
		padding: 5%;
	}

	.xcmphoto text {
		color: red;
		font-size: 14rpx;
	}

	.grxxItem .sfzhm {
		margin: 0 10px;
		border-bottom: 1px solid #CCCCCC;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px;
		font-size: 84%;
		color: #999999;
		position: relative;
	}


	.hxx {
		position: absolute;
		color: red;
		left: 3px;
		top: 25%;
	}

	.grxxItem .sfzhm {
		border: none;
		height: 36rpx;
		font-size: 14px;
	}

	.grxxItem .sfzhm:last-of-type .uni-combox {
		width: 100%;
	}

	.grxxItem .sfzhm:last-of-type .uni-combox .uni-input-input {
		margin-left: 50rpx;
	}

	.dxkxxx label {
		display: block;
		width: 100%;
	}

	.xx {
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 4px 10px;
		padding: 10px 0;
	}

	.xx1 {
		margin: 0;
		padding: 0;
		width: 34%;
		border-radius: 68px 0 0 68px;
		height: 34px;
		line-height: 34px;
		border: none;
		font-size: 15px;

	}

	.xx2 {
		margin: 0;
		padding: 0;
		width: 34%;
		border-radius: 0 68px 68px 0;
		height: 34px;
		line-height: 34px;
		border: none;
		font-size: 15px;
	}

	.xx3 {
		background-color: #007AFF;
		color: white;
	}

	.xxdz {
		margin: 0 10px;
		padding: 10px;
		font-size: 84%;
		color: #999999;
		position: relative;
	}

	.xxdz .hxx {
		top: 7%;
	}

	.xxdz .sfzhm {
		margin: 0;
		border-bottom: 1px solid #CCCCCC;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px 0;
		font-size: 84%;
		color: #999999;
		border: none;
	}



	.sfzhm radio {
		border-radius: 0;
		transform: scale(0.7)
	}

	.sfzhm image {
		width: 30rpx;
		height: 30rpx;
	}

	.sfzhm .radio {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.sfzhm .radio image {
		width: 40rpx;
		height: 40rpx;
	}

	uni-picker {
		width: 100%;
	}

	.gzdd {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
	}

	.gzdd input {
		width: 20%;
		font-size: 14px;
	}

	.xzdzxx {
		text-align: center;
	}

	.xzdzxx {
		padding: 10px;
		text-align: center;
		color: #007AFF;
	}

	.footer {
		padding: 10px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.footer button {
		width: 50%;
		background-color: #007AFF;
		color: white;
	}

	.picTime {
		z-index: 10;
		height: 100%;
		width: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.uni-padding-wrap {
		width: 750rpx;
		background-color: white;
		display: flex;
		justify-content: center;
		padding: 10px 0;
	}

	.uni-padding-wrap button {
		height: 30px;
		line-height: 30px;
		font-size: 15px;
	}

	.uni-padding-wrap button:last-of-type {
		background-color: #007AFF;
		color: white;
	}

	.yymc {
		position: absolute;
		bottom: 0;
		left: 0;
		z-index: 100;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
	}

	.pickers {
		position: absolute;
		bottom: 0;
		left: 0;
		height: 40%;
		z-index: 10;
		text-align: center;
		background-color: white;
	}

	.picker-view {
		width: 750rpx;
		height: 600rpx;
		margin-top: 20rpx;
	}

	.item {
		height: 50px;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
	}

	.dqxz {
		position: absolute;
		left: 0;
		bottom: 0;
		height: 70%;
		width: 100%;
		background-color: white;
		padding: 10px;
	}

	.dqxz .uni-title {
		padding: 10px 0;
		text-align: center;
	}

	.dqxz .uni-list-cell-db {
		margin: 10px 20px 10px 10px;
		padding: 5px;
		border-radius: 6px;
		background-color: #CCCCCC;
		border-top: 1px solid #CCCCCC;
		border-bottom: 1px solid #CCCCCC;
	}

	.dyButton {
		overflow: hidden;
		text-align: center;
		border-bottom: 1px solid #f3eded;
		padding: 1%;
	}

	.dyButtons {
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		position: relative;
		height: 4.1%;
		text-align: center;
		padding: 1%;
		border-bottom: 1px solid #f3eded;
	}

	.dyButton view {
		float: left;

		border: none;
		background-color: white;
		font-size: 15px;
	}

	.dyButtons view:first-of-type {
		position: absolute;
		left: 0%;
		top: 0%;
		border: 1px solid rgba(0, 0, 0, 0);
		background-color: white;
		font-size: 15px;
	}

	.dyButtons .dybuttonst {
		position: absolute;
		right: 5%;
		top: 0%;
		border: 1px solid rgba(0, 0, 0, 0);
		background-color: white;
		font-size: 15px;
	}

	.dyButtons .dybuttonst {
		color: #007AFF;
	}

	.container .ql-container {
		height: 80%;
	}
</style>
