Socket
Book a DemoInstallSign in
Socket

ant-mini-flip-draw

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ant-mini-flip-draw

支付宝小程序翻牌抽奖

1.0.2
latest
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

翻牌抽奖小程序模块

API

属性名类型默认值描述
prizeListArray[]奖项列表【必填】,须包含 nameicon 字段
prizeNameString''抽奖结果的奖品 name【必填】,其值必须位于 prizeList
cardNumNumber9展示多少张卡片,推荐3/6/9
cardHeightNumber210宽度固定210,高度需要等比换算设置
cardBgImgString-卡背图片
unawardImgString-未中奖展示图片
isDrawingBoolean-是否正在抽奖,用于限制点击
flipAllCardsString-是否翻转剩余卡片
onFlipStartFunction() => {}转动开始的回调【选填】

示例

视图:

<view>
<flipdraw
    prizeList="{{prizeList}}"
    prizeName="{{prizeName}}"
    isDrawing="{{isDrawing}}"
    flipAllCards="{{flipAllCards}}"
    onFlipStart="onFlipStart"
  />
</view>

逻辑:

Page({
  data: {
    prizeList: [{
      'name': '谢谢参与1',
      'icon': 'https://zos.alipayobjects.com/rmsportal/dexmbhnbsLRGIZGBqTcA.png'
    }, ... ],
    prizeName: '',
    flipAllCards: false,
    isDrawing: false,
  },
  onFlipStart() {
    console.log('开始了,这个时候最好页面控制下 loading 状态,组件内不做控制');
    this.setData({
      isDrawing: true, // 修改抽奖状态,防止重复点击多次请求
    });
    // 开始抽奖
    drawRequest().then(res => {
      console.log('拿到结果,设置奖品信息');
      if (res.success) {
        this.setData({
          prizeName: '666元红包',
          isDrawing: false,
        });
      } else {
        this.setData({
          isDrawing: false, // 抽奖结束一定要还原 isDrawing 状态
        });
      }
      this.showResultDialog()
    });
  },
  showResultDialog() {
    // do something
    this.setData({
      flipAllCards: true, // 将剩下未翻过的牌自动翻,展示奖品结果。
    })
  }
});

注意

  • 请求前一定要设置 isDrawing = true,请求结束后一定要设置 isDrawing = false。
  • cardHeight 卡片高度是相对750视觉稿设置的,宽高默认210x210rpx。宽度固定,高度可变。比如210x300的图片,cardHeight就设置为300;如果是200x250的图片需要等比转换一下,cardHeight = 210 * (250/200)

Keywords

支付宝

FAQs

Package last updated on 12 Jun 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.