<template>
	<view class='container'>
		<view style="background: linear-gradient( 180deg, #1FCA7C 0%, #1FCAA7 100%);">
			<u-navbar :autoBack="true" placeholder="true" :title="title" bgColor="transparent" leftIconColor="#FFF"
				:title-style="{color: '#FFF'}">
			</u-navbar>
		</view>
		<view class="mar-20">
			<view class="flex-column-center">
				<image class="w-30 h-30" src="/static/icon_home_dw.png"></image>
				<text>{{userinfo.communityName}}</text>
			</view>
			<view class="flex-column-center fs-32 fw-700  mt-30 ml-10">
				<image class="w-10 h-40 mr-15" style="background-color: #1FCA7C;"></image>
				<text>业主信息</text>
			</view>
			<view class="flex-column br-12 fs-28 mt-30" style="box-shadow: 0px 0px 15px 1px rgba(142,142,142,0.16);">
				<view class="flex-row-between pad-30" style="border-bottom: 1rpx solid #E9E9E9;">
					<text style="color: #999999;">业主姓名</text>
					<text>{{$wskj.isNullStr(userinfo.name)}}</text>
				</view>
				<view class="flex-row-between pad-30" style="border-bottom: 1rpx solid #E9E9E9;">
					<text style="color: #999999;">业主房间号</text>
					<text>{{$wskj.isNullStr(userinfo.room)}}</text>
				</view>
				<view class="flex-row-between pad-30" style="border-bottom: 1rpx solid #E9E9E9;">
					<text style="color: #999999;">业主手机号</text>
					<text>{{userinfo.mobile}}</text>
				</view>
			</view>
			<view class="flex-column-center fs-32 fw-700  mt-30">
				<image class="w-10 h-40 mr-15" style="background-color: #1FCA7C;"></image>
				<text>报修信息</text>
			</view>
			<view class="flex-column br-12 fs-28 mt-30 pad-30"
				style="box-shadow: 0px 0px 15px 1px rgba(142,142,142,0.16);">
				<u--textarea v-model="reason" height="260rpx" maxlength="100" placeholder="填写下详细报修内容，有助于工作人员快速帮您解决问题"
					count border="border"></u--textarea>
				<view class="mt-30">
					<upload-image @upload="upload" v-model="imgurl" maxCount="3" width="70" height="70"
						type="fullurl"></upload-image>
				</view>
			</view>

		</view>
		<view @click="onSubmit" class="fullscreen-btn">
			<text>提交</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '居家报修',
				type: 0,
				reason: '',
				images: '',
				userinfo: '',
			};
		},
		onLoad(e) {
			this.type = e.type
			if (e.type == 1) {
				this.title = "居家报修"
			} else {
				this.title = "公区报事"
			}
			this.userinfo = uni.getStorageSync("userInfo")
		},
		methods: {
			upload(e) {
				this.images = e
			},
			onSubmit() {
				console.log(this.images)
				if (!this.reason) {
					this.$wskj.toast('请输入报修信息');
					return
				}
				if (!this.images) {
					this.$wskj.toast('请上传图片');
					return
				}
				const params = {
					url: '/api/repairs/add',
					loadingTip: '加载中...',
					data: {
						repairsDescription: this.reason,
						repairsImg: this.images,
						type: this.type
					}
				}
				this.$request(params).then(res => {
					this.$wskj.toast('提交成功')
					setTimeout(() => {
						this.$wskj.goBack(1)
					}, 600)
				})
			}
		},
	};
</script>

<style scoped>
	.container {
		display: flex;
		flex-direction: column;
		background: #fff;
	}
</style>