<template>
	<view>
		<view class="form">
			<form>
				<view class="uni-form-item">
					<view class="title">项目名称</view>
					<view class="input">
						<input placeholder="运营商名称" v-model="formData.name" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">项目编号</view>
					<view class="input">
						<input placeholder="运营商编号" v-model="formData.number" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">关联运营商编号</view>
					<view class="input">
						<input placeholder="运营商编号" v-model="formData.operatorNumber" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">省份</view>
					<view class="input">
						<input placeholder="省份" v-model="formData.province" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">城市</view>
					<view class="input">
						<input placeholder="城市" v-model="formData.city" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">详细地址</view>
					<view class="input">
						<input placeholder="详细地址" v-model="formData.address" style="margin-left: 30rpx;" />
					</view>
				</view>

				<view class="uni-form-item">
					<view class="title">客户名称</view>
					<view class="input">
						<input placeholder="联系电话" v-model="formData.customer" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">客户电话</view>
					<view class="input">
						<input placeholder="联系电话" v-model="formData.customerTel" style="margin-left: 30rpx;" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="title">项目描述</view>
					<view class="input">
						<input placeholder="联系电话" v-model="formData.description" style="margin-left: 30rpx;" />
					</view>
				</view>

				<view class="uni-btn-v">
					<button class="button2" @tap="edit">修改</button>
				</view>
			</form>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData: {
					code: '',
					name: '',
					number: '',
					description: '',
					customer: '',
					customerTel: '',
					address: '',
					province: '',
					city: '',
					operatorCode: '',
					operatorNumber: ''
				}
			}
		},
		onLoad(e) {
			console.log(e);
			uni.request({
				url: 'http://127.0.0.1:9999/project/detail?code=' + e.code,
				method: 'GET',
				data: {},
				success: res => {
					this.formData = res.data.data.project;
					console.log(this.formData);
				},

			});
		},


		methods: {
			async edit(e) {
				let vm = this;
				let url = uni.$api.project.update;
				let data = {
					code: this.formData.code,
					name: this.formData.name,
					number: this.formData.number,
					customer: this.formData.customer,
					customerTel: this.formData.customerTel,
					description: this.formData.description,

					operatorCode: this.formData.operatorCode,
					operatorNumber: this.formData.operatorNumber,
					address: this.formData.address,
					province: this.formData.province,
					city: this.formData.city,

				};
				let res = await uni.$http.get(url, data);
				console.log('form发生了submit事件')

				uni.$emit('flush');

				uni.navigateBack({
					url: '/pages/projectInfo/projectInfo'
				})
			},

		}
	}
</script>

<style>
	.title {
		margin-left: 30rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		font-size: 26rpx;
	}

	.form {
		margin-top: 26rpx;
		padding-top: 10rpx;
		background-color: white;
		width: 702rpx;
		height: 1720rpx;
		margin-left: 24rpx;
		border-radius: 10rpx;
	}


	.input {
		background-color: #F7F8F9;
		width: 654rpx;
		margin-left: 24rpx;
		height: 98rpx;
		border-radius: 10rpx;

		display: flex;
		align-items: center;
	}

	.uni-btn-v {
		margin-top: 40rpx;
		display: flex;
		flex-direction: row;
	}



	.button2 {
		width: 600rpx;
		height: 76rpx;
		margin-top: 30rpx;
		background-color: #007AFF;
		color: white;
		font-size: unset;
	}
</style>
