uni-app小程序接入腾讯云天御 验证码

2021-01-26  本文已影响0人  _奈_

1、前提条件

使用小程序插件接入验证码前,需要先在 验证码控制台 中注册小程序插件 AppID 和 AppSecret,注册完成后,您可以在验证码控制台的验证详情的基础配置中,查看 AppID 以及 AppSecret。

2、在小程序后台添加“天御验证”插件

3、uni-app项目内添加和使用插件

"mp-weixin" : {
  "appid" : "xxxx",
  "setting" : {
    "urlCheck" : false
  },
  "usingComponents" : true,
  // 添加以下代码
  "plugins": {
    "t-captcha": {
      "version": "1.0.0",
        "provider": "wxb302e0fc8ab232b4"
    }
  }
},
{
  "path" : "xxx",
  "style" :  {
    "navigationBarTitleText": "xxx",
    "enablePullDownRefresh": false,
    // 加入以下代码
    "usingComponents": {
      "t-captcha": "plugin://t-captcha/t-captcha"
    }
  }
}
<t-captcha id="captcha" app-id="填写第一步申请的AppID" @verify="handlerVerify" />

// selectComponent需要通过以下方式调用
const arr = getCurrentPages();
arr[arr.length - 1].selectComponent('#captcha').show();
上一篇 下一篇

猜你喜欢

热点阅读