<template>
	<view class="content">
		<u-form ref="uForm">
			<u-form-item label="反馈内容:" label-width="150" >
				<u-input v-model="content" type="textarea"/>
			</u-form-item>
			
			<u-form-item label="上传图片:" label-width="150"  >
				<u-upload upload-text="选择或拍照" width="180" height="180" ref="uUpload" :action="action"  :fileList="fileList" :form-data="form_data" ></u-upload>
			</u-form-item>
			
			<u-button type="primary" @click="submit">确定</u-button>
		</u-form>
	</view>
</template>

<script>
	import {toast, clearStorageSync, setStorageSync, getStorageSync, useRouter} from '@/utils/utils.js'
	
	export default {
		data() {
			return {
				action: '/api/index/upload_cos',
				content : '',
				fileList:[],
				form_data : {
					floder : 'photo'
				},
				
			}
		},
		onLoad(op) {
		},
		onReady(){
		},
		methods: {
			submit(){
				
				let _uploadPhoto_data = {}
				var _list = this.$refs.uUpload.lists
							
				for (let i = 0; i < _list.length; i++) {
					 _uploadPhoto_data[i] = {
						url: _list[i].response.data.file
					 }
				} 
				
				const param={
					photo :JSON.stringify(_uploadPhoto_data),
					content:  this.content
				}
				this.$api.feedback(param).then(res => {
					if(res.code==0){
						toast(res.msg)
						setTimeout(()=>{
						   uni.navigateBack()
						},500)						
						console.log('提交成功'); 
					}else{
						toast(res.msg)
						console.log('提交失败');
					}
				})	
				
			}
		}	
	}
</script>

<style lang="scss">
	page{background: #f2f2f2;}
	.content{margin: 10rpx;background: #fff;padding:20rpx}
</style>
