Turntable

概述[自定义转盘]

<Turntable /> 是转盘组件,通过设置属性可以实现内容自定义,样式自定义的转盘效果,转动的主体是 canvas 绘图。

示例代码

import cooApp, { basicWidgets } from 'coolink'

const { Turntable } = basicWidgets

export default class Turntable extends cooApp.Widget {
  render () {
    const awardNameList = ["喝半杯", "真心话", "上家曝光", "下家曝光", "大家干杯", "男士喝光", "PASS", "女士干杯", "和异性交杯", "找人干杯", "自己唱首歌", "干一杯"];
    const awardRatioList = [1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12];
    const awardBgList = [Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray];

    return {
        <Turntable height={700}
            awardNameList={awardNameList}
            awardRatioList={awardRatioList}
            awardBgColorList={awardBgList}
            awardBgUrl={'http://beta.webapp.skysrt.com/coolink/app/coo-movie/turnbg.png'}
            bgWidth={350}
            bgHeight={350}
            contentWidth={300}
            contentHeight={300}
            secondUrl={'http://beta.webapp.skysrt.com/coolink/app/coo-movie/center.png'}
            secondWidth={50}
            secondHeight={50}
            circle={5}
            fontSize={28}
            result={5}
            start={0}
            onStopBack={(resule) => {
                return new Promise(resolve => {
                        // 通知上层转盘动作完成
                    resolve()
                })
            }}
        >
        </Turntable>
    }
  }
}

组件属性

属性名类型说明默认值
awardNameListarray转盘选项内容2<=选项格式<=12
awardRatioListarray转盘选项概率和为 1
awardBgListarray转盘选项背景色灰白相间
awardBgUrlstring转盘背景图不为空
bgWidthnumber转盘背景图宽度不为空
bgHeightnumber转盘背景图高度不为空
contentWidthnumber转盘内容宽度内容和转盘边际有距离
contentHeightnumber转盘内容高度内容和转盘边际有距离
secondUrlstring转盘指针图不为空
secondWidthnumber转盘指针宽度不为空
secondHeightnumber转盘指针高度不为空
circlenumber转盘转动圈速不为空
fontSizenumber转盘文案大小不为空
resultnumber转盘最终结果不为空
startnumber控制转盘转动0 为只更新内容不转动,1 转动
onStopBackFunction转动结束回调不为空

样例 1

export default class Turntable extends cooApp.Widget {
  render () {
    const awardNameList = ["喝半杯", "真心话", "上家曝光", "下家曝光", "大家干杯", "男士喝光", "PASS", "女士干杯", "和异性交杯", "找人干杯", "自己唱首歌", "干一杯"];
    const awardRatioList = [1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12, 1 / 12];
    const awardBgList = [Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray, Colors.Transparent, Colors.Lightgray];

    return {
        <Turntable height={700}
            awardNameList={awardNameList}
            awardRatioList={awardRatioList}
            awardBgColorList={awardBgList}
            awardBgUrl={'http://beta.webapp.skysrt.com/coolink/app/coo-movie/turnbg.png'}
            bgWidth={350}
            bgHeight={350}
            contentWidth={300}
            contentHeight={300}
            secondUrl={'http://beta.webapp.skysrt.com/coolink/app/coo-movie/center.png'}
            secondWidth={50}
            secondHeight={50}
            circle={5}
            fontSize={28}
            result={5}
            start={0}
            onStopBack={(resule) => {
                return new Promise(resolve => {
                        // 通知上层转盘动作完成
                    resolve()
                })
            }}
        >
        </Turntable>
    }
  }
}

上述例子的效果图:

Last Updated:
Contributors: linxinwang, wangyong-debug
©深圳市酷开网络科技股份有限公司 ICP备案号粤ICP备06098778号