我是靠谱客的博主 任性嚓茶,这篇文章主要介绍微信小程序流程进度的图样式功能实现方法,现在分享给大家,希望可以做个参考。

在做微信开发的时候我们会遇到各种功能,本文就和大家分享要实现一个流程进度的图样式的方法。


需求:

  1. 没完成的灰色小圆点表示

  2. 完成的使用蓝色小圆点设置

  3. 当前状态使用有外圈的小圆点表示

实现起来比较简单,实现思路,使用一个列表实现,列表中的每一个item的样式如下图


使用win10画板画的不好看

图上的意思就是每个item 前面有一段线条 中间是个圆圈然后后面有一段线条。之所以这样是因为下面的文字需要居中显示在圆圈的下面。如果不需要文字的话可以一个圆圈后面跟一条直线会更简单一点。

按照上面的图片,html布局为下面


复制代码
1
2
3
4
5
6
7
8
9
10
<view class='order_process'> <view class='process_wrap' wx:for="{{processData}}" wx:key=""> <view class='process'> <view class='process_line' style="background:{{item.start}}"></view> <image class='process_icon' src="{{item.icon}}"></image> <view class='process_line' style="background:{{item.end}}"></view> </view> <text class='process_name'>{{item.name}}</text> </view> </view>
登录后复制

OK 列表肯定需要一个数组啦数组如下面


复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
processData: [{ name: '提交工单', start: '#fff', end: '#EFF3F6', icon: '../../img/process_1.png' }, { name: '已接单', start: '#EFF3F6', end: '#EFF3F6', icon: '../../img/process_1.png' }, { name: '开始维修', start: '#EFF3F6', end: '#EFF3F6', icon: '../../img/process_1.png' }, { name: '维修结束', start: '#EFF3F6', end: '#EFF3F6', icon: '../../img/process_1.png' }, { name: '已确认', start: '#EFF3F6', end: '#fff', icon: '../../img/process_1.png' }], },
登录后复制

按照上面的item图片我们会看到直接显示的话两边会多处一条线来怎么去掉这两条线呢,很简单,让父容器的背景颜色跟先的颜色一样就好啦。

把父布局的背景改为白色,然后控制列表中第一个item中的前面的线段的颜色为白色,最后一个item中的后面的线段为白色。这样看起来两边的线段就去掉了

当数据改变的时候,我们只需要改变数组中对象的属性就好了。不如下面的做参考


复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//进度条的状态 setPeocessIcon: function () { var index = 0//记录状态为1的最后的位置 var processArr = this.data.processData // console.log("progress", this.data.detailData.progress) for (var i = 0; i < this.data.detailData.progress.length; i++) { var item = this.data.detailData.progress[i] processArr[i].name = item.word if (item.state == 1) { index = i processArr[i].icon = "../../img/process_3.png" processArr[i].start = "#45B2FE" processArr[i].end = "#45B2FE" } else { processArr[i].icon = "../../img/process_1.png" processArr[i].start = "#EFF3F6" processArr[i].end = "#EFF3F6" } } processArr[index].icon = "../../img/process_2.png" processArr[index].end = "#EFF3F6" processArr[0].start = "#fff" processArr[this.data.detailData.progress.length - 1].end = "#fff" this.setData({ processData: processArr }) },
登录后复制

上面代码的数据中,使用state代表完成和没完成。我们把完成的设置为蓝色 把没完成的设置为灰色。

使用 index 来记录是不是当前点(当前点就是state表示完成的最后一个)。

最后css中的代码也很简单


复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
.order_process { display: flex; flex-wrap: nowrap; padding: 10rpx 10rpx 20rpx 10rpx; background-color: #fff; } .process_wrap { display: flex; flex-direction: column; flex: 1; align-items: center; } .process { display: flex; align-items: center; width: 100%; } .process_icon { width: 50rpx; height: 50rpx; } .process_line { background: #eff3f6; flex: 1; height: 5rpx; } .process_name { font-size: 24rpx; }
登录后复制

相关推荐:

javascript基于定时器实现进度条功能实例

HTML5 Canvas玩转酷炫大波浪进度图效果实例(附demo)

JS与HTML结合实现流程进度条展示方法介绍

以上就是微信小程序流程进度的图样式功能实现方法的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是任性嚓茶最近收集整理的关于微信小程序流程进度的图样式功能实现方法的全部内容,更多相关微信小程序流程进度内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(111)

评论列表共有 0 条评论

立即
投稿
返回
顶部