<template>
	<view class="content">
		<view class="container">
			<view class="my-header">
				<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
				<view class="my-text">编辑预留信息</view>
				<view class="my-icons"></view>
			</view>
			<view class="box-gang">
				<view class="g-name">姓名</view>
				<input type="text" placeholder="请输入联系人姓名" style="text-align: right;" v-model='dataForm.name' />
			</view>
			<view class="box-gang">
				<view class="g-name">性别</view>
				<view >
					<u-radio-group v-model="dataForm.sex" >
						<u-radio label="0">先生</u-radio>
						<u-radio label="1">女士</u-radio>
					</u-radio-group>
				</view>
				
			</view>
			<view class="box-gang">
				<view class="g-name">电话</view>
				<input type="text" placeholder="请输入联系人手机号码" style="text-align: right;" v-model='dataForm.mobile' />
			</view>
			<!-- <view class="box-gang">
				<view class="g-name">所在地区</view>
				<input type="text" placeholder="请填写所在地区" v-model='dataForm.address' />
			</view>
			<view class="box-gang">
				<view class="g-name">详细地区</view>
				<input type="text" placeholder="请填写详细地区" v-model='dataForm.fullAddress' />
			</view> -->

			<!-- 顶部区域 -->

			<view class="bottom-anniu" @click="goedit()">
				<view class="">保存</view>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request'

	export default {
		data() {
			return {
				title: '',
				value: true,
				dataForm: {
					id: null,
					name: '',
					mobile: '',
					address: '',
					ifDefault: '',
					fullAddress: '',
				}

			}
		},
		onLoad() {
			this.dataForm = {}
			uni.$on('addressInfo', (data) => {
				if (data != null) {
					this.dataForm = data
					if (this.dataForm.ifDefault == 1) {
						this.value = true
					} else {
						this.value = false
					}
				}
			})
			uni.$emit('unAddressInfo')
		},
		components: {

		},
		methods: {
			change(e) {
				console.log(e);
			},
			goback() {
				uni.navigateBack()
			},
			goedit() {
				if (this.value) {
					this.dataForm.ifDefault = 1
				} else {
					this.dataForm.ifDefault = 2
				}
				let url = 'business/userManager/mtUserExpressAddress'
				if (this.dataForm.id != null) {
					request({
						url: url,
						method: 'put',
						data: this.dataForm
					}).then((res) => {
						if (res.code == 200) {
							uni.showToast({
									title: '修改成功',
									icon: 'none'
								}),
								uni.navigateBack()
						}
					})
				} else {
					request({
						url: url,
						method: 'post',
						data: this.dataForm
					}).then((res) => {
						if (res.code == 200) {
							uni.showToast({
									title: '提交成功',
									icon: 'none'
								}),
								uni.navigateBack()
						}
					})
				}

				console.log("123123", this.dataForm)
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #f4f5f6;
	}

	.container {
		width: 100%;
		height: 100vh;
		box-sizing: border-box;
		padding-top: 89px;
	}

	.my-header {
		width: 100%;
		height: 88px;
		background: #ffffff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #000;
		box-sizing: border-box;
		padding: 0px 15px;
		padding-top: 40px;

		.my-icons {
			width: 20px;

		}

		position: fixed;
		top: 0px;
	}

	.box-gang {
		width: 100%;
		background-color: #ffffff;
		box-sizing: border-box;
		padding: 15px;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #f4f5f6;
		justify-content: space-between;
	}

	.g-name {
		margin-right: 5px;
	}

	.box-gang-bt {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #ffffff;
		box-sizing: border-box;
		padding: 15px;
	}

	.dataform {
		background-color: #ffffff;

		margin: 20px 20px 20px 20px;

	}

	.bottom-anniu {
		width: 84%;
		height: 40px;
		display: flex;
		align-items: center;
		background: #FF9655;
		color: white;
		justify-content: center;
		position: fixed;
		bottom: 40px;
		left: 50%;
		transform: translateX(-50%);
		border-radius: 50px;

	}
</style>