<template>
	<view class="my-card-box">
		<view class="card-detail">
			<view class="title">名片信息</view>
			<view class="item-field">
				<view class="item-lable is-required">
					<image src="@/static/mine/required.png" mode="aspectFit"></image>平台
				</view>
				<view class="item-value">
					<uni-data-select v-model="dataObj.platformCode" :localdata="range"
						@change="change($event,'platformCode')" :clear="false"
						:imgCode="dataObj.platformCode"></uni-data-select>
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable is-required">
					<image src="@/static/mine/required.png" mode="aspectFit"></image>粉丝数
				</view>
				<view class="item-value">
					<input class="uni-input" v-model="dataObj.fansNum" type="number" placeholder="请输入" />
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable is-required">
					<image src="@/static/mine/required.png" mode="aspectFit"></image>联系电话
				</view>
				<view class="item-value">
					<input class="uni-input" v-model="dataObj.tel" type="tel" placeholder="请输入" />
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable is-required">
					<image src="@/static/mine/required.png" mode="aspectFit"></image>收货地址
				</view>
				<view class="item-value">
					<view class="choose-add" @click="chooseAddr()">请选择收货地址</view>
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable">
					商单自报价（选填）
				</view>
				<view class="item-value">
					<input class="uni-input" v-model="dataObj.price" type="decimal" placeholder="请输入" />
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable">
					所在领域/合作方式（选填）
				</view>
				<view class="item-value">
					<textarea v-model="dataObj.content" placeholder="请输入" />
				</view>
			</view>
			<view class="item-field">
				<view class="item-lable is-required">
					<image src="@/static/mine/required.png" mode="aspectFit"></image>证明材料
				</view>
				<view class="item-value">
					<uni-file-picker :value="fileList" :sizeType="sizeType" @select="afterRead" @delete="deleteFile"
						limit="9"></uni-file-picker>
				</view>
			</view>
			<view class="item-field" style="align-items: center;">
				<view class="submit-box">提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/config'
	export default {
		data() {
			return {
				//所有可选的平台
				range: [{
						value: 'xiaohongshu',
						text: "小红书"
					},
					{
						value: 'douyin',
						text: "抖音"
					}
				],
				sizeType: ['compressed'],
				//图片数组
				fileList: [],
				//名片数据对象
				dataObj: {
					platformCode: "xiaohongshu",
					fansNum: null,
					tel: null
				}
			}
		},
		methods: {
			//改变选中值
			change(e, type) {},
			/**
			 * 选择收货地址
			 */
			chooseAddr() {

			},
			afterRead(file) {
				for (let i = 0; i < file.tempFilePaths.length; i++) {
					upload({
						url: '',
						filePath: file.tempFilePaths[i]
					}).then((res) => {
						this.fileList.push({
							url: config.baseUrl + res.data
						})
						console.log(this.fileList)
					})
				}
			},
			deleteFile(file, index) {
				console.log('删除文件');
				this.fileList.splice(index, 1);
			},
		}
	}
</script>

<style lang="scss">
	.my-card-box {
		border-top: 1rpx solid #F4F4F4;
		padding: 30rpx;
		width: 100%;
		color: #363636;
		font-size: 30rpx;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: self-start;
		justify-content: center;
		position: relative;

		.card-detail {
			width: 100%;
			padding: 20rpx;
			background-color: white;
			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: self-start;
			justify-content: center;
			position: relative;

			.title {
				font-size: 33rpx;
				width: 100%;
				padding-bottom: 20rpx;
				border-bottom: 1rpx solid #F4F4F4;
			}

			.item-field {
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: self-start;
				justify-content: center;

				.is-required {
					image {
						width: 20rpx;
						height: 20rpx;
						margin-right: 10rpx;
					}
				}

				.item-lable {
					padding: 15rpx 0;
					display: flex;
					align-items: center;
					justify-content: center;

				}

				.item-value {
					width: 100%;

					input {
						padding-left: 20rpx;
						line-height: 1;
						height: 70rpx;
						border: 1rpx solid #dcdfe6;
						border-radius: 8rpx;
					}

					.choose-add {
						color: #686868;
						padding: 10rpx 0 10rpx 20rpx;
						display: flex;
						align-items: center;
						justify-content: flex-start;
						border: 1rpx solid #dcdfe6;
						border-radius: 8rpx;
					}

					textarea {
						width: 100%;
						height: 150rpx;
						color: #686868;
						padding: 10rpx 0 10rpx 20rpx;
						border: 1rpx solid #dcdfe6;
						border-radius: 8rpx;
					}
				}

				.submit-box {
					padding: 15rpx 0;
					background-color: #FC1F3E;
					color: white;
					width: 70%;
					border-radius: 10rpx;
					margin-top: 80rpx;
					text-align: center;
				}
			}


		}
	}
</style>