npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@haici/wepy-component-verification

v1.0.0-beta.2

Published

## 介绍

Downloads

3

Readme

滑动验证组件

介绍

用于简单验证用户为智能生命体。

安装

yarn add @haici/wepy-component-verification

代码演示

wxml code

<view class="p-verification-demo">
  <verification />
  <view class="action">
    <view class="button" bindtap="openVerification">打开验证组件</view>
  </view>
</view>

wpy code

import Verification from "@haici/wepy-component-verification";
import * as Api from "./api";

export default class PageWidget extends wepy.page {
  components = {
    verification: Verification,
  };
  methods = {
    // 页面中打开滑块组件
    openVerification() {
      this.$broadcast("verification-show", {});
    },
  };
  events = {
    // 验证事件
    "verification-validator": async function (validatorData) {
      // 调用后台验证接口
      const { data } = await Api.getVerificationResult(validatorData);
      if (data.data.result) {
        // 验证成功 通知滑动组件
        this.$broadcast("verification-validator-success", { isValid: true });
      } else {
        // 验证失败 通知滑动组件
        this.$broadcast("verification-validator-failure", { isValid: false });
      }
    },
    // 验证成功后的回调事件
    "verification-validator-success-callback": async function () {
      this.$broadcast("verification-close", {});
      // 执行后续正常逻辑
      // ...
    },
    // 刷新事件
    "verification-refresh": async function () {
      const { data } = await Api.getVerificationResource();
      const { background, slider, id } = data.data;
      this.$broadcast("verification-resource-fetcher", {
        backgroundSrc: `http://xxx${background}.png`,
        sliderSrc: `http://xxx${slider}.png`,
        id,
      });
    },
  };
}

API

页面事件

定义在页面里,由组件被动触发,以下事件必须定义,否则功能无法使用。

| 参数 | 说明 | 类型 | 参数 | | --------------------------------------- | ------------ | ------- | ------------- | | verification-refresh | 资源获取事件 | event | | | verification-validator | 验证事件 | event | validatorData | | verification-validator-success-callback | 验证成功回调 | event | |

组件事件

以下事件内置组件中,无需用户手动定义,由页面主动触发

| 参数 | 说明 | 类型 | 参数 | | ------------------------------ | ---------------- | ------- | ------------- | | verification-show | 打开滑动验证组件 | event | | | verification-close | 关闭滑动验证组件 | event | | | verification-resource-fetcher | 资源同步事件 | event | resourceProps | | verification-validator-success | 验证成功 | event | | | verification-validator-failure | 验证失败 | event | |

事件参数

resourceProps

| 参数 | 说明 | 类型 | 参数 | | ------------- | ------------ | -------- | ------------- | | id | id | string | | | backgroundSrc | 背景图片地址 | string | | | sliderSrc | 滑块图片地址 | string | resourceProps |

事件触发流程

verification-show(打开滑动组件) =>
verification-refresh(获取资源) =>
verification-resource-fetcher(同步资源) =>
verification-validator(验证) =>
verification-validator-success | verification-validator-failure(通知验证结果) =>
verification-validator-success-callback(验证成功回调)