代码拉取完成,页面将自动刷新
wxapp-market是小程序营销组件,主要有 大转盘 刮刮乐 水果机 九宫格翻纸牌 摇一摇 手势解锁等功能。
npm install @ohos/wxapp_market --save
OpenHarmony npm环境配置等更多内容,请参考 如何安装OpenHarmony npm包 。
<element src='../../common/component/wheel/wheel.hml'></element>
<div class="container">
<wheel areaNumber=" {{ areaNumber }}"
speed=" {{ speed }}"
awardNumer=" {{ awardNumer }}"
mode=" {{ mode }}">
</wheel>
</div>
areaNumber: 8, //抽奖间隔
speed: 16, //转动速度
awardNumer: 2, //中奖区域从1开始
mode: 1, //1是指针旋转,2为转盘旋转
<element src='../../common/component/scratch/scratch.hml'></element>
<div class="container">
<scratch canvasWidth="{{canvasWidth}}"
imageResource="{{imageResource}}"
r="{{r}}"
awardTxt="{{awardTxt}}"
awardTxtColor="{{awardTxtColor}}"
awardTxtFontSize="{{awardTxtFontSize}}">
</scratch>
</div>
canvasWidth: 197,
canvasHeight: 72,
imageResource: 'https://misc.aotu.io/pfan123/wx/placeholder.png',
maskColor: 'red',
r: 4,
awardTxt: '中大奖',
awardTxtColor: '#3985ff',
awardTxtFontSize: '24px',
<element src='../../common/component/slotMachine/slotMachine.hml'></element>
<div class="container">
<slotMachine height="{{ height }}"
len="{{ len }}"
num1="{{ num1 }}"
transY1="{{ transY1 }}"
num2="{{ num2 }}"
transY3="{{ transY3 }}"
num3="{{ num3 }}"
transY4="{{ transY4 }}"
num4="{{ num4 }}"
transY1="{{ transY1 }}"
speed="{{ speed }}">
</slotMachine>
</div>
height: 40, // 单个数字高度
len: 10,
transY1: 0,
num1: 3,
transY2: 0,
num2: 0,
transY3: 0,
num3: 0,
transY4: 0,
num4: 1,
speed: 24,
<element src='../../common/component/fruitMachine/fruitMachine.hml'></element>
<div class="container">
<fruitMachine ret="{{ret}}}" speed="{{speed}}"></fruitMachine>
</div>
title:"水果机",
ret: 8, // 取值1~8
speed: 100,
<element src='../../common/component/card/card.hml'></element>
<card data="{{ data }}"></card>
data: [
{
inlineStyle: '', isBack: false, isMove: false, award: '一等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '二等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '三等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '四等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '五等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '六等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '七等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '八等奖'
},
{
inlineStyle: '', isBack: false, isMove: false, award: '九等奖'
}
],
<element src='../../common/component/shake/shake.hml'></element>
<div class="container">
<shake shakeThreshold="{{shakeThreshold}}}"></shake>
</div>
shakeThreshold: 100, // 阈值
<element src='../../common/component/lock/lock.hml'></element>
<lock canvasWidth="{{ canvasWidth }}"
canvasHeight="{{ canvasHeight }}"
canvasId="{{ canvasId }}"
drawColor="{{ drawColor }}"></lock>
canvasWidth: 300,
canvasHeight: 300,
canvasId: 'canvasLock',
drawColor: '#3985ff'
初始化解锁密码面板
drawCle(x, y)
计算各个点坐标,画圆,根据canvas的大小来平均分配半径
createCircle()
滑动动作执行完毕
onTouchstart(e)
关闭STUN server
close()
监听滑动
onTouchmove(e)
监听点击事件
onTouchend()
监听取消事件
onTouchcancel()
获取touch点相对于canvas的坐标
getPosition()
核心变换方法在touchmove时候调用到剪贴板
update()
初始化圆心
drawPoint()
解锁轨迹
drawLine(po)
touchend结束之后对密码和状态的处理
storePass()
画矩形
drawRect(x, y)
支持 OpenHarmony API version 8 及以上版本。
|---- wxapp_market
| |---- entry # 示例代码文件夹
| |---- wxapp_market # wxapp_market库文件夹
| |---- src/main/js/components
| |---- wheel # 大转盘组件
| |---- titlebar # 状态栏组件
| |---- slotMachine # slot组件
| |---- shake # 摇一摇组件
| |---- scratch # 刮刮乐组件
| |---- lock # 手势解锁组件
| |---- fruitMachine # 水果机组件
| |---- card # 九宫格翻纸牌组件
| |---- index.ets # 对外接口
| |---- README.MD # 安装使用方法
使用过程中发现任何问题都可以提 Issue 给我们,当然,我们也非常欢迎你给我们发 PR 。
本项目基于 Apache License 2.0 ,请自由地享受和参与开源。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。