uniapp-vue2-微信小程序-滑块验证组件wo-slider

这篇具有很好参考价值的文章主要介绍了uniapp-vue2-微信小程序-滑块验证组件wo-slider。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

wo-slider是一款支持高度自定义的滑块验证组件,采用uniapp-vue2编写

采用touchstart、touchmove、touchend事件实现的滑块组件,支持H5、微信小程序(其他小程序未试过,可自行尝试)

可到插件市场下载尝试: https://ext.dcloud.net.cn/search?q=wo-slider

  • 使用示例

uniapp滑块,uni-app,vue.js文章来源地址https://www.toymoban.com/news/detail-722938.html

<template>
	<view style="height: 100vh;font-size: 12rpx;margin-top: 20px;">
		<view v-for="(item, index) in compOptions" :key="index" style="display: flex; justify-content: center; align-items: center;padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">{{ item.title }}</view>
				<wo-slider
				 :height="item.height"
				 :round="item.round"
				 :border="item.border"
				 :slider-size="item.sliderSize"
				 @slideFinish="onFinish">
				</wo-slider>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view>
				<view style="margin-bottom: 10px; text-align: center;">
					外边框有间隙滑块
				</view>
				<view style="border: 1rpx solid #DEE1E6; padding: 16rpx; border-radius: 80rpx;width: 400rpx;">
					<wo-slider @slideFinish="onFinish" :round="{show: true, style: '80rpx'}">
						<template v-slot:begin>
							<view style="background-color: #E5673B; height: 100%; display: flex; justify-content: center; align-items: center">
								<image style="height: 50rpx;width: 50rpx;" src="/static/right.png" alt="logo"></image>
							</view>
						</template>
						<template v-slot:end>
							<view style="background-color: #1BA035; height: 100%; display: flex; justify-content: center; align-items: center">
								<image style="height: 50rpx;width: 50rpx;" src="../../static/select-bold.png"></image>
							</view>
						</template>
					</wo-slider>
				</view>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">
					插槽:自定义滑块
				</view>
				<wo-slider @slideFinish="onFinish" :round="{show: true, style: '10rpx'}">
					<template v-slot:begin>
						<view style="background-color: #E5673B; height: 100%; display: flex; justify-content: center; align-items: center">
							<image style="height: 50rpx;width: 50rpx;" src="/static/wow.png"></image>
						</view>
					</template>
					<template v-slot:end>
						<view style="background-color: #1BA035; height: 100%; display: flex; justify-content: center; align-items: center">
							<image style="height: 50rpx;width: 50rpx;" src="/static/smile.png"></image>
						</view>
					</template>
				</wo-slider>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">
					插槽:滑道-成功态内容
				</view>
				<wo-slider
				 @slideFinish="onFinishSuccess" :round="{show: true, style: '10rpx'}">
					<template v-slot:isFinished>
						<view style="height: 100%;background-color: #65B58A; color: #fff; display: flex; justify-content: center;align-items: center;">
							<view>
								{{content}}
							</view>
						</view>
					</template>
				</wo-slider>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">
					插槽:滑道-初始态内容
				</view>
				<wo-slider @slideFinish="onFinish" :round="{show: true, style: '10rpx'}">
					<template v-slot:init>
						<view style="background-color: #107BBA; color: #fff; height: 100%; display: flex; justify-content: center;align-items: center;">😀滑动解锁大礼包</view>
					</template>
				</wo-slider>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">
					根据接口判断验证通过
				</view>
				<wo-slider
				 @slideFinish="onFinishOne" :round="{show: true, style: '10rpx'}">
					<template v-slot:isFinished>
						<view :style="{backgroundColor: loadingOne ? '#709bff' : signOne ? '#65B58A' : '#ed9576'}" style="height: 100%; color: #fff; display: flex; justify-content: center;align-items: center;">
							<view>
								{{resOne}}
							</view>
						</view>
					</template>
					<template v-slot:begin>
						<view style="background-color: #E5673B; height: 100%; display: flex; justify-content: center; align-items: center">
							<image style="height: 30rpx;width: 30rpx;" src="@/static/arrow-double-right.png"></image>
						</view>
					</template>
					<template v-slot:end>
						<view :style="{backgroundColor: loadingOne ? '#3370FF' : signOne ? '#1BA035' : '#E23E31'}" style=" height: 100%; display: flex; justify-content: center; align-items: center">
							<view class="spinner" v-if="loadingOne">
							  <view class="double-bounce1"></view>
							  <view class="double-bounce2"></view>
							</view>
							<image v-else style="height: 30rpx;width: 30rpx;" :src="signOne ? successImg : closeImg"></image>
						</view>
					</template>
				</wo-slider>
			</view>
		</view>
		<view style="display: flex; justify-content: center; align-items: center; padding: 10px;">
			<view style="width: 400rpx;">
				<view style="margin-bottom: 10px; text-align: center;">
					根据接口判断验证失败
				</view>
				<wo-slider
				 @slideFinish="onFinishTwo" :round="{show: true, style: '10rpx'}">
					<template v-slot:isFinished>
						<view :style="{backgroundColor: loading ? '#709bff' : sign ? '#65B58A' : '#ed9576'}" style="height: 100%; color: #fff; display: flex; justify-content: center;align-items: center;">
							<view>
								{{res}}
							</view>
						</view>
					</template>
					<template v-slot:begin>
						<view style="background-color: #E5673B; height: 100%; display: flex; justify-content: center; align-items: center">
							<image style="height: 50rpx;width: 50rpx;" src="@/static/right.png"></image>
						</view>
					</template>
					<template v-slot:end>
						<view :style="{backgroundColor: loading ? '#3370FF' : sign ? '#1BA035' : '#E23E31'}" style=" height: 100%; display: flex; justify-content: center; align-items: center">
							<view class="spinner" v-if="loading">
							  <view class="double-bounce1"></view>
							  <view class="double-bounce2"></view>
							</view>
							<image v-else style="height: 50rpx;width: 50rpx;" :src="sign ? successImg : closeImg"></image>
						</view>
					</template>
				</wo-slider>
			</view>
		</view>
		<view style="padding-top: 100rpx;">
			<button @click="clickEvent">重置</button>
		</view>
	</view>
