1 Star 2 Fork 0

hihopeorg / wxapp-market

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

wxapp-market

简介

wxapp-market是小程序营销组件,主要有 大转盘 刮刮乐 水果机 九宫格翻纸牌 摇一摇 手势解锁等功能。

效果展示

下载安装

npm install @ohos/wxapp_market --save

OpenHarmony npm环境配置等更多内容,请参考 如何安装OpenHarmony npm包

使用说明

1 使用大转盘组件
hml中实现:
<element src='../../common/component/wheel/wheel.hml'></element>
<div class="container">
    <wheel areaNumber=" {{ areaNumber }}"
           speed=" {{ speed }}"
           awardNumer=" {{ awardNumer }}"
           mode=" {{ mode }}">
    </wheel>
</div>
js中实现:
        areaNumber: 8,   //抽奖间隔
        speed: 16,       //转动速度
        awardNumer: 2,   //中奖区域从1开始
        mode: 1,         //1是指针旋转,2为转盘旋转
2 使用刮刮乐组件
hml中实现:
<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>
js中实现:
     canvasWidth: 197,
     canvasHeight: 72,
     imageResource: 'https://misc.aotu.io/pfan123/wx/placeholder.png',
     maskColor: 'red',
     r: 4,
     awardTxt: '中大奖',
     awardTxtColor: '#3985ff',
     awardTxtFontSize: '24px',
3 使用slot组件
hml中实现:
<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>
js中实现:
     height: 40, // 单个数字高度
     len: 10,
     transY1: 0,
     num1: 3,
     transY2: 0,
     num2: 0,
     transY3: 0,
     num3: 0,
     transY4: 0,
     num4: 1,
     speed: 24,
4 使用水果机组件
hml中实现:
<element src='../../common/component/fruitMachine/fruitMachine.hml'></element>
<div class="container">
 <fruitMachine ret="{{ret}}}" speed="{{speed}}"></fruitMachine>
</div>
js中实现:
     title:"水果机",
     ret: 8, // 取值1~8
     speed: 100,
5 使用九宫格翻纸牌组件
hml中实现:
<element src='../../common/component/card/card.hml'></element>
<card data="{{ data }}"></card>
js中实现:
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: '九等奖'
     }
 ],
6 使用摇一摇组件
hml中实现:
<element src='../../common/component/shake/shake.hml'></element>
<div class="container">
 <shake shakeThreshold="{{shakeThreshold}}}"></shake>
</div>
js中实现:
     shakeThreshold: 100, // 阈值
7 使用手势解锁组件
hml中实现:
<element src='../../common/component/lock/lock.hml'></element>
<lock canvasWidth="{{ canvasWidth }}"
   canvasHeight="{{ canvasHeight }}"
   canvasId="{{ canvasId }}"
   drawColor="{{ drawColor }}"></lock>
js中实现:
     canvasWidth: 300,
     canvasHeight: 300,
     canvasId: 'canvasLock',
     drawColor: '#3985ff'

接口说明

  1. 初始化解锁密码面板

    drawCle(x, y)

  2. 计算各个点坐标,画圆,根据canvas的大小来平均分配半径

    createCircle()

  3. 滑动动作执行完毕 onTouchstart(e)

  4. 关闭STUN server close()

  5. 监听滑动 onTouchmove(e)

  6. 监听点击事件 onTouchend()

  7. 监听取消事件 onTouchcancel()

  8. 获取touch点相对于canvas的坐标 getPosition()

  9. 核心变换方法在touchmove时候调用到剪贴板 update()

  10. 初始化圆心 drawPoint()

  11. 解锁轨迹 drawLine(po)

  12. touchend结束之后对密码和状态的处理 storePass()

  13. 画矩形 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 ,请自由地享受和参与开源。

MIT License Copyright (c) 2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

商城营销组件,支持大转盘、水果机、九宫格翻纸牌、摇一摇、手势解锁等功能 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/hihopeorg/wxapp-market.git
git@gitee.com:hihopeorg/wxapp-market.git
hihopeorg
wxapp-market
wxapp-market
master

搜索帮助