<template>
	<view>
		<view class="cu-bar bg-white  margin-top">
			<view class="action">
				<text class="cuIcon-titles text-red"></text>
				<text>反馈意见</text>
			</view>
		</view>
		<textarea class="texta" :value="form.symptomatic" placeholder="请输入之前的效果" />
		<view class="flex solid-bottom padding align-center">
		<view  v-for="(item,index) in before" :key='index'>
			<view class="huiyuan_img">
	     <image style='width: 120upx;height: 120upx; ' :src="item.url" mode=""></image>
		 <text class="cuIcon-delete" @click="before.splice(index,1)" style="position: absolute;bottom: 5upx;right: 5upx; color: #000000;"></text>
			</view>
	     </view>
		 <view class="cuIcon-add addiamge" @click="beforeupload" ></view>
		</view>
		 <view class="sub-titles">
		 	<button class="bg-red"  @click="subit">提 交</button>
		 </view>
		</view>
		
</template>

<script>
	import zhUpFile from '@/components/zh-upFile'
	import host from "../../../../../utils/host.js"
	export default {
		components:{
		},
		data() {
			return {
				imageList:[],
				image:'blob:http://192.168.31.193:8080/5d05aa59-3036-46c0-9ae0-9f5b81261e9b',
				before:[],
				form:{
					docNum:null,
					docDate:null,
					projectName:null,
					projectId:null,
					memberPhone:null,
					feedBack:null,
				}
				
			}
		},
		methods: {
			subit:function(){
				console.log(this.form);
				const header = {}
				header['content-type'] = 'application/x-www-form-urlencoded'
				if(uni.getStorageSync('userInfo').token!=undefined){
					header['token'] = uni.getStorageSync('userInfo').token
				}
			    uni.request({
			        method:'post',
			        header:header,
			        url:host + '/demay/ssm/memberCs/addProjectProgress',
			        data:this.form,
					withCredentials:true,
			        dataType:'json',
			    }).then((response) => {
					console.log(response);
				})
			},
			beforeupload:function(){
				var that = this
				uni.chooseImage({
				    count: 5, //上传图片的数量，默认是9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album'], //从相册选择
				    success: function (res) {
						console.log('res',res);
					  let image = []
					  const header = {}
					  // header['content-type'] = 'application/x-www-form-urlencoded'
					  if(uni.getStorageSync('userInfo').token!=undefined){
					  	header['token'] = uni.getStorageSync('userInfo').token
					  }
					          uni.uploadFile({
					              url: host + '/demay/ssm/memberCs/addProjectProgress', //仅为示例，非真实的接口地址
					              filePath: res.tempFilePaths[0],
								  header:header,
					              name: 'before',
					              formData:that.form,
					              success: (uploadFileRes) => {
					                  console.log(uploadFileRes.data);
					              }
					          });
							  
					  res.tempFilePaths.forEach(item=>{
						  
						  let items = {url:item}
						  image.push(items)
					  })
					  that.before = [...  that.before ,...image]
				    }
				});
			},
	
			onLoad :function(option){
				if(option.item){
					console.log(JSON.parse(option.item));
					let form = JSON.parse(option.item)
					let ids = ''
					let names = ''
					this.form.storeId = form.storeId
					this.form.storeName = form.storeName
					this.form.memberId = form.memberId
					this.form.memberName = form.memberName
					this.form.memberIdentity = form.memberIdentity
					this.form.memberIdentity = null
					this.form.memberPhone = uni.getStorageSync('userInfo').mobilePhone
					this.form.projectId = form.projectId
					this.form.projectName = form.projectName
					this.form.docId = form.id
					this.form.docNum = form.cashNum 
					this.form.docDate = form.cashDate
					
					form.entities.forEach(item=>{
						// ids = ids+item.saleStaffId +','
						// names =names+ item.saleStaffName +','
						ids = ids+item.saleStaffId
						names =names+ item.saleStaffName
					})
					this.form.staffNames = names
					this.form.staffIds = ids
					
				}
			}
		}
	}
</script>

<style>
.texta{
	padding: 10upx 5%;
	height: 10vh;
	width: 100%;
}
.texta view{
	display: inline-block;
}	
.huiyuan_img{
	width: 120upx;
	height: 120upx;
	border: #b5ccd9 1upx solid;
	margin: 10upx;
	background-color: #DDDDDD;
	overflow: hidden;
	position: relative;
}
.addiamge{
	width: 120upx;height: 120upx; text-align: center;line-height: 120upx;border: #CCCCCC 1upx solid;margin: 10upx;
	background-color: #fff;
	font-size: 48upx;
	display: inline-block;
}
.sub-titles{
	width: 90%;
	margin:10upx 5%;
	background-color: red;
	border-radius: 15upx;
}
</style>