</template>

<script>
	import refreshImg from '../../static/refresh.png'
	import closeImg from '../../static/close.png'
	import successImg from '../../static/select-bold.png'
	export default {
		data() {
			return {
				content: '',
				res: '',
				loading: true,
				sign: false,
				resOne: '',
				loadingOne: true,
				signOne: false,
				resetFuncList: [],
				refreshImg: refreshImg,
				closeImg: closeImg,
				successImg: successImg,
				compOptions: [
					{
						title: '边框方块滑道',
						height: 60,
						sliderSize: 60,
						width: 400,
						round: {show: true, style: "0rpx"},
						border: {show: true, style: '1rpx solid blue'}
					},
					{
						title: '无边框方块滑道',
						height: 60,
						sliderSize: 80,
						width: 400,
						round: {show: true, style: "10rpx"},
						border: {show: false, style: ''},
					},
					{
						title: '边框圆角滑道',
						height: 60,
						sliderSize: 60,
						width: 400,
						round: {show: true, style: "20rpx"},
						border: {show: true, style: '1rpx solid blue'}
					},
					{
						title: '无边框圆角滑道',
						height: 60,
						sliderSize: 80,
						width: 400,
						round: {show: true, style: "30rpx"},
						border: {show: false, style: ''}
					},
					{
						title: '大圆角滑道',
						height: 80,
						sliderSize: 80,
						width: 500,
						round: {show: true, style: "40rpx"},
						border: {show: false, style: ''}
					}
				]
			}
		},
		methods: {
			onFinish(e) {
				console.log('滑动完成', e);
				this.resetFuncList.push(e.resetFunc)
			},
			onFinishSuccess(e) {
				this.resetFuncList.push(e.resetFunc)
				this.content = '😊验证成功'
			},
			clickEvent() {
				this.resetFuncList.forEach((item) => {
					item()
				})
				this.content = ''
			},
			onFinishOne(e) {
				this.resetFuncList.push(e.resetFunc)
				this.loadingOne = true
				this.resOne = '⏳验证中...'
				setTimeout(()=> {
					this.signOne = true
					this.loadingOne = false
					this.resOne = '✅验证成功'
				}, 3000)
			},
			onFinishTwo(e) {
				this.resetFuncList.push(e.resetFunc)
				this.loading = true
				this.res = '⏳验证中...'
				setTimeout(()=> {
					this.sign = false
					this.loading = false
					this.res = '⚠验证失败'
				}, 3000)
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.spinner {
	  width: 20px;
	  height: 20px;
	
	  position: relative;
	  margin: 100px auto;
	}
	
	.double-bounce1, .double-bounce2 {
	  width: 100%;
	  height: 100%;
	  border-radius: 50%;
	  background-color: #fff;
	  opacity: 0.6;
	  position: absolute;
	  top: 0;
	  left: 0;
	  
	  -webkit-animation: sk-bounce 2.0s infinite ease-in-out;
	  animation: sk-bounce 2.0s infinite ease-in-out;
	}
	
	.double-bounce2 {
	  -webkit-animation-delay: -1.0s;
	  animation-delay: -1.0s;
	}
	
	@-webkit-keyframes sk-bounce {
	  0%, 100% { -webkit-transform: scale(0.0) }
	  50% { -webkit-transform: scale(1.0) }
	}
	
	@keyframes sk-bounce {
	  0%, 100% { 
	    transform: scale(0.0);
	    -webkit-transform: scale(0.0);
	  } 50% { 
	    transform: scale(1.0);
	    -webkit-transform: scale(1.0);
	  }
	}
</style>

到了这里,关于uniapp-vue2-微信小程序-滑块验证组件wo-slider的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 微信小程序自定义slider组件实现双向滑块

    实现效果: zy-slider标签是封装的自定义组件 我放到了资源这里地址:https://download.csdn.net/download/Axiaoheng_/86399342?spm=1001.2014.3001.5503 wxml引入 参数 说明 min Number/String slider 最小值 max Number/String slider 最大值 minValue Number/String slider 左边滑块初始位置 maxValue Number/String slider 右边滑块

    2024年02月10日
    浏览(24)
  • uniapp----微信小程序 日历组件(周日历&& 月日历)【Vue3+ts+uView】

    用Vue3+ts+uView来编写日历组件; 存在周日历和月日历两种显示方式; 高亮显示当天日期,红点渲染有数据的日期,点击显示数据 1. calendar-week-mouth组件代码 2. 在页面引用组件

    2024年02月04日
    浏览(34)
  • vue uniapp 同意验证码滑块验证

    发送验证码以及登录的时候会做验证,防止机刷等 效果图 字段 类型 默认值 说明 show Boolean false 是否显示验证码弹框 canvasWidth Number 310 主图区域的宽度 canvasHeight Number 160 主图区域的高度 imgs Array null 自定义图片,见下方例子 successText String 验证通过 验证成功时的提示文字 f

    2024年02月11日
    浏览(26)
  • uniapp-vue3语法实现小程序全局分享(setup,mixin)

    随着vue3的普及uniapp官方也支持了vue3语法的编写 相信大家在开发过程中肯定碰到过小程序所有页面都要开启分享功能的需求;指定的页面(如:文章详情页)有单独的配置,而非单独配置的页面(如:付费的订单详情页)都是统一跳转到首页 我的做法如下: 此时小程序所有页的分

    2024年01月21日
    浏览(41)
  • 基于Taro + React 实现微信小程序半圆滑块组件、半圆进度条、弧形进度条、半圆滑行轨道(附源码)

    1、四个档位 2、可点击加减切换档位 3、可以点击区域切换档位 4、可以滑动切换档位 给大家提供一些实现思路,找了一圈,一些文章基本不能直接用,错漏百出,代码还藏着掖着,希望可以帮到大家 ts的写法风格 index.tsx      index.module.less 防抖的工具函数debounce 的详细代码

    2024年02月06日
    浏览(45)
  • 【b站咸虾米】chapter4_vue组件_新课uniapp零基础入门到项目打包(微信小程序/H5/vue/安卓apk)全掌握

    课程地址:【新课uniapp零基础入门到项目打包(微信小程序/H5/vue/安卓apk)全掌握】 https://www.bilibili.com/video/BV1mT411K7nW/?p=12share_source=copy_webvd_source=b1cb921b73fe3808550eaf2224d1c155 uni-app官网 组件,无论是小程序还是vue,都是非常关键的。 现在单页面程序,主要的依据就是组件。 组件

    2024年01月20日
    浏览(43)
  • 微信小程序手机号快速验证组件调用方式

    目录 一、测试环境 二、问题现象 三、总结 手机号验证组件(包括快速验证组件和实时验证组件)调用后无法对事件进行回调这个问题,先说结论,以下是正确的使用方式: 一、测试环境 windows10 微信开发者工具(1.06.2307260win32-x64) 基础库(3.0.1[1028]) iPhone XR(IOS 15.2.1) 微信(

    2024年02月10日
    浏览(48)
  • uniapp引入微信小程序直播组件

    在manifest.json配置即可,与直接在小程序代码中引入相同。 在工程的manifest.json文件中引入直播插件 通过直播间列表接口查询直播间列表,显示在小程序中 点击直播间,跳转到小程序直播组件即可 未整理参考 未整理参考 未整理参考

    2024年02月22日
    浏览(33)
  • UniApp转微信小程序之全局组件

    1.全局注册组件 两种方法推荐使用easycom 注册,easycom可以大规模注册组件 2.全局插入组件 1.下载插件 2.配置vue.config.js文件 没有这个文件的话,新建一个vue.config.js文件 3.注册全局组件 和uniapp中注册全局组件操作一样 4.配置pages.json文件

    2024年02月03日
    浏览(43)
  • uniapp微信小程序如何创建树形组件

    目录   1:前言 2:最终效果: 2.1一级菜单 2.2二级菜单 2.3三级菜单 3:实现方法 3.1:创建一级菜单  3.2创建二级三级菜单 4:完整代码如下 树形组件应用很广,应用于一些分层次的内容。vue有树形组件,但是uniapp没有树形组件,想要在uniapp使用树形组件,必须要自己写个树形

    2024年02月16日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包