├── .commitlintrc.js ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .parser-preset.js ├── README.md ├── app.js ├── app.json ├── assets ├── .gitkeep ├── card_front.png ├── fruitMachine.png ├── gestureLock.png ├── gridcard.png ├── logo.png ├── marquee_btn.png ├── marquee_lottery1.png ├── marquee_lottery2.png ├── marquee_lottery3.png ├── scratch.png ├── shake.png ├── shake_box.png ├── shake_smile.png ├── slotMachine.png ├── sound │ └── shake_sound.mp3 └── wheel.png ├── components ├── card │ ├── card.js │ ├── card.wxml │ ├── card.wxss │ └── promise.min.js ├── fruitMachine │ ├── fruitMachine.js │ ├── fruitMachine.wxml │ └── fruitMachine.wxss ├── lock │ ├── lock.js │ ├── lock.wxml │ └── lock.wxss ├── scratch │ ├── images │ │ └── placeholder.png │ ├── scratch.js │ └── scratch.wxml ├── shake │ ├── shake.js │ ├── shake.wxml │ └── shake.wxss ├── slotMachine │ ├── slotMachine.js │ ├── slotMachine.wxml │ └── slotMachine.wxss └── wheel │ ├── images │ ├── dial_bg.png │ └── dial_pointer.png │ ├── wheel.js │ ├── wheel.wxml │ └── wheel.wxss ├── docs ├── Card.html ├── FruitMachine.html ├── Lock.html ├── Machine.html ├── Scratch.html ├── Shake.html ├── Wheel.html ├── card_card.js.html ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ └── OpenSans-Regular-webfont.woff ├── fruitMachine_fruitMachine.js.html ├── global.html ├── index.html ├── lock_lock.js.html ├── module.exports.html ├── scratch_scratch.js.html ├── scripts │ ├── linenumber.js │ └── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js ├── shake_shake.js.html ├── slotMachine_slotMachine.js.html ├── styles │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css └── wheel_wheel.js.html ├── package-lock.json ├── pages ├── fruitMachine │ ├── fruitMachine.js │ ├── fruitMachine.json │ ├── fruitMachine.wxml │ └── fruitMachine.wxss ├── gestureLock │ ├── gestureLock.js │ ├── gestureLock.json │ ├── gestureLock.wxml │ └── gestureLock.wxss ├── gridcard │ ├── gridcard.js │ ├── gridcard.json │ ├── gridcard.wxml │ └── gridcard.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── scratch │ ├── scratch.js │ ├── scratch.json │ ├── scratch.wxml │ └── scratch.wxss ├── shake │ ├── shake.js │ ├── shake.json │ ├── shake.wxml │ └── shake.wxss ├── slotMachine │ ├── slotMachine.js │ ├── slotMachine.json │ ├── slotMachine.wxml │ └── slotMachine.wxss └── wheel │ ├── wheel.js │ ├── wheel.json │ ├── wheel.wxml │ └── wheel.wxss └── project.config.json /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parserPreset: './.parser-preset.js', 3 | rules: { 4 | 'type-empty': [2, 'never'], 5 | 'type-case': [2, 'always', 'lower-case'], 6 | 'subject-empty': [2, 'never'], 7 | 'type-enum': [2, 'always', [ 8 | 'feat', 9 | 'fix', 10 | 'docs', 11 | 'style', 12 | 'refactor', 13 | 'test', 14 | 'chore', 15 | 'up', 16 | 'revert', 17 | 'merge' 18 | ]] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | test/ 3 | coverage/ 4 | .vscode/ 5 | .nyc_output/ 6 | git_stats/ 7 | yarn-offline/ 8 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 该 ESLint 配置扩展自 eslint-config-o2team-wx 3 | * https://www.npmjs.com/package/eslint-config-o2team-wx 4 | * o2team-wx 这一套规则是参考了 StandardJS 和 Airbnb 的 JS 规范,然后结合业务中的最佳实践整理输出的。 5 | */ 6 | module.exports = { 7 | 'extends': 'o2team-wx', 8 | 'plugins': [ 9 | 'html' 10 | ], 11 | 'settings': { 12 | 'html/html-extensions': ['.wxml'] 13 | }, 14 | 'rules': { 15 | 'no-restricted-globals': ['error', 'Promise'], // 禁止直接使用原生Promise,必须引入lib 16 | 'newline-per-chained-call': 'off', 17 | 'eqeqeq': 'off', 18 | 'indent': ['error', 4, { SwitchCase: 1 }], 19 | 'prefer-rest-params': 'off', 20 | 'prefer-template': 'off', 21 | 'no-else-return': 'off', 22 | 'no-nested-ternary': 'off', 23 | 'brace-style': 'off', 24 | 'semi': 'off', 25 | 'camelcase': ['off', { properties: 'never' }], // ESLint 配置问题,暂时不强制所有变量名都用驼峰式命名 26 | 'array-callback-return': 'off', // 暂时关闭 27 | 'prefer-const': 'warn', 28 | 'no-mixed-operators': 'off', 29 | 'callback-return': 'warn', 30 | 'class-methods-use-this': 'warn', 31 | 32 | // 不能直接使用以下 api,如果修改该 api 的封装库,可以在代码加上以下注释忽略检查: 33 | // /* eslint-disable no-restricted-properties */ 34 | // [your code] 35 | // /* eslint-enable no-restricted-properties */ 36 | 37 | 'no-restricted-properties': [2, { 38 | 'object': 'wx', 39 | 'property': 'navigateTo', 40 | 'message': 'Please use this.$goto!!!' 41 | }, { 42 | 'object': 'wx', 43 | 'property': 'redirectTo', 44 | 'message': 'Please use this.$goto!!!' 45 | }, { 46 | 'object': 'wx', 47 | 'property': 'switchTab', 48 | 'message': 'Please use this.$goto!!!' 49 | }, { 50 | 'object': 'wx', 51 | 'property': 'request', 52 | 'message': 'Please use common/request lib!!!' 53 | }, { 54 | 'object': 'wx', 55 | 'property': 'connectSocket', 56 | 'message': 'Please use common/request lib!!!' 57 | }, { 58 | 'object': 'wx', 59 | 'property': 'setStorage', 60 | 'message': 'Please use common/localStorage lib!!!' 61 | }, { 62 | 'object': 'wx', 63 | 'property': 'setStorageSync', 64 | 'message': 'Please use common/localStorage lib!!!' 65 | }, { 66 | 'object': 'wx', 67 | 'property': 'getStorage', 68 | 'message': 'Please use common/localStorage lib!!!' 69 | }, { 70 | 'object': 'wx', 71 | 'property': 'getStorageSync', 72 | 'message': 'Please use common/localStorage lib!!!' 73 | }] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .eslintrc.json 4 | node_modules/ 5 | demo/ 6 | yarn.lock 7 | npm-debug.log 8 | gulpfile.js 9 | **.css 10 | !docs/styles/*.css 11 | .sass-cache 12 | ./utils/ 13 | common/ 14 | models/ 15 | app.css 16 | app.wxss 17 | gulpfile.js 18 | config.js 19 | jsdoc.conf.json 20 | test.js 21 | package.json 22 | out/ 23 | CHANGELOG.md 24 | -------------------------------------------------------------------------------- /.parser-preset.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parserOpts: { 3 | headerPattern: /^(\w*)(?:\((.*)\))?:[ ]?(.*)$/, 4 | headerCorrespondence: ['type', 'scope', 'subject'] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## wxapp-market 2 | 3 | 小程序营销组件, Marketing components for WeChatApp 4 | 5 | 6 | ## 支持营销玩法 7 | 8 | - 大转盘 9 | - 刮刮乐 10 | - 老虎机 11 | - 水果机 12 | - 九宫格翻纸牌 13 | - 摇一摇 14 | - 手势解锁 15 | 16 | 17 | ## 如何使用 18 | 19 | ### 1.拉取仓库 20 | 21 | ``` 22 | git clone git@github.com:o2team/wxapp-market.git 23 | ``` 24 | 25 | ### 2.查看组件文件 26 | 27 | - 大转盘 (Big wheel) : `/components/wheel/` 28 | - 刮刮乐 (Scratch tickets) : `/components/scratch/` 29 | - 老虎机 (Slot machine) : `/components/slotMachine/` 30 | - 水果机 (Fruit machine) : `/components/fruitMachine/` 31 | - 九宫格翻纸牌 (Grid card) : `/components/card/` 32 | - 摇一摇 (Shake) : `/components/shake/` 33 | - 手势解锁 (Gesture lock) : `/components/lock/` 34 | 35 | ### 3.使用引入方式 36 | 37 | #### ➀ 使用大转盘组件 38 | 39 | - WXSS中引用样式:`@import "../../components/wheel/wheel.wxss"` 40 | 41 | - WXML中引用结构:`` 42 | 43 | - JS中引用:`import Wheel from "../../components/wheel/wheel.js"` 44 | 45 | - JS中实例调用: 46 | 47 | ```js 48 | new Wheel(this,{ 49 | areaNumber: 8, //抽奖间隔 50 | speed: 16, //转动速度 51 | awardNumer: 2, //中奖区域从1开始 52 | mode: 1, //1是指针旋转,2为转盘旋转 53 | callback: (idx, award) => { 54 | //结束回调, 参数对应宫格索引,对应奖项 55 | } 56 | }) 57 | ``` 58 | 59 | #### ➁ 使用刮刮乐组件 60 | 61 | - WXML中引用结构:`` 62 | 63 | - JS中引用:`import Scratch from "../../components/scratch/scratch.js"` 64 | 65 | - JS中实例调用: 66 | 67 | ```js 68 | new Scratch(this,{ 69 | canvasWidth: 197, //画布宽带 70 | canvasHeight: 72, //画布高度 71 | imageResource: "./images/placeholder.png", //遮罩层图片 72 | r: 4, //笔触半径 73 | awardTxt: '中大奖', //底部抽奖文字奖项 74 | awardTxtColor: "#1AAD16", //底部抽奖文字颜色 75 | awardTxtFontSize: "24px", //底部抽奖文字大小 76 | maskColor: "red", //没有图片遮罩层颜色 77 | callback: () => { 78 | //清除画布回调 79 | } 80 | }) 81 | ``` 82 | 83 | > 注意:小程序无 globalCompositeOperation = "destination-out" 属性,所以采用 `clearRect` 做擦除处理 84 | 85 | 86 | #### ➂ 使用老虎机组件 87 | 88 | - WXSS中引用样式:`@import "../../components/slotMachine/slotMachine.wxss"` 89 | 90 | - WXML中引用结构:`` 91 | 92 | - JS中引用:`import SlotMachine from "../../components/slotMachine/slotMachine.js"` 93 | 94 | - JS中实例调用: 95 | 96 | ```js 97 | new SlotMachine(this,{ 98 | height: 40, //单个数字高度 99 | len: 10, //单个项目数字个数 100 | transY1: 0, //第一列初始位置 101 | num1: 3, //第一列结束数字 102 | transY2: 0, //第二列初始位置 103 | num2: 0, //第二列结束数字 104 | transY3: 0, //第三列初始位置 105 | num3: 0, //第三列结束数字 106 | transY4: 0, //第四列结束数字 107 | num4: 1, //第四列结束数字 108 | speed: 24, //速度 109 | callback: (idx, award) => { 110 | //结束回调, 参数对应宫格索引,对应奖项 111 | } 112 | }) 113 | ``` 114 | 115 | #### ➃ 使用水果机组件 116 | 117 | - WXSS中引用样式:`@import "../../components/fruitMachine/fruitMachine.wxss"` 118 | 119 | - WXML中引用结构:`` 120 | 121 | - JS中引用:`import FruitMachine from "../../components/fruitMachine/fruitMachine.js"` 122 | 123 | - JS中实例调用: 124 | 125 | ```js 126 | new FruitMachine(this,{ 127 | len: 9, //宫格个数 128 | ret: 9, //抽奖结果对应值1~9 129 | speed: 100, // 速度值 130 | callback: (idx, award) => { 131 | //结束回调, 参数对应宫格索引,对应奖项 132 | } 133 | }) 134 | ``` 135 | 136 | #### ➄ 使用九宫格翻纸牌组件 137 | 138 | - WXSS中引用样式:`@import "../../components/card/card.wxss"` 139 | 140 | - WXML中引用结构:`` 141 | 142 | - JS中引用:`import Card from "../../components/card/card.js"` 143 | 144 | - JS中实例调用: 145 | 146 | ```js 147 | new Card(this,{ 148 | data: [ //宫格信息,内联样式、是否是反面、是否运动、对应奖项 149 | {isBack: false, isMove: false, award: "一等奖"}, 150 | {isBack: false, isMove: false, award: "二等奖"}, 151 | {isBack: false, isMove: false, award: "三等奖"}, 152 | {isBack: false, isMove: false, award: "四等奖"}, 153 | {isBack: false, isMove: false, award: "五等奖"}, 154 | {isBack: false, isMove: false, award: "六等奖"}, 155 | {isBack: false, isMove: false, award: "七等奖"}, 156 | {isBack: false, isMove: false, award: "八等奖"}, 157 | {isBack: false, isMove: false, award: "九等奖"} 158 | ], 159 | callback: (idx, award) => { 160 | //结束回调, 参数对应宫格索引,对应奖项 161 | } 162 | }) 163 | ``` 164 | 165 | #### ➅ 使用摇一摇组件 166 | 167 | - WXSS中引用样式:`@import "../../components/shake/shake.wxss"` 168 | 169 | - WXML中引用结构:`` 170 | 171 | - JS中引用:`import Shake from "../../components/shake/shake.js"` 172 | 173 | - JS中实例调用: 174 | 175 | ```js 176 | new Shake(this,{ 177 | shakeThreshold: 70, //阈值 178 | callback: (idx, award) => { 179 | //结束回调, 参数对应宫格索引,对应奖项 180 | } 181 | }) 182 | ``` 183 | 184 | #### ➆ 使用手势解锁组件 185 | 186 | - WXSS中引用样式:`@import "../../components/lock/lock.wxss"` 187 | 188 | - WXML中引用结构:`` 189 | 190 | - JS中引用:`import Lock from "../../components/lock/lock.js"` 191 | 192 | - JS中实例调用: 193 | 194 | ```js 195 | new Lock(this,{ 196 | canvasWidth: 300, //canvas画布宽度 px 197 | canvasHeight: 300, //canvas画布高度 px 198 | canvasId: "canvasLock", //canvas画布id 199 | drawColor: "#3985ff" //绘制颜色 200 | }) 201 | ``` 202 | 203 | 文档详情,请[查阅](https://o2team.github.io/wxapp-market/index.html) 204 | 205 | ## 件体验二维码 206 | 207 | ![营销组件体验二维码](https://img.pfan123.com/qrcode.jpg) 208 | 209 | ## 效果图展示 210 | 211 | ![支持营销](https://img.pfan123.com/wx_market_0.gif?t=1112&imageView2/1/w/356/h/634) 212 | ![大转盘组件](https://img.pfan123.com/wx_market_1.gif?t=1112&imageView2/1/w/356/h/634) 213 | ![刮刮乐组件](https://img.pfan123.com/wx_market_2.gif?t=1112&imageView2/1/w/356/h/634) 214 | ![老虎机组件](https://img.pfan123.com/wx_market_3.gif?t=1112&imageView2/1/w/356/h/634) 215 | ![水果机组件](https://img.pfan123.com/wx_market_4.gif?t=11122&imageView2/1/w/356/h/634) 216 | ![九宫格翻纸组件](https://img.pfan123.com/wx_market_5.gif?t=1221112&imageView2/1/w/356/h/634) 217 | ![摇一摇组件](https://img.pfan123.com/wx_market_6.gif?t=1112&imageView2/1/w/356/h/634) 218 | ![手势解锁组件](https://img.pfan123.com/wx_market_7.gif?t=11112&imageView2/1/w/356/h/634) 219 | 220 | ## 更新记录 221 | 222 | - [x] 优化文件目录结构 2017-09-18 223 | - [x] 手势解锁组件 2017-09-17 224 | - [x] 摇一摇组件 2017-09-16 225 | - [x] 九宫格翻纸组件 2017-09-16 226 | - [x] 增加老虎机组件、水果机组件 2017-09-02 227 | - [x] 增加刮刮乐组件 2017-08-29 228 | - [x] 增加大转盘组件 2017-08-27 229 | - [x] create wx-market repository 2017-08-26 230 | 231 | ## 开源协议 232 | 233 | 本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。 234 | 235 | 236 | ## 贡献 237 | 238 | 如果你有好的意见或建议,欢迎给我们提 [Issue](https://github.com/o2team/wxapp-market/issues) 或 [PR](https://github.com/o2team/wxapp-market/compare),为优化 [wxapp-market](https://github.com/o2team/wxapp-market) 贡献力量。 239 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | // 展示本地存储能力 5 | var logs = wx.getStorageSync('logs') || [] 6 | logs.unshift(Date.now()) 7 | wx.setStorageSync('logs', logs) 8 | 9 | // 登录 10 | wx.login({ 11 | success: res => { 12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId 13 | } 14 | }) 15 | // 获取用户信息 16 | wx.getSetting({ 17 | success: res => { 18 | if (res.authSetting['scope.userInfo']) { 19 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 20 | wx.getUserInfo({ 21 | success: res => { 22 | // 可以将 res 发送给后台解码出 unionId 23 | this.globalData.userInfo = res.userInfo 24 | 25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 26 | // 所以此处加入 callback 以防止这种情况 27 | if (this.userInfoReadyCallback) { 28 | this.userInfoReadyCallback(res) 29 | } 30 | } 31 | }) 32 | } 33 | } 34 | }) 35 | }, 36 | globalData: { 37 | userInfo: null 38 | } 39 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/wheel/wheel", 5 | "pages/scratch/scratch", 6 | "pages/slotMachine/slotMachine", 7 | "pages/fruitMachine/fruitMachine", 8 | "pages/gridcard/gridcard", 9 | "pages/shake/shake", 10 | "pages/gestureLock/gestureLock" 11 | ], 12 | "window": { 13 | "navigationBarTextStyle": "black", 14 | "navigationBarTitleText": "O2营销组件", 15 | "navigationBarBackgroundColor": "#F8F8F8", 16 | "backgroundColor": "#F8F8F8" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/.gitkeep -------------------------------------------------------------------------------- /assets/card_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/card_front.png -------------------------------------------------------------------------------- /assets/fruitMachine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/fruitMachine.png -------------------------------------------------------------------------------- /assets/gestureLock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/gestureLock.png -------------------------------------------------------------------------------- /assets/gridcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/gridcard.png -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/logo.png -------------------------------------------------------------------------------- /assets/marquee_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/marquee_btn.png -------------------------------------------------------------------------------- /assets/marquee_lottery1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/marquee_lottery1.png -------------------------------------------------------------------------------- /assets/marquee_lottery2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/marquee_lottery2.png -------------------------------------------------------------------------------- /assets/marquee_lottery3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/marquee_lottery3.png -------------------------------------------------------------------------------- /assets/scratch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/scratch.png -------------------------------------------------------------------------------- /assets/shake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/shake.png -------------------------------------------------------------------------------- /assets/shake_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/shake_box.png -------------------------------------------------------------------------------- /assets/shake_smile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/shake_smile.png -------------------------------------------------------------------------------- /assets/slotMachine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/slotMachine.png -------------------------------------------------------------------------------- /assets/sound/shake_sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/sound/shake_sound.mp3 -------------------------------------------------------------------------------- /assets/wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/assets/wheel.png -------------------------------------------------------------------------------- /components/card/card.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Card 3 | * @class 4 | * @classdesc 九宫格翻纸牌组件逻辑部分 5 | * @author pfan 6 | * @todo 注意:移动端真机,不支持requestAnimationFrame. 7 | * 8 | * @example 9 | * new Card(this,{ 10 | * data: [ //宫格信息,内联样式、是否是反面、是否运动、对应奖项 11 | * {isBack: false, isMove: false, award: "一等奖"}, 12 | * {isBack: false, isMove: false, award: "二等奖"}, 13 | * {isBack: false, isMove: false, award: "三等奖"}, 14 | * {isBack: false, isMove: false, award: "四等奖"}, 15 | * {isBack: false, isMove: false, award: "五等奖"}, 16 | * {isBack: false, isMove: false, award: "六等奖"}, 17 | * {isBack: false, isMove: false, award: "七等奖"}, 18 | * {isBack: false, isMove: false, award: "八等奖"}, 19 | * {isBack: false, isMove: false, award: "九等奖"} 20 | * ], 21 | * callback: (idx, award) => { 22 | * //结束回调, 参数对应宫格索引,对应奖项 23 | * } 24 | * }) 25 | */ 26 | 27 | const Promise = require('./promise.min.js') 28 | 29 | class Card { 30 | /** 31 | * @constructs Card构造函数 32 | * @param {Object} pageContext page路由指针 33 | * @param {Object} opts 组件所需参数 34 | * @param {String} opts.inlineStyle 组件所需参数 35 | * @param {Boolean} opts.isBack 是否是反面 36 | * @param {Boolean} opts.isMove 是否运动 37 | * @param {String} opts.award 对应奖项 38 | * @param {Function} opts.callback 结束回调 39 | */ 40 | 41 | constructor (pageContext, opts) { 42 | this.page = pageContext 43 | this.isFlip = false 44 | this.card = opts.data || [] 45 | this.init() 46 | this.endCallBack = opts.callback 47 | this.page.start = this.start.bind(this) 48 | this.page.onClick = this.onClick.bind(this) 49 | } 50 | 51 | init () { 52 | const { card } = this 53 | 54 | for (let i = 0; i < 9; i++) { 55 | card[i] = { isBack: false, isMove: false, award: card[i].award } 56 | } 57 | this.page.setData({ card }) 58 | this.card = card 59 | } 60 | 61 | start () { 62 | const { card } = this 63 | 64 | runAsync(100).then(() => { 65 | for (let i = 0; i < 3; i++) { 66 | card[i].isBack = true 67 | } 68 | this.page.setData({ card }) 69 | return runAsync(200) 70 | }).then(() => { 71 | for (let i = 3; i < 6; i++) { 72 | card[i].isBack = true 73 | } 74 | this.page.setData({ card }) 75 | return runAsync(200) 76 | }).then(() => { 77 | for (let i = 6; i <= 8; i++) { 78 | card[i].isBack = true 79 | } 80 | this.page.setData({ card }) 81 | return runAsync(800) 82 | }).then(() => { 83 | for (let i = 0; i < 9; i++) { 84 | card[i].isBack = false 85 | } 86 | this.page.setData({ card }) 87 | return runAsync(400) 88 | }).then(() => { 89 | for (let i = 0; i < 9; i++) { 90 | card[i].isMove = true 91 | } 92 | this.page.setData({ card }) 93 | return runAsync(500) 94 | }).then(() => { 95 | for (let i = 0; i < 9; i++) { 96 | card[i].isMove = false 97 | } 98 | this.page.setData({ card }) 99 | this.isFlip = true 100 | this.card = card 101 | }) 102 | } 103 | 104 | reset () { 105 | const { card } = this 106 | this.isFlip = false 107 | for (let i = 0; i < 9; i++) { 108 | card[i] = { isBack: false, isMove: false, award: card[i].award } 109 | } 110 | this.card = card 111 | this.page.setData({ card }) 112 | 113 | runAsync(800).then(() => { 114 | this.start() 115 | }) 116 | } 117 | 118 | onClick (event) { 119 | const { card, isFlip, endCallBack } = this 120 | if (!isFlip) return 121 | const idx = event.currentTarget.dataset.idx 122 | const award = event.currentTarget.dataset.award 123 | card[idx].isBack = !card[idx].isBack 124 | this.page.setData({ card }) 125 | runAsync(600).then(() => { 126 | endCallBack(idx, award) 127 | }) 128 | } 129 | } 130 | 131 | 132 | /** 133 | * runAsync 延迟返回 promise 方法 134 | * @param {Number} time 延迟时间 135 | * @return {type} 返回Promise对象 136 | */ 137 | function runAsync (time) { 138 | return new Promise(function (resolve, reject) { 139 | const timer = setTimeout(function () { 140 | resolve() 141 | clearTimeout(timer) 142 | }, time) 143 | }) 144 | } 145 | 146 | 147 | export default Card 148 | -------------------------------------------------------------------------------- /components/card/card.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/card/card.wxss: -------------------------------------------------------------------------------- 1 | /** 2 | * perspective: 400px属性,焦距影响其子元素,会影响整个子元素大空间,perspective(400px) 影响元素本身 3 | */ 4 | .gridcard{ 5 | margin: 0 20rpx; 6 | position: relative; 7 | height: 710rpx; 8 | } 9 | /*perspective: 400px;*/ 10 | .gridcard .gridcard_item{ 11 | position: absolute; 12 | width: 230rpx; 13 | height: 230rpx; 14 | -webkit-transform-style: preserve-3d; 15 | transform-style: preserve-3d; 16 | -webkit-transition: all 0.8s ease-in-out; 17 | transition: all 0.8s ease-in-out; 18 | } 19 | /* -webkit-transform: translate3d(240rpx, 102rpx, 0); 20 | transform: translate3d(240rpx, 102rpx, 0);*/ 21 | .gridcard .gridcard_item image{ 22 | display: block; 23 | width: 100%; 24 | height: 100%; 25 | } 26 | .gridcard .gridcard_item .gridcard_front,.gridcard .gridcard_item .gridcard_back{ 27 | position: absolute; 28 | top: 0; 29 | left: 0; 30 | right: 0; 31 | bottom: 0; 32 | font-size: 20px; 33 | color: #fff; 34 | text-align: center; 35 | line-height: 230rpx; 36 | -webkit-backface-visibility: hidden; 37 | backface-visibility: hidden; 38 | z-index: 1; 39 | } 40 | .gridcard .gridcard_item .gridcard_back{ 41 | -webkit-transform: rotateY(180deg) translateZ(0); 42 | transform: rotateY(180deg) translateZ(0); 43 | background: #1E9FD9; 44 | } 45 | .gridcard .gridcard_item.back{ 46 | -webkit-transform: perspective(1000px) rotateY(-180deg) translateZ(0); 47 | transform: perspective(1000px) rotateY(-180deg) translateZ(0); 48 | } 49 | .gridcard .gridcard_item.move{ 50 | z-index: 3; 51 | -webkit-transition: all 0.4s linear; 52 | transition: all 0.4s linear; 53 | } 54 | .gridcard .gridcard_item:nth-child(1){ 55 | top: 0; 56 | left: 0; 57 | } 58 | .gridcard .gridcard_item:nth-child(1).move{ 59 | -webkit-transform: translate3d(240rpx,240rpx,0); 60 | transform: translate3d(240rpx,240rpx,0); 61 | } 62 | .gridcard .gridcard_item:nth-child(2){ 63 | top: 0; 64 | left: 240rpx; 65 | } 66 | .gridcard .gridcard_item:nth-child(2).move{ 67 | -webkit-transform: translate3d(0,240rpx,0); 68 | transform: translate3d(0,240rpx,0); 69 | } 70 | .gridcard .gridcard_item:nth-child(3){ 71 | top: 0; 72 | left: 480rpx; 73 | } 74 | .gridcard .gridcard_item:nth-child(3).move{ 75 | -webkit-transform: translate3d(-240rpx,240rpx,0); 76 | transform: translate3d(-240rpx,240rpx,0); 77 | } 78 | .gridcard .gridcard_item:nth-child(4){ 79 | top: 240rpx; 80 | left: 0; 81 | } 82 | .gridcard .gridcard_item:nth-child(4).move{ 83 | -webkit-transform: translate3d(240rpx,0,0); 84 | transform: translate3d(240rpx,0,0); 85 | } 86 | .gridcard .gridcard_item:nth-child(5){ 87 | top: 240rpx; 88 | left: 240rpx; 89 | } 90 | .gridcard .gridcard_item:nth-child(6){ 91 | top: 240rpx; 92 | left: 480rpx; 93 | } 94 | .gridcard .gridcard_item:nth-child(6).move{ 95 | -webkit-transform: translate3d(-240rpx,0rpx,0); 96 | transform: translate3d(-240rpx,0rpx,0); 97 | } 98 | .gridcard .gridcard_item:nth-child(7){ 99 | top: 480rpx; 100 | left: 0; 101 | } 102 | .gridcard .gridcard_item:nth-child(7).move{ 103 | -webkit-transform: translate3d(240rpx,-240rpx,0); 104 | transform: translate3d(240rpx,-240rpx,0); 105 | } 106 | .gridcard .gridcard_item:nth-child(8){ 107 | top: 480rpx; 108 | left: 240rpx; 109 | } 110 | .gridcard .gridcard_item:nth-child(8).move{ 111 | -webkit-transform: translate3d(0,-240rpx,0); 112 | transform: translate3d(0,-240rpx,0); 113 | } 114 | .gridcard .gridcard_item:nth-child(9){ 115 | top: 480rpx; 116 | left: 480rpx; 117 | } 118 | .gridcard .gridcard_item:nth-child(9).move{ 119 | -webkit-transform: translate3d(-240rpx,-240rpx,0); 120 | transform: translate3d(-240rpx,-240rpx,0); 121 | } 122 | 123 | -------------------------------------------------------------------------------- /components/card/promise.min.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n { 13 | * //结束回调, 参数对应宫格索引,对应奖项 14 | * } 15 | * }) 16 | */ 17 | class FruitMachine { 18 | 19 | /** 20 | * @constructs FruitMachine构造函数 21 | * @param {Object} pageContext page路由指针 22 | * @param {Object} opts 组件所需参数 23 | * @param {Number} opts.len 宫格个数 24 | * @param {Number} opts.ret 抽奖结果对应值1~9 25 | * @param {Number} opts.speed 速度值 26 | * @param {Function} opts.callback 结束回调 27 | */ 28 | constructor (pageContext, opts) { 29 | this.page = pageContext 30 | this.len = opts.len || 8 31 | this.ret = opts.ret 32 | this.speed = opts.speed 33 | this.isStart = false 34 | this.endCallBack = opts.callback 35 | this.page.start = this.start.bind(this) 36 | } 37 | 38 | start () { 39 | 40 | let { idx, ret, len, speed, isStart } = this 41 | if(isStart)return 42 | this.isStart = true 43 | let range = Math.floor(Math.random()*2 + 2) 44 | let count = 0 45 | let spd2 = speed*2 46 | !(function interval(self){ 47 | setTimeout( () => { 48 | count++ 49 | if(count > range * len){ 50 | speed = spd2 51 | } 52 | if(count != (range + 1) * len + ret ){ 53 | interval(self) 54 | }else{ 55 | self.isStart = false 56 | self.endCallBack && self.endCallBack() 57 | } 58 | 59 | self.page.setData({ 60 | machine: { 61 | idx: count % 8 == 0 ? 8 : count % 8 62 | } 63 | }) 64 | 65 | }, speed) 66 | })(this) 67 | } 68 | 69 | reset () { 70 | this.page.setData({ 71 | machine: { 72 | idx: '' 73 | } 74 | }) 75 | } 76 | 77 | } 78 | 79 | export default FruitMachine -------------------------------------------------------------------------------- /components/fruitMachine/fruitMachine.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/fruitMachine/fruitMachine.wxss: -------------------------------------------------------------------------------- 1 | .marquee_wp{ 2 | margin: 0 20rpx; 3 | display: flex; 4 | flex-wrap: wrap; 5 | } 6 | .marquee_wp .marquee_item{ 7 | width: 230rpx; 8 | height: 230rpx; 9 | margin: 0 10rpx 10rpx 0; 10 | opacity: .8; 11 | background: #1E9FD9; 12 | box-sizing: border-box; 13 | } 14 | .marquee_wp .marquee_item.on{ 15 | opacity: 1; 16 | } 17 | .marquee_wp .marquee_item image{ 18 | display: block; 19 | width: 100%; 20 | height: 100%; 21 | } 22 | .marquee_wp .marquee_item:nth-child(3n){ 23 | margin-right: 0; 24 | } 25 | .marquee_wp .marquee_item_btn{ 26 | background: transparent; 27 | } 28 | .marquee_wp .marquee_item_btn text{ 29 | display: block; 30 | text-align: center; 31 | color: #fff; 32 | } 33 | -------------------------------------------------------------------------------- /components/lock/lock.js: -------------------------------------------------------------------------------- 1 | const LIMIT = 60 2 | let prev = 0 3 | 4 | /** 5 | * Class Lock 6 | * @class 7 | * @classdesc 手势解锁组件逻辑部分 8 | * @author pfan 9 | * 10 | * @example 11 | * new Lock(this,{ 12 | * canvasWidth: 300, //canvas画布宽度 px 13 | * canvasHeight: 300, //canvas画布高度 px 14 | * canvasId: 'canvasLock', //canvas画布id 15 | * drawColor: '#3985ff' //绘制颜色 16 | * }) 17 | */ 18 | class Lock { 19 | /** 20 | * @constructs Lock构造函数 21 | * @param {Object} pageContext page路由指针 22 | * @param {Object} opts 组件所需参数 23 | * @param {Number} opts.canvasWidth canvas画布宽度 px 24 | * @param {Number} opts.canvasHeight canvas画布高度 px 25 | * @param {String} opts.canvasId canvas画布id 26 | * @param {String} opts.drawColor 绘制颜色 27 | */ 28 | constructor (pageContext, opts) { 29 | this.page = pageContext 30 | this.canvasWidth = opts.canvasWidth || 300 31 | this.canvasHeight = opts.canvasHeight || 300 32 | this.canvasId = opts.id || 'canvasLock' 33 | this.chooseType = opts.chooseType || 3 // 宫格 3x3 34 | this.drawColor = opts.drawColor || '#3985ff' 35 | 36 | this.init() 37 | 38 | this.page.updatePassword = this.updatePassword.bind(this) 39 | this.page.onTouchstart = this.onTouchstart.bind(this) 40 | this.page.onTouchmove = this.onTouchmove.bind(this) 41 | this.page.onTouchend = this.onTouchend.bind(this) 42 | this.page.onTouchcancel = this.onTouchcancel.bind(this) 43 | } 44 | 45 | init () { 46 | this.setData() 47 | this.pswObj = {} 48 | 49 | this.lastPoint = [] 50 | this.touchFlag = false 51 | this.ctx = wx.createCanvasContext(this.canvasId) 52 | this.createCircle() 53 | } 54 | 55 | createCircle () { // 计算各个点坐标,画圆,根据canvas的大小来平均分配半径 56 | const n = this.chooseType 57 | let count = 0 58 | this.r = this.canvasWidth / (2 + 4 * n) // 计算cricle半径 59 | const r = this.r 60 | this.lastPoint = [] 61 | this.arr = [] // 记录9宫格位置 62 | this.restPoint = [] 63 | for (let i = 0; i < n; i++) { 64 | for (let j = 0; j < n; j++) { 65 | count++; 66 | const obj = { 67 | x: j * 4 * r + 3 * r, 68 | y: i * 4 * r + 3 * r, 69 | index: count 70 | }; 71 | this.arr.push(obj) 72 | this.restPoint.push(obj) 73 | } 74 | } 75 | this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight) 76 | 77 | for (let i = 0; i < this.arr.length; i++) { 78 | this.drawCle(this.arr[i].x, this.arr[i].y) 79 | } 80 | this.ctx.draw(true) 81 | } 82 | 83 | drawCle (x, y) { // 初始化解锁密码面板 84 | this.ctx.setStrokeStyle(this.drawColor) 85 | this.ctx.setLineWidth(2) 86 | this.ctx.beginPath(); 87 | this.ctx.arc(x, y, this.r, 0, Math.PI * 2, true) 88 | this.ctx.closePath() 89 | this.ctx.stroke() 90 | } 91 | 92 | onTouchstart (e) { 93 | const po = this.getPosition(e) 94 | for (let i = 0; i < this.arr.length; i++) { 95 | if (Math.abs(po.x - this.arr[i].x) < this.r && Math.abs(po.y - this.arr[i].y) < this.r) { 96 | this.touchFlag = true 97 | this.drawPoint(this.arr[i].x, this.arr[i].y) 98 | this.lastPoint.push(this.arr[i]) 99 | this.restPoint.splice(i, 1) 100 | break; 101 | } 102 | } 103 | 104 | this.touchFlag && this.ctx.draw(true) 105 | } 106 | 107 | onTouchmove (e) { 108 | const now = new Date() 109 | const duration = now - prev 110 | // 由于小程序canvas效率低下,帧频率大于60丢弃 111 | if (duration < Math.floor(1000 / LIMIT)) return; 112 | prev = now 113 | 114 | if (this.touchFlag) { 115 | this.update(this.getPosition(e)) 116 | } 117 | } 118 | 119 | onTouchend (e) { 120 | if (this.touchFlag) { 121 | this.touchFlag = false 122 | this.storePass(this.lastPoint) 123 | 124 | // 300ms 重置,重置时间会影响lastPoint取值, 影响drawline报错 125 | setTimeout(() => { 126 | this.reset() 127 | }, 300) 128 | } 129 | } 130 | 131 | onTouchcancel (e) { 132 | this.touchFlag = false 133 | } 134 | 135 | getPosition (e) { // 获取touch点相对于canvas的坐标 136 | return { 137 | x: e.touches[0].x, 138 | y: e.touches[0].y 139 | } 140 | } 141 | 142 | update (po) { // 核心变换方法在touchmove时候调用 143 | this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight) 144 | for (let i = 0; i < this.arr.length; i++) { // 每帧先把面板画出来 145 | this.drawCle(this.arr[i].x, this.arr[i].y) 146 | } 147 | 148 | this.drawPoint(this.lastPoint) // 每帧花轨迹 149 | this.drawLine(po, this.lastPoint) // 每帧画圆心 150 | 151 | for (let i = 0; i < this.restPoint.length; i++) { 152 | const pt = this.restPoint[i] 153 | 154 | if (Math.abs(po.x - pt.x) < this.r && Math.abs(po.y - pt.y) < this.r) { 155 | this.drawPoint(pt.x, pt.y) 156 | this.pickPoints(this.lastPoint[this.lastPoint.length - 1], pt) 157 | break; 158 | } 159 | } 160 | this.ctx.draw(true) 161 | } 162 | 163 | drawPoint () { // 初始化圆心 164 | for (let i = 0; i < this.lastPoint.length; i++) { 165 | this.ctx.setFillStyle(this.drawColor) // 注意用set方法 166 | this.ctx.beginPath() 167 | this.ctx.arc(this.lastPoint[i].x, this.lastPoint[i].y, this.r / 2, 0, Math.PI * 2, true) 168 | this.ctx.closePath() 169 | this.ctx.fill() 170 | } 171 | } 172 | 173 | drawLine (po, lastPoint) { // 解锁轨迹 174 | this.ctx.beginPath() 175 | this.ctx.lineWidth = 3 176 | this.ctx.moveTo(this.lastPoint[0].x, this.lastPoint[0].y) 177 | 178 | for (let i = 1; i < this.lastPoint.length; i++) { 179 | this.ctx.lineTo(this.lastPoint[i].x, this.lastPoint[i].y) 180 | } 181 | this.ctx.lineTo(po.x, po.y) 182 | this.ctx.stroke() 183 | this.ctx.closePath() 184 | } 185 | 186 | pickPoints (fromPt, toPt) { 187 | const lineLength = getDis(fromPt, toPt) 188 | const dir = toPt.index > fromPt.index ? 1 : -1 189 | 190 | const len = this.restPoint.length; 191 | let i = dir === 1 ? 0 : (len - 1) 192 | let limit = dir === 1 ? len : -1 193 | 194 | while (i !== limit) { 195 | const pt = this.restPoint[i] 196 | 197 | if (getDis(pt, fromPt) + getDis(pt, toPt) === lineLength) { 198 | this.drawPoint(pt.x, pt.y) 199 | this.lastPoint.push(pt) 200 | this.restPoint.splice(i, 1) 201 | if (limit > 0) { 202 | i-- 203 | limit-- 204 | } 205 | } 206 | 207 | i += dir 208 | } 209 | } 210 | 211 | storePass (psw) { // touchend结束之后对密码和状态的处理 212 | let title, color 213 | if (this.pswObj.step == 1) { 214 | if (this.checkPass(this.pswObj.fpassword, psw)) { 215 | this.pswObj.step = 2 216 | this.pswObj.spassword = psw 217 | title = '密码保存成功' 218 | color = this.drawColor 219 | this.drawStatusPoint(this.drawColor) 220 | } else { 221 | title = '两次不一致,重新输入' 222 | color = 'red' 223 | this.drawStatusPoint('red') 224 | delete this.pswObj.step 225 | } 226 | } else if (this.pswObj.step == 2) { 227 | if (this.checkPass(this.pswObj.spassword, psw)) { 228 | title = '解锁成功' 229 | this.drawStatusPoint(this.drawColor) 230 | } else { 231 | title = '解锁失败' 232 | this.drawStatusPoint('red') 233 | } 234 | } else { 235 | this.pswObj.step = 1 236 | this.pswObj.fpassword = psw 237 | title = '再次输入' 238 | } 239 | 240 | this.setData(title, color) 241 | } 242 | 243 | checkPass (psw1, psw2) { // 检测密码 244 | let p1 = '' 245 | let p2 = '' 246 | psw1.forEach(item => { 247 | p1 += item.index + item.index 248 | }) 249 | psw2.forEach(item => { 250 | p2 += item.index + item.index 251 | }) 252 | return p1 === p2 253 | } 254 | 255 | drawStatusPoint (color) { // 初始化状态线条 256 | for (let i = 0; i < this.lastPoint.length; i++) { 257 | this.ctx.setStrokeStyle(color) 258 | this.ctx.beginPath() 259 | this.ctx.arc(this.lastPoint[i].x, this.lastPoint[i].y, this.r, 0, Math.PI * 2, true) 260 | this.ctx.closePath() 261 | this.ctx.stroke() 262 | } 263 | 264 | this.ctx.draw(true) 265 | } 266 | 267 | updatePassword () { 268 | this.pswObj = {} 269 | this.setData() 270 | this.reset() 271 | } 272 | 273 | setData (title = '绘制解锁图案', color = '#888') { 274 | const { canvasWidth, canvasHeight } = this 275 | this.page.setData({ 276 | lockData: { 277 | title, 278 | color, 279 | canvasHeight, 280 | canvasWidth 281 | } 282 | }) 283 | if (title == '密码保存成功') { 284 | setTimeout(() => { 285 | this.page.setData({ 286 | lockData: { 287 | title: '开始解锁', 288 | color, 289 | canvasHeight, 290 | canvasWidth 291 | } 292 | }) 293 | }, 1000) 294 | } 295 | } 296 | 297 | reset () { 298 | this.createCircle() 299 | } 300 | } 301 | 302 | 303 | /** 304 | * getDis 获取两点直线距离 305 | * @param {Object} a 坐标 306 | * @param {Object} b 坐标 307 | * @return {Number} 距离值 308 | */ 309 | function getDis (a, b) { 310 | return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); 311 | } 312 | 313 | export default Lock 314 | -------------------------------------------------------------------------------- /components/lock/lock.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/lock/lock.wxss: -------------------------------------------------------------------------------- 1 | .lock_wp{ 2 | margin: 30rpx auto; 3 | } 4 | 5 | .canvasLock{ 6 | display: block; 7 | margin: 0 auto; 8 | } 9 | 10 | .lock_title{ 11 | text-align: center; 12 | color: #888; 13 | } 14 | 15 | .lock_reset{ 16 | width: 300rpx; 17 | font-size: 12px; 18 | color: #888; 19 | } -------------------------------------------------------------------------------- /components/scratch/images/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/components/scratch/images/placeholder.png -------------------------------------------------------------------------------- /components/scratch/scratch.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Scratch 3 | * @class 4 | * @classdesc 九宫格翻纸牌组件逻辑部分 5 | * @author pfan 6 | * @todo 1.drawImage 与 clearRect 清除展示移动端和模拟器不一致 7 | * @todo 2.小程序无globalCompositeOperation = 'destination-out'属性 8 | * @todo 3.小程序无getImageData获取像素点对比擦除范围 9 | * @todo 4.使用 downloadFile 这种方式来先加载图片再绘制 10 | * 11 | * @example 12 | * new Scratch(this,{ 13 | * canvasWidth: 197, //画布宽带 14 | * canvasHeight: 72, //画布高度 15 | * imageResource: './images/placeholder.png', //遮罩层图片 16 | * r: 4, //笔触半径 17 | * awardTxt: '中大奖', //底部抽奖文字奖项 18 | * awardTxtColor: "#1AAD16", //底部抽奖文字颜色 19 | * awardTxtFontSize: "24px", //底部抽奖文字大小 20 | * maskColor: "red", //没有图片遮罩层颜色 21 | * callback: () => { 22 | * //清除画布回调 23 | * } 24 | * }) 25 | */ 26 | class Scratch { 27 | /** 28 | * @constructs Scratch构造函数 29 | * @param {Object} pageContext page路由指针 30 | * @param {Object} opts 组件所需参数 31 | * @param {Number} opts.canvasWidth 画布宽带 32 | * @param {Number} opts.canvasHeight 画布高度 33 | * @param {String} opts.imageResource 遮罩层图片 34 | * @param {Number} opts.r 笔触半径 35 | * @param {String} opts.awardTxt 底部抽奖文字奖项 36 | * @param {String} opts.awardTxtColor 底部抽奖文字颜色 37 | * @param {String} opts.awardTxtFontSize 底部抽奖文字大小 38 | * @param {String} opts.maskColor 没有图片遮罩层颜色 39 | * @param {Function} opts.callback 结束回调 40 | */ 41 | constructor (pageContext, opts) { 42 | this.page = pageContext 43 | this.canvasWidth = opts.canvasWidth 44 | this.canvasHeight = opts.canvasHeight 45 | this.imageResource = opts.imageResource 46 | this.maskColor = opts.maskColor 47 | // this.canvasId = opts.canvasId 48 | this.r = opts.r || 4 49 | this.endCallBack = opts.callback 50 | this.lastX = 0 51 | this.lastY = 0 52 | this.minX = '' 53 | this.minY = '' 54 | this.maxX = '' 55 | this.maxY = '' 56 | this.isStart = false 57 | this.init() 58 | 59 | this.page.touchStart = this.touchStart.bind(this) 60 | this.page.touchMove = this.touchMove.bind(this) 61 | this.page.touchEnd = this.touchEnd.bind(this) 62 | this.page.imgOnLoad = this.imgOnLoad.bind(this) 63 | 64 | this.page.setData({ 65 | scratch: { 66 | 'awardTxt': opts.awardTxt, 67 | 'awardTxtColor': opts.awardTxtColor, 68 | 'awardTxtFontSize': opts.awardTxtFontSize, 69 | 'awardTxtLineHeight': opts.canvasHeight, 70 | 'width': opts.canvasWidth, 71 | 'height': opts.canvasHeight, 72 | 'imageResource': opts.imageResource 73 | }, 74 | 'isScroll': true 75 | }) 76 | } 77 | 78 | init () { 79 | const { canvasWidth, canvasHeight, imageResource, maskColor } = this 80 | const self = this 81 | this.ctx = wx.createCanvasContext('scratch') 82 | this.ctx.clearRect(0, 0, canvasWidth, canvasHeight) 83 | if (imageResource && imageResource != '') { 84 | wx.downloadFile({ 85 | url: imageResource, 86 | success: res => { 87 | self.ctx.drawImage(res.tempFilePath, 0, 0, canvasWidth, canvasHeight) 88 | self.ctx.draw() 89 | } 90 | }) 91 | } else { 92 | self.ctx.setFillStyle(maskColor) 93 | self.ctx.fillRect(0, 0, canvasWidth, canvasHeight) 94 | self.ctx.draw() 95 | } 96 | } 97 | 98 | drawRect (x, y) { 99 | const { r, minX, minY, maxX, maxY } = this 100 | const x1 = x - r > 0 ? x - r : 0 101 | const y1 = y - r > 0 ? y - r : 0 102 | if ('' != minX) { 103 | this.minX = minX > x1 ? x1 : minX 104 | this.minY = minY > y1 ? y1 : minY 105 | this.maxX = maxX > x1 ? maxX : x1 106 | this.maxY = maxY > y1 ? maxY : y1 107 | } else { 108 | this.minX = x1 109 | this.minY = y1 110 | this.maxX = x1 111 | this.maxY = y1 112 | } 113 | this.lastX = x1 114 | this.lastY = y1 115 | 116 | return [x1, y1, 2 * r] 117 | } 118 | 119 | start () { 120 | this.isStart = true 121 | this.page.setData({ 122 | 'isScroll': false 123 | }) 124 | } 125 | 126 | restart () { 127 | this.init() 128 | this.lastX = 0 129 | this.lastY = 0 130 | this.minX = '' 131 | this.minY = '' 132 | this.maxX = '' 133 | this.maxY = '' 134 | this.isStart = true 135 | this.page.setData({ 136 | 'isScroll': false 137 | }) 138 | } 139 | 140 | touchStart (e) { 141 | if (!this.isStart) return 142 | const pos = this.drawRect(e.touches[0].x, e.touches[0].y) 143 | this.ctx.clearRect(pos[0], pos[1], pos[2], pos[2]) 144 | this.ctx.draw(true) 145 | } 146 | 147 | touchMove (e) { 148 | if (!this.isStart) return 149 | const pos = this.drawRect(e.touches[0].x, e.touches[0].y) 150 | this.ctx.clearRect(pos[0], pos[1], pos[2], pos[2]) 151 | this.ctx.draw(true) 152 | } 153 | 154 | touchEnd (e) { 155 | if (!this.isStart) return 156 | // 自动清楚采用点范围值方式判断 157 | const { canvasWidth, canvasHeight, minX, minY, maxX, maxY } = this 158 | if (maxX - minX > .7 * canvasWidth && maxY - minY > .7 * canvasHeight) { 159 | this.ctx.draw() 160 | this.endCallBack && this.endCallBack() 161 | this.isStart = false 162 | this.page.setData({ 163 | 'isScroll': true 164 | }) 165 | } 166 | } 167 | 168 | reset () { 169 | this.init() 170 | } 171 | 172 | imgOnLoad () { 173 | 174 | } 175 | } 176 | 177 | export default Scratch 178 | -------------------------------------------------------------------------------- /components/scratch/scratch.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/shake/shake.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Shake 3 | * @class 4 | * @classdesc 摇一摇组件逻辑部分 5 | * @author pfan 6 | * 7 | * @example 8 | * new Shake(this,{ 9 | * shakeThreshold: 70, //阈值 10 | * callback: (idx, award) => { 11 | * //结束回调, 参数对应宫格索引,对应奖项 12 | * } 13 | * }) 14 | */ 15 | class Shake { 16 | /** 17 | * @constructs Shake构造函数 18 | * @param {Object} pageContext page路由指针 19 | * @param {Object} opts 组件所需参数 20 | * @param {Number} opts.shakeThreshold 频率阈值 21 | * @param {Function} opts.callback 结束回调 22 | */ 23 | constructor (pageContext, opts) { 24 | this.page = pageContext 25 | this.shakeThreshold = opts.shakeThreshold || 80 26 | this.lastX = 0 27 | this.lastY = 0 28 | this.lastZ = 0 29 | this.lastUpdate = 0 30 | this.isStart = true 31 | this.endCallBack = opts.callback 32 | this.page.audioCtx = wx.createAudioContext('shakeAudio') 33 | this.start() 34 | } 35 | 36 | start () { 37 | let { shakeThreshold, lastX, lastY, lastZ, lastUpdate } = this 38 | wx.onAccelerometerChange(res => { 39 | const curTime = new Date().getTime() 40 | if ((curTime - lastUpdate) > 100) { 41 | const curX = res.x 42 | const curY = res.y 43 | const curZ = res.z 44 | const speed = Math.abs(curX + curY + curZ - lastX - lastY - lastZ) / (curTime - lastUpdate) * 10000 45 | if (speed > shakeThreshold && this.isStart) { 46 | this.page.audioCtx.play() 47 | this.update() 48 | } 49 | lastUpdate = curTime 50 | lastX = curX 51 | lastY = curY 52 | lastZ = curZ 53 | } 54 | }) 55 | } 56 | 57 | update () { 58 | this.page.setData({ 59 | anim: true 60 | }) 61 | this.isStart = false 62 | setTimeout(() => { 63 | this.page.setData({ 64 | anim: false 65 | }) 66 | this.endCallBack && this.endCallBack() 67 | }, 2000) 68 | } 69 | 70 | reset () { 71 | 72 | } 73 | } 74 | 75 | 76 | export default Shake 77 | -------------------------------------------------------------------------------- /components/shake/shake.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/slotMachine/slotMachine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Machine 3 | * @class 4 | * @classdesc 老虎机游戏逻辑部分 5 | * @author pfan 6 | * 7 | * @example 8 | * new Machine(this,{ 9 | * height: 40, //单个数字高度 10 | * len: 10, //单个项目数字个数 11 | * transY1: 0, //第一列初始位置 12 | * num1: 3, //第一列结束数字 13 | * transY2: 0, //第二列初始位置 14 | * num2: 0, //第二列结束数字 15 | * transY3: 0, //第三列初始位置 16 | * num3: 0, //第三列结束数字 17 | * transY4: 0, //第四列结束数字 18 | * num4: 1, //第四列结束数字 19 | * speed: 24, //速度 20 | * callback: (idx, award) => { 21 | * //结束回调, 参数对应宫格索引,对应奖项 22 | * } 23 | * }) 24 | */ 25 | class Machine { 26 | /** 27 | * @constructs Machine构造函数 28 | * @param {Object} pageContext page路由指针 29 | * @param {Object} opts 组件所需参数 30 | * @param {Number} opts.height 单个数字高度 31 | * @param {Number} opts.len 单个项目数字个数 32 | * @param {Number} opts.transY1 第一列初始位置 33 | * @param {Number} opts.num1 第一列结束数字 34 | * @param {Number} opts.transY2 第二列初始位置 35 | * @param {Number} opts.num2 第二列结束数字 36 | * @param {Number} opts.transY3 第三列初始位置 37 | * @param {Number} opts.num3 第三列结束数字 38 | * @param {Number} opts.transY4 第四列初始位置 39 | * @param {Number} opts.num4 第四列结束数字 40 | * @param {Number} opts.speed 速度 41 | * @param {Function} opts.callback 结束回调 42 | */ 43 | constructor (pageContext, opts) { 44 | this.page = pageContext 45 | this.height = opts.height 46 | this.len = opts.len 47 | this.transY1 = opts.transY1 48 | this.num1 = opts.num1 49 | this.transY2 = opts.transY2 50 | this.num2 = opts.num2 51 | this.transY3 = opts.transY3 52 | this.num3 = opts.num3 53 | this.transY4 = opts.transY4 54 | this.num4 = opts.num4 55 | this.speed = opts.speed 56 | this.isStart = false 57 | this.endCallBack = opts.callback 58 | this.page.start = this.start.bind(this) 59 | } 60 | 61 | start () { 62 | let { isStart, len, height, transY1, transY2, transY3, transY4, speed, num1, num2, num3, num4, endCallBack } = this 63 | if (isStart) return 64 | this.isStart = true 65 | const totalHeight = height * len 66 | const sRange = Math.floor(Math.random() * 2 + 2) 67 | const halfSpeed = speed / 2 68 | const endDis1 = num1 == 0 ? 10 * height : num1 * height 69 | const endDis2 = num2 == 0 ? 10 * height : num2 * height 70 | const endDis3 = num3 == 0 ? 10 * height : num3 * height 71 | const endDis4 = num4 == 0 ? 10 * height : num4 * height 72 | let i1 = 1; let i2 = 1; let i3 = 1; let i4 = 1 73 | 74 | this.timer = setInterval(() => { 75 | if (i1 <= sRange) { 76 | transY1 -= speed 77 | if (Math.abs(transY1) > totalHeight) { 78 | transY1 += totalHeight 79 | i1++ 80 | } 81 | } else if (i1 > sRange && i1 < sRange + 2) { 82 | transY1 -= halfSpeed 83 | if (Math.abs(transY1) > totalHeight) { 84 | transY1 += totalHeight 85 | i1++ 86 | } 87 | } else { 88 | if (transY1 == endDis1) return 89 | let dropSpeed = (endDis1 + transY1) / halfSpeed 90 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed 91 | transY1 -= dropSpeed 92 | transY1 = Math.abs(transY1) > endDis1 ? transY1 = -endDis1 : transY1 93 | } 94 | 95 | this.timer1 = setTimeout(() => { 96 | if (i2 <= sRange) { 97 | transY2 -= speed 98 | if (Math.abs(transY2) > totalHeight) { 99 | transY2 += totalHeight 100 | i2++ 101 | } 102 | } else if (i2 > sRange && i2 < sRange + 2) { 103 | transY2 -= halfSpeed 104 | if (Math.abs(transY2) > totalHeight) { 105 | transY2 += totalHeight 106 | i2++ 107 | } 108 | } else { 109 | if (transY2 == endDis2) return 110 | let dropSpeed = (endDis2 + transY2) / halfSpeed 111 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed 112 | transY2 -= dropSpeed 113 | transY2 = Math.abs(transY2) > endDis2 ? transY2 = -endDis2 : transY2 114 | } 115 | }, 200) 116 | 117 | this.timer2 = setTimeout(() => { 118 | if (i3 <= sRange) { 119 | transY3 -= speed 120 | if (Math.abs(transY3) > totalHeight) { 121 | transY3 += totalHeight 122 | i3++ 123 | } 124 | } else if (i3 > sRange && i3 < sRange + 2) { 125 | transY3 -= halfSpeed 126 | if (Math.abs(transY3) > totalHeight) { 127 | transY3 += totalHeight 128 | i3++ 129 | } 130 | } else { 131 | if (transY3 == endDis3) return 132 | let dropSpeed = (endDis3 + transY3) / halfSpeed 133 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed 134 | transY3 -= dropSpeed 135 | transY3 = Math.abs(transY3) > endDis3 ? transY3 = -endDis3 : transY3 136 | } 137 | }, 400) 138 | 139 | this.timer3 = setTimeout(() => { 140 | if (i4 <= sRange) { 141 | transY4 -= speed 142 | if (Math.abs(transY4) > totalHeight) { 143 | transY4 += totalHeight 144 | i4++ 145 | } 146 | } else if (i4 > sRange && i4 < sRange + 2) { 147 | transY4 -= halfSpeed 148 | if (Math.abs(transY4) > totalHeight) { 149 | transY4 += totalHeight 150 | i4++ 151 | } 152 | } else { 153 | let dropSpeed = (endDis4 + transY4) / halfSpeed 154 | if (num4 < 3) { 155 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .1 ? .1 : dropSpeed 156 | } else if (num4 < 5 && num4 >= 3) { 157 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .3 ? .3 : dropSpeed 158 | } else { 159 | dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .3 ? .3 : dropSpeed 160 | } 161 | 162 | transY4 -= dropSpeed 163 | transY4 = Math.abs(transY4) > endDis4 ? transY4 = -endDis4 : transY4 164 | if (Math.abs(transY4) >= endDis4) { 165 | clearInterval(this.timer) 166 | clearTimeout(this.timer1) 167 | clearTimeout(this.timer2) 168 | clearTimeout(this.timer3) 169 | this.isStart = false 170 | endCallBack && endCallBack() 171 | } 172 | } 173 | }, 600) 174 | 175 | 176 | this.page.setData({ 177 | machine: { 178 | transY1, 179 | transY2, 180 | transY3, 181 | transY4 182 | } 183 | }) 184 | }, 1000 / 60) 185 | } 186 | 187 | reset () { 188 | this.transY1 = 0 189 | this.transY2 = 0 190 | this.transY3 = 0 191 | this.transY4 = 0 192 | 193 | this.page.setData({ 194 | machine: { 195 | transY1: 0, 196 | transY2: 0, 197 | transY3: 0, 198 | transY4: 0 199 | } 200 | }) 201 | } 202 | } 203 | 204 | 205 | export default Machine 206 | -------------------------------------------------------------------------------- /components/slotMachine/slotMachine.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/slotMachine/slotMachine.wxss: -------------------------------------------------------------------------------- 1 | .machine_wp{ 2 | display: flex; 3 | width: 200px; 4 | margin: 30px auto; 5 | } 6 | .machine_wp .machine_item_wp{ 7 | width: 40px; 8 | height: 40px; 9 | position: relative; 10 | border: 1rpx solid #6190e8; 11 | border-radius: 2px; 12 | overflow: hidden; 13 | margin-right: 10px; 14 | } 15 | .machine_wp .machine_item_wp:last-child{ 16 | margin-right: 0; 17 | } 18 | .machine_wp .machine_item_wp .machine_item_slide{ 19 | position: absolute; 20 | width: 40px; 21 | height: 40px; 22 | top: 0; 23 | left: 0; 24 | } 25 | .machine_wp .machine_item_wp .machine_item_ele{ 26 | width: 40px; 27 | height: 40px; 28 | line-height: 40px; 29 | font-size: 24px; 30 | color: #6190e8; 31 | text-align: center; 32 | } 33 | -------------------------------------------------------------------------------- /components/wheel/images/dial_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/components/wheel/images/dial_bg.png -------------------------------------------------------------------------------- /components/wheel/images/dial_pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/components/wheel/images/dial_pointer.png -------------------------------------------------------------------------------- /components/wheel/wheel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Wheel 3 | * @class 4 | * @classdesc 大转盘游戏逻辑部分 5 | * @author pfan 6 | * @todo 注意:移动端真机,不支持requestAnimationFrame. 7 | * 8 | * @example 9 | * new Wheel(this,{ 10 | * areaNumber: 8, //抽奖间隔 11 | * speed: 16, //转动速度 12 | * awardNumer: 2, //中奖区域从1开始 13 | * mode: 1, //1是指针旋转,2为转盘旋转 14 | * callback: (idx, award) => { 15 | * //结束回调, 参数对应宫格索引,对应奖项 16 | * } 17 | * }) 18 | */ 19 | class Wheel { 20 | /** 21 | * @constructs Wheel构造函数 22 | * @param {Object} pageContext page路由指针 23 | * @param {Object} opts 组件所需参数 24 | * @param {Number} opts.areaNumber 抽奖间隔 25 | * @param {Number} opts.speed 转动速度 26 | * @param {Number} opts.awardNumer 中奖区域从1开始 27 | * @param {Number} opts.mode 1是指针旋转,2为转盘旋转 28 | * @param {Function} opts.callback 结束回调 29 | */ 30 | constructor (pageContext, opts) { 31 | this.page = pageContext 32 | this.deg = 0 33 | this.areaNumber = opts.areaNumber // 奖区数量 34 | this.speed = opts.speed || 16 // 每帧速度 35 | this.awardNumer = opts.awardNumer // 中奖区域 从1开始 36 | this.mode = opts.mode || 2 37 | this.singleAngle = '' // 每片扇形的角度 38 | this.isStart = false 39 | this.endCallBack = opts.callback 40 | 41 | 42 | this.init() 43 | 44 | this.page.start = this.start.bind(this) 45 | } 46 | 47 | init () { 48 | let { areaNumber, singleAngle, mode } = this 49 | singleAngle = 360 / areaNumber 50 | this.singleAngle = singleAngle 51 | this.page.setData({ 52 | wheel: { 53 | singleAngle, 54 | mode 55 | } 56 | }) 57 | } 58 | 59 | start () { 60 | let { deg, awardNumer, singleAngle, speed, isStart, mode } = this 61 | if (isStart) return 62 | this.isStart = true 63 | const endAddAngle = (awardNumer - 1) * singleAngle + singleAngle / 2 + 360 // 中奖角度 64 | const rangeAngle = (Math.floor(Math.random() * 4) + 4) * 360 // 随机旋转几圈再停止 65 | let cAngle 66 | deg = 0 67 | this.timer = setInterval(() => { 68 | if (deg < rangeAngle) { 69 | deg += speed 70 | } else { 71 | cAngle = (endAddAngle + rangeAngle - deg) / speed 72 | cAngle = cAngle > speed ? speed : cAngle < 1 ? 1 : cAngle 73 | deg += cAngle 74 | 75 | if (deg >= (endAddAngle + rangeAngle)) { 76 | deg = endAddAngle + rangeAngle 77 | this.isStart = false 78 | clearInterval(this.timer) 79 | this.endCallBack() 80 | } 81 | } 82 | 83 | this.page.setData({ 84 | wheel: { 85 | singleAngle, 86 | deg, 87 | mode 88 | } 89 | }) 90 | }, 1000 / 60) 91 | } 92 | 93 | reset () { 94 | const { mode } = this 95 | this.deg = 0 96 | this.page.setData({ 97 | wheel: { 98 | singleAngle: this.singleAngle, 99 | deg: 0, 100 | mode 101 | } 102 | }) 103 | } 104 | 105 | switch (mode) { 106 | this.mode = mode 107 | } 108 | } 109 | 110 | export default Wheel 111 | 112 | -------------------------------------------------------------------------------- /components/wheel/wheel.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/wheel/wheel.wxss: -------------------------------------------------------------------------------- 1 | 2 | .wheel_wp{ 3 | width: 500rpx; 4 | height: 500rpx; 5 | position: relative; 6 | margin: 0 auto; 7 | } 8 | .wheel_wp image{ 9 | display: block; 10 | width: 100%; 11 | height: 100%; 12 | } 13 | .wheel_wp .wheel_pointer{ 14 | position: absolute; 15 | width: 150rpx; 16 | height: 150rpx; 17 | top: 50%; 18 | left: 50%; 19 | margin: -75rpx 0 0 -75rpx; 20 | transform-origin: 50% 50%; 21 | } 22 | .wheel_wp .wheel_pointer image{ 23 | position: absolute; 24 | width: 150rpx; 25 | height: 238rpx; 26 | left: 0; 27 | top: -64rpx; 28 | } -------------------------------------------------------------------------------- /docs/Card.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Card 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Card

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Card(pageContext, opts)

32 | 33 |
九宫格翻纸牌组件逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Card(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 269 | 270 | 271 | 272 | 273 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
NameTypeDescription
inlineStyle 157 | 158 | 159 | String 160 | 161 | 162 | 163 | 组件所需参数
isBack 180 | 181 | 182 | Boolean 183 | 184 | 185 | 186 | 是否是反面
isMove 203 | 204 | 205 | Boolean 206 | 207 | 208 | 209 | 是否运动
award 226 | 227 | 228 | String 229 | 230 | 231 | 232 | 对应奖项
callback 249 | 250 | 251 | function 252 | 253 | 254 | 255 | 结束回调
267 | 268 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 |
Author:
300 |
301 |
    302 |
  • pfan
  • 303 |
304 |
305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 |
Source:
315 |
318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 |
To Do:
326 |
327 |
    328 |
  • 注意:移动端真机,不支持requestAnimationFrame.
  • 329 |
330 |
331 | 332 |
333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 |
Example
351 | 352 |
new Card(this,{
353 |    data: [   //宫格信息,内联样式、是否是反面、是否运动、对应奖项
354 |      {isBack: false, isMove: false, award: "一等奖"},    
355 |      {isBack: false, isMove: false, award: "二等奖"},
356 |      {isBack: false, isMove: false, award: "三等奖"},
357 |      {isBack: false, isMove: false, award: "四等奖"},
358 |      {isBack: false, isMove: false, award: "五等奖"},
359 |      {isBack: false, isMove: false, award: "六等奖"},
360 |      {isBack: false, isMove: false, award: "七等奖"},
361 |      {isBack: false, isMove: false, award: "八等奖"},
362 |      {isBack: false, isMove: false, award: "九等奖"}
363 |    ],
364 |    callback: (idx, award) => {
365 |      //结束回调, 参数对应宫格索引,对应奖项    
366 |    }
367 |  })
368 | 369 | 370 | 371 | 372 |
373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 |
394 | 395 |
396 | 397 | 398 | 399 | 400 |
401 | 402 | 405 | 406 |
407 | 408 |
409 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 410 |
411 | 412 | 413 | 414 | 415 | -------------------------------------------------------------------------------- /docs/FruitMachine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: FruitMachine 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: FruitMachine

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

FruitMachine(pageContext, opts)

32 | 33 |
水果机游戏逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new FruitMachine(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 246 | 247 | 248 | 249 | 250 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 |
NameTypeDescription
len 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | 宫格个数
ret 180 | 181 | 182 | Number 183 | 184 | 185 | 186 | 抽奖结果对应值1~9
speed 203 | 204 | 205 | Number 206 | 207 | 208 | 209 | 速度值
callback 226 | 227 | 228 | function 229 | 230 | 231 | 232 | 结束回调
244 | 245 |
251 | 252 | 253 | 254 | 255 | 256 | 257 |
258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 |
Author:
277 |
278 |
    279 |
  • pfan
  • 280 |
281 |
282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 |
Source:
292 |
295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 |
303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 |
Example
321 | 322 |
new FruitMachine(this,{
323 |    len: 9, //宫格个数
324 |    ret: 9, //抽奖结果对应值1~9   
325 |    speed: 100  // 速度值
326 |    ],
327 |    callback: (idx, award) => {
328 |      //结束回调, 参数对应宫格索引,对应奖项    
329 |    }
330 |  })
331 | 332 | 333 | 334 | 335 |
336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 |
357 | 358 |
359 | 360 | 361 | 362 | 363 |
364 | 365 | 368 | 369 |
370 | 371 |
372 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 373 |
374 | 375 | 376 | 377 | 378 | -------------------------------------------------------------------------------- /docs/Lock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Lock 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Lock

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Lock(pageContext, opts)

32 | 33 |
手势解锁组件逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Lock(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 246 | 247 | 248 | 249 | 250 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 |
NameTypeDescription
canvasWidth 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | canvas画布宽度 px
canvasHeight 180 | 181 | 182 | Number 183 | 184 | 185 | 186 | canvas画布高度 px
canvasId 203 | 204 | 205 | String 206 | 207 | 208 | 209 | canvas画布id
drawColor 226 | 227 | 228 | String 229 | 230 | 231 | 232 | 绘制颜色
244 | 245 |
251 | 252 | 253 | 254 | 255 | 256 | 257 |
258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 |
Author:
277 |
278 |
    279 |
  • pfan
  • 280 |
281 |
282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 |
Source:
292 |
295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 |
303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 |
Example
321 | 322 |
new Lock(this,{
323 |    canvasWidth: 300,   //canvas画布宽度 px
324 |    canvasHeight: 300,  //canvas画布高度 px 
325 |    canvasId: 'canvasLock', //canvas画布id
326 |    drawColor: '#3985ff'  //绘制颜色
327 |  })
328 | 329 | 330 | 331 | 332 |
333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 |
354 | 355 |
356 | 357 | 358 | 359 | 360 |
361 | 362 | 365 | 366 |
367 | 368 |
369 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 370 |
371 | 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /docs/Machine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Machine 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Machine

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Machine(pageContext, opts)

32 | 33 |
老虎机游戏逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Machine(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 430 | 431 | 432 | 433 | 434 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 |
NameTypeDescription
height 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | 单个数字高度
len 180 | 181 | 182 | Number 183 | 184 | 185 | 186 | 单个项目数字个数
transY1 203 | 204 | 205 | Number 206 | 207 | 208 | 209 | 第一列初始位置
num1 226 | 227 | 228 | Number 229 | 230 | 231 | 232 | 第一列结束数字
transY2 249 | 250 | 251 | Number 252 | 253 | 254 | 255 | 第二列初始位置
num2 272 | 273 | 274 | Number 275 | 276 | 277 | 278 | 第二列结束数字
transY3 295 | 296 | 297 | Number 298 | 299 | 300 | 301 | 第三列初始位置
num3 318 | 319 | 320 | Number 321 | 322 | 323 | 324 | 第三列结束数字
transY4 341 | 342 | 343 | Number 344 | 345 | 346 | 347 | 第四列初始位置
num4 364 | 365 | 366 | Number 367 | 368 | 369 | 370 | 第四列结束数字
speed 387 | 388 | 389 | Number 390 | 391 | 392 | 393 | 速度
callback 410 | 411 | 412 | function 413 | 414 | 415 | 416 | 结束回调
428 | 429 |
435 | 436 | 437 | 438 | 439 | 440 | 441 |
442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 |
Author:
461 |
462 |
    463 |
  • pfan
  • 464 |
465 |
466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 |
Source:
476 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 |
487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 |
Example
505 | 506 |
new Machine(this,{
507 |     height: 40,  //单个数字高度
508 |     len: 10,     //单个项目数字个数
509 |     transY1: 0,  //第一列初始位置
510 |     num1: 3,     //第一列结束数字
511 |     transY2: 0,  //第二列初始位置
512 |     num2: 0,     //第二列结束数字
513 |     transY3: 0,  //第三列初始位置
514 |     num3: 0,     //第三列结束数字
515 |     transY4: 0,  //第四列结束数字
516 |     num4: 1,     //第四列结束数字
517 |     speed: 24,   //速度
518 |     callback: (idx, award) => {
519 |      //结束回调, 参数对应宫格索引,对应奖项    
520 |    }
521 |  })
522 | 523 | 524 | 525 | 526 |
527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 |
548 | 549 |
550 | 551 | 552 | 553 | 554 |
555 | 556 | 559 | 560 |
561 | 562 |
563 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 564 |
565 | 566 | 567 | 568 | 569 | -------------------------------------------------------------------------------- /docs/Scratch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Scratch 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Scratch

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Scratch(pageContext, opts)

32 | 33 |
九宫格翻纸牌组件逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Scratch(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 361 | 362 | 363 | 364 | 365 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 |
NameTypeDescription
canvasWidth 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | 画布宽带
canvasHeight 180 | 181 | 182 | Number 183 | 184 | 185 | 186 | 画布高度
imageResource 203 | 204 | 205 | String 206 | 207 | 208 | 209 | 遮罩层图片
r 226 | 227 | 228 | Number 229 | 230 | 231 | 232 | 笔触半径
awardTxt 249 | 250 | 251 | String 252 | 253 | 254 | 255 | 底部抽奖文字奖项
awardTxtColor 272 | 273 | 274 | String 275 | 276 | 277 | 278 | 底部抽奖文字颜色
awardTxtFontSize 295 | 296 | 297 | String 298 | 299 | 300 | 301 | 底部抽奖文字大小
maskColor 318 | 319 | 320 | String 321 | 322 | 323 | 324 | 没有图片遮罩层颜色
callback 341 | 342 | 343 | function 344 | 345 | 346 | 347 | 结束回调
359 | 360 |
366 | 367 | 368 | 369 | 370 | 371 | 372 |
373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 |
Author:
392 |
393 |
    394 |
  • pfan
  • 395 |
396 |
397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 |
Source:
407 |
410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 |
To Do:
418 |
419 |
    420 |
  • 1.drawImage 与 clearRect 清除展示移动端和模拟器不一致
  • 421 | 422 |
  • 2.小程序无globalCompositeOperation = 'destination-out'属性
  • 423 | 424 |
  • 3.小程序无getImageData获取像素点对比擦除范围
  • 425 | 426 |
  • 4.使用 downloadFile 这种方式来先加载图片再绘制
  • 427 |
428 |
429 | 430 |
431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 |
Example
449 | 450 |
new Scratch(this,{
451 |    canvasWidth: 197,   //画布宽带
452 |    canvasHeight: 72,  //画布高度
453 |    imageResource: './images/placeholder.png', //遮罩层图片
454 |    r: 4, //笔触半径
455 |    awardTxt: '中大奖', //底部抽奖文字奖项
456 |    awardTxtColor: "#1AAD16", //底部抽奖文字颜色
457 |    awardTxtFontSize: "24px", //底部抽奖文字大小
458 |    maskColor: "red",  //没有图片遮罩层颜色
459 |    callback: () => {
460 |      //清除画布回调
461 |    }
462 |  })
463 | 464 | 465 | 466 | 467 |
468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 |
489 | 490 |
491 | 492 | 493 | 494 | 495 |
496 | 497 | 500 | 501 |
502 | 503 |
504 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 505 |
506 | 507 | 508 | 509 | 510 | -------------------------------------------------------------------------------- /docs/Shake.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Shake 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Shake

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Shake(pageContext, opts)

32 | 33 |
九宫格翻纸牌组件逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Shake(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 200 | 201 | 202 | 203 | 204 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 |
NameTypeDescription
shakeThreshold 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | 频率阈值
callback 180 | 181 | 182 | function 183 | 184 | 185 | 186 | 结束回调
198 | 199 |
205 | 206 | 207 | 208 | 209 | 210 | 211 |
212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 |
Author:
231 |
232 |
    233 |
  • pfan
  • 234 |
235 |
236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 |
Source:
246 |
249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 |
257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 |
Example
275 | 276 |
new Shake(this,{
277 |    shakeThreshold: 70, //阈值
278 |    callback: (idx, award) => {
279 |      //结束回调, 参数对应宫格索引,对应奖项    
280 |    }
281 |  })
282 | 283 | 284 | 285 | 286 |
287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 |
308 | 309 |
310 | 311 | 312 | 313 | 314 |
315 | 316 | 319 | 320 |
321 | 322 |
323 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 324 |
325 | 326 | 327 | 328 | 329 | -------------------------------------------------------------------------------- /docs/Wheel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: Wheel 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: Wheel

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

Wheel(pageContext, opts)

32 | 33 |
大转盘游戏逻辑部分
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new Wheel(pageContext, opts)

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Parameters:
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 122 | 123 | 124 | 125 | 126 | 127 | 269 | 270 | 271 | 272 | 273 |
NameTypeDescription
pageContext 92 | 93 | 94 | Object 95 | 96 | 97 | 98 | page路由指针
opts 115 | 116 | 117 | Object 118 | 119 | 120 | 121 | 组件所需参数 128 |
Properties
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
NameTypeDescription
areaNumber 157 | 158 | 159 | Number 160 | 161 | 162 | 163 | 抽奖间隔
speed 180 | 181 | 182 | Number 183 | 184 | 185 | 186 | 转动速度
awardNumer 203 | 204 | 205 | Number 206 | 207 | 208 | 209 | 中奖区域从1开始
mode 226 | 227 | 228 | Number 229 | 230 | 231 | 232 | 1是指针旋转,2为转盘旋转
callback 249 | 250 | 251 | function 252 | 253 | 254 | 255 | 结束回调
267 | 268 |
274 | 275 | 276 | 277 | 278 | 279 | 280 |
281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 |
Author:
300 |
301 |
    302 |
  • pfan
  • 303 |
304 |
305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 |
Source:
315 |
318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 |
To Do:
326 |
327 |
    328 |
  • 注意:移动端真机,不支持requestAnimationFrame.
  • 329 |
330 |
331 | 332 |
333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 |
Example
351 | 352 |
new Wheel(this,{
353 |    areaNumber: 8,   //抽奖间隔
354 |    speed: 16,       //转动速度
355 |    awardNumer: 2,   //中奖区域从1开始
356 |    mode: 1,         //1是指针旋转,2为转盘旋转
357 |    callback: (idx, award) => {
358 |      //结束回调, 参数对应宫格索引,对应奖项    
359 |    }
360 |  })
361 | 362 | 363 | 364 | 365 |
366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 |
387 | 388 |
389 | 390 | 391 | 392 | 393 |
394 | 395 | 398 | 399 |
400 | 401 |
402 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 403 |
404 | 405 | 406 | 407 | 408 | -------------------------------------------------------------------------------- /docs/card_card.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: card/card.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: card/card.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class Card
 31 |  * @class
 32 |  * @classdesc 九宫格翻纸牌组件逻辑部分
 33 |  * @author pfan
 34 |  * @todo 注意:移动端真机,不支持requestAnimationFrame.
 35 |  * 
 36 |  * @example
 37 |  *  new Card(this,{
 38 |  *    data: [   //宫格信息,内联样式、是否是反面、是否运动、对应奖项
 39 |  *      {isBack: false, isMove: false, award: "一等奖"},    
 40 |  *      {isBack: false, isMove: false, award: "二等奖"},
 41 |  *      {isBack: false, isMove: false, award: "三等奖"},
 42 |  *      {isBack: false, isMove: false, award: "四等奖"},
 43 |  *      {isBack: false, isMove: false, award: "五等奖"},
 44 |  *      {isBack: false, isMove: false, award: "六等奖"},
 45 |  *      {isBack: false, isMove: false, award: "七等奖"},
 46 |  *      {isBack: false, isMove: false, award: "八等奖"},
 47 |  *      {isBack: false, isMove: false, award: "九等奖"}
 48 |  *    ],
 49 |  *    callback: (idx, award) => {
 50 |  *      //结束回调, 参数对应宫格索引,对应奖项    
 51 |  *    }
 52 |  *  })
 53 |  */
 54 | class Card {
 55 | 
 56 |   /**
 57 |    * @constructs Card构造函数
 58 |    * @param  {Object} pageContext page路由指针
 59 |    * @param  {Object} opts      组件所需参数
 60 |    * @param  {String} opts.inlineStyle  组件所需参数
 61 |    * @param  {Boolean} opts.isBack  是否是反面
 62 |    * @param  {Boolean} opts.isMove  是否运动
 63 |    * @param  {String} opts.award    对应奖项
 64 |    * @param  {Function} opts.callback    结束回调
 65 |    */
 66 |   
 67 |   constructor (pageContext, opts) {
 68 |     this.page = pageContext
 69 |     this.isFlip = false
 70 |     this.card = opts.data || []
 71 |     this.init()
 72 |     this.endCallBack = opts.callback
 73 |     this.page.start = this.start.bind(this)
 74 |     this.page.onClick = this.onClick.bind(this)
 75 |   }
 76 | 
 77 |   init () {
 78 |      let {card} = this
 79 |      
 80 |      for(let i = 0; i < 9; i++){
 81 |         card[i] = {isBack: false, isMove: false, award: card[i].award}
 82 |      }
 83 |      this.page.setData({card})
 84 |      this.card = card
 85 |   }
 86 | 
 87 |   start () {
 88 |      let {card} = this
 89 |     
 90 |      runAsync(100).then( () => {
 91 |        for(let i = 0; i < 3; i++){
 92 |           card[i].isBack = true
 93 |        }
 94 |        this.page.setData({card})
 95 |        return runAsync(200)
 96 | 
 97 |      }).then( () => {
 98 |        for(let i = 3; i < 6; i++){
 99 |           card[i].isBack = true
100 |        }
101 |       this.page.setData({card})
102 |       return runAsync(200)
103 | 
104 |      }).then( () => {
105 |        for(let i = 6; i <= 8; i++){
106 |           card[i].isBack = true
107 |        }
108 |       this.page.setData({card})
109 |       return runAsync(800)
110 | 
111 |      }).then( () => {
112 |        for(let i = 0; i < 9; i++){
113 |           card[i].isBack = false
114 |        }
115 |       this.page.setData({card})
116 |       return runAsync(400)
117 |       
118 |      }).then( () => {
119 |        for(let i = 0; i < 9; i++){
120 |           card[i].isMove = true
121 |        }
122 |       this.page.setData({card})
123 |       return runAsync(500)
124 |       
125 |      }).then( () => {
126 |        for(let i = 0; i < 9; i++){
127 |           card[i].isMove = false
128 |        }
129 |       this.page.setData({ card })
130 |       this.isFlip = true
131 |       this.card = card
132 |      })    
133 |   }
134 | 
135 |   reset () {
136 |      let {card} = this
137 |      this.isFlip = false
138 |      for(let i = 0; i < 9; i++){
139 |         card[i] = {isBack: false, isMove: false, award: card[i].award}
140 |      }     
141 |      this.card = card
142 |      this.page.setData({card})
143 | 
144 |     runAsync(800).then( () => {
145 |       this.start()
146 |     })     
147 |      
148 |   }
149 | 
150 |   onClick (event) {
151 |     let {card, isFlip, endCallBack} = this
152 |     if(!isFlip)return
153 |     let idx = event.currentTarget.dataset.idx
154 |     let award = event.currentTarget.dataset.award
155 |     card[idx].isBack = !card[idx].isBack
156 |     this.page.setData({card})
157 |     runAsync(600).then( () => {
158 |       endCallBack(idx, award)
159 |     })
160 |   }  
161 | 
162 | }
163 | 
164 | 
165 | /**
166 |  * runAsync 延迟返回 promise 方法
167 |  * @param  {Number} time 延迟时间
168 |  * @return {type}   返回Promise对象
169 |  */
170 | function runAsync(time) {
171 |   return new Promise(function(resolve, reject) {
172 |     let timer = setTimeout(function(){
173 |       resolve()
174 |       clearTimeout(timer)
175 |     }, time)
176 |   })
177 | }
178 | 
179 | 
180 | export default Card
181 | 
182 |
183 |
184 | 185 | 186 | 187 | 188 |
189 | 190 | 193 | 194 |
195 | 196 |
197 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 198 |
199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/o2team/wxapp-market/2704ee8ae635d2b560cad330c38739ca8c59a48c/docs/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/fruitMachine_fruitMachine.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: fruitMachine/fruitMachine.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: fruitMachine/fruitMachine.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class FruitMachine
 31 |  * @class
 32 |  * @classdesc 水果机游戏逻辑部分
 33 |  * @author pfan
 34 |  * 
 35 |  * @example
 36 |  *  new FruitMachine(this,{
 37 |  *    len: 9, //宫格个数
 38 |  *    ret: 9, //抽奖结果对应值1~9   
 39 |  *    speed: 100  // 速度值
 40 |  *    ],
 41 |  *    callback: (idx, award) => {
 42 |  *      //结束回调, 参数对应宫格索引,对应奖项    
 43 |  *    }
 44 |  *  })
 45 |  */
 46 |  class FruitMachine {
 47 | 
 48 |   /**
 49 |    * @constructs FruitMachine构造函数
 50 |    * @param  {Object} pageContext page路由指针
 51 |    * @param  {Object} opts      组件所需参数
 52 |    * @param  {Number} opts.len  宫格个数
 53 |    * @param  {Number} opts.ret  抽奖结果对应值1~9
 54 |    * @param  {Number} opts.speed  速度值
 55 |    * @param  {Function} opts.callback  结束回调
 56 |    */  
 57 |   constructor (pageContext, opts) {
 58 |     this.page = pageContext
 59 |     this.len = opts.len || 8
 60 |     this.ret = opts.ret
 61 |     this.speed = opts.speed
 62 |     this.isStart = false
 63 |     this.endCallBack = opts.callback
 64 |     this.page.start = this.start.bind(this)
 65 |   }
 66 | 
 67 |   start () {
 68 | 
 69 |     let { idx, ret, len, speed, isStart } = this
 70 |     if(isStart)return
 71 |     this.isStart = true
 72 |     let range = Math.floor(Math.random()*2 + 2)
 73 |     let count = 0
 74 |     let spd2 = speed*2
 75 |     !(function interval(self){
 76 |       setTimeout( () => {
 77 |         count++
 78 |         if(count > range * len){
 79 |           speed = spd2
 80 |         }
 81 |         if(count != (range + 1) * len + ret ){
 82 |           interval(self)
 83 |         }else{
 84 |           self.isStart = false
 85 |           self.endCallBack && self.endCallBack()
 86 |         }
 87 | 
 88 |         self.page.setData({
 89 |           machine: {
 90 |             idx: count % 8  == 0 ? 8 : count % 8
 91 |           }
 92 |         })
 93 |         
 94 |       }, speed)
 95 |     })(this)
 96 |   }
 97 | 
 98 |   reset () {
 99 |      this.page.setData({
100 |       machine: {
101 |         idx: ''
102 |       }
103 |     })   
104 |   }
105 | 
106 | }
107 | 
108 | export default FruitMachine
109 |
110 |
111 | 112 | 113 | 114 | 115 |
116 | 117 | 120 | 121 |
122 | 123 |
124 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 125 |
126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Global 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Global

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
78 | 79 | 80 | 81 | 82 |
83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |

Methods

100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

getDis(a, b) → {Number}

108 | 109 | 110 | 111 | 112 | 113 | 114 |
115 | getDis 获取两点直线距离 116 |
117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 |
Parameters:
127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 |
NameTypeDescription
a 155 | 156 | 157 | Object 158 | 159 | 160 | 161 | 坐标
b 178 | 179 | 180 | Object 181 | 182 | 183 | 184 | 坐标
196 | 197 | 198 | 199 | 200 | 201 | 202 |
203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 |
Source:
230 |
233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 |
241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |
Returns:
255 | 256 | 257 |
258 | 距离值 259 |
260 | 261 | 262 | 263 |
264 |
265 | Type 266 |
267 |
268 | 269 | Number 270 | 271 | 272 |
273 |
274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 |

runAsync(time) → {type}

288 | 289 | 290 | 291 | 292 | 293 | 294 |
295 | runAsync 延迟返回 promise 方法 296 |
297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 |
Parameters:
307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 |
NameTypeDescription
time 335 | 336 | 337 | Number 338 | 339 | 340 | 341 | 延迟时间
353 | 354 | 355 | 356 | 357 | 358 | 359 |
360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 |
Source:
387 |
390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 |
398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 |
Returns:
412 | 413 | 414 |
415 | 返回Promise对象 416 |
417 | 418 | 419 | 420 |
421 |
422 | Type 423 |
424 |
425 | 426 | type 427 | 428 | 429 |
430 |
431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 |
445 | 446 |
447 | 448 | 449 | 450 | 451 |
452 | 453 | 456 | 457 |
458 | 459 |
460 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 461 |
462 | 463 | 464 | 465 | 466 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 55 | 56 |
57 | 58 |
59 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /docs/module.exports.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: exports 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: exports

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

exports()

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 |

new exports()

45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 大转盘游戏逻辑部分 53 |
54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
Author:
87 |
88 |
    89 |
  • pfan 90 | 91 | 问题: 92 | 移动端真机,不支持requestAnimationFrame 93 | 94 | * 调用方式: 95 | 96 | 例如:import Wheel from "../../components/wheel/wheel.js" 97 | 98 | wxss 文件需要引入 wheel.wxss 99 | `@import '../../components/wheel/wheel.wxss'` 100 | 101 | wxml 文件需要引入 wheel.wxml 102 | 例如:<import src="../../components/wheel/wheel.wxml" /> 103 | <template is = "wheel" data="{{...wheel}}"></template> 104 | 105 | js 中调用 106 | 107 | this.wheel = new Wheel(this, { 108 | areaNumber: 8, //抽奖间隔 109 | speed: 16, //转动速度 110 | awardNumer: 2, //中奖区域从1开始 111 | mode: 1, //1是指针旋转,2为转盘旋转 112 | callback: () => { 113 | //运动停止回调 114 | } 115 | })
  • 116 |
117 |
118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
Source:
128 |
131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 |
159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 |
180 | 181 |
182 | 183 | 184 | 185 | 186 |
187 | 188 | 191 | 192 |
193 | 194 |
195 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:29:27 GMT+0800 (HKT) 196 |
197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /docs/scratch_scratch.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: scratch/scratch.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: scratch/scratch.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class Scratch
 31 |  * @class
 32 |  * @classdesc 九宫格翻纸牌组件逻辑部分
 33 |  * @author pfan
 34 |  * @todo 1.drawImage 与 clearRect 清除展示移动端和模拟器不一致
 35 |  * @todo 2.小程序无globalCompositeOperation = 'destination-out'属性
 36 |  * @todo 3.小程序无getImageData获取像素点对比擦除范围
 37 |  * @todo 4.使用 downloadFile 这种方式来先加载图片再绘制
 38 |  * 
 39 |  * @example
 40 |  *  new Scratch(this,{
 41 |  *    canvasWidth: 197,   //画布宽带
 42 |  *    canvasHeight: 72,  //画布高度
 43 |  *    imageResource: './images/placeholder.png', //遮罩层图片
 44 |  *    r: 4, //笔触半径
 45 |  *    awardTxt: '中大奖', //底部抽奖文字奖项
 46 |  *    awardTxtColor: "#1AAD16", //底部抽奖文字颜色
 47 |  *    awardTxtFontSize: "24px", //底部抽奖文字大小
 48 |  *    maskColor: "red",  //没有图片遮罩层颜色
 49 |  *    callback: () => {
 50 |  *      //清除画布回调
 51 |  *    }
 52 |  *  })
 53 |  */
 54 | class Scratch {
 55 | 
 56 |   /**
 57 |    * @constructs Scratch构造函数
 58 |    * @param  {Object} pageContext page路由指针
 59 |    * @param  {Object} opts      组件所需参数
 60 |    * @param  {Number} opts.canvasWidth  画布宽带
 61 |    * @param  {Number} opts.canvasHeight  画布高度
 62 |    * @param  {String} opts.imageResource  遮罩层图片
 63 |    * @param  {Number} opts.r    笔触半径
 64 |    * @param  {String} opts.awardTxt    底部抽奖文字奖项
 65 |    * @param  {String} opts.awardTxtColor    底部抽奖文字颜色
 66 |    * @param  {String} opts.awardTxtFontSize    底部抽奖文字大小
 67 |    * @param  {String} opts.maskColor     没有图片遮罩层颜色
 68 |    * @param  {Function} opts.callback    结束回调
 69 |    */
 70 |   constructor (pageContext, opts) {
 71 |     this.page = pageContext
 72 |     this.canvasWidth = opts.canvasWidth
 73 |     this.canvasHeight = opts.canvasHeight
 74 |     this.imageResource = opts.imageResource
 75 |     this.maskColor = opts.maskColor
 76 |     // this.canvasId = opts.canvasId
 77 |     this.r = opts.r || 4
 78 |     this.endCallBack = opts.callback
 79 |     this.lastX = 0
 80 |     this.lastY = 0
 81 |     this.minX = ''
 82 |     this.minY = ''
 83 |     this.maxX = ''
 84 |     this.maxY = ''
 85 |     this.isStart = false
 86 |     this.init()
 87 | 
 88 |     this.page.touchStart = this.touchStart.bind(this)
 89 |     this.page.touchMove = this.touchMove.bind(this)
 90 |     this.page.touchEnd = this.touchEnd.bind(this)
 91 |     this.page.imgOnLoad = this.imgOnLoad.bind(this)
 92 | 
 93 |     this.page.setData({
 94 |       scratch: {
 95 |         "awardTxt": opts.awardTxt,
 96 |         "awardTxtColor": opts.awardTxtColor,
 97 |         "awardTxtFontSize": opts.awardTxtFontSize,
 98 |         "awardTxtLineHeight": opts.canvasHeight,   
 99 |         "width": opts.canvasWidth,   
100 |         "height": opts.canvasHeight,
101 |         "imageResource": opts.imageResource
102 |       },
103 |       "isScroll": true
104 |     })
105 |   }
106 | 
107 |   init () {
108 |     let {canvasWidth, canvasHeight, imageResource, maskColor} = this
109 |     let self = this
110 |     this.ctx = wx.createCanvasContext('scratch')
111 |     this.ctx.clearRect(0, 0, canvasWidth, canvasHeight) 
112 |     if(imageResource && imageResource != ''){
113 |       wx.downloadFile({
114 |         url: imageResource, 
115 |         success: (res) => {
116 |           self.ctx.drawImage(res.tempFilePath, 0, 0, canvasWidth, canvasHeight)
117 |           self.ctx.draw()
118 |         }
119 |       })      
120 |     }else{
121 |       self.ctx.setFillStyle(maskColor)
122 |       self.ctx.fillRect(0, 0, canvasWidth, canvasHeight) 
123 |       self.ctx.draw()   
124 |     }
125 |   }
126 | 
127 |   drawRect (x, y) {
128 |     let {r, canvasWidth, canvasHeight, lastX, lastY, minX, minY, maxX, maxY} = this
129 |     let x1 = x - r > 0 ? x - r : 0
130 |     let y1 = y - r > 0 ? y - r : 0
131 |     if('' != minX){
132 |       this.minX = minX > x1 ? x1 : minX
133 |       this.minY = minY > y1 ? y1 : minY
134 |       this.maxX = maxX > x1 ? maxX : x1
135 |       this.maxY = maxY > y1 ? maxY : y1
136 |     }else{
137 |       this.minX = x1
138 |       this.minY = y1
139 |       this.maxX = x1
140 |       this.maxY = y1
141 |     }
142 |     this.lastX = x1
143 |     this.lastY = y1
144 | 
145 |     return [x1, y1, 2*r]
146 |   }  
147 | 
148 |   start () {
149 |     this.isStart = true
150 |     this.page.setData({
151 |       "isScroll": false
152 |     })
153 |   }
154 | 
155 |   restart () {    
156 |     this.init()
157 |     this.lastX = 0
158 |     this.lastY = 0
159 |     this.minX = ''
160 |     this.minY = ''
161 |     this.maxX = ''
162 |     this.maxY = ''    
163 |     this.isStart = true
164 |     this.page.setData({
165 |       "isScroll": false
166 |     })    
167 |   }
168 | 
169 |   touchStart (e) {
170 |     if(!this.isStart)return
171 |     let pos = this.drawRect(e.touches[0].x, e.touches[0].y)
172 |     this.ctx.clearRect(pos[0] ,pos[1] , pos[2], pos[2]) 
173 |     this.ctx.draw(true)
174 |   }
175 | 
176 |   touchMove (e) {
177 |     if(!this.isStart)return
178 |     let pos = this.drawRect(e.touches[0].x, e.touches[0].y)
179 |     this.ctx.clearRect(pos[0] ,pos[1] , pos[2], pos[2]) 
180 |     this.ctx.draw(true) 
181 |   }
182 | 
183 |   touchEnd (e) {
184 |     if(!this.isStart)return
185 |     //自动清楚采用点范围值方式判断
186 |     let {canvasWidth, canvasHeight, minX, minY, maxX, maxY} = this
187 |     if(maxX - minX > .7 * canvasWidth && maxY - minY > .7 * canvasHeight ){
188 |       this.ctx.draw() 
189 |       this.endCallBack && this.endCallBack()
190 |       this.isStart = false
191 |       this.page.setData({
192 |         "isScroll": true
193 |       })      
194 |     }
195 |   } 
196 | 
197 |   reset () {
198 |     this.init()
199 |   }
200 | 
201 |   imgOnLoad () {
202 |     
203 |   }   
204 | }
205 | 
206 | export default Scratch
207 | 
208 |
209 |
210 | 211 | 212 | 213 | 214 |
215 | 216 | 219 | 220 |
221 | 222 |
223 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 224 |
225 | 226 | 227 | 228 | 229 | 230 | -------------------------------------------------------------------------------- /docs/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (function() { 3 | var source = document.getElementsByClassName('prettyprint source linenums'); 4 | var i = 0; 5 | var lineNumber = 0; 6 | var lineId; 7 | var lines; 8 | var totalLines; 9 | var anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = 'line' + lineNumber; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/shake_shake.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: shake/shake.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: shake/shake.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class Shake
 31 |  * @class
 32 |  * @classdesc 九宫格翻纸牌组件逻辑部分
 33 |  * @author pfan
 34 |  * 
 35 |  * @example
 36 |  *  new Shake(this,{
 37 |  *    shakeThreshold: 70, //阈值
 38 |  *    callback: (idx, award) => {
 39 |  *      //结束回调, 参数对应宫格索引,对应奖项    
 40 |  *    }
 41 |  *  })
 42 |  */
 43 | class Shake {
 44 | 
 45 |   /**
 46 |    * @constructs Shake构造函数
 47 |    * @param  {Object} pageContext page路由指针
 48 |    * @param  {Object} opts      组件所需参数
 49 |    * @param  {Number} opts.shakeThreshold  频率阈值
 50 |    * @param  {Function} opts.callback    结束回调
 51 |    */      
 52 |   constructor (pageContext, opts) {
 53 |     this.page = pageContext
 54 |     this.shakeThreshold = opts.shakeThreshold || 80
 55 |     this.lastX = 0
 56 |     this.lastY = 0
 57 |     this.lastZ = 0
 58 |     this.lastUpdate = 0
 59 |     this.isStart = true
 60 |     this.endCallBack = opts.callback
 61 |     this.page.audioCtx = wx.createAudioContext('shakeAudio')
 62 |     this.start()
 63 |     
 64 |   }
 65 | 
 66 |   start () {
 67 |     let { isStart, shakeThreshold, lastX, lastY, lastZ, lastUpdate } = this
 68 |     wx.onAccelerometerChange((res) => {
 69 |       let curTime = new Date().getTime()
 70 |       if ((curTime - lastUpdate) > 100) {
 71 |         let curX = res.x
 72 |         let curY = res.y
 73 |         let curZ = res.z
 74 |         let speed = Math.abs(curX + curY + curZ - lastX - lastY - lastZ) / (curTime - lastUpdate) * 10000
 75 |         if(speed > shakeThreshold && this.isStart){
 76 |           this.page.audioCtx.play()   
 77 |           this.update()
 78 |         }
 79 |         lastUpdate = curTime
 80 |         lastX = curX
 81 |         lastY = curY
 82 |         lastZ = curZ
 83 |       }
 84 |     })
 85 |   }
 86 | 
 87 |   update () {
 88 |     this.page.setData({
 89 |       anim: true
 90 |     })
 91 |     this.isStart = false
 92 |     setTimeout(() => {
 93 |       this.page.setData({
 94 |         anim: false
 95 |       })
 96 |       this.endCallBack && this.endCallBack()
 97 |     }, 2000)
 98 | 
 99 |   }
100 | 
101 |   reset () {
102 |   
103 |   }
104 | 
105 | }
106 | 
107 | 
108 | export default Shake
109 | 
110 |
111 |
112 | 113 | 114 | 115 | 116 |
117 | 118 | 121 | 122 |
123 | 124 |
125 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 126 |
127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /docs/slotMachine_slotMachine.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: slotMachine/slotMachine.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: slotMachine/slotMachine.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class Machine
 31 |  * @class
 32 |  * @classdesc 老虎机游戏逻辑部分
 33 |  * @author pfan
 34 |  * 
 35 |  * @example
 36 |  *  new Machine(this,{
 37 |  *     height: 40,  //单个数字高度
 38 |  *     len: 10,     //单个项目数字个数
 39 |  *     transY1: 0,  //第一列初始位置
 40 |  *     num1: 3,     //第一列结束数字
 41 |  *     transY2: 0,  //第二列初始位置
 42 |  *     num2: 0,     //第二列结束数字
 43 |  *     transY3: 0,  //第三列初始位置
 44 |  *     num3: 0,     //第三列结束数字
 45 |  *     transY4: 0,  //第四列结束数字
 46 |  *     num4: 1,     //第四列结束数字
 47 |  *     speed: 24,   //速度
 48 |  *     callback: (idx, award) => {
 49 |  *      //结束回调, 参数对应宫格索引,对应奖项    
 50 |  *    }
 51 |  *  })
 52 |  */
 53 | class Machine {
 54 |   /**
 55 |    * @constructs Machine构造函数
 56 |    * @param  {Object} pageContext page路由指针
 57 |    * @param  {Object} opts      组件所需参数
 58 |    * @param  {Number} opts.height  单个数字高度
 59 |    * @param  {Number} opts.len  单个项目数字个数
 60 |    * @param  {Number} opts.transY1  第一列初始位置
 61 |    * @param  {Number} opts.num1     第一列结束数字
 62 |    * @param  {Number} opts.transY2  第二列初始位置
 63 |    * @param  {Number} opts.num2     第二列结束数字
 64 |    * @param  {Number} opts.transY3  第三列初始位置
 65 |    * @param  {Number} opts.num3     第三列结束数字
 66 |    * @param  {Number} opts.transY4  第四列初始位置
 67 |    * @param  {Number} opts.num4     第四列结束数字
 68 |    * @param  {Number} opts.speed    速度
 69 |    * @param  {Function} opts.callback    结束回调
 70 |    */  
 71 |   constructor (pageContext, opts) {
 72 |     this.page = pageContext
 73 |     this.height = opts.height
 74 |     this.len = opts.len
 75 |     this.transY1 = opts.transY1
 76 |     this.num1 = opts.num1
 77 |     this.transY2 = opts.transY2
 78 |     this.num2 = opts.num2
 79 |     this.transY3 = opts.transY3
 80 |     this.num3 = opts.num3
 81 |     this.transY4 = opts.transY4
 82 |     this.num4 = opts.num4
 83 |     this.speed = opts.speed
 84 |     this.isStart = false
 85 |     this.endCallBack = opts.callback
 86 |     this.page.start = this.start.bind(this)
 87 |   }
 88 | 
 89 |   start () {
 90 |     let { isStart, len, height, transY1, transY2, transY3, transY4, speed, num1, num2, num3, num4, endCallBack } = this
 91 |     if(isStart)return
 92 |     this.isStart = true    
 93 |     let totalHeight = height * len 
 94 |     let sRange = Math.floor(Math.random()*2 + 2)
 95 |     let halfSpeed = speed / 2
 96 |     let endDis1 = num1 == 0 ? 10 * height : num1 * height
 97 |     let endDis2 = num2 == 0 ? 10 * height : num2 * height
 98 |     let endDis3 = num3 == 0 ? 10 * height : num3 * height
 99 |     let endDis4 = num4 == 0 ? 10 * height : num4 * height
100 |     let i1 = 1, i2 = 1, i3 = 1, i4 = 1
101 | 
102 |     this.timer = setInterval(() => {
103 |       if(i1 <= sRange){
104 |         transY1 -= speed
105 |         if(Math.abs(transY1) > totalHeight){
106 |           transY1 = transY1 + totalHeight
107 |           i1++
108 |         }
109 |       }else if(i1 > sRange && i1 < sRange + 2){
110 |         transY1 -= halfSpeed
111 |         if(Math.abs(transY1) > totalHeight){
112 |           transY1 = transY1 + totalHeight
113 |           i1++
114 |         }      
115 |       }else{
116 |         if(transY1 == endDis1)return
117 |         let dropSpeed = (endDis1 + transY1) / halfSpeed
118 |         dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed
119 |         transY1 -= dropSpeed
120 |         transY1 =  Math.abs(transY1) > endDis1 ? transY1 = -endDis1: transY1
121 |       }
122 | 
123 |       this.timer1 = setTimeout( () => {
124 |         if(i2 <= sRange){
125 |           transY2 -= speed
126 |           if(Math.abs(transY2) > totalHeight){
127 |             transY2 = transY2 + totalHeight
128 |             i2++
129 |           }
130 |         }else if(i2 > sRange && i2 < sRange + 2){
131 |           transY2 -= halfSpeed
132 |           if(Math.abs(transY2) > totalHeight){
133 |             transY2 = transY2 + totalHeight
134 |             i2++
135 |           }      
136 |         }else{
137 |           if(transY2 == endDis2)return
138 |           let dropSpeed = (endDis2 + transY2) / halfSpeed
139 |           dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed
140 |           transY2 -= dropSpeed
141 |           transY2 =  Math.abs(transY2) > endDis2 ? transY2 = -endDis2: transY2
142 |         }
143 |       }, 200)
144 | 
145 |       this.timer2 = setTimeout( () => {
146 |         if(i3 <= sRange){
147 |           transY3 -= speed
148 |           if(Math.abs(transY3) > totalHeight){
149 |             transY3 = transY3 + totalHeight
150 |             i3++
151 |           }
152 |         }else if(i3 > sRange && i3 < sRange + 2){
153 |           transY3 -= halfSpeed
154 |           if(Math.abs(transY3) > totalHeight){
155 |             transY3 = transY3 + totalHeight
156 |             i3++
157 |           }      
158 |         }else{
159 |           if(transY3 == endDis3)return
160 |           let dropSpeed = (endDis3 + transY3) / halfSpeed
161 |           dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < 1 ? 1 : dropSpeed
162 |           transY3 -= dropSpeed
163 |           transY3 =  Math.abs(transY3) > endDis3 ? transY3 = -endDis3: transY3
164 |         }
165 |       }, 400)     
166 | 
167 |       this.timer3 = setTimeout( () => {
168 |         if(i4 <= sRange){
169 |           transY4 -= speed
170 |           if(Math.abs(transY4) > totalHeight){
171 |             transY4 = transY4 + totalHeight
172 |             i4++
173 |           }
174 |         }else if(i4 > sRange && i4 < sRange + 2){
175 |           transY4 -= halfSpeed
176 |           if(Math.abs(transY4) > totalHeight){
177 |             transY4 = transY4 + totalHeight
178 |             i4++
179 |           }      
180 |         }else{
181 |           let dropSpeed = (endDis4 + transY4) / halfSpeed
182 |           if(num4 < 3){
183 |             dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .1 ? .1 : dropSpeed
184 |           }else if(num4 < 5 && num4 >= 3) {
185 |             dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .3 ? .3 : dropSpeed
186 |           }else{
187 |             dropSpeed = dropSpeed > halfSpeed ? halfSpeed : dropSpeed < .3 ? .3 : dropSpeed
188 |           }
189 |           
190 |           transY4 -= dropSpeed
191 |           transY4 =  Math.abs(transY4) > endDis4 ? transY4 = -endDis4: transY4
192 |           if(Math.abs(transY4) >= endDis4){
193 |             clearInterval(this.timer)
194 |             clearTimeout(this.timer1)
195 |             clearTimeout(this.timer2)
196 |             clearTimeout(this.timer3)
197 |             this.isStart = false
198 |             endCallBack && endCallBack()
199 |             return 
200 |           }          
201 |         }
202 |       }, 600)   
203 | 
204 | 
205 |       this.page.setData({
206 |         machine: {
207 |           transY1: transY1,
208 |           transY2: transY2,
209 |           transY3: transY3,
210 |           transY4: transY4
211 |         }
212 |       })
213 | 
214 |     }, 1000/60)   
215 |   }
216 | 
217 |   reset () {
218 |     this.transY1 = 0 
219 |     this.transY2 = 0 
220 |     this.transY3 = 0 
221 |     this.transY4 = 0 
222 | 
223 |     this.page.setData({
224 |       machine: {
225 |         transY1: 0,
226 |         transY2: 0,
227 |         transY3: 0,
228 |         transY4: 0
229 |       }
230 |     })    
231 |   }
232 | 
233 | }
234 | 
235 | 
236 | export default Machine
237 | 
238 |
239 |
240 | 241 | 242 | 243 | 244 |
245 | 246 | 249 | 250 |
251 | 252 |
253 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 254 |
255 | 256 | 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /docs/styles/jsdoc-default.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Open Sans'; 3 | font-weight: normal; 4 | font-style: normal; 5 | src: url('../fonts/OpenSans-Regular-webfont.eot'); 6 | src: 7 | local('Open Sans'), 8 | local('OpenSans'), 9 | url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'), 10 | url('../fonts/OpenSans-Regular-webfont.woff') format('woff'), 11 | url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg'); 12 | } 13 | 14 | @font-face { 15 | font-family: 'Open Sans Light'; 16 | font-weight: normal; 17 | font-style: normal; 18 | src: url('../fonts/OpenSans-Light-webfont.eot'); 19 | src: 20 | local('Open Sans Light'), 21 | local('OpenSans Light'), 22 | url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'), 23 | url('../fonts/OpenSans-Light-webfont.woff') format('woff'), 24 | url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg'); 25 | } 26 | 27 | html 28 | { 29 | overflow: auto; 30 | background-color: #fff; 31 | font-size: 14px; 32 | } 33 | 34 | body 35 | { 36 | font-family: 'Open Sans', sans-serif; 37 | line-height: 1.5; 38 | color: #4d4e53; 39 | background-color: white; 40 | } 41 | 42 | a, a:visited, a:active { 43 | color: #0095dd; 44 | text-decoration: none; 45 | } 46 | 47 | a:hover { 48 | text-decoration: underline; 49 | } 50 | 51 | header 52 | { 53 | display: block; 54 | padding: 0px 4px; 55 | } 56 | 57 | tt, code, kbd, samp { 58 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 59 | } 60 | 61 | .class-description { 62 | font-size: 130%; 63 | line-height: 140%; 64 | margin-bottom: 1em; 65 | margin-top: 1em; 66 | } 67 | 68 | .class-description:empty { 69 | margin: 0; 70 | } 71 | 72 | #main { 73 | float: left; 74 | width: 70%; 75 | } 76 | 77 | article dl { 78 | margin-bottom: 40px; 79 | } 80 | 81 | article img { 82 | max-width: 100%; 83 | } 84 | 85 | section 86 | { 87 | display: block; 88 | background-color: #fff; 89 | padding: 12px 24px; 90 | border-bottom: 1px solid #ccc; 91 | margin-right: 30px; 92 | } 93 | 94 | .variation { 95 | display: none; 96 | } 97 | 98 | .signature-attributes { 99 | font-size: 60%; 100 | color: #aaa; 101 | font-style: italic; 102 | font-weight: lighter; 103 | } 104 | 105 | nav 106 | { 107 | display: block; 108 | float: right; 109 | margin-top: 28px; 110 | width: 30%; 111 | box-sizing: border-box; 112 | border-left: 1px solid #ccc; 113 | padding-left: 16px; 114 | } 115 | 116 | nav ul { 117 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; 118 | font-size: 100%; 119 | line-height: 17px; 120 | padding: 0; 121 | margin: 0; 122 | list-style-type: none; 123 | } 124 | 125 | nav ul a, nav ul a:visited, nav ul a:active { 126 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 127 | line-height: 18px; 128 | color: #4D4E53; 129 | } 130 | 131 | nav h3 { 132 | margin-top: 12px; 133 | } 134 | 135 | nav li { 136 | margin-top: 6px; 137 | } 138 | 139 | footer { 140 | display: block; 141 | padding: 6px; 142 | margin-top: 12px; 143 | font-style: italic; 144 | font-size: 90%; 145 | } 146 | 147 | h1, h2, h3, h4 { 148 | font-weight: 200; 149 | margin: 0; 150 | } 151 | 152 | h1 153 | { 154 | font-family: 'Open Sans Light', sans-serif; 155 | font-size: 48px; 156 | letter-spacing: -2px; 157 | margin: 12px 24px 20px; 158 | } 159 | 160 | h2, h3.subsection-title 161 | { 162 | font-size: 30px; 163 | font-weight: 700; 164 | letter-spacing: -1px; 165 | margin-bottom: 12px; 166 | } 167 | 168 | h3 169 | { 170 | font-size: 24px; 171 | letter-spacing: -0.5px; 172 | margin-bottom: 12px; 173 | } 174 | 175 | h4 176 | { 177 | font-size: 18px; 178 | letter-spacing: -0.33px; 179 | margin-bottom: 12px; 180 | color: #4d4e53; 181 | } 182 | 183 | h5, .container-overview .subsection-title 184 | { 185 | font-size: 120%; 186 | font-weight: bold; 187 | letter-spacing: -0.01em; 188 | margin: 8px 0 3px 0; 189 | } 190 | 191 | h6 192 | { 193 | font-size: 100%; 194 | letter-spacing: -0.01em; 195 | margin: 6px 0 3px 0; 196 | font-style: italic; 197 | } 198 | 199 | table 200 | { 201 | border-spacing: 0; 202 | border: 0; 203 | border-collapse: collapse; 204 | } 205 | 206 | td, th 207 | { 208 | border: 1px solid #ddd; 209 | margin: 0px; 210 | text-align: left; 211 | vertical-align: top; 212 | padding: 4px 6px; 213 | display: table-cell; 214 | } 215 | 216 | thead tr 217 | { 218 | background-color: #ddd; 219 | font-weight: bold; 220 | } 221 | 222 | th { border-right: 1px solid #aaa; } 223 | tr > th:last-child { border-right: 1px solid #ddd; } 224 | 225 | .ancestors, .attribs { color: #999; } 226 | .ancestors a, .attribs a 227 | { 228 | color: #999 !important; 229 | text-decoration: none; 230 | } 231 | 232 | .clear 233 | { 234 | clear: both; 235 | } 236 | 237 | .important 238 | { 239 | font-weight: bold; 240 | color: #950B02; 241 | } 242 | 243 | .yes-def { 244 | text-indent: -1000px; 245 | } 246 | 247 | .type-signature { 248 | color: #aaa; 249 | } 250 | 251 | .name, .signature { 252 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 253 | } 254 | 255 | .details { margin-top: 14px; border-left: 2px solid #DDD; } 256 | .details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } 257 | .details dd { margin-left: 70px; } 258 | .details ul { margin: 0; } 259 | .details ul { list-style-type: none; } 260 | .details li { margin-left: 30px; padding-top: 6px; } 261 | .details pre.prettyprint { margin: 0 } 262 | .details .object-value { padding-top: 0; } 263 | 264 | .description { 265 | margin-bottom: 1em; 266 | margin-top: 1em; 267 | } 268 | 269 | .code-caption 270 | { 271 | font-style: italic; 272 | font-size: 107%; 273 | margin: 0; 274 | } 275 | 276 | .prettyprint 277 | { 278 | border: 1px solid #ddd; 279 | width: 80%; 280 | overflow: auto; 281 | } 282 | 283 | .prettyprint.source { 284 | width: inherit; 285 | } 286 | 287 | .prettyprint code 288 | { 289 | font-size: 100%; 290 | line-height: 18px; 291 | display: block; 292 | padding: 4px 12px; 293 | margin: 0; 294 | background-color: #fff; 295 | color: #4D4E53; 296 | } 297 | 298 | .prettyprint code span.line 299 | { 300 | display: inline-block; 301 | } 302 | 303 | .prettyprint.linenums 304 | { 305 | padding-left: 70px; 306 | -webkit-user-select: none; 307 | -moz-user-select: none; 308 | -ms-user-select: none; 309 | user-select: none; 310 | } 311 | 312 | .prettyprint.linenums ol 313 | { 314 | padding-left: 0; 315 | } 316 | 317 | .prettyprint.linenums li 318 | { 319 | border-left: 3px #ddd solid; 320 | } 321 | 322 | .prettyprint.linenums li.selected, 323 | .prettyprint.linenums li.selected * 324 | { 325 | background-color: lightyellow; 326 | } 327 | 328 | .prettyprint.linenums li * 329 | { 330 | -webkit-user-select: text; 331 | -moz-user-select: text; 332 | -ms-user-select: text; 333 | user-select: text; 334 | } 335 | 336 | .params .name, .props .name, .name code { 337 | color: #4D4E53; 338 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 339 | font-size: 100%; 340 | } 341 | 342 | .params td.description > p:first-child, 343 | .props td.description > p:first-child 344 | { 345 | margin-top: 0; 346 | padding-top: 0; 347 | } 348 | 349 | .params td.description > p:last-child, 350 | .props td.description > p:last-child 351 | { 352 | margin-bottom: 0; 353 | padding-bottom: 0; 354 | } 355 | 356 | .disabled { 357 | color: #454545; 358 | } 359 | -------------------------------------------------------------------------------- /docs/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /docs/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /docs/wheel_wheel.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: wheel/wheel.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: wheel/wheel.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Class Wheel
 31 |  * @class
 32 |  * @classdesc 大转盘游戏逻辑部分
 33 |  * @author pfan
 34 |  * @todo 注意:移动端真机,不支持requestAnimationFrame.
 35 |  * 
 36 |  * @example
 37 |  *  new Wheel(this,{
 38 |  *    areaNumber: 8,   //抽奖间隔
 39 |  *    speed: 16,       //转动速度
 40 |  *    awardNumer: 2,   //中奖区域从1开始
 41 |  *    mode: 1,         //1是指针旋转,2为转盘旋转
 42 |  *    callback: (idx, award) => {
 43 |  *      //结束回调, 参数对应宫格索引,对应奖项    
 44 |  *    }
 45 |  *  })
 46 |  */
 47 | class Wheel {
 48 |   /**
 49 |    * @constructs Wheel构造函数
 50 |    * @param  {Object} pageContext page路由指针
 51 |    * @param  {Object} opts      组件所需参数
 52 |    * @param  {Number} opts.areaNumber  抽奖间隔
 53 |    * @param  {Number} opts.speed       转动速度
 54 |    * @param  {Number} opts.awardNumer  中奖区域从1开始
 55 |    * @param  {Number} opts.mode     1是指针旋转,2为转盘旋转
 56 |    * @param  {Function} opts.callback    结束回调
 57 |    */  
 58 |   constructor (pageContext, opts) {
 59 |     this.page = pageContext
 60 |     this.deg = 0 
 61 |     this.areaNumber = opts.areaNumber  // 奖区数量
 62 |     this.speed = opts.speed || 16   // 每帧速度
 63 |     this.awardNumer = opts.awardNumer //中奖区域 从1开始
 64 |     this.mode = opts.mode || 2
 65 |     this.singleAngle = ''   //每片扇形的角度
 66 |     this.isStart = false
 67 |     this.endCallBack = opts.callback
 68 | 
 69 | 
 70 |     this.init()
 71 | 
 72 |     this.page.start = this.start.bind(this)
 73 |   }
 74 | 
 75 |   init () {
 76 |     let {areaNumber, singleAngle, mode} = this
 77 |     singleAngle = 360 / areaNumber
 78 |     this.singleAngle = singleAngle
 79 |     this.page.setData({
 80 |       wheel: {
 81 |         singleAngle: singleAngle,
 82 |         mode: mode
 83 |       }
 84 |     })
 85 |   }
 86 | 
 87 |   start () {
 88 |     let {deg, awardNumer, singleAngle, speed, isStart, mode} = this
 89 |     if(isStart)return
 90 |     this.isStart = true
 91 |     let endAddAngle = (awardNumer - 1) * singleAngle + singleAngle/2 + 360   //中奖角度
 92 |     let rangeAngle = (Math.floor(Math.random() * 4) + 4) * 360 // 随机旋转几圈再停止  
 93 |     let cAngle
 94 |     deg = 0
 95 |     this.timer = setInterval( () => {
 96 |       if( deg < rangeAngle ){
 97 |         deg += speed
 98 |       }else{
 99 |         cAngle = (endAddAngle + rangeAngle - deg) / speed
100 |         cAngle = cAngle > speed ? speed : cAngle < 1 ? 1 : cAngle
101 |         deg += cAngle
102 | 
103 |         if(deg >= ( endAddAngle + rangeAngle )){
104 |           deg = endAddAngle + rangeAngle
105 |           this.isStart = false
106 |           clearInterval(this.timer)
107 |           this.endCallBack()         
108 |         }
109 |       }
110 |       
111 |       this.page.setData({
112 |         wheel: {
113 |           singleAngle: singleAngle,
114 |           deg: deg,
115 |           mode: mode
116 |         }
117 |       })
118 |     }, 1000/60)      
119 |   }
120 | 
121 |   reset () {
122 |     let {mode} = this
123 |     this.deg = 0
124 |     this.page.setData({
125 |       wheel: {
126 |         singleAngle: this.singleAngle,
127 |         deg: 0,
128 |         mode: mode
129 |       }
130 |     })    
131 |   }
132 | 
133 |   switch (mode) {
134 |     this.mode = mode
135 |   }
136 | 
137 | }
138 | 
139 | export default Wheel
140 | 
141 | 
142 |
143 |
144 | 145 | 146 | 147 | 148 |
149 | 150 | 153 | 154 |
155 | 156 |
157 | Documentation generated by JSDoc 3.5.5 on Tue Sep 19 2017 21:36:13 GMT+0800 (HKT) 158 |
159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /pages/fruitMachine/fruitMachine.js: -------------------------------------------------------------------------------- 1 | import FruitMachine from '../../components/fruitMachine/fruitMachine.js' 2 | 3 | Page({ 4 | data: { 5 | 6 | }, 7 | 8 | onLoad () { 9 | this.fruitMachine = new FruitMachine(this, { 10 | ret: 8, // 取值1~8 11 | speed: 100, 12 | callback: () => { 13 | wx.showModal({ 14 | title: '提示', 15 | content: '恭喜您,中奖了', 16 | showCancel: false, 17 | success: res => { 18 | this.fruitMachine.reset() 19 | if (res.confirm) { 20 | console.log('用户点击确定') 21 | } else if (res.cancel) { 22 | console.log('用户点击取消') 23 | } 24 | } 25 | }) 26 | } 27 | }) 28 | }, 29 | 30 | onReady () { 31 | console.log('onReady') 32 | } 33 | 34 | }) 35 | -------------------------------------------------------------------------------- /pages/fruitMachine/fruitMachine.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "水果机" 3 | } 4 | -------------------------------------------------------------------------------- /pages/fruitMachine/fruitMachine.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序水果机组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/fruitMachine/fruitMachine.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/fruitMachine/fruitMachine.wxss' 2 | 3 | .index-hd { 4 | padding: 80rpx; 5 | text-align: center; 6 | padding: 20rpx 26rpx 40rpx; 7 | } 8 | 9 | .index-desc { 10 | margin-top: 20rpx; 11 | color: #888888; 12 | font-size: 28rpx; 13 | } 14 | 15 | button{ 16 | margin-top: 40rpx; 17 | width: 400rpx; 18 | } -------------------------------------------------------------------------------- /pages/gestureLock/gestureLock.js: -------------------------------------------------------------------------------- 1 | import Lock from '../../components/lock/lock.js' 2 | 3 | Page({ 4 | data: { 5 | 6 | }, 7 | 8 | onLoad () { 9 | this.lock = new Lock(this, { 10 | canvasWidth: 300, 11 | canvasHeight: 300, 12 | canvasId: 'canvasLock', 13 | drawColor: '#3985ff' 14 | }) 15 | }, 16 | 17 | onReady () { 18 | console.log('onReady') 19 | } 20 | 21 | }) 22 | 23 | -------------------------------------------------------------------------------- /pages/gestureLock/gestureLock.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "手势解锁" 3 | } 4 | -------------------------------------------------------------------------------- /pages/gestureLock/gestureLock.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序手势解锁组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/gestureLock/gestureLock.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/lock/lock.wxss' 2 | 3 | .index-hd { 4 | padding: 80rpx; 5 | text-align: center; 6 | padding: 20rpx 26rpx 40rpx; 7 | } 8 | 9 | .index-desc { 10 | margin-top: 20rpx; 11 | color: #888; 12 | font-size: 28rpx; 13 | } 14 | 15 | button{ 16 | margin-top: 40rpx; 17 | width: 400rpx; 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /pages/gridcard/gridcard.js: -------------------------------------------------------------------------------- 1 | import Card from '../../components/card/card.js' 2 | 3 | Page({ 4 | data: { 5 | }, 6 | 7 | onLoad () { 8 | this.count = 0 9 | this.card = new Card(this, { 10 | data: [ 11 | { inlineStyle: '', isBack: false, isMove: false, award: '一等奖' }, 12 | { inlineStyle: '', isBack: false, isMove: false, award: '二等奖' }, 13 | { inlineStyle: '', isBack: false, isMove: false, award: '三等奖' }, 14 | { inlineStyle: '', isBack: false, isMove: false, award: '四等奖' }, 15 | { inlineStyle: '', isBack: false, isMove: false, award: '五等奖' }, 16 | { inlineStyle: '', isBack: false, isMove: false, award: '六等奖' }, 17 | { inlineStyle: '', isBack: false, isMove: false, award: '七等奖' }, 18 | { inlineStyle: '', isBack: false, isMove: false, award: '八等奖' }, 19 | { inlineStyle: '', isBack: false, isMove: false, award: '九等奖' } 20 | ], 21 | callback: (idx, award) => { 22 | wx.showModal({ 23 | title: '提示', 24 | content: `您点击了第${idx + 1}个方块,中${award}`, 25 | showCancel: false, 26 | success: res => { 27 | // this.card.reset() 28 | // if (res.confirm) { 29 | // console.log('用户点击确定') 30 | // } else if (res.cancel) { 31 | // console.log('用户点击取消') 32 | // } 33 | } 34 | }) 35 | } 36 | }) 37 | }, 38 | 39 | onReady () { 40 | console.log('onReady') 41 | }, 42 | 43 | onStart () { 44 | this.count++ 45 | if (this.count != 0) { 46 | this.card.reset() 47 | } else { 48 | this.card.start() 49 | } 50 | } 51 | }) 52 | -------------------------------------------------------------------------------- /pages/gridcard/gridcard.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "九宫格翻纸牌" 3 | } 4 | -------------------------------------------------------------------------------- /pages/gridcard/gridcard.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序九宫格翻纸牌组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pages/gridcard/gridcard.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/card/card.wxss' 2 | 3 | .index-hd { 4 | padding: 80rpx; 5 | text-align: center; 6 | padding: 20rpx 30rpx 40rpx; 7 | } 8 | 9 | .index-desc { 10 | margin-top: 20rpx; 11 | color: #888888; 12 | font-size: 28rpx; 13 | } 14 | 15 | button{ 16 | margin-top: 40rpx; 17 | width: 400rpx; 18 | } 19 | 20 | 21 | button{ 22 | margin-top: 40rpx; 23 | width: 400rpx; 24 | } -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | list: [ 4 | { 5 | id: 'wheel', 6 | sub: 'wheel', 7 | name: '大转盘' 8 | }, 9 | { 10 | id: 'scratch', 11 | sub: 'scratch', 12 | name: '刮刮乐' 13 | }, 14 | { 15 | id: 'slotMachine', 16 | sub: 'slotMachine', 17 | name: '老虎机' 18 | }, 19 | { 20 | id: 'fruitMachine', 21 | sub: 'fruitMachine', 22 | name: '水果机' 23 | }, 24 | { 25 | id: 'gridcard', 26 | sub: 'gridcard', 27 | name: '九宫格翻纸牌' 28 | }, 29 | { 30 | id: 'shake', 31 | sub: 'shake', 32 | name: '摇一摇' 33 | }, 34 | { 35 | id: 'gestureLock', 36 | sub: 'gestureLock', 37 | name: '手势解锁' 38 | } 39 | ] 40 | } 41 | }) 42 | -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "营销组件" 3 | } 4 | -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下将小程序营销组件能力,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.name}} 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background: #FBF9FE 3 | } 4 | 5 | .index-hd { 6 | padding: 80rpx; 7 | text-align: center; 8 | } 9 | .index-bd { 10 | padding: 0 30rpx 40rpx; 11 | } 12 | .index-ft { 13 | padding-bottom: 20rpx; 14 | text-align: center; 15 | } 16 | .index-logo { 17 | width: 86rpx; 18 | height: 86rpx; 19 | } 20 | .index-desc { 21 | margin-top: 20rpx; 22 | color: #888888; 23 | font-size: 28rpx; 24 | } 25 | 26 | 27 | .navigator { 28 | position: relative; 29 | display: block; 30 | align-items: center; 31 | width: 100%; 32 | } 33 | 34 | .kind-list-item { 35 | margin: 20rpx 0; 36 | background-color: #FFFFFF; 37 | border-radius: 4rpx; 38 | overflow: hidden; 39 | } 40 | .kind-list-item:first-child { 41 | margin-top: 0; 42 | } 43 | .kind-list-text{ 44 | flex: 1; 45 | } 46 | .kind-list-img { 47 | width: 60rpx; 48 | height: 60rpx; 49 | position: absolute; 50 | right: 0; 51 | top: 0; 52 | } 53 | .kind-list-item-hd { 54 | padding: 30rpx; 55 | display: flex; 56 | align-items: center; 57 | 58 | transition: opacity .3s; 59 | } 60 | .kind-list-item-hd-show { 61 | opacity: .2; 62 | } 63 | .kind-list-item-bd { 64 | height: 0; 65 | overflow: hidden; 66 | } 67 | .kind-list-item-bd-show { 68 | height: auto; 69 | } -------------------------------------------------------------------------------- /pages/scratch/scratch.js: -------------------------------------------------------------------------------- 1 | import Scratch from '../../components/scratch/scratch.js' 2 | 3 | Page({ 4 | data: { 5 | isStart: true, 6 | txt: '开始刮奖' 7 | }, 8 | 9 | onLoad () { 10 | this.scratch = new Scratch(this, { 11 | canvasWidth: 197, 12 | canvasHeight: 72, 13 | imageResource: 'https://misc.aotu.io/pfan123/wx/placeholder.png', 14 | maskColor: 'red', 15 | r: 4, 16 | awardTxt: '中大奖', 17 | awardTxtColor: '#3985ff', 18 | awardTxtFontSize: '24px', 19 | callback: () => { 20 | wx.showModal({ 21 | title: '提示', 22 | content: `您中奖了`, 23 | showCancel: false, 24 | success: res => { 25 | this.scratch.reset() 26 | if (res.confirm) { 27 | console.log('用户点击确定') 28 | } else if (res.cancel) { 29 | console.log('用户点击取消') 30 | } 31 | } 32 | }) 33 | } 34 | }) 35 | }, 36 | 37 | onReady () { 38 | console.log('onReady') 39 | }, 40 | 41 | onStart () { 42 | const { isStart } = this.data 43 | if (isStart) { 44 | this.scratch.start() 45 | this.setData({ 46 | txt: '重新开始', 47 | isStart: false 48 | }) 49 | } else { 50 | this.scratch.restart() 51 | } 52 | } 53 | 54 | }) 55 | -------------------------------------------------------------------------------- /pages/scratch/scratch.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "刮刮乐" 3 | } 4 | -------------------------------------------------------------------------------- /pages/scratch/scratch.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序刮刮乐组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /pages/scratch/scratch.wxss: -------------------------------------------------------------------------------- 1 | .index-hd { 2 | padding: 80rpx; 3 | text-align: center; 4 | padding: 20rpx 26rpx 40rpx; 5 | } 6 | 7 | .index-desc { 8 | margin-top: 20rpx; 9 | color: #888888; 10 | font-size: 28rpx; 11 | } 12 | 13 | button{ 14 | margin-top: 40rpx; 15 | width: 400rpx; 16 | } -------------------------------------------------------------------------------- /pages/shake/shake.js: -------------------------------------------------------------------------------- 1 | import Shake from '../../components/shake/shake.js' 2 | 3 | Page({ 4 | data: { 5 | 6 | }, 7 | 8 | onLoad () { 9 | this.shake = new Shake(this, { 10 | shakeThreshold: 100, // 阈值 11 | callback: () => { 12 | wx.showModal({ 13 | title: '提示', 14 | content: '恭喜您,中奖了', 15 | showCancel: false, 16 | success: res => { 17 | if (res.confirm) { 18 | this.shake.isStart = true 19 | console.log('用户点击确定') 20 | } else if (res.cancel) { 21 | console.log('用户点击取消') 22 | this.shake.isStart = true 23 | } 24 | } 25 | }) 26 | } 27 | }) 28 | }, 29 | 30 | onUnload () { 31 | wx.stopAccelerometer() 32 | }, 33 | 34 | onReady () { 35 | console.log('onReady') 36 | } 37 | 38 | }) 39 | -------------------------------------------------------------------------------- /pages/shake/shake.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "摇一摇" 3 | } 4 | -------------------------------------------------------------------------------- /pages/shake/shake.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序摇一摇组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/shake/shake.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/shake/shake.wxss' 2 | 3 | .index-hd { 4 | padding: 80rpx; 5 | text-align: center; 6 | padding: 20rpx 26rpx 40rpx; 7 | } 8 | 9 | .index-desc { 10 | margin-top: 20rpx; 11 | color: #888888; 12 | font-size: 28rpx; 13 | } 14 | 15 | button{ 16 | margin-top: 40rpx; 17 | width: 400rpx; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /pages/slotMachine/slotMachine.js: -------------------------------------------------------------------------------- 1 | import SlotMachine from '../../components/slotMachine/slotMachine.js' 2 | 3 | Page({ 4 | data: { 5 | 6 | }, 7 | 8 | onLoad () { 9 | this.slotMachine = new SlotMachine(this, { 10 | height: 40, // 单个数字高度 11 | len: 10, 12 | transY1: 0, 13 | num1: 3, 14 | transY2: 0, 15 | num2: 0, 16 | transY3: 0, 17 | num3: 0, 18 | transY4: 0, 19 | num4: 1, 20 | speed: 24, 21 | callback: () => { 22 | wx.showModal({ 23 | title: '提示', 24 | content: '恭喜您,中奖了', 25 | showCancel: false, 26 | success: res => { 27 | this.slotMachine.reset() 28 | if (res.confirm) { 29 | console.log('用户点击确定') 30 | } else if (res.cancel) { 31 | console.log('用户点击取消') 32 | } 33 | } 34 | }) 35 | } 36 | }) 37 | }, 38 | 39 | onReady () { 40 | console.log('onReady') 41 | }, 42 | 43 | onStart () { 44 | this.slotMachine.start() 45 | } 46 | 47 | }) 48 | -------------------------------------------------------------------------------- /pages/slotMachine/slotMachine.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "老虎机" 3 | } 4 | -------------------------------------------------------------------------------- /pages/slotMachine/slotMachine.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序老虎机组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pages/slotMachine/slotMachine.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/slotMachine/slotMachine.wxss' 2 | 3 | .index-hd { 4 | padding: 80rpx; 5 | text-align: center; 6 | padding: 20rpx 26rpx 40rpx; 7 | } 8 | 9 | .index-desc { 10 | margin-top: 20rpx; 11 | color: #888888; 12 | font-size: 28rpx; 13 | } 14 | 15 | .index-tip{ 16 | color: #888; 17 | font-size: 28rpx; 18 | text-align: center; 19 | margin: 20rpx 0; 20 | } 21 | 22 | button{ 23 | margin-top: 40rpx; 24 | width: 400rpx; 25 | } -------------------------------------------------------------------------------- /pages/wheel/wheel.js: -------------------------------------------------------------------------------- 1 | import Wheel from '../../components/wheel/wheel.js' 2 | 3 | Page({ 4 | data: { 5 | mode: 1 6 | }, 7 | 8 | onLoad () { 9 | const self = this 10 | this.wheel = new Wheel(this, { 11 | areaNumber: 8, 12 | speed: 16, 13 | awardNumer: 1, 14 | mode: 1, 15 | callback: () => { 16 | wx.showModal({ 17 | title: '提示', 18 | content: '恭喜您,中奖了', 19 | showCancel: false, 20 | success: res => { 21 | self.wheel.reset() 22 | if (res.confirm) { 23 | console.log('用户点击确定') 24 | } else if (res.cancel) { 25 | console.log('用户点击取消') 26 | } 27 | } 28 | }) 29 | } 30 | }) 31 | }, 32 | 33 | onReady () { 34 | console.log('onReady') 35 | }, 36 | 37 | onSwitchMode (event) { 38 | const mode = event.currentTarget.dataset.mode 39 | this.setData({ mode }) 40 | this.wheel.switch(mode) 41 | } 42 | 43 | }) 44 | -------------------------------------------------------------------------------- /pages/wheel/wheel.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "大转盘" 3 | } 4 | -------------------------------------------------------------------------------- /pages/wheel/wheel.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 以下是小程序大转盘组件,组件样式仅供参考,开发者可根据自身需求自定义组件样式,具体属性参数详见开发文档。 6 | 7 | 8 | 9 | 选择旋转物体: 10 | 指针旋转 11 | 大转盘旋转 12 | 13 | 14 | 15 | tip: 点击开始抽奖 16 | 17 | 18 | -------------------------------------------------------------------------------- /pages/wheel/wheel.wxss: -------------------------------------------------------------------------------- 1 | @import '../../components/wheel/wheel.wxss' 2 | .index-hd { 3 | padding: 80rpx; 4 | text-align: center; 5 | padding: 20rpx 26rpx 40rpx; 6 | } 7 | 8 | .index-desc { 9 | margin-top: 20rpx; 10 | color: #888; 11 | font-size: 28rpx; 12 | } 13 | 14 | .index-tip{ 15 | color: #888; 16 | font-size: 28rpx; 17 | text-align: center; 18 | margin: 20rpx 0; 19 | } 20 | .index-mod{ 21 | margin: 30rpx 80rpx 60rpx 60rpx; 22 | color: #888; 23 | } 24 | .index-mod text{ 25 | display: inline-block; 26 | line-height: 20px; 27 | } 28 | .index-mod-btn{ 29 | display: inline-block; 30 | flex: 1; 31 | height: 20px; 32 | line-height: 20px; 33 | text-align: center; 34 | border: 1px solid #666; 35 | border-radius: 6rpx; 36 | font-size: 12px; 37 | padding: 0 20rpx; 38 | } 39 | .index-mod-btn.on{ 40 | color: #3985ff; 41 | border: 1px solid #3985ff; 42 | } 43 | .index-mod-btn:last-child{ 44 | margin-left: 20rpx; 45 | } -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": true, 6 | "postcss": false, 7 | "minified": true, 8 | "newFeature": true 9 | }, 10 | "compileType": "miniprogram", 11 | "libVersion": "1.5.3", 12 | "appid": "wx4886dac7da9bd358", 13 | "projectname": "%E8%90%A5%E9%94%80%E7%BB%84%E4%BB%B6", 14 | "condition": { 15 | "search": { 16 | "current": -1, 17 | "list": [] 18 | }, 19 | "conversation": { 20 | "current": -1, 21 | "list": [] 22 | }, 23 | "game": { 24 | "list": [] 25 | }, 26 | "miniprogram": { 27 | "current": -1, 28 | "list": [ 29 | { 30 | "id": 0, 31 | "name": "手势解锁", 32 | "pathName": "pages/gestureLock/gestureLock", 33 | "query": "" 34 | }, 35 | { 36 | "id": -1, 37 | "name": "search", 38 | "pathName": "pages/search/list/list", 39 | "query": "" 40 | } 41 | ] 42 | } 43 | } 44 | } --------------------------------------------------------------------------------