Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ant-mini-scratch-card

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ant-mini-scratch-card

支付宝小程序刮刮卡组件

  • 1.0.8
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-86.67%
Maintainers
4
Weekly downloads
 
Created
Source

小程序刮刮卡组件

使用说明

安装组件

yarn add @alipay/ant-mini-scratchCard

使用示例

json

{
  "defaultTitle": "刮刮卡小程序组件",
  "allowsBounceVertical": "NO",
  "usingComponents": {
    "scratch": "@alipay/ant-mini-scratchCard/es/scratch/index"
  }
}

xaml

<view>
  <scratch
    tipText="刮刮我,有惊喜~"
    tipColor="#902d02"
    coverColor="#ffae8a"
    ctxLogoUrl="https://gw.alipayobjects.com/zos/rmsportal/iGLmHkSxYfXveGhuzzFf.png"
    resultText=''
    autoFadeOut=true
    resultText="{{result}}"
    onFinish="onFinish"
  />
</view>
<!-- 其中,result 为动态获取的抽奖结果 -->

js

const app = getApp();
Page({
  data: {
    content: 'demo',
    result: ''
  },
  onLoad(options) {
    setTimeout(() => {
      this.setData({
        result: '很遗憾,差点就中奖了'
      });
    }, 1000);
  },
  onFinish() {
    console.log('刮奖结束了');
  }
});

效果图

高级用法

当抽奖结果显示为图片或需要自定义样式修饰时,可以传入slot,并将resultText值设置为''

<!-- 将 resultText 设置为空字符串 -->
<scratch resultText=''>
  <!-- 此处为 slot 子节点内容 -->
  <view class="result">
    <text>{{result}}</text>
  </view>
</scratch>

参数说明

属性类型默认值含义
idStringscratch-canvas组件标识,页面唯一
widthNumber300刮刮卡宽度,单位px
heightNumber150刮刮卡高度,单位px
tipTextString刮刮我,有惊喜刮奖区域提示文字
tipColorString#aaa提示文字的颜色
tipSizeNumber20提示文字的字号,单位px
lineWidthNumber25擦除线宽度,单位px
activePercentNumber0.4当被擦除比例达到该值时刮奖结束,取值范围0-1
autoFadeOutBooleantrue当值为true且被擦除比例达到activePercent选项值时刮奖图层自动消失
ctxLogoUrlString刮奖区图片背景,小程序接口限制目前只支持线上cdn地址或离线包地址,cdn需返回头 Access-Control-Allow-Origin: *
coverColorString#dbdbdb刮奖区背景色,当背景图片透明度为0时无效
resultTextString谢谢参与刮奖结果
onFinishFunction()=>{}刮奖结束回调,当被擦除比例达到activePercent选项值时触发

由于小程序当前接口限制,暂不支持 rpxrem等像素单位,目前仅支持 px

开发

  • 文档 https://docs.alipay.com/mini/ide/overview

Keywords

FAQs

Package last updated on 10 Feb 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc