分段式进度条process

news/2024/7/6 2:18:37
// An highlighted block
<template>
	<view>
		<view class="gift-out-box">
			<!--
				除以时得到下标, 有余数/无余数,  
				if(index <= rIndex) 下标之前的orange,
				else-if( 余数>0 && rIndex+1 == index) 有余数的部分占比width,
				else 灰颜色
			-->
			<view class="gift-in-box">
				<view class="item" v-for="(item,index) in list" :key='index'>
					<view class="out-process" v-if='index <= rIndex'>
						<view class="in-process in-process-width"></view>
					</view>
					<view class="out-process" v-else-if='rIndex+1 == index && remainder>0'>
						<view class="in-process in-process-orange" :style="{width:`${remainderWidth}rpx`}"></view>
					</view>
					<view class="out-process in-process-grey" v-else>
						<view class="in-process"></view>
					</view>
					<image :src="index <= rIndex ? '/static/gift.png' : '/static/gift-grey.png'" mode="aspectFit" class="img"></image>
				</view>
			</view>
			<view class="person-box">
				<text>0</text>
				<text v-for='(item,index) in list' :key='index'>{{getNum(item.num,index)}}</text>
			</view>
		</view>
		<!-- <view class="out-process">
			<view class="in-process" :style="{width:`${percent*200/100}rpx`}"></view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				percent:58,  
				personNum:18,   //人数
				
				list:[
					{num:5},
					{num:10},
					{num:15},
					{num:20}
				],
				rIndex:-1,
				remainder:0,
				remainderWidth:0,  //余数的宽
			}
		},
		computed: {  
			
		},
		mounted() {
			this.getIndex();
		},
		methods: {
			getIndex(){
				//整数
				this.rIndex = parseInt(this.personNum/5) - 1;
				//余数  
				if(this.personNum%5 > 0){
					this.remainder = this.personNum%5;
					this.remainderWidth = (this.personNum%5)/5*100;
				} 
				console.log(this.rIndex,"...",this.remainderWidth)
			},
			getNum(num,index){
				return num = index <= this.rIndex?`已邀${num}`:`${num}`;
			},
		}
	}
</script>
<style lang="scss" scoped>
	.out-process{
		width:200rpx;
		height:20rpx;
		background-color: #cccccc;
		border-radius: 8rpx;
		position: relative;
		.in-process{
			position: absolute;
			top:0;
			left:0;
			height:20rpx;
			border-radius: 8rpx;
			background-color: orangered;
		}
	}
	.gift-out-box{
		margin:40rpx 20rpx;
		padding: 20rpx;
		border: 1rpx solid #c0c0c0;
		.person-box{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin:0 30rpx;
			font-size: 24rpx;
		}
		.gift-in-box{
			display: flex;
			align-items: center;
			justify-content: center;
			
			.item{
				display: flex;
				align-items: center;
				.out-process{
					position: relative;
					width:100rpx;
					height:14rpx;
					background-color: #cccccc;
					border-radius: 4rpx;
					.in-process{
						position: absolute;
						top:0;
						left:0;
						height:14rpx;
						border-radius: 4rpx;
					}
					// orange + width
					.in-process-width{
						width:100rpx;
						background-color: orangered;
					}
					//orange
					.in-process-orange{
						background-color: orangered;
					}
					// grey + width
					.in-process-grey{
						width:100rpx;
						background-color: #c0c0c0;
					}
				}
				.img{
					width:50rpx;
					height: 56rpx;
					margin:0 4rpx;
				}
			}
		}
		
	}
</style>
```![在这里插入图片描述](https://img-blog.csdnimg.cn/90dc836364bb4f0ea5dd1636295130eb.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/5ed29f9edc0d4c71a4822a8c715c264a.png#pic_center)


http://lihuaxi.xjx100.cn/news/1294704.html

相关文章

跨境电商如何做好跨境物流和仓储管理?

跨境电商如何做好跨境物流和仓储管理&#xff1f; 企业的仓库管理是涉及企业生产、企业资金流和企业的经营风险的关键环节。在众多的工业企业、制造型企业、贸易型企业、服务型企业中都会有仓库管理的需求。而在跨境电商仓储物流环节复杂、流程繁琐的情况下&#xff0c;更需要…

03单链表面试题

声明&#xff1a;基于之前的代码 这里只编写核心业务 求单链表中有效结点的个数 这里判断的是有头结点的链表。 /*** 获取链表有效结点个数 (这里的链表是有头结点的)* param head 传入头结点就相当于传入的单链表* return 有效结点个数*/public static int getLength(Her…

DAY42动态规划

动态规划 509. 斐波那契数 509. 斐波那契数 题目描述 斐波那契数 &#xff08;通常用 F(n) 表示&#xff09;形成的序列称为 斐波那契数列 。该数列由 0 和 1 开始&#xff0c;后面的每一项数字都是前面两项数字的和。也就是&#xff1a; F(0) 0&#xff0c;F(1) 1 F(n…

量子 能源,节能减排还是另有“端倪”?

光子盒研究院 前言&#xff1a;如今&#xff0c;量子技术早已走出实验室、广泛赋能电力、化学、医学等各个领域&#xff1b;创新赛道上&#xff0c;加速奔跑的量子产业&#xff0c;将带来无限可能。现在&#xff0c;光子盒特开启「量子」专栏&#xff0c;解读量子技术将为下游应…

华为智能高校出口安全解决方案(1)

华为智能高校出口安全解决方案&#xff08;1&#xff09; 视频链接方案背景需求分析高校园区网概述高校园区网全景高校出口场景介绍高校出口整体需求分析业务安全需求攻击防御需求运维审计需求 方案规划华为智能高校出口安全解决方案架构华为智能高校出口安全解决方案功能划分业…

实用类详解

第二章 实用类介绍 目录 第二章 实用类介绍 1.枚举 2.包装类及其构造方法 3.Math类 4.Random类 5.String类 6.StringBuffer类 7.操作日期时间 总结 内容仅供学习交流&#xff0c;如有问题请留言或私信&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;…

threejs 入门 (vite + vue3)

threejs threejs用于实现3D效果 vite创建vuejs项目 npm create vite选择vue 和js创建vue3项目 安装threejs npm install three运行项目 cd project npm i npm run dev修改App.vue 创建一个场景和立方体&#xff08;Creating a scene&#xff09; <script setup> …

点分治及其例题

点分治 处理树上问题&#xff0c;将问题范围分为穿过树根的与子树内部 对于子树内部采用递归处理&#xff0c;对穿过树根具体题目具体分析 为了让递归层数尽量少&#xff0c;先要找重心 找重心&#xff1a; 重心为所有子树的最大值最小的节点 用 s z [ i ] sz[i] sz[i]记…