<template>
	<view>
		<view style='background:#fff;margin:20px 10px 10px;border-radius:10px;'>
			<uni-card class="box" :isFull="true" title="反馈意见" >
				<textarea v-model="data.content" placeholder="您的反馈对我们非常重要,请在此输入."></textarea>
				<view style='position:absolute;right:22px;bottom:16px;font-size:13px;'>{{data.content.length}}/150个字</view>
			</uni-card>
			<uni-card class="box contact" :isFull="true" title="联系方式" >
				<input v-model="data.contact" placeholder="手机 QQ或e-mail,方便我们联系您" />
			</uni-card>
		</view>
		
		<button class="submit-btn" @click="submit">提交</button>
	</view>
</template>

<script>
	import uniCard from '@/components/uni-card/uni-card.vue';
	export default {
		components:{
			uniCard
		},
		data() {
			return {
				data: {
					imgList: [],
					content: "",
					contact: ""
				},
				contentIcon: require("./icons/suggestion.png"),
				contactIcon: require("./icons/contact.png"),
				imgListIcon: require("./icons/image.png")
			}
		},
		methods: {
			chooseImage() {
				let _self = this;
				uni.chooseImage({
					sizeType: ['compressed', 'original'],
					sourceType: ['album', 'camera'],
					success: function(res) {
						_self.data.imgList = _self.data.imgList.concat(res.tempFiles)
					},
					fail: function(err) {
						console.log(err);
					}
				});
			},
			removeImage(index) {
				this.data.imgList.splice(index, 1)
			},
			previewImage(index) {
				uni.previewImage({
					current: index,
					urls: this.data.imgList.map(r => r.path)
				});
			},
			submit() {
				this.$emit("submit", this.data)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		margin-bottom: 10rpx;
		position: relative;
	}
	.imgs {
		position: relative;
		display: inline-flex;
		flex-wrap: wrap;
		margin: 10rpx;
		width: 150rpx;
		height: 150rpx;
		.img {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
			border: 1rpx solid #ebebeb;
		}
		.remove {
			line-height: 30rpx;
			text-align: center;
			border-radius: 10rpx;
			position: absolute;
			right: 0rpx;	
			top: 0rpx;
			width: 30rpx;
			height: 30rpx;
			font-weight: bold;
			background-color: #e53c25;
		}
		.add-img {
			background-color: #f0f0f0;
		}
	}
	.submit-btn {
		background-color: #22C572;
		color:#fff;
		border-radius:30px;
		margin: 20rpx;
		margin-top:30px;
	}
	textarea,input{
		background:#F9F9FA;
		border: 1px solid #eee;
	}
	textarea{
		margin:0 auto;
		padding:10px;
		font-size:14px;
	}
	input{
		padding:20px;
	}
	.contact{
		padding-bottom:20px;
	}
</style>
