<template>
	<view class="app">
		<view class="message">请填写下面的信息</view>
		<view class="user">
			<view class="item">
				<span>姓名：</span>
				<span>{{personInfo.patientName}}</span>
			</view>
			<view class="item">
				<span>电话：</span>
				<span>{{personInfo.phone}}</span>
			</view>
			<view class="item">
				<span>地址：</span>
				<span>{{personInfo.address}}</span>
			</view>
			<view class="selecttime" @tap='timeshow=true'>
				<span>时间：</span>
				<text v-if="usertime==''" style="color: black;">请选择时间
				<image src="../../static/jiantou.png"></image></text>
				<text v-else style="color: black;">{{usertime}}</text>

			</view>
		</view>
		<view class="remarks">
			服务时长:{{orderlist.serveDurationUnit}}
		</view>
		<view class="Package">套餐信息：
			<text class="money">￥{{orderlist.nurseItemPrice}}</text>
			<text class="detail">
				·{{orderlist.nurseItemName}}
			</text>
		</view>
		<view class="Consumablespackage">耗材包详情：
			<text class="money">￥{{orderlist.consumableTotalPrice}}</text>
			<text class="detail">
				{{orderlist.itemConsumableList}}
			</text>
		</view>
		<view class="remarks">
			<span>备注：</span>
			<input placeholder="">
		</view>
		<view class="radio-content">
			<view class="radio-right">
				<view class="radio" :class="radio1 == 2 ? 'radio-default':''" @tap="changeRadio2">
					<view :class="radio1 == 2 ? 'radio-active':''"></view>
				</view>
			</view>
			<text class="agreement" @tap="changeRadio2">我已阅读并同意</text>
			<text @tap='maskshow=true;showRegectAgreeButton=false'>《用户协议》</text>
		</view>
		<view class="priceback">
			<view class="prices">￥{{orderlist.totalPrice}}</view>
			<view class="xiugai">修改信息</view>
			<view class="queren" @tap='updata'>确认预约</view>
		</view>
		<u-toast ref="uToast" />
		<upicker v-model="timeshow" mode="time" start-year='2022' :params="timeparams" @confirm='timeconfirm'></upicker>
	</view>
</template>
<script>
	import {
		getAppStationItemInfo,
		getAppPatientList,
		submitAppointment
	} from '@/api/appointmenttime/appointmenttime.js'
	import baseurl from '@/api/baseurl.js'
	import upicker from './@/pages/u-picker/u-picker.vue'
	export default {
		components: {
			upicker
		},
		data() {
			return {
				timeparams: {
					year: true,
					month: true,
					day: true,
					hour: true,
					endhour: true,
					minute: true,
					endminute: true,
				},
				timeshow: false,
				maskshow: false,
				orderlist: {
					"patientId": '',
					"stationId": 2,
					"stationItemId": 2,
					"stationItemPriceId": 3,
					"serviceAddress": "",
					"serviceDate": "",
					"serviceStartTime": "",
					"serviceEndTime": "",
					"nurseItemName": "",
					"nurseItemPrice": '',
					"serveDurationUnit": "",
					"consumableTotalPrice": '',
					"totalPrice": '',
					"remark": "",
					"orderCount": 1,
					"orderConsumableList": []
				},
				maskshow: false,
				userlist: [],
				patientId: 46,
				phone: '',
				patientName: '',
				address: '',
				usertime: '',
				radio1: 1,
				stationId: 2,
				stationItemId: 2,
				stationItemPriceId: 3,
				username: "",
				personInfo: [],
			}
		},
		onLoad(options) {
			console.log(options)
			this.getInfo()
			this.getPatientInfo()
			//获取护理站id等信息
			this.personInfo.patientId = options.patientId
			this.orderlist.stationId = options.stationId
			this.orderlist.stationItemId = options.stationItemId
			this.orderlist.stationItemPriceId = options.stationItemPriceId
			//耗材包详情方法调用
			// this.getPatientInfo(options.stationId, options.stationItemId, options.stationItemPriceId)
		},
		methods: {
			//获取时间
			timeconfirm(e) {
				console.log(e)
				this.orderlist.serviceDate = e.year + '-' + e.month + '-' + e.day
				this.orderlist.serviceStartTime = e.hour + ":" + e.minute
				this.orderlist.serviceEndTime = e.endhour + ":" + e.endminute
				this.usertime = e.year + '年' + e.month + '月' + e.day + '日' + e.hour + ":" + e.minute + '至' +e.endhour + ":" + e.endminute
				console.log(this.orderlist,this.usertime)
			},
			getInfo() { //被护理人信息
				getAppPatientList(this.patientId).then(res => {
					this.personInfo = res.data[0]
					console.log("this.personInfo", this.personInfo);
				})
			},

			//获取耗材包详情
			getPatientInfo(stationId, stationItemId, stationItemPriceId) {
				getAppStationItemInfo(this.stationId, this.stationItemId, this.stationItemPriceId).then(res => {
					console.log(res)
					this.orderlist = res.data
					//被护理人信
				})
			},
			//确认预约
			updata() {
				this.orderlist.orderCount = 1;
				// console.log(this.orderlist)
				submitAppointment(this.orderlist).then(res => {

					}

				)
			},
			changeRadio2() {
				this.radio1 = 2;
				// console.log("个人")
			},

		}
	}
</script>
<style lang="scss">
	@import './appointmenttime.scss'
</style>
