Socket
Socket
Sign inDemoInstall

vue-social-captcha

Package Overview
Dependencies
15
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-social-captcha

> 一个集极验验证、腾讯验证的vue组件


Version published
Weekly downloads
158
increased by30.58%
Maintainers
1
Install size
4.16 MB
Created
Weekly downloads
 

Readme

Source

vue-social-captcha

一个集极验验证、腾讯验证的vue组件

截图

vue-contribution

依赖

  • axios

安装

$ npm install vue-social-captcha -S

使用

main.js 文件中引入插件并注册

# main.js
import captcha from 'vue-social-captcha'
Vue.use(captcha)

在项目中使用 vue-social-captcha

<template>
    <div id="app">
        <Captcha
            id="Captcha"
            scene="Login"
            type="Geetest"
            :parm="captchaOption"
            @callback="captchaNotice"
            url="http://pay.test.com/admin/captcha/"
        >
            <input id="Captcha" type="button" value="登陆"/>
        </Captcha>
    </div>
</template>

<script>
export default {
    name: 'app',
    data () {
        return {
            captchaOption: {
                // 各平台的参数,具体请参阅个平台文档
                // 以下为腾讯验证码的参数
                // appid: '',
                // 以下为极验验证码的参数
                product: 'bind',
            }
        }
    },
    methods: {
        // 回调监听
        // status: 1成功,2验证中,0失败
        // res: 三方返回的原始数据
        captchaNotice(status, res){
            console.log(status)
            console.log(res)
        }
    }
}
</script>

props属性

通过以下属性来设置你的验证码

属性说明类型默认值必须
parm验证码参数(请参阅各平台文档)Object
url后端验证地址,返回格式请参阅下面的【数据返回格式】String
type验证码类型,可选参数 TencentCaptcha GeetestString
id绑定元素idString
scene使用场景,会传递给后端,主要用于后端业务逻辑String

服务端Url请求

请求

url请求时会附带以下两个参数到服务端,以便于业务逻辑开发。

{
    g_type: 'TencentCaptcha',
    g_scene: 'Login',
}
数据返回格式

服务端返回参数主要有三个,分别是code msg data

属性说明必须
code验证码状态,有2个值,1为成功,0为失败必须
msg说明文本
data当验证码类型为Geetest时该数据必须

例:

// 极验验证
{
    "code":1,
    "msg":"验证成功",
    "data":
    {
        "success":1,
        "gt":"29e4e065c7ba05ff77ba896e5d577f89",
        "challenge":"bd26076b3afe9ed3c17738f3f8a7eec7",
        "new_captcha":1
    }
}
// 腾讯验证
{
    "code":1,
    "msg":"验证成功"
}

相关资源

Keywords

FAQs

Last updated on 25 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc