<template>
	<view class="layout">
		<view class="assessHead">
			<span style="padding-right: 10upx;">评价</span>
			<van-rate
			  :value="valueNumber"
			  :size="20"
			  void-color="#ee0a24"
			  void-icon="star"
			  color="#eee"
			/>
		</view>
		 <TextArea :tips="tips" @submitValue="submitValue"/>	
		<view>
			<view>添加图片(最多3张)</view>
				<view class="cell-pd">
					<view class="uni-uploader">
						<view class="uni-uploader-body">
							<view class="uni-uploader__files">
								<block v-for="(image,index) in imageList" :key="index">
									<view class="uni-uploader__file">
										<image class="uni-uploader__img" :src="image" :data-src="image" @tap="previewImage"></image>
									</view>
								</block>
								<view class="uni-uploader__input-box deepHeight">
									<view class="uni-uploader__input" @tap="chooseImage"></view>
								</view>
							</view>
						</view>
					</view>
				</view>
		</view>
		<view class="submitRemin">提交</view>
	</view>
</template>

<script>
	import TextArea from '@/component/textarea.vue'
	export default {
		components: {
			TextArea
		},
		data() {
			return{
				valueNumber: 0,
				imageList:[],
				size: 25,
				goodComment:'',
				sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				sourceType: ['album'], //从相册选择
				countIndex: 1,
				count: [1, 2, 3],
				tips: '五星好评超过20个字就有机会获得积分'
			}
		},
		onUnload() {
			    this.imageList = [],
				this.sourceTypeIndex = 2,
				this.sourceType =  ['album'],
				this.sizeType = ['original', 'compressed'],
				this.countIndex = 1;
		},
		methods: {
			submitValue(e) {
				this.goodComment = e.detail.value;
			},
			chooseImage() {
				if (this.imageList.length === 3) {
					// let isContinue = await this.isFullImg();
					// console.log("是否继续?", isContinue);
					// if (!isContinue) {
					// 	return;
					// }
					return;
				}
				uni.chooseImage({
					sourceType: this.sourceType,
					sizeType: this.sizeType,
					count: this.imageList.length + this.count[this.countIndex] > 3 ? 3 - this.imageList.length : this.count[this.countIndex],
					success: (res) => {
						this.imageList = this.imageList.concat(res.tempFilePaths);
					}
				})
			},
			previewImage() {
				
			}
		}
	}
</script>

<style lang="scss">
	.layout {
		padding: 0 32upx;
		.assessHead {
			padding: 20upx 0;
		}
		.deepHeight {
			height: 108upx;
			width: 108upx;
		}
	}
</style>
