<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="jctimeshow = true">
								<text>*</text>{{time}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<u-calendar :show="jctimeshow" 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="jclxshow = true">
							<view class="serve-title">寄存类型</view>
							<view class="serve-right">
								<text>*</text>{{from.type}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<u-picker :show="jclxshow"  @confirm="xzjclx" @cancel="jclxclose" :columns="jclxcolumns"></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="jcgwshow = true">
								<text>*</text>{{from.storageLocation}}
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view> -->
			<u-picker :show="jcgwshow"  @confirm="xzjcgw" @cancel="jcgwclose" :columns="jcgwcolumns"></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,
					},
				},
				jctimeshow:false,
				time:"请选择",
				from:{
					storageStartTime:"",
					storageEndTime:"",
					storageLocation:"请选择",
					type:"请选择",
					
					obituaryOrderNumber: "28827136",
					others: "",
					rating: "未评价",
					relativeRelationship: "亲属",
					reservatorName:"",
					reservatorPhone: "",
					status:"等通知"
				},
				
				jclxcolumns:[
					['永久', '暂存']
				],
				jclxshow:false,
				
				jcgwcolumns:[
					['第一格', '第二格']
				],
				jcgwshow: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.storageStartTime = e[0]
				var i = e.length - 1
				this.from.storageEndTime = e[i]
				this.time = this.from.storageStartTime + "-" + this.from.storageEndTime
				this.jctimeshow = false
			},
			timeclose(){
				this.jctimeshow = 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
			},
			// 亲属关系选择
			qsgxxz(e){
				this.from.relativeRelationship = e.value[0]
				this.qsgxshow = false
			},
			qsgxclose(){
				this.qsgxshow = false
			},
			// 寄存类型的确认
			xzjclx(e){
				this.from.type = e.value[0]
				this.jclxshow = false
			},
			// 寄存类型弹窗的取消
			jclxclose(){
				this.jclxshow = false
			},
			// 寄存格位的确认
			xzjcgw(e){
				console.log(e);
				this.from.storageLocation = e.value[0]
				this.jcgwshow = false
			},
			// 寄存类型弹窗的取消
			jcgwclose(){
				this.jcgwshow = 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.API.ghjcyy(this.from).then(res=>{
					console.log("骨灰寄存",res);
				})
				uni.navigateTo({
					url: '/pages/funeralresult/funeralresult',
				})
			},
		}
	}
</script>

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