<template>
	<view v-if="state.visible">
		<u-mask :show="state.visible" :z-index="9998" duration="0" />
		<view class="qiniu-upload-progress-panel">
			<view class="qiniu-upload-progress-title">{{ state.title }}</view>
			<view class="qiniu-upload-progress-sub">{{ state.sizeText || '正在准备上传...' }}</view>
			<view class="qiniu-upload-progress-track">
				<view class="qiniu-upload-progress-fill" :style="{ width: state.progress + '%' }"></view>
			</view>
			<view class="qiniu-upload-progress-meta">
				<text>上传速度 {{ state.speedText }}</text>
				<text>{{ state.progress }}%</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { qiniuUploadProgressState } from '@/common/qiniuUploadProgress.js'

	export default {
		name: 'QiniuUploadProgress',
		computed: {
			state() {
				return qiniuUploadProgressState
			}
		}
	}
</script>

<style lang="scss" scoped>
	.qiniu-upload-progress-panel {
		position: fixed;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		z-index: 9999;
		width: 620rpx;
		background: #fff;
		border-radius: 16rpx;
		padding: 36rpx 30rpx 30rpx;
		box-sizing: border-box;
	}
	.qiniu-upload-progress-title {
		font-size: 30rpx;
		color: #2E4975;
		font-weight: 600;
		text-align: center;
	}
	.qiniu-upload-progress-sub {
		margin-top: 16rpx;
		font-size: 24rpx;
		color: #666;
		text-align: center;
		line-height: 1.5;
	}
	.qiniu-upload-progress-track {
		margin-top: 24rpx;
		height: 16rpx;
		background: #EEF3FA;
		border-radius: 10rpx;
		overflow: hidden;
	}
	.qiniu-upload-progress-fill {
		height: 100%;
		background: #4297F3;
		border-radius: 10rpx;
		transition: width 0.2s;
	}
	.qiniu-upload-progress-meta {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 14rpx;
		font-size: 22rpx;
		color: #7c7c7c;
	}
</style>
