<template>
	<view class="container">
		<uni-forms ref="form" :modelValue="form" :rules="rules" class="padding-wrap" label-position="top">
			<uni-forms-item label="账号" name="employeeId" label-width="200upx">
				<uni-easyinput trim="all" v-model="form.employeeId" placeholder="请输入账号"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="名称" name="name" label-width="200upx">
				<uni-easyinput trim="all" v-model="form.name" placeholder="请输入名称"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="经度" name="longitude" label-width="200upx">
				<uni-easyinput trim="all" v-model="form.longitude" placeholder="请输入经度"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="维度" name="latitude" label-width="200upx">
				<uni-easyinput trim="all" v-model="form.latitude" placeholder="请输入纬度"></uni-easyinput>
			</uni-forms-item>
			<view class="btn-box">
				<view class="submit-btn" @click="submit">保存</view>
			</view>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					employeeId: '',
					name: '',
					longidute: '',
					latidute: '',
				},
				rules: {
					longidute: {
						rules: [{
							required: true,
							errorMessage: "请输入经度"
						}]
					},
					latidute: {
						rules: [{
							required: true,
							errorMessage: "请输入维度"
						}]
					}
				}
			}
		},
		onLoad() {
			// #ifdef APP-PLUS
			// #endif
		},
		methods: {
			submit() {
				this.$refs.form.validate().then(res => {
					uni.request({
					    url: 'http://172.19.0.11:8081/employee/modify',
					    data: {
					        employeeId: this.form.employeeId,
									name: this.form.name,
									longidute: this.form.longidute,
									latidute: this.form.latidute
					    },
					    method: "POST",
					    success: (res) => {
					        console.log(res.data);
					        uni.showToast({
					        	title: '设置成功'
					        });
									uni.setStorageSync("employeeId",this.form.employeeId);
									// this.getEmployeeInfo();
					    }
					});
				}).catch(err => {
					console.log('表单错误信息：', err);
					uni.showToast({
						title: err
					});
				})
			}
		},
		//获取成员信息
		getEmployeeInfo(){
			uni.request({
			    url: 'http://172.19.2.195:8081/api/userManage/getEmployeeByEID?employeeId='+this.form.employeeId,
			    method: "GET",
			    success: (res) => {
			        console.log(res.data);
							uni.setStorageSync("employeeId",this.form.employeeId);
							// uni.setStorageSync("groupNum",res.data.groupNum);
			    }
			});
		}
	}
</script>

<style lang="scss" scoped>
	page,
	.container {
		min-height: 100vh;
		background-color: #FFFFFF;
		/deep/.uni-forms-item__label{
			color: #031945;
			font-size: 28upx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
		}
		/deep/.uni-easyinput__content{
			height: 99upx;
			border: 0;
			border-bottom: 1px solid #D6D8DF;;
			border-radius: 0;
		}
		/deep/.uni-easyinput__content-input{
			font-size: 28upx;
			height: 99upx;
		}
		/deep/.uni-input-placeholder{
			color: #90959D;
			font-size: 28upx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
		}
	}

	.padding-wrap {
		padding: 30upx;
	}
	
	.voice-rocord-box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 40upx;
		.voice-box{
			display: flex;
			align-items: center;
			justify-content: flex-end;
			min-width: 300px;
			height: 90upx;
			background: #338AF8 url(@/static/voive_bg.png) 40upx 28upx no-repeat;
			background-size: 226upx 34upx;
			border-radius: 100upx;
			.voice-mins{
				color: #FFFFFF;
				font-size: 28upx;
				font-family: Arial-Regular, Arial;
				font-weight: 400;
				margin-right: 40upx;
			}
		}
		.voice-del{
			color: #B6B8BB;
			font-size: 28upx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			margin-left: 20upx;
		}
	}

	.submit-btn {
		display: block;
		color: #338AF8;
		font-size: 28upx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		line-height: 66upx;
		text-align: center;
		background: #E5F0FF;
		border-radius: 20upx;
		border: 1px solid #338AF8;
	}

	.tab-switch {
		display: flex;
		justify-content: flex-end;
		align-items: center;

		.tab-btn {
			display: flex;
			width: 80upx;
			height: 40upx;
			border-radius: 20upx;
			background-color: #eee;
			margin-right: 10upx;

			.tab-btn-item {
				float: right;
				width: 36upx;
				height: 36upx;
				border-radius: 18upx;
				background-color: #FFFFFF;
				margin: 2upx;
			}

			&.active {
				background-color: #338AF8;

				.tab-btn-item {
					float: left;
				}
			}
		}
	}

	.btn-box{
		position: fixed;
		left: 30upx;
		right: 30upx;
		bottom: 100upx;
		.submit-btn{
			color: #FFFFFF;
			font-size: 28px;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			line-height: 90upx;
			text-align: center;
			background: #338AF8;
			border-radius: 100upx;
		}
	}
</style>