Skip to main content

Lucky Draw Grid

Lottery

Applicable Scenarios

Used to implement basic Lucky Draw Grid activities.

Basic Capabilities Description

Prize Configuration

Supports configuring up to 8 prize items in the prize settings properties.

Lucky Draw Execution Logic

  1. After clicking the start lucky draw button in the center of the component, the draw animation is triggered and begins sequentially cycling through each prize only when one of the following conditions is met (this capability ensures developers can perform pre-draw condition checks on users during the draw process).
    1. When the 'Start Lucky Draw' property is enabled
    2. The built-in component action 'Start Lucky Draw' has been triggered
  2. When the draw animation is triggered, a timer will start. After 2 seconds, the winning number in the 'draw result' property will be read, causing the prize selection box to select that prize.

Extended Scenarios Description

Generating Dynamic Prize Content Using Data Model Data

  1. Create one data model and add two fields within it: prize name (text type), prize icon (image type).

  2. Enter several sample data records into the model.

  3. Create a variable 'prize' of array type, and select the newly created model for the data model.

  4. When the page load event is triggered, it calls the list method of this data model to query its list data, and stores the output parameters in the prize variable.

  5. Click the data binding mode button on the right side of the component's prize setting property.

  6. Click the data binding button on the right side of the variable property; bind the variable property to the prize variable.

  7. Enter the field identifier of the prize name field from the data model into the prize name property, and enter the field identifier of the prize image field from the data model into the prize icon property. You will then observe that the prize content displays the data pre-entered in the data model.

Property Introduction

External properties received by the component

Property Name
Property Identifier
Type
Description
奖品设置prizeListarray

仅前8项奖品会展示在组件中

Example: [ { "title": "8元优惠券", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/70122750-ba8b-4ac7-be71-c2300f1f8c6f.png" }, { "title": "劳动节水杯", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/c2842881-5e15-409d-8dd3-352205abe38c.png" }, { "title": "10元优惠券", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/b99c4350-c619-4fff-90e0-1980075e0417.png" }, { "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/7cefce40-73e4-4cdd-aa30-d178a4cb6624.png", "title": "旅行背包" }, { "title": "谢谢参与", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/0aa4dc06-e375-45c2-8ec2-0461a83d5d4a.png" }, { "title": "20积分", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/de35f413-6971-4ab3-a816-9c488e169d46.png" }, { "title": "流量券", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/3c0ff8a2-8362-4219-875d-0778d65bba80.png" }, { "title": "10元优惠券", "image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/d11056cc-b8a1-4d50-b993-65d8a434802f.png" } ]

启动抽奖enablePrizeboolean

Example: true

抽奖时长durationnumber

Default value: 2000

抽奖结果prizeResultstring

以左上角为起始位置,顺时针确定8个奖品位置分别1-8

Example: "1"

Events

Events exposed by the component. You can listen to component events to trigger external actions

Event Name
Event Code
Event Output Parameters event.detail
Applicable Scenarios
Description
点击开始抽奖按钮clickLotteryButtonCompatible with all platforms

-

开奖finishLotteryobject
  • prize: string开奖结果

    开奖结果, 等于 prizeResult属性

  • result: object
    • desc: string中奖项名称
    • idx: number中奖项索引
Compatible with all platforms

-

Method API

Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()

Method Name
Method Identifier
Parameters
Method Description
开始抽奖start

-