<template>
	<view class="page">
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop +'px')}">
		<view class="content">
			<view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">报丧人</view>
							<view class="serve-right" @click="bspersonshow = true">
								<text>*</text>{{bspersoninfo.name}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-picker :show="bspersonshow"  @confirm="bspersonconfirm" @cancel="bspersonclose" :columns="bspersoncolumns"></u-picker>
			<!-- <view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">礼堂时间</view>
							<view class="serve-right" @click="ltsjshow = true">
								<text>*</text>{{time}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<u-calendar :show="ltsjshow" mode="range" @confirm="timeconfirm" @close="timeclose"></u-calendar>
			<!-- <view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve" @click="ltwzshow = true">
							<view class="serve-title">礼堂位置</view>
							<view class="serve-right">
								<text>*</text>{{from.hallLocation}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<u-picker :show="ltwzshow"  @confirm="xzltwz" @cancel="ltwzclose" :columns="jclxcolumns"></u-picker>
			<view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve" @click="qsgxshow = true">
							<view class="serve-title">亲属关系</view>
							<view class="serve-right">
								<text>*</text>{{from.relativeRelationship}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-picker :show="qsgxshow"  @confirm="qsgxxz" @cancel="qsgxclose" :columns="qsgxcolumns"></u-picker>
			<view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="info-box-width width100">
							<view>
								<input v-model="from.others" class="input-text" type="text" placeholder="请输入" placeholder-class="inputtext" />
							</view>
							<view class="info-box-small">预约意向</view>
						</view>
					</view>
				</view>
			</view>
			<view class="page-footer">
			  <view class="footer-buy">
			    <view class="cart-add" @click="open">
					<view><image src="../../static/btn3.png"></image></view>
					<view class="cart-add-text"><image src="../../static/phone.png"></image><text>联系电话</text></view>
			    </view>
			    <view class="buy-at" @click="funeralresult">
					<image src="../../static/btn4.png"></image>
			      <text>立即预约</text>
			    </view>
			  </view>
			</view>
			
		</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				OrderType: 0,
				nvConfig:{
					title:"礼堂预约",
					bgColor:"#ffffff",
					color:"#000000",
					fixedAssist:{
						hide:true,
					},
				},
				ltsjshow:false,
				time:"请选择",
				from:{
					scheduledStartTime:"",
					scheduledEndTime:"",
					hallLocation:"请选择",
					obituaryOrderNumber: "24681216",
					others: "暂时没有",
					rating: "未评价",
					relativeRelationship: "请选择",
					reservatorName: "",
					reservatorPhone: "",
					status: "等通知",
				},
				jclxcolumns:[
					['第一栋', '第二栋']
				],
				ltwzshow:false,
				
				qsgxshow:false,
				qsgxcolumns:[
					['爱人','兄弟','父母','其他']
				],
				
				bspersoninfo:{
					name:"",
					obituaryOrderNumber:"",
				},
				bspersonshow:false,
				bspersonlist:[],
				bspersoncolumns:[],
			};
		},
		onPageScroll(e) {this.$refs.nv.pageScroll(e)},
		computed:{
			pageTop(){return parseInt(88*uni.getSystemInfoSync().windowWidth/750) + uni.getSystemInfoSync().statusBarHeight}
		},
		onLoad(params) {
			this.OrderType = params.type;
			this.getbsinfo();
		},
		methods:{
			open(){
				console.log("123",this.contentshow);
				var that = this
				uni.showModal({
					title: '联系电话',
					content: '如有问题请拨打电话:' + "02836241643",
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 获取用户的报丧记录
			getbsinfo(){
				console.log("userinfo",uni.getStorageSync("USERS_KEY"));
				var info = {
					userId:uni.getStorageSync("USERS_KEY").userId
				}
				this.API.getbsinfo(info).then(res=>{
					console.log("获取用户报丧信息",res);
					this.bzpersonlist = res.rows;
					this.bspersoninfo.name = res.rows[0].deceasedName
					this.bspersoninfo.obituaryOrderNumber = res.rows[0].orderNumber
					var info = []
					for(let i = 0;i < res.rows.length;i++){
						info.push(res.rows[i].deceasedName)
					}
					this.bspersoncolumns.push(info)
				})
			},
			// 礼堂时间选择
			timeconfirm(e){
				console.log(e);
				this.from.scheduledStartTime = e[0]
				var i = e.length - 1
				this.from.scheduledEndTime = e[i]
				this.time = this.from.scheduledStartTime + "-" + this.from.scheduledEndTime
				this.ltsjshow = false
			},
			timeclose(){
				this.ltsjshow = false
			},
			// 报丧人确定
			bspersonconfirm(e){
				this.bspersonshow = false
				this.bspersoninfo.name = e.value[0]
				this.bspersoninfo.obituaryOrderNumber = this.bspersonlist[e.indexs[0]].orderNumber
			},
			bspersonclose(){
				this.bspersonshow = false
			},
			// 礼堂位置的确认
			xzltwz(e){
				console.log(e);
				this.from.hallLocation = e.value[0]
				this.ltwzshow = false
			},
			// 礼堂位置弹窗的取消
			ltwzclose(){
				this.ltwzshow = false
			},
			// 亲属关系选择
			qsgxxz(e){
				this.from.relativeRelationship = e.value[0]
				this.qsgxshow = false
			},
			qsgxclose(){
				this.qsgxshow = false
			},
			funeralresult(){
				var user = uni.getStorageSync('USERS_KEY')
				this.from.reservatorName = user.nickName
				this.from.reservatorPhone = user.phonenumber
				this.from.obituaryOrderNumber = this.bspersoninfo.obituaryOrderNumber
				// this.from.handledTime = user.loginDate;
				this.API.ltyy(this.from).then(res=>{
					console.log("礼堂预约",res);
				})
				uni.navigateTo({
					url: '/pages/funeralresult/funeralresult',
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'auditorium.scss';
</style>
