更新记录

1.16(2023-12-12)

优化

1.1.5(2023-12-08)

弹窗层级

1.1.4(2023-12-08)

兼容小程序

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
× ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

使用说明

配合后端仓库

gitee poster

github poster

一起使用的滑块验证 vue 版本

示例

复制到浏览器打开查看效果

https://gitee.com/langlanglang/poster/raw/master/tests/122301561368230151165-1.gif

Attributes

属性名 类型 默认值 说明
visible Boolean false 开关
options Object { sliderImg: '背景图', sliderKey: '验证key', sliderY: '滑块高度' } 参数
loading Boolean false 加载状态
title String 滑块安全验证 标题
tips String 拖动下方滑块完成拼图 提示
successText String 验证成功 成功提示
errorText String 是不是太难了,咱换一个 错误提示
question String 拖动滑块完成拼图,欢迎提建议! 问题提示

Events

事件名称 说明 回调参数
check 检查是否正确的回调函数 sliderKey, sliderX, done, error (验证需要的key, 移动距离, 完成回调, 错误回调)
close 弹窗关闭回调函数 -
refresh 刷新回调函数 -
error 错误回调函数 -

示例

<template>
  <view id="app">
    <button @click="open">验证</button>
    <slider-captcha 
      v-model="visible"
      :options="options"
      :loading="loading"
      @check="check"
      @close="close"
      @refresh="getSliderOptions"
      @error="getSliderOptions"
    >
            <!-- vue2 -->
      <view slot="title">自定义标题-安全验证</view>
      <view slot="successText">自定义成功提示-登录中</view>
      <view slot="errorText">自定义错误提示-是不是太难了换一个</view>
      <view slot="tips">自定义提示拖动下方滑块完成拼图</view>
            <!-- <view slot="question">自定义提示</view> -->
            <!-- vue2 -->

            <!-- vue3 -->
            <template #title>自定义标题-安全验证</template>
            <template #successText>自定义成功提示-登录中</template>
            <template #errorText>自定义错误提示-是不是太难了换一个</template>
            <template #tips>自定义提示拖动下方滑块完成拼图</template>
            <!-- <template #question>自定义提示</template> -->
            <!-- vue3 -->
    </slider-captcha> 
  </view>
</template>

<script>
import SliderCaptcha from '@/components/kkokk-slider-captcha.vue'
export default {
  components:{SliderCaptcha},
  data(){
    return {
      visible: false,
      loading: false,
      options: {}
    }
  },
  methods: {
    // 打开触发
    open() {
      this.visible = true
      this.getSliderOptions()
    },
    // 验证
    check(sliderKey, sliderX, done, error)
    {
      // 这里是验证是否成功的接口
            this.loading = true
            uni.request({
                url: 'http://192.168.10.76:8111/', 
                header: {
                    // 'Content-Type': 'application/x-www-form-urlencoded'
                     'Content-Type': 'application/json' //自定义请求头信息
                },
                data:{
                    sliderKey:sliderKey,
                    sliderX:sliderX
                },
                method:'POST',//请求方式,必须为大写
                success: (res) => {
                    this.loading = false
                    done()
                },
                fail: () => {
                    this.loading = false
                    error()
                }
            })
    },
    // 关闭触发
    close() {

    },
    // 获取滑块验证参数
    getSliderOptions()
    {
      this.loading = true
            uni.request({
                url: 'http://192.168.10.76:8111/', 
                header: {
                    // 'Content-Type': 'application/x-www-form-urlencoded'
                     'Content-Type': 'application/json' //自定义请求头信息
                },
                method:'GET',//请求方式,必须为大写
                success: (res) => {
                    const {img, key, y} = res.data
                    this.options = {
                        sliderImg: img,
                        sliderKey: key,
                        sliderY: y
                    }
                    this.loading = false
                }
            })
    }
  }
}
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问