<template>
	<view class="page">
		<u-navbar title="基础设置" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='50' id="navbar">
		</u-navbar>
        <view class="box">
        	<!-- <view class="orderqx">
        		<view class="top">
        			<view class="one">
        				订单取消设置
        			</view>
        			<view class="two" @click="delflag = !delflag">
        				编辑
        			</view>
        		</view>
        		<view class="toptab">
        			<view class="">取消时长</view>
        			<view class="">违约金</view>
					<view class="" v-if="delflag">操作</view>
        		</view>
        		<view class="bottab" v-for="(item,index) in 3" :key="index">
        			<view class="">开始前30分钟内</view>
        			<view class="">10%</view>
					<view class="" v-if="delflag">
						<text style="color: #000;" @click="btnxg(item)">编辑</text> <text @click="btndel(item.wifiId)">删除</text>
					</view>
        		</view>
        		<view class="addpz" @click="flag = true">
        			添加取消配置
        		</view>
        	</view> -->
			<view class="ones">
				<view class="">
					取消时长
				</view>
				<view class="">
					开始前<input type="text" v-model="min" placeholder="输入"/>分钟内
				</view>
			</view>
			<view class="ones">
				<view class="">
					违约金
				</view>
				<view class="">
			        收取<input type="text" v-model="price" placeholder="输入"/>元				
				</view>
			</view>
			
        	<view class="orderqx">
        		<view class="top">
        			<view class="one">
        				保洁设置
        			</view>
        		</view>
        	    <view class="tongzhi" @click="showone = true">
        	    	<view class="one">
        	    		保洁通知
        	    	</view>
        			<view class="two">
        				{{onetxt}} <u-icon name="arrow-right" color="#7C7C7C" size="28"></u-icon>
        			</view>
        	    </view>
        		<view class="tongzhi" style="border: none;padding-bottom: 0;">
        			<view class="one">
        				保洁时长
        			</view>
        			<view class="two">
        				<input type="text" v-model="twotxt" placeholder="输入时间" /><view class="">分钟 <u-icon name="arrow-right" color="#7C7C7C" size="28"></u-icon></view>
        			</view>
        		</view>
        	</view> 
        	<view class="orderqx">
        		<view class="top">
        			<view class="one">
        				订单设置
        			</view>
        		</view>
        		<view class="tongzhi" style="border: none;padding-bottom: 0;">
        			<view class="one">
        				提前开始使用
        			</view>
        			<view class="two">
        				<input type="text" v-model="thrtxt" placeholder="输入时间" /><view class="">分钟 <u-icon name="arrow-right" color="#7C7C7C" size="28"></u-icon></view>
        			</view>
        		</view>
        	</view> 
        </view>
		
		<view class="mask" v-if="flag"></view>
		<view class="addwifi" v-if="flag">
			<view class="name">
				添加取消配置
			</view>
			<view class="one">
				<view class="">
					取消时长
				</view>
				<view class="">
					开始前<input type="text" v-model="wifiname" placeholder="输入"/>分钟内
				</view>
			</view>
			<view class="one">
				<view class="">
					违约金
				</view>
				<view class="">
                    收取订单<input type="text" v-model="wifipwd" placeholder="输入"/>%					
				</view>
			</view>
			<view class="baocun" @click="btnadd">
				保存
			</view>
			<view class="cha" @click="flag = false">×</view>
		</view>
		
		<u-select v-model="showone" :list="listone" @confirm="confirmone"></u-select>
		<view class="anniu">
			<view class="" @click="btnbc">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				showone: false,
				flag:false,
				min:'',
				price:'',
				listone: [
					{
						value: '0',
						label: '不通知'
					},{
						value: '1',
						label: '通知给商户'
					},{
						value: '2',
						label: '通知给保洁'
					},{
						value: '3',
						label: '通知商户和保洁'
					}
				],
				showtwo: false,
				delflag:false,
				cleanDuration:'',
				cleanNotice:'',
				onetxt:'',
				twotxt:'',
				thrtxt:'',
				beforeTime:''
			}
		},
		onLoad() {
            this.getinfo()
		},
		methods: {
			// 获取个人信息拿到基础信息
			getinfo(){
				this.$u.get(`/getAppInfo`).then(res => {
					if(res.code == 200){
						this.min = res.user.agoCancel
						this.price = res.user.penalty * 10
						this.twotxt = res.user.cleanDuration
						this.thrtxt = res.user.beforeTime
						this.cleanNotice = res.user.cleanNotice
						if(res.user.cleanNotice == 0){
							this.onetxt = '不通知'
						}else if(res.user.cleanNotice == 1){
							this.onetxt = '通知给商户'
						}else if(res.user.cleanNotice == 2){
							this.onetxt = '通知给保洁'
						}else if(res.user.cleanNotice == 3){
							this.onetxt = '通知商户和保洁'
						}
					}
				})
			},
			// 保存基础设置
			btnbc(){
				let data = {
					agoCancel:this.min, //最少时长
					penalty:this.price / 10, //百分比
					cleanDuration:this.twotxt, //保洁时长
					cleanNotice:this.cleanNotice, //通知类型
					beforeTime:this.thrtxt //提前开始使用
				}
				this.$u.post(`/app/user/basicConfig`,data).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '保存成功',
							icon: 'success',
							duration:2000
						})
						setTimeout(()=>{
							uni.navigateBack()
						},2000)
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration:2000
						})
					}
				})
			},
			// 点击确定选择通知
			confirmone(e){
				this.cleanNotice = e[0].value
				this.onetxt = e[0].label
			},
		}
	}
</script>

<style lang="scss">
	/deep/ .u-iconfont,
	/deep/ .u-title{
		padding-bottom: 20rpx;
	}
	.ones{
		display: flex;
		    justify-content: space-between;
		    padding-bottom: 34rpx;
		    /* border-bottom: 1px solid #D8D8D8; */
		    /* margin-top: 58rpx; */
		    box-sizing: border-box;
		    font-size: 32rpx;
		    color: #3D3D3D;
		    background-color: #fff;
		    width: 680rpx;
		    padding: 0 20rpx;
		    box-sizing: border-box;
		    height: 100rpx;
		    line-height: 100rpx;
		    margin: auto;
		    margin-top: 30rpx;
		    border-radius: 16rpx;
		view{
			display: flex;
			input{
				width: 80rpx;
				margin-left: 10rpx;
				height: 100rpx;
				line-height: 100rpx;
			}
		}
	}
	.addwifi{
		width: 750rpx;
		height: 598rpx;
		background: #FFFFFF;
		position: fixed;
		left: 0;
		bottom: 0;
		border-radius: 50rpx  50rpx 0 0;
		padding: 0 72rpx;
		box-sizing: border-box;
		.cha{
			color: #3D3D3D;
			font-size: 50rpx;
			font-weight: 600;
			position: absolute;
			top: 30rpx;
			right: 30rpx;
		}
		.baocun{
			width: 680rpx;
			height: 104rpx;
			background: #48893B;
			font-weight: 600;
			font-size: 36rpx;
			color: #FFFFFF;
			margin: auto;
			text-align: center;
			line-height: 104rpx;
			border-radius: 24rpx;
			position: fixed;
			left: 50%;
			transform: translateX(-50%);
			bottom: 32rpx;
		}
		.one{
			display: flex;
			justify-content: space-between;
			padding-bottom: 34rpx;
			border-bottom: 1px solid #D8D8D8;
			margin-top: 58rpx;
			box-sizing: border-box;
			font-size: 32rpx;
			color: #3D3D3D;
			view{
				display: flex;
				input{
					width: 80rpx;
					margin-left: 10rpx;
				}
			}
		}
		.name{
			font-weight: 600;
			font-size: 36rpx;
			color: #3D3D3D;
			width: 100%;
			text-align: center;
			margin-top: 42rpx;
			margin-bottom: 86rpx;
		}
	}
	.mask{
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		background-color: #000;
		opacity: .2;
	}
	.box{
		height: 80vh;
		overflow: scroll;
		padding-bottom: 200rpx;
		box-sizing: border-box;
	}
	.anniu{
		width: 750rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0,0,0,0.3);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		padding-top: 24rpx;
		box-sizing: border-box;
		view{
			width: 680rpx;
			height: 104rpx;
			background: #48893B;
			font-weight: 600;
			font-size: 36rpx;
			color: #FFFFFF;
			margin: auto;
			text-align: center;
			line-height: 104rpx;
			border-radius: 24rpx;
		}
	}
	.addpz{
		font-size: 28rpx;
		color: #48893B;
		text-align: center;
		line-height: 66rpx;
		width: 100%;
		height: 66rpx;
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		border: 1rpx dashed #48893B;
		margin-top: 10rpx;
	}
	.orderqx{
		width: 680rpx;
		max-height: 49200rpx;
		background: #FFFFFF;
		margin: auto;
		margin-top: 22rpx;
		border-radius: 20rpx;
		padding: 36rpx 34rpx;
		padding-bottom: 28rpx;
		box-sizing: border-box;
		.tongzhi{
			display: flex;
			justify-content: space-between;
			margin-top: 34rpx;
			padding-bottom: 20rpx;
			box-sizing: border-box;
			border-bottom: 1px solid #D8D8D8;
			.two{
				font-size: 28rpx;
				display: flex;
				align-items: center;
				/deep/ .uicon-arrow-right{
					padding-bottom: 0;
				}
				input{ 
					width: 200rpx;
					height: 22rpx;
					line-height: 22rpx;
					text-align: right;
					margin-right: 20rpx;
				}
			}
		}
		.bottab{
			width: 100%;
			height: 76rpx;
			line-height: 76rpx;
			background: #fff;
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			display: flex;
			view{
				width: 50%;
				text-align: center;
				text{
					display: inline-block;
					margin-left: 20rpx;
					color: red;
				}
			}
		}
		.toptab{
			margin-top: 24rpx;
			width: 100%;
			height: 76rpx;
			line-height: 76rpx;
			background: #F0F0F0;
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			display: flex;
			view{
				width: 50%;
				text-align: center;
			}
		}
		.top{
			display: flex;
			justify-content: space-between;
			.one{
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
			}
			.two{
				font-size: 28rpx;
				color: #48893B;
				display: flex;
				align-items: center;
				input{ 
					width: 200rpx;
				}
			}
		}
	}
	page {
		background: #F6F6F6;
	}


</style>