<template>
	<view>
		<view class="swiper-wrap">
			<u-swiper :list="list1" indicator indicatorMode="dot"
			autoplay
		    @change="change" @click="click">
			</u-swiper>	
		</view>
		<view>
			<u-upload
					:fileList="fileList1"
					@afterRead="afterRead"
					@delete="deletePic"
					name="1"
					multiple
					:maxCount="10"
				></u-upload>
		</view>
		<!-- <u-skeleton
			    rows="3"
			    title
				loading
		></u-skeleton> -->
		<view class="company-title">
		 	<u--input v-model="companyData.companyName" placeholder="请选择性别" border="none" ></u--input>
		</view>
		<view class="intro">
			<u--input v-model="companyData.companyIntroduction" placeholder="请选择性别" border="none" ></u--input>
		</view>
		<view class="scope">
			<u--input v-model="companyData.scopeOfBusiness" placeholder="请选择性别" border="none" ></u--input>
		</view>
		<u-list>
			<u-list-item>
				<u--input v-model="companyData.companyAddress" placeholder="请选择性别" border="none" ></u--input>
			</u-list-item>
			<u-list-item>
				<u--input v-model="companyData.phone" placeholder="请选择性别" border="none" ></u--input>
			</u-list-item>
			<u-list-item>
				<u--input v-model="companyData.portraiture" placeholder="请选择性别" border="none" ></u--input>
			</u-list-item>
			<u-list-item>
				<u--input v-model="companyData.postbox" placeholder="请选择性别" border="none" ></u--input>
			</u-list-item>
		</u-list>
		<view class="footer">
			<view @click='edit' class='button'>编辑</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [],
				companyData:{},
			}
		},
		methods: {
			edit(){
				
				// uni.showLoading({
				// 	title: '数据加载中'
				// })
				// this.$request.baseRequest('personalHomepageInfo', 'list', {
				// 	remark2: this.route,
				// 	carpoolingType: this.type,
				// 	companyId: 1,
				// 	pageNum: page.num,
				// 	pageSize: page.size,
				// }, failres => {
				// 	console.log('res+++++', failres.errmsg)
				// 	this.$refs.uToast.show({
				// 		type: 'error',
				// 		message: failres.errmsg,
				// 	})
				// 	uni.hideLoading()
				// }).then(res => {
				// 	// if (res.errno == 200) {
				// 	uni.hideLoading()
				// 	console.log(11)
				// 	let curPageData = res.data.items;
				// 	let totalPage = res.data.total;
				// 	let curPageLen = curPageData.length;
				// 	this.mescroll.endByPage(curPageLen, totalPage);
				// 	console.log(res.data)
				// 	// this.makeData(res.data)
				// 	if (page.num == 1) this.infoList = []; //如果是第一页需手动置空列表
				// 	this.infoList = this.infoList.concat(curPageData); //追加新数据
				// 	// }
				// })
				// uni.navigateTo({
				// 	url:_url
				// })
			},
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					// uploadImage(res.tempFilePaths[0], 'cardImages/',
					// 				result => {
					// 					// this.trainImg = result
					// 					uni.hideLoading();
					// 				}
					// 			)
					// let a = uni.uploadFile({
					// 	url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
					// 	filePath: url,
					// 	name: 'file',
					// 	formData: {
					// 		user: 'test'
					// 	},
					// 	success: (res) => {
					// 		setTimeout(() => {
					// 			resolve(res.data.data)
					// 		}, 1000)
					// 	}
					// });
				})
			},
		}
	}
</script>

<style>

</style>
