├── .babelrc ├── .gitattributes ├── .gitignore ├── .jshintrc ├── README.md ├── app ├── css │ ├── layout.css │ ├── lottery.css │ └── myreset.css ├── img │ ├── 100x100.png │ └── favicon.ico ├── js │ ├── base.js │ ├── calc.js │ ├── index.js │ ├── interface.js │ ├── lottery.js │ └── time.js └── views │ ├── error.ejs │ └── index.ejs ├── gulpfile.babel.js ├── npm-debug.log ├── package.json ├── resource ├── .DS_Store ├── .babelrc ├── .gitignore ├── LICENSE ├── README.md ├── app │ ├── css │ │ ├── layout.css │ │ ├── lottery.css │ │ └── reset.css │ ├── js │ │ ├── .DS_Store │ │ ├── class │ │ │ ├── .DS_Store │ │ │ ├── lesson1.js │ │ │ ├── lesson10.js │ │ │ ├── lesson11.js │ │ │ ├── lesson12.js │ │ │ ├── lesson13.js │ │ │ ├── lesson14.js │ │ │ ├── lesson15.js │ │ │ ├── lesson16.js │ │ │ ├── lesson17.js │ │ │ ├── lesson2.js │ │ │ ├── lesson3.js │ │ │ ├── lesson4.js │ │ │ ├── lesson5.js │ │ │ ├── lesson6.js │ │ │ ├── lesson7.js │ │ │ ├── lesson8.js │ │ │ ├── lesson9.js │ │ │ └── test.js │ │ ├── index.js │ │ ├── lottery.js │ │ └── lottery │ │ │ ├── base.js │ │ │ ├── calculate.js │ │ │ ├── interface.js │ │ │ └── timer.js │ └── views │ │ ├── error.ejs │ │ └── index.ejs ├── gulpfile.babel.js ├── package.json ├── server │ ├── app.js │ ├── bin │ │ └── www │ ├── package.json │ ├── public │ │ ├── css │ │ │ ├── layout.css │ │ │ ├── lottery.css │ │ │ └── reset.css │ │ └── js │ │ │ ├── cp.min.js │ │ │ └── index.js │ ├── routes │ │ ├── index.js │ │ └── users.js │ └── views │ │ ├── error.ejs │ │ └── index.ejs └── tasks │ ├── browser.js │ ├── build.js │ ├── clean.js │ ├── css.js │ ├── default.js │ ├── pages.js │ ├── scripts.js │ ├── server.js │ └── util │ └── args.js ├── server ├── app.js ├── bin │ └── www ├── package.json ├── public │ ├── css │ │ ├── layout.css │ │ ├── lottery.css │ │ └── myreset.css │ ├── img │ │ ├── 100x100.png │ │ └── favicon.ico │ └── js │ │ ├── base.js │ │ ├── calc.js │ │ ├── cp.min.js │ │ ├── index.js │ │ ├── interface.js │ │ ├── lottery.js │ │ └── time.js ├── routes │ ├── index.js │ └── users.js └── views │ ├── error.ejs │ └── index.ejs └── tasks ├── .jshintrc ├── browser.js ├── build.js ├── clean.js ├── default.js ├── pages.js ├── scripts.js ├── server.js ├── styles.js └── util └── args.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | // ES6 转 ES5 3 | "presets": ["es2015"] 4 | } 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | // Enforcing options 3 | // http://jshint.com/docs/options/#enforcing-options 4 | 5 | "esversion": 6, 6 | "eqeqeq": true 7 | // "sub": true, 8 | // "laxbreak": true, 9 | // "laxcomma": true, 10 | // "regexp": true, 11 | // "asi": true, 12 | // "browser": true, 13 | // "loopfunc": true, 14 | // "expr": true, 15 | // "jquery": true, 16 | // "node": true, 17 | // "es5": true, 18 | // "esnext": true, 19 | // "bitwise": true, 20 | // "curly": true, 21 | // "immed": true, 22 | // "latedef": false, 23 | // "expr": true, 24 | // "eqnull": false, 25 | // "newcap": true, 26 | // "noarg": true, 27 | // "undef": true, 28 | // "proto": true, 29 | // "strict": false, 30 | // "smarttabs": true, 31 | // "forin": true, 32 | // "nonbsp": true, 33 | // "nonew": true, 34 | // "unused": true, 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # 彩票项目(11选5) 3 | 4 | ![项目演示图片](http://oph264zoo.bkt.clouddn.com/17-7-3/87703335.jpg) 5 | 6 | 👉 GitHub: https://github.com/bxm0927/lottery 7 | 8 | 👉 项目演示地址: http://es6lottery.t.imooc.io 9 | 10 | ## 项目简介 11 | 12 | 这一个彩票项目(11选5),大量使用 ES6 原生语法,也是为了学习 ES6 而实战的项目。本案例通过业务需求分析、项目架构思考、需求划分模块、前端代码编写、部署服务器端程序、前后端接口联调测试、部署上线几个步骤,真实还原实际业务开发流程。 13 | 14 | 本项目主要功能模块:期号自动更新、倒计时、开售状态、玩法切换、自主选号、随机选号、金额计算、奖金预测等。 15 | 16 | ## 技术栈 17 | 18 | - **Sass(Scss)**: 预编译 CSS,方便快捷 19 | - **ES6**: 这是以后的趋势,let、const、class、箭头函数、Set Map 数据结构、Promise 等新特性十分实用 20 | - **Gulp**: 编写 gulp 脚本完成ES6的自动编译、打包、文件监听、浏览器热更新、模板自动更新、服务热启动等 21 | - **Babel**: gulp 的一个插件,实现了 ES6 转 ES5 22 | - **Webpack**: 自动编译 23 | - **Express.js**: 搭建服务器 24 | - **mockjs**: 模拟后端数据,与前端实现数据对接 25 | 26 | ## 收获 27 | 28 | 1. 初步掌握了 ES6 29 | 2. 领悟了模块化编程的好处 30 | 3. 加深对 gulp 自动化配置的掌握 31 | 4. 了解了一个项目完整的开发流程 32 | 33 | ## Build Setup 34 | 35 | ``` 36 | # clone the repo into your disk. 37 | $ git clone https://github.com/bxm0927/lottery.git 38 | 39 | # run gulp 40 | $ gulp --watch 41 | 42 | # visit 43 | $ http://localhost:3000/ 44 | ``` 45 | -------------------------------------------------------------------------------- /app/css/myreset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * 作品:myreset.css 3 | * 维护:白小明 4 | * 更新:2017年6月21日 5 | * 理念:1. 适应中文,基于最新主流浏览器 6 | * 2. reset 的目的不是清除浏览器的默认样式,这仅是部分工作。清除和重置是紧密不可分的。 7 | * 3. reset 的目的不是让默认样式在所有浏览器下一致,而是减少默认样式有可能带来的问题。 8 | */ 9 | 10 | /* 清除内外边距 */ 11 | @charset "utf-8"; 12 | body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, 13 | pre,dl, dt, dd, ul, ol, li, 14 | form, fieldset, lengend, button, input, textarea, 15 | th, td { margin: 0; padding: 0; } 16 | 17 | /* 重置列表元素 */ 18 | ul, ol { list-style: none; } 19 | 20 | /* 重置文本格式元素 */ 21 | a { text-decoration: none; } 22 | q:before, q:after { content: ''; } 23 | 24 | /* 重置表单元素 */ 25 | legend { color: #000; } /* for ie6 */ 26 | button, textarea { font-size: 100%; border: 0; } /* 使得表单元素在 ie 下能继承字体大小 */ 27 | fieldset, img { border: 0; } /* img 搭车:让链接里的 img 无边框 */ 28 | 29 | /* 重置表格元素 */ 30 | table { border-collapse: collapse; border-spacing: 0; } 31 | 32 | /* 清除浮动 */ 33 | .fl { float: left; } 34 | .fr { float: right; } 35 | .clearfix:after { display: block; clear: both; content: ""; visibility: hidden; height: 0; } 36 | .clearfix { zoom: 1; } 37 | 38 | /* 文字选中效果 */ 39 | ::selection { 40 | background-color: #b3d4fc; 41 | text-shadow: none; 42 | } 43 | 44 | /* 浏览器升级 */ 45 | .browser-up { 46 | padding: 1rem; 47 | background: #ccc; 48 | text-align: center; 49 | } 50 | -------------------------------------------------------------------------------- /app/img/100x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/app/img/100x100.png -------------------------------------------------------------------------------- /app/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/app/img/favicon.ico -------------------------------------------------------------------------------- /app/js/base.js: -------------------------------------------------------------------------------- 1 | // 基础功能模块 2 | 3 | import $ from 'jquery'; 4 | 5 | class Base { 6 | /** 7 | * 初始化各玩法的说明 8 | * @return {[type]} [description] 9 | */ 10 | initTypeList() { 11 | // type_list 是一个 Map 数据结构 12 | this.type_list 13 | .set('r2', { 14 | name: '任二', 15 | bouns: 6, 16 | tip: '从01~11中任选两个或多个号码,所选中号码与开奖号码任意两个号码相同,即中奖6元', 17 | }) 18 | .set('r3', { 19 | name: '任三', 20 | bouns: 19, 21 | tip: '从01~11中任选三个或多个号码,所选中号码与开奖号码任意三个号码相同,即中奖19元', 22 | }) 23 | .set('r4', { 24 | name: '任四', 25 | bouns: 78, 26 | tip: '从01~11中任选四个或多个号码,所选中号码与开奖号码任意四个号码相同,即中奖78元', 27 | }) 28 | .set('r5', { 29 | name: '任五', 30 | bouns: 540, 31 | tip: '从01~11中任选五个或多个号码,所选中号码与开奖号码号码相同,即中奖540元', 32 | }) 33 | .set('r6', { 34 | name: '任六', 35 | bouns: 90, 36 | tip: '从01~11中任选六个或多个号码,所选中号码与开奖号码五个号码相同,即中奖90元', 37 | }) 38 | .set('r7', { 39 | name: '任七', 40 | bouns: 26, 41 | tip: '从01~11中任选七个或多个号码,所选中号码与开奖号码五个号码相同,即中奖26元', 42 | }) 43 | .set('r8', { 44 | name: '任八', 45 | bouns: 9, 46 | tip: '从01~11中任选八个或多个号码,所选中号码与开奖号码五个号码相同,即中奖9元', 47 | }); 48 | } 49 | 50 | /** 51 | * 初始化1~11号码 52 | * @return {[type]} [description] 53 | */ 54 | initNumber() { 55 | for (let i = 0; i < 12; i++) { 56 | // number 是一个 Set 数据结构 57 | this.number.add(('' + i).padStart(2, '0')); 58 | } 59 | } 60 | 61 | /** 62 | * 设置遗漏数据 63 | * @param {Map} omit 遗漏数据的 Map 集合 64 | */ 65 | setOmit(omit) { 66 | // 逻辑:先清空,再重新赋值 67 | let self = this; 68 | self.omit.clear(); 69 | 70 | for (let [key, value] of omit.entries()) { 71 | self.omit.set(key, value); 72 | } 73 | // 反映到 DOM 上 74 | $(self.omit_el).each(function(index, el) { 75 | $(el).text(self.omit.get(key)); 76 | }); 77 | } 78 | 79 | /** 80 | * 设置开奖数据 81 | * @param {Map} open_code 开奖数据的 Set 集合 82 | */ 83 | setOpenCode(code) { 84 | // 逻辑:先清空,再重新赋值 85 | let self = this; 86 | self.open_code.clear(); 87 | 88 | for (let item of open_code.values()) { 89 | self.open_code.add(item); 90 | } 91 | // 调用接口 92 | if (self.updateOpenCode) { 93 | self.updateOpenCode.call(self, code); 94 | } 95 | } 96 | 97 | /** 98 | * 号码选中与取消 99 | * @param {[type]} e [description] 100 | * @return {[type]} [description] 101 | */ 102 | toggleCodeActive(e) { 103 | let self = this; 104 | let $cur = $(e.currentTarget); 105 | $cur.toggleClass('btn-boll-active'); 106 | self.getCount(); 107 | } 108 | 109 | /** 110 | * 切换玩法 111 | * @param {[type]} e [description] 112 | * @return {[type]} [description] 113 | */ 114 | changePlayNav(e) { 115 | let self = this; 116 | let $cur = $(e.currentTarget); 117 | // 选中的 active,没选中的去掉 active 118 | $cur.addClass('active').siblings().removeClass('active'); 119 | // 获取玩法字符串,并转为小写 120 | self.cur_play = $cur.attr('desc').toLocaleLowerCase(); 121 | // 更新 DOM 122 | $('#zx_sm span').html(self.type_list.get(self.cur_play).tip); 123 | // 切换玩法后要把上次选中的号码重置 124 | $('.boll-list .btn-boll').removeClass('.btn-boll-sctive'); 125 | self.getCount(); 126 | } 127 | 128 | /** 129 | * 操作区:全 大 小 奇 偶 清空 130 | * @param {[type]} e [description] 131 | * @return {[type]} [description] 132 | */ 133 | assistHandle(e) { 134 | e.preventDefault(); 135 | let self = this; 136 | let $cur = $(e.currentTarget); 137 | let index = $cur.index(); 138 | 139 | $('.boll-list .btn-boll').removeClass('.btn-boll-sctive'); 140 | 141 | // 全选 142 | if (index === 0) { 143 | $('.boll-list .btn-boll').addClass('.btn-boll-sctive'); 144 | } 145 | 146 | // 大 147 | if (index === 1) { 148 | $('.boll-list .btn-boll').each(function(index, el) { 149 | if (el.textContent > 6) { 150 | $(el).addClass('.btn-boll-sctive'); 151 | } 152 | }); 153 | } 154 | 155 | // 小 156 | if (index === 2) { 157 | $('.boll-list .btn-boll').each(function(index, el) { 158 | if (el.textContent < 6) { 159 | $(el).addClass('.btn-boll-sctive'); 160 | } 161 | }); 162 | } 163 | 164 | // 奇 165 | if (index === 3) { 166 | $('.boll-list .btn-boll').each(function(index, el) { 167 | if (el.textContent % 2 === 1) { 168 | $(el).addClass('.btn-boll-sctive'); 169 | } 170 | }); 171 | } 172 | 173 | // 偶 174 | if (index === 4) { 175 | $('.boll-list .btn-boll').each(function(index, el) { 176 | if (el.textContent % 2 === 0) { 177 | $(el).addClass('.btn-boll-sctive'); 178 | } 179 | }); 180 | } 181 | 182 | self.getCount(); 183 | } 184 | 185 | /** 186 | * 获取当前彩票的名称 187 | * @return {[type]} [description] 188 | */ 189 | getName() { 190 | return this.name; 191 | } 192 | 193 | /** 194 | * 添加号码到购物车 195 | */ 196 | addCode() { 197 | let self = this; 198 | // 拿到选择的号码,\d 查找数字,[01 ,02, 03, 04] 199 | let $active = $('.boll-list .btn-boll-active').text().match(/\d{2}/g); 200 | let active = $active ? $active.length : 0; 201 | let count = self.calcCount(active, self.cur_play); 202 | 203 | if (count) { 204 | // join() 方法用于把数组中的所有元素放入一个字符串。 205 | self.addCodeItem($active.join(' '), self.cur_play, self.type_list.get(self.cur_play).name, count); 206 | } 207 | } 208 | 209 | /** 210 | * 添加单次号码到购物车 211 | * @param {[type]} code [description] 212 | * @param {[type]} type [description] 213 | * @param {[type]} typeName [description] 214 | * @param {[type]} count [description] 215 | */ 216 | addCodeItem(code, type, typeName, count) { 217 | let self = this; 218 | const tpl = ` 219 |
  • 220 |
    221 | ${typeName}${count>1?'复式':'单式'} 222 | ${code} 223 | [${count}注,${count*2}元] 224 |
    225 |
  • 226 | `; 227 | // 反映到 DOM 228 | $(self.cart_el).append(tpl); 229 | self.getTotal(); 230 | } 231 | 232 | getCount() { 233 | let self = this; 234 | let active = $('.boll-list .btn-boll-active').length; 235 | // 当前选中的注数 236 | let count = self.calcCount(active, self.cur_play); 237 | // 计算奖金范围 238 | let range = self.calcBonus(active, self.cur_play); 239 | let money = count * 2; 240 | let win1 = range[0] - money; 241 | let win2 = range[1] - money; 242 | let tpl; 243 | let c1 = (win1 < 0 && win2 < 0) ? Math.abs(win1) : win1; 244 | let c2 = (win1 < 0 && win2 < 0) ? Math.abs(win2) : win2; 245 | 246 | if (count === 0) { 247 | tpl = `您选了${count}注,共${count*2}元`; 248 | } else if (range[0] === range[1]) { 249 | tpl = ` 250 | 您选了${count}注,共${count*2}元, 251 | 若中奖,奖金:${range[0]}元, 252 | 您将${win1>=0?'盈利':'亏损'} 253 | ${Math.abs(win1)} 254 | `; 255 | } else { 256 | tpl = ` 257 | 您选了${count}注,共${count*2}元, 258 | 若中奖,奖金:${range[0]}元至${range[1]}元, 259 | 您将${(win1>=0&&win2>=0)?'盈利':'亏损'} 260 | ${c1}至 261 | ${c2}元 262 | `; 263 | } 264 | $('.sel_info').html(tpl); 265 | } 266 | 267 | /** 268 | * 计算购物车总金额 269 | * @return {[type]} [description] 270 | */ 271 | getTotal() { 272 | let count = 0; 273 | $('.codelist li').each(function(index, el) { 274 | count += $(el).attr('count') * 1; 275 | }); 276 | $('#count').text(count); 277 | $('#money').text(count * 2); 278 | } 279 | 280 | /** 281 | * 生成随机数 282 | * @param {number} num 随机数的个数 283 | * @return {[type]} [description] 284 | */ 285 | getRandom(num) { 286 | let arr = []; 287 | let index; 288 | // 将 Set 转为 Array 289 | let number = Array.from(this.number); 290 | 291 | while (num--) { 292 | index = Number.parseInt(Math.random() * number.length); 293 | arr.push(number[index]); 294 | // 保证每次号码不重复 295 | number.splice(inde, 1); 296 | } 297 | return arr.join(' '); 298 | } 299 | 300 | /** 301 | * 随机选号 302 | * @param {[type]} e [description] 303 | * @return {[type]} [description] 304 | */ 305 | getRandomCode(e) { 306 | e.preventDefault(); 307 | // 获取注数 308 | let num = e.currentTarget.getAttribute('count'); 309 | // 获取玩法,如:3 310 | let type = this.cur_play.match(/\d+/g)[1]; 311 | let self = this; 312 | 313 | if (num === '0') { 314 | $(self.cart_el).html(''); 315 | } else { 316 | for (let i = 0; i < num; i++) { 317 | self.addCodeItem(self.getRandom(type), self.cur_play, self.type_list.get(self.cur_play).name, 1); 318 | } 319 | } 320 | } 321 | } 322 | 323 | export default Base; 324 | -------------------------------------------------------------------------------- /app/js/calc.js: -------------------------------------------------------------------------------- 1 | // 计算模块 2 | // 您选了15注,共30元,若中奖,奖金:6元至60元,您将盈利-24元至30元 3 | 4 | class Calc { 5 | /** 6 | * 排列组合运算 7 | * @param {array} arr 选号列表,如:[01, 02, 03, 04] 8 | * @param {number} size 玩法后缀,如:3 9 | * @return {number} 注数 10 | */ 11 | static combine(arr, size) { 12 | // 保存最后各种组合的结果 13 | let allResult = []; 14 | 15 | // restlt 初始为 [] 16 | (function f(arr, size, restlt) { 17 | let arrLen = arr.length; 18 | 19 | if (arrLen < size) { 20 | return; 21 | } 22 | if (arrLen === size) { 23 | allResult.push([].concat(restlt, arr)) // [01, 02, 03] 24 | } else { 25 | // 不断增加新的数组 26 | for (let i = 0; i < arrLen; i++) { 27 | // 保存上次运行结果 28 | let newResult = [].concat(result); 29 | newResult.push(arr[i]); 30 | 31 | // 如果选择的是‘任一’,则结束计算 32 | if (size === 1) { 33 | allResult.push(newResult); 34 | } else { 35 | // 保存上次运行结果 36 | let newArr = [].concat(result); 37 | // 重点!截取数组片段 38 | newArr.splice(0, i + 1); 39 | // 递归 40 | f(newArr, size - 1, newResult); 41 | } 42 | } 43 | } 44 | })(arr, size, []); 45 | 46 | return allResult; 47 | } 48 | 49 | /** 50 | * 当前选中的注数 51 | * @param {number} active 当前选中的号码的个数 52 | * @param {string} type 当前选中的玩法类型,如:r3(任三) 53 | * @return {number} 注数 54 | */ 55 | calcCount(active, type) { 56 | let count = 0; 57 | // type_list 是一个 Map 数据结构 58 | const exist = this.type_list.has(type); 59 | // 生成一个长度为 active 的数组,并全部填充 0 60 | const arr = new Array(active).fill(0); 61 | 62 | if (exist && type.at(0) === 'r') { 63 | // 取 rx 后面的 x 64 | count = Calc.combine(arr, type.split('')[1]).length; 65 | } 66 | return count; 67 | } 68 | 69 | /** 70 | * 计算奖金范围 71 | * @param {number} active 当前选中的号码的个数 72 | * @param {string} type 当前选中的玩法类型,如:r3(任三) 73 | * @return {array} [min, max] 74 | */ 75 | calcBonus(active, type) { 76 | const self = this; 77 | let type_split = type.split(''); // ['r', '3'] 78 | // string 隐式转换成 number 79 | let arr = new Array(type_split[1] * 1).fill(0); 80 | let min, max; 81 | 82 | if (type_split[0] === 'r') { 83 | // 最小命中数 84 | let min_active = active - 6; 85 | 86 | if (min_active > 0) { 87 | if (min_active - type_split[1] >= 0) { 88 | arr = new Array(min_active).fill(0); 89 | min = Calc.combine(arr, type_split[1]).length; 90 | } else { 91 | // 是否是‘任6 7 8’ 92 | if (type_split[1] - 5 > 0 && active - type_split[1] >= 0) { 93 | arr = new Array(active - 5).fill(0); 94 | min = Calc.combine(arr, type_split[1] - 5).length; 95 | } else { 96 | min = active - type_split[1] > 1 ? 1 : 0; 97 | } 98 | } 99 | } else { 100 | min = active - type_split[1] > -1 ? 1 : 0; 101 | } 102 | 103 | // 最大命中数 104 | let max_active = Math.min(active, 5); 105 | 106 | if (type_split[1] - 5 > 0) { 107 | if (active - type_split[1] >= 0) { 108 | arr = new Array(active - 5).fill(0); 109 | min = Calc.combine(arr, type_split[1] - 5).length; 110 | } else { 111 | max = 0; 112 | } 113 | } else if (type_split[1] - 5 < 0) { 114 | arr = new Array(Math.min(active, 5)).fill(0); 115 | min = Calc.combine(arr, type_split[1]).length; 116 | } else { 117 | max = 1; 118 | } 119 | } 120 | return [min,max].map((item) => { 121 | return item*self.type_list.get(type.bonus); 122 | }); 123 | } 124 | } 125 | 126 | export default Calc; 127 | -------------------------------------------------------------------------------- /app/js/index.js: -------------------------------------------------------------------------------- 1 | // 入口文件 2 | import Lottery from './lottery.js'; 3 | 4 | const syy = new Lottery(); 5 | -------------------------------------------------------------------------------- /app/js/interface.js: -------------------------------------------------------------------------------- 1 | // 接口模块 2 | // 期号接口、倒计时 end 时间戳接口、销售状态接口、遗漏接口、开奖号接口 3 | 4 | import $ from 'jquery'; 5 | 6 | class Interface { 7 | /** 8 | * 遗漏接口 9 | * @param {string} issue 当前期号 10 | * @return {[type]} [description] 11 | */ 12 | getOmit(issue) { 13 | let self = this; 14 | return new Promise((resolve, reject) => { 15 | $.ajax({ 16 | url: '/get/omit', 17 | dataType: 'json', 18 | data: { issue: issue }, 19 | success: function(res) { 20 | self.setOmint(res.data); 21 | resolve.call(self, res); 22 | }, 23 | error: function(err) { 24 | reject.call(err); 25 | } 26 | }); 27 | }); 28 | } 29 | 30 | /** 31 | * 开奖号接口 32 | * @param {string} issue 当前期号 33 | * @return {[type]} [description] 34 | */ 35 | getOpenNumber(issue) { 36 | let self = this; 37 | return new Promise((resolve, reject) => { 38 | $.ajax({ 39 | url: '/get/openNumber', 40 | dataType: 'json', 41 | data: { issue: issue }, 42 | success: function(res) { 43 | self.setOpenNumber(res.data); 44 | resolve.call(self, res); 45 | }, 46 | error: function(err) { 47 | reject.call(err); 48 | } 49 | }); 50 | }); 51 | } 52 | 53 | /** 54 | * 销售状态接口 55 | * @param {string} issue 当前期号 56 | * @return {[type]} [description] 57 | */ 58 | getState(issue) { 59 | let self = this; 60 | return new Promise((resolve, reject) => { 61 | $.ajax({ 62 | url: '/get/state', 63 | dataType: 'json', 64 | data: { issue: issue }, 65 | success: function(res) { 66 | resolve.call(self, res); 67 | }, 68 | error: function(err) { 69 | reject.call(err); 70 | } 71 | }); 72 | }); 73 | } 74 | } 75 | 76 | export default Interface; 77 | -------------------------------------------------------------------------------- /app/js/lottery.js: -------------------------------------------------------------------------------- 1 | // 集成模块 2 | 3 | import 'babel-polyfill'; 4 | import $ from 'jquery'; 5 | import Base from './base.js'; 6 | import Interface from './interface.js'; 7 | import Calc from './calc.js'; 8 | import Time from './time.js'; 9 | 10 | /** 11 | * 深拷贝 12 | * @param {[type]} target [description] 13 | * @param {[type]} source [description] 14 | * @return {[type]} [description] 15 | */ 16 | const copyProperties = function(target, source) { 17 | // Reflect.ownKeys()方法返回target对象自己的属性键的数组。 18 | for (let key of Reflect.ownKeys(source)) { 19 | if (key !== 'constructor' && key !== 'prototype' && key !== 'name') { 20 | // 获取指定对象的自身属性描述符 21 | let desc = Object.getOwnPropertyDescriptor(source, key); 22 | Object.defineProperty(target, key, desc); 23 | } 24 | } 25 | }; 26 | 27 | /** 28 | * 类的多重继承 29 | * @param {...[type]} rest [description] 30 | * @return {[type]} [description] 31 | */ 32 | const mix = function(...rest) { 33 | class Mix {} 34 | for (let item of rest) { 35 | copyProperties(Mix, item); 36 | copyProperties(Mix.prototype, item.prototype); 37 | } 38 | return Mix; 39 | }; 40 | 41 | class Lottery extends mix(Base, Interface, Calc, Time) { 42 | // name 用于标识彩种 43 | // cname 彩种名称 44 | // issue 期号 45 | // state 销售状态 46 | constructor(name = 'syy', cname = '11选5', issue = '**', state = '**') { 47 | super(); 48 | this.name = name; 49 | this.cname = cname; 50 | this.issue = issue; 51 | this.state = state; 52 | 53 | // 遗漏 54 | this.omit = new Map(); 55 | // 玩法列表 56 | this.type_list = new Map(); 57 | // 初始化1~11号码 58 | this.number = new Set(); 59 | // 开奖号码 60 | this.open_code = new Set(); 61 | this.open_code_list = new Map(); 62 | 63 | this.el = ''; 64 | // 期号选择器 65 | this.issue_el = '#curr_issue'; 66 | // 状态选择器 67 | this.state_el = '.state_el'; 68 | // 倒计时选择器 69 | this.countdown_el = '#countdown'; 70 | // 购物车选择器 71 | this.cart_el = '.codelist'; 72 | // 遗漏选择器 73 | this.omit_el = ''; 74 | // 当前玩法选择器 75 | this.cur_play = 'r5'; 76 | 77 | // 初始化各玩法的说明 78 | this.initTypeList(); 79 | // 初始化1~11号码 80 | this.initNumber(); 81 | this.updateState(); 82 | this.initEvent(); 83 | } 84 | 85 | /** 86 | * 各种更新 87 | * @return {[type]} [description] 88 | */ 89 | updateState() { 90 | let self = this; 91 | this.getState().then(function(res) { 92 | self.issue = res.issue; 93 | self.end_time = res.end_time; 94 | self.state = res.state; 95 | // 更新当前期号 96 | $(self.issue_el).text(res.issue); 97 | // 更新倒计时 98 | self.countDown(res.end_time, function(time) { 99 | $(self.countdown_el).text(time); 100 | }, function() { 101 | setTimeout(function() { 102 | self.updateState(); 103 | self.getOmit(this.issue).then(function(res) { 104 | // body... 105 | }); 106 | self.getOpenNumber(this.issue).then(function(res) { 107 | // body... 108 | }); 109 | }, 500); 110 | }); 111 | }); 112 | } 113 | 114 | /** 115 | * 初始化事件 116 | * @return {[type]} [description] 117 | */ 118 | initEvent() { 119 | let self = this; 120 | // 玩法切换 121 | $('#plays').on('click', 'li', self.changePlayNav.bind(self)); 122 | // 号码的选中 123 | $('.boll-list').on('click', '.btn-boll', self.toggleCodeActive.bind(self)); 124 | // 添加号码 125 | $('#confirm_sel_code').on('click', self.addCode.bind(self)); 126 | // 清空 127 | $('.dxjo').on('click', 'li', self.assistHandle.bind(self)); 128 | // 随机号码 129 | $('.qkmethod').on('click', '.btn-middle', self.getRandomCode.bind(self)); 130 | } 131 | } 132 | 133 | export default Lottery; 134 | -------------------------------------------------------------------------------- /app/js/time.js: -------------------------------------------------------------------------------- 1 | // 时间模块 2 | 3 | class Time { 4 | /** 5 | * 倒计时 6 | * @param {Number} end 截止时间 7 | * @param {[type]} update 时间更新的回调 8 | * @param {[type]} handle 结束回调 9 | * @return {[type]} [description] 10 | */ 11 | countDown(end, update, handle) { 12 | // now 1498917683022 13 | // end 1498917826710 14 | const now = new Date().getTime(); 15 | const self = this; 16 | 17 | if (now - end > 0) { 18 | handle.call(self); 19 | } else { 20 | // 剩余时间 21 | let last_time = end - now; 22 | 23 | const d_to_ms = 24 * 60 * 60 * 1000; 24 | const h_to_ms = 60 * 60 * 1000; 25 | const m_to_ms = 60 * 1000; 26 | const s_to_ms = 1000; 27 | 28 | let d = Math.floor(last_time / d_to_ms); 29 | let h = Math.floor((last_time - d * d_to_ms) / h_to_ms); 30 | let m = Math.floor((last_time - d * d_to_ms - h * h_to_ms) / m_to_ms); 31 | let s = Math.floor((last_time - d * d_to_ms - h * h_to_ms - m * m_to_ms) / s_to_ms); 32 | 33 | let arr = []; 34 | 35 | if (d > 0) { 36 | arr.push(`${d}天`); 37 | } 38 | if (h > 0 || arr.length > 0) { 39 | arr.push(`${h}小时`); 40 | } 41 | if (m > 0 || arr.length > 0) { 42 | arr.push(`${m}分钟`); 43 | } 44 | if (s > 0 || arr.length > 0) { 45 | arr.push(`${s}秒`); 46 | } 47 | 48 | self.last_time = arr.join(''); 49 | update.call(self, arr.join('')); 50 | 51 | setTimeout(function() { 52 | self.countDown(end, update, handle); 53 | }, 1000); 54 | } 55 | } 56 | } 57 | 58 | export default Time; 59 | -------------------------------------------------------------------------------- /app/views/error.ejs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/app/views/error.ejs -------------------------------------------------------------------------------- /app/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 彩票项目(11选5) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 35 | 36 |
    37 |
    38 |
    39 |
    40 | 43 |

    11选5 **

    44 |
      45 |
    • 购彩剩余时间:
    • 46 |
    • 47 |
    • 48 | 销售:9:00~22:00(78期) 10分钟开奖 返奖59% 49 |
    • 50 |
    51 | 暂停销售 52 |
    53 |
    54 | 75 |
    76 |
    77 | 78 |
    79 | 90 |
    91 | 92 | 93 |
    94 | 95 |
    96 |
    97 |
    98 |
    99 |

    玩法提示:从01~11中任选5个或多个号码,所选号码与开奖号码相同,即中奖540

    100 |
    101 |
    102 |
    103 |

    104 | 105 | 选号区 至少选5个 106 | 107 | 操作区 快捷选号 108 |

    109 |
    110 |
    111 |
    112 |
    113 |
    114 | 号码 115 | 遗漏 116 |
    117 |
    118 |
    119 |
      120 |
    • 010
    • 121 |
    • 020
    • 122 |
    • 035
    • 123 |
    • 041
    • 124 |
    • 051
    • 125 |
    • 062
    • 126 |
    • 070
    • 127 |
    • 083
    • 128 |
    • 090
    • 129 |
    • 101
    • 130 |
    • 110
    • 131 |
    132 |
    133 |
    134 |
    135 |
    136 | 144 |
    145 |
    146 |
    147 |
    148 |
    149 |

    您选了 0 注,共 0

    150 |
    151 |
    152 |
    153 |
    154 |
    155 |
    156 |
    157 | 158 | 清空选号 159 |
    160 |
    161 |
    162 |
    163 |
      164 |
      165 |
      166 |
      167 | 173 |
      174 |
      175 |
      176 |
      177 |
      178 |
      179 | 您选了 0 注, 倍投 倍,共 0 元 180 |
      181 |
      182 |
      183 |
      184 | 185 |
      186 |
      187 | 188 | 189 |
      190 |
      191 |
      192 |

      11选5 第 022478 期 开奖

      193 |
      194 |
        195 |
      • 09
      • 196 |
      • 02
      • 197 |
      • 01
      • 198 |
      • 07
      • 199 |
      • 11
      • 200 |
      201 |
      202 |

      今天已售78期,还剩0期

      203 |
      204 |
      205 |
      206 | 207 | 208 | 209 | 210 | 211 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 |
      期号开奖号码 212 | 大小比 213 | 奇偶比 214 |
      02247809 02 01 07 113:24:1
      225 |
      226 |
      227 | 228 |
      229 |
      230 |
      231 |
      232 |
      233 | 234 | 235 | 236 | 237 | -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置默认文件 3 | * 执行: gulp --watch 4 | */ 5 | 6 | import gulp from 'gulp'; // 获取 gulp 7 | import yargs from 'yargs'; // node.js 命令行框架 8 | import requireDir from 'require-dir'; // 包含文件 9 | import del from 'del'; // 清除文件 10 | // import copy from 'copy'; // 复制文件 11 | // import rev from 'gulp-rev'; // 12 | // import revReplace from 'gulp-rev-replace'; // 13 | // import useref from 'gulp-useref'; // 14 | // import filter from 'gulp-filter'; // 15 | // import csso from 'gulp-csso'; // 16 | import gulpSequence from 'gulp-sequence'; // 设置 gulp task 的顺序 17 | import gulpif from 'gulp-if'; // gulp 判断语句 18 | import livereload from 'gulp-livereload'; // 浏览器热更新 19 | import util from 'gulp-util'; // 命令行输出 20 | import concat from 'gulp-concat'; // 字符串拼接(合并文件) 21 | import webpack from 'webpack'; // 构建 22 | import gulpWebpack from 'webpack-stream'; // 基于流的构建 23 | import plumber from 'gulp-plumber'; // 处理文件信息流 24 | import named from 'vinyl-named'; // 文件命名 25 | import rename from 'gulp-rename'; // 文件重命名 26 | import htmlmin from 'gulp-htmlmin'; // html 压缩 27 | import htmlReplace from 'gulp-html-replace'; // html 文件对合并文件后的替换处理插件 28 | import uglify from 'gulp-uglify'; // js 压缩 29 | import minifyCSS from 'gulp-minify-css'; // css 压缩 30 | import imagemin from 'gulp-imagemin'; // 图片压缩 31 | import liveserver from 'gulp-live-server'; // 启动服务器 32 | 33 | 34 | 35 | // npm install ... --save-dev 36 | 37 | // 对命令行参数进行解析 38 | const args = yargs 39 | // 生产环境,默认关闭 40 | .option('production', { 41 | boolean: true, 42 | default: false, 43 | describe: 'min all scripts' 44 | }) 45 | // 监听开发环境中的文件,自动更新 46 | .option('watch', { 47 | boolean: true, 48 | default: false, 49 | describe: 'min all files' 50 | }) 51 | // 输出命令行执行日志 52 | .option('verbose', { 53 | boolean: true, 54 | default: false, 55 | describe: 'log' 56 | }) 57 | // 压缩 58 | .option('sourcemaps', { 59 | describe: 'force the creation of sourcemaps' 60 | }) 61 | // 服务器端口 62 | .option('port', { 63 | string: true, 64 | default: 8080, 65 | describe: 'server port' 66 | }) 67 | .argv; 68 | 69 | // default task 70 | gulp.task('default', ['build']); 71 | 72 | // 设置 gulp task 的顺序 73 | gulp.task('build', gulpSequence('clean', 'pages', 'styles', 'images', 'scripts', ['browser', 'serve'])); 74 | 75 | // 清空指定文件夹里的文件(清除旧部署文件) 76 | gulp.task('clean', () => { 77 | return del(['server/public', 'server/views']); 78 | }); 79 | 80 | // 处理模板 views 信息 81 | gulp.task('pages', () => { 82 | return gulp.src('app/**/*.ejs') 83 | // 文件存放路径 84 | .pipe(gulp.dest('server')) 85 | // 热更新,若命令行中有 watch 这个参数才执行 86 | .pipe(gulpif(args.watch, livereload())); 87 | }); 88 | 89 | // 处理 css 文件 90 | gulp.task('styles', () => { 91 | return gulp.src('app/**/*.css') 92 | // 压缩文件 93 | .pipe(minifyCSS()) 94 | // 文件存放路径 95 | .pipe(gulp.dest('server/public')) 96 | // 热更新,若命令行中有 watch 这个参数才执行 97 | .pipe(gulpif(args.watch, livereload())); 98 | }); 99 | 100 | // 图片处理 101 | gulp.task('images', function() { 102 | return gulp.src('app/**/*.{png,jpg,jpeg,gif,webp,svg,ico}') 103 | // 压缩图片 104 | // .pipe(imagemin({ 105 | // progressive: true 106 | // })) 107 | // 文件存放路径 108 | .pipe(gulp.dest('server/public')) 109 | // 热更新,若命令行中有 watch 这个参数才执行 110 | .pipe(gulpif(args.watch, livereload())); 111 | }); 112 | 113 | // 处理 js 代码 114 | gulp.task('scripts', () => { 115 | return gulp.src('app/**/*.js') 116 | .pipe(plumber({ 117 | errorHandle: function() {} 118 | })) 119 | .pipe(named()) 120 | .pipe(gulpWebpack({ 121 | module: { 122 | loaders: [{ 123 | test: /\.js$/, 124 | loader: 'babel' 125 | }] 126 | } 127 | }), null, (err, stats) => { 128 | log(`Finished '${colors.cyan('scripts')}'`, stats.toString({ 129 | chunks: false 130 | })) 131 | }) 132 | .pipe(gulp.dest('server/public/js')) 133 | .pipe(rename({ 134 | basename: 'cp', 135 | extname: '.min.js' 136 | })) 137 | .pipe(uglify({ compress: { properties: false }, output: { 'quote_keys': true } })) 138 | .pipe(gulp.dest('server/public/js')) 139 | .pipe(gulpif(args.watch, livereload())) 140 | }); 141 | 142 | // 在 html 中替换调用的 js代码,以及压缩 html 143 | // 例如: a.html 调用了 a.js b.js,然后 a.js b.js在前面被合并成 c.min.js,这个 task 的作用就是将 a.html 中改成调用 c.min.js 144 | // gulp.task('htmlmin', function() { 145 | // let options = { 146 | // // 压缩HTML 147 | // collapseWhitespace: true, 148 | // // 压缩页面JS 149 | // minifyJS: true, 150 | // // 压缩页面CSS 151 | // minifyCSS: true, 152 | // // 省略布尔属性的值 153 | // collapseBooleanAttributes: false 154 | // }; 155 | 156 | // return gulp.src('../**/*.{htm,html,ejs}') 157 | // .pipe(htmlReplace({ 158 | // 'cpjs': '/js/cp.min.js', 159 | // })) 160 | // .pipe(htmlmin(options)) 161 | // // 文件存放路径 162 | // .pipe(gulp.dest('server/public')) 163 | // // 热更新,若命令行中有 watch 这个参数才执行 164 | // .pipe(gulpif(args.watch, livereload())); 165 | // }); 166 | 167 | // 浏览器热更新监听,当 前者变化时,启动后面的任务 168 | gulp.task('browser', (cb) => { 169 | if (!args.watch) { 170 | return cb(); 171 | } 172 | 173 | // 热更新 174 | gulp.watch(['app/**/*.js'], ['scripts']); 175 | gulp.watch(['app/**/*.css'], ['styles']); 176 | gulp.watch(['app/**/*.ejs'], ['pages']); 177 | }); 178 | 179 | // 处理服务器的脚本 180 | gulp.task('serve', (cb) => { 181 | // 若命令行不处于监听状态,返回 182 | // if (!args.watch) { 183 | // return cb(); 184 | // } 185 | 186 | // 创建一个服务器并启动 187 | var server = liveserver.new(['--harmony', 'server/bin/www']); 188 | server.start(); 189 | 190 | // 热更新 191 | gulp.watch(['server/public/**/*.js', 'server/public/**/*.css', 'server/views/*.ejs'], (file) => { 192 | server.notify.apply(server, [file]); 193 | }); 194 | 195 | // 需要重启服务器才能更新 196 | gulp.watch(['server/routes/**/*.js', 'server/app.js'], () => { 197 | server.start.bind(server)(); 198 | }); 199 | }); 200 | -------------------------------------------------------------------------------- /npm-debug.log: -------------------------------------------------------------------------------- 1 | 0 info it worked if it ends with ok 2 | 1 verbose cli [ 'D:\\nodejs\\node.exe', 3 | 1 verbose cli 'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 4 | 1 verbose cli 'install', 5 | 1 verbose cli 'babrl-plugins-transform-decorators-legacy', 6 | 1 verbose cli '--save-dev' ] 7 | 2 info using npm@3.10.10 8 | 3 info using node@v6.10.3 9 | 4 silly loadCurrentTree Starting 10 | 5 silly install loadCurrentTree 11 | 6 silly install readLocalPackageData 12 | 7 silly fetchPackageMetaData babrl-plugins-transform-decorators-legacy 13 | 8 silly fetchNamedPackageData babrl-plugins-transform-decorators-legacy 14 | 9 silly mapToRegistry name babrl-plugins-transform-decorators-legacy 15 | 10 silly mapToRegistry using default registry 16 | 11 silly mapToRegistry registry https://registry.npmjs.org/ 17 | 12 silly mapToRegistry data Result { 18 | 12 silly mapToRegistry raw: 'babrl-plugins-transform-decorators-legacy', 19 | 12 silly mapToRegistry scope: null, 20 | 12 silly mapToRegistry escapedName: 'babrl-plugins-transform-decorators-legacy', 21 | 12 silly mapToRegistry name: 'babrl-plugins-transform-decorators-legacy', 22 | 12 silly mapToRegistry rawSpec: '', 23 | 12 silly mapToRegistry spec: 'latest', 24 | 12 silly mapToRegistry type: 'tag' } 25 | 13 silly mapToRegistry uri https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 26 | 14 verbose request uri https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 27 | 15 verbose request no auth needed 28 | 16 info attempt registry request try #1 at 22:45:48 29 | 17 verbose request id 626b38689cff1976 30 | 18 http request GET https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 31 | 19 http 404 https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 32 | 20 verbose headers { 'content-type': 'application/json', 33 | 20 verbose headers 'cache-control': 'max-age=0', 34 | 20 verbose headers 'content-length': '2', 35 | 20 verbose headers 'accept-ranges': 'bytes', 36 | 20 verbose headers date: 'Sun, 02 Jul 2017 14:45:52 GMT', 37 | 20 verbose headers via: '1.1 varnish', 38 | 20 verbose headers age: '0', 39 | 20 verbose headers connection: 'keep-alive', 40 | 20 verbose headers 'x-served-by': 'cache-nrt6125-NRT', 41 | 20 verbose headers 'x-cache': 'MISS', 42 | 20 verbose headers 'x-cache-hits': '0', 43 | 20 verbose headers 'x-timer': 'S1499006752.809881,VS0,VE715', 44 | 20 verbose headers vary: 'Accept-Encoding' } 45 | 21 silly get cb [ 404, 46 | 21 silly get { 'content-type': 'application/json', 47 | 21 silly get 'cache-control': 'max-age=0', 48 | 21 silly get 'content-length': '2', 49 | 21 silly get 'accept-ranges': 'bytes', 50 | 21 silly get date: 'Sun, 02 Jul 2017 14:45:52 GMT', 51 | 21 silly get via: '1.1 varnish', 52 | 21 silly get age: '0', 53 | 21 silly get connection: 'keep-alive', 54 | 21 silly get 'x-served-by': 'cache-nrt6125-NRT', 55 | 21 silly get 'x-cache': 'MISS', 56 | 21 silly get 'x-cache-hits': '0', 57 | 21 silly get 'x-timer': 'S1499006752.809881,VS0,VE715', 58 | 21 silly get vary: 'Accept-Encoding' } ] 59 | 22 silly fetchPackageMetaData Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 60 | 22 silly fetchPackageMetaData at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12) 61 | 22 silly fetchPackageMetaData at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14) 62 | 22 silly fetchPackageMetaData at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14) 63 | 22 silly fetchPackageMetaData at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22) 64 | 22 silly fetchPackageMetaData at emitTwo (events.js:106:13) 65 | 22 silly fetchPackageMetaData at Request.emit (events.js:191:7) 66 | 22 silly fetchPackageMetaData at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10) 67 | 22 silly fetchPackageMetaData at emitOne (events.js:96:13) 68 | 22 silly fetchPackageMetaData at Request.emit (events.js:188:7) 69 | 22 silly fetchPackageMetaData at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12) 70 | 22 silly fetchPackageMetaData error for babrl-plugins-transform-decorators-legacy { Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 71 | 22 silly fetchPackageMetaData at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12) 72 | 22 silly fetchPackageMetaData at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14) 73 | 22 silly fetchPackageMetaData at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14) 74 | 22 silly fetchPackageMetaData at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22) 75 | 22 silly fetchPackageMetaData at emitTwo (events.js:106:13) 76 | 22 silly fetchPackageMetaData at Request.emit (events.js:191:7) 77 | 22 silly fetchPackageMetaData at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10) 78 | 22 silly fetchPackageMetaData at emitOne (events.js:96:13) 79 | 22 silly fetchPackageMetaData at Request.emit (events.js:188:7) 80 | 22 silly fetchPackageMetaData at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12) 81 | 22 silly fetchPackageMetaData pkgid: 'babrl-plugins-transform-decorators-legacy', 82 | 22 silly fetchPackageMetaData statusCode: 404, 83 | 22 silly fetchPackageMetaData code: 'E404' } 84 | 23 silly rollbackFailedOptional Starting 85 | 24 silly rollbackFailedOptional Finishing 86 | 25 silly runTopLevelLifecycles Finishing 87 | 26 silly install printInstalled 88 | 27 verbose stack Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 89 | 27 verbose stack at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12) 90 | 27 verbose stack at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14) 91 | 27 verbose stack at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14) 92 | 27 verbose stack at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22) 93 | 27 verbose stack at emitTwo (events.js:106:13) 94 | 27 verbose stack at Request.emit (events.js:191:7) 95 | 27 verbose stack at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10) 96 | 27 verbose stack at emitOne (events.js:96:13) 97 | 27 verbose stack at Request.emit (events.js:188:7) 98 | 27 verbose stack at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12) 99 | 28 verbose statusCode 404 100 | 29 verbose pkgid babrl-plugins-transform-decorators-legacy 101 | 30 verbose cwd E:\Web\Project-2\lottery 102 | 31 error Windows_NT 10.0.14393 103 | 32 error argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "babrl-plugins-transform-decorators-legacy" "--save-dev" 104 | 33 error node v6.10.3 105 | 34 error npm v3.10.10 106 | 35 error code E404 107 | 36 error 404 Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy 108 | 37 error 404 109 | 38 error 404 'babrl-plugins-transform-decorators-legacy' is not in the npm registry. 110 | 39 error 404 You should bug the author to publish it (or use the name yourself!) 111 | 40 error 404 Note that you can also install from a 112 | 41 error 404 tarball, folder, http url, or git url. 113 | 42 verbose exit [ 1, true ] 114 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lottery", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "babel-core": "^6.25.0", 13 | "babel-loader": "^7.1.0", 14 | "babel-polyfill": "^6.23.0", 15 | "babel-preset-env": "^1.5.2", 16 | "babel-preset-es2015": "^6.24.1", 17 | "connect-livereload": "^0.6.0", 18 | "del": "^3.0.0", 19 | "gulp": "^3.9.1", 20 | "gulp-concat": "^2.6.1", 21 | "gulp-html-replace": "^1.6.2", 22 | "gulp-htmlmin": "^3.0.0", 23 | "gulp-if": "^2.0.2", 24 | "gulp-imagemin": "^3.3.0", 25 | "gulp-live-server": "0.0.30", 26 | "gulp-livereload": "^3.8.1", 27 | "gulp-minify-css": "^1.2.4", 28 | "gulp-plumber": "^1.1.0", 29 | "gulp-rename": "^1.2.2", 30 | "gulp-sequence": "^0.4.6", 31 | "gulp-uglify": "^3.0.0", 32 | "gulp-util": "^3.0.8", 33 | "jquery": "^3.2.1", 34 | "require-dir": "^0.3.2", 35 | "vinyl-named": "^1.1.0", 36 | "webpack": "^3.0.0", 37 | "webpack-stream": "^3.2.0", 38 | "yargs": "^8.0.2" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /resource/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/.DS_Store -------------------------------------------------------------------------------- /resource/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets":["es2015"], 3 | "plugins":["transform-decorators-legacy"] 4 | } 5 | -------------------------------------------------------------------------------- /resource/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /resource/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) 2017 快乐动起来 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /resource/README.md: -------------------------------------------------------------------------------- 1 | #cp-lessons 2 | -------------------------------------------------------------------------------- /resource/app/css/reset.css: -------------------------------------------------------------------------------- 1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,audio,canvas,details,figcaption,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video{margin:0;padding:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,th,var,optgroup{font-style:normal;font-weight:normal}ins{text-decoration:none}li{list-style:none}table{font-size:inherit;font:100%;border-collapse:collapse;border-spacing:0}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}legend{color:#000}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}input,button,textarea,select{margin:0;*font-size:100%;line-height:1.2}a img,img{-ms-interpolation-mode:bicubic}sub,sup{vertical-align:baseline}article,aside,dialog,figure,footer,header,hgroup,nav,section,blockquote{display:block}pre{white-space:pre-wrap;word-wrap:break-word} 2 | -------------------------------------------------------------------------------- /resource/app/js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/.DS_Store -------------------------------------------------------------------------------- /resource/app/js/class/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/class/.DS_Store -------------------------------------------------------------------------------- /resource/app/js/class/lesson1.js: -------------------------------------------------------------------------------- 1 | function test(){ 2 | // for(let i=1;i<3;i++){ 3 | // console.log(i); 4 | // } 5 | // console.log(i); 6 | let a = 1; 7 | // let a = 2; 8 | } 9 | 10 | function last(){ 11 | const PI=3.1415926; 12 | const k={ 13 | a:1 14 | } 15 | k.b=3; 16 | console.log(PI,k); 17 | } 18 | 19 | 20 | // test(); 21 | last(); 22 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson10.js: -------------------------------------------------------------------------------- 1 | { 2 | let list = new Set(); 3 | list.add(5); 4 | list.add(7); 5 | 6 | console.log('size',list.size); 7 | } 8 | 9 | { 10 | let arr = [1,2,3,4,5]; 11 | let list = new Set(arr); 12 | 13 | console.log('size',list.size); 14 | } 15 | 16 | { 17 | let list = new Set(); 18 | list.add(1); 19 | list.add(2); 20 | list.add(1); 21 | 22 | console.log('list',list); 23 | 24 | let arr=[1,2,3,1,'2']; 25 | let list2=new Set(arr); 26 | 27 | console.log('unique',list2); 28 | } 29 | 30 | { 31 | let arr=['add','delete','clear','has']; 32 | let list=new Set(arr); 33 | 34 | console.log('has',list.has('add')); 35 | console.log('delete',list.delete('add'),list); 36 | list.clear(); 37 | console.log('list',list); 38 | } 39 | 40 | { 41 | let arr=['add','delete','clear','has']; 42 | let list=new Set(arr); 43 | 44 | for(let key of list.keys()){ 45 | console.log('keys',key); 46 | } 47 | for(let value of list.values()){ 48 | console.log('value',value); 49 | } 50 | for(let [key,value] of list.entries()){ 51 | console.log('entries',key,value); 52 | } 53 | 54 | list.forEach(function(item){console.log(item);}) 55 | } 56 | 57 | 58 | { 59 | let weakList=new WeakSet(); 60 | 61 | let arg={}; 62 | 63 | weakList.add(arg); 64 | 65 | // weakList.add(2); 66 | 67 | console.log('weakList',weakList); 68 | } 69 | 70 | { 71 | let map = new Map(); 72 | let arr=['123']; 73 | 74 | map.set(arr,456); 75 | 76 | console.log('map',map,map.get(arr)); 77 | } 78 | 79 | { 80 | let map = new Map([['a',123],['b',456]]); 81 | console.log('map args',map); 82 | console.log('size',map.size); 83 | console.log('delete',map.delete('a'),map); 84 | console.log('clear',map.clear(),map); 85 | } 86 | 87 | { 88 | let weakmap=new WeakMap(); 89 | 90 | let o={}; 91 | weakmap.set(o,123); 92 | console.log(weakmap.get(o)); 93 | } 94 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson11.js: -------------------------------------------------------------------------------- 1 | { 2 | let obj={ 3 | time:'2017-03-11', 4 | name:'net', 5 | _r:123 6 | }; 7 | 8 | let monitor=new Proxy(obj,{ 9 | // 拦截对象属性的读取 10 | get(target,key){ 11 | return target[key].replace('2017','2018') 12 | }, 13 | // 拦截对象设置属性 14 | set(target,key,value){ 15 | if(key==='name'){ 16 | return target[key]=value; 17 | }else{ 18 | return target[key]; 19 | } 20 | }, 21 | // 拦截key in object操作 22 | has(target,key){ 23 | if(key==='name'){ 24 | return target[key] 25 | }else{ 26 | return false; 27 | } 28 | }, 29 | // 拦截delete 30 | deleteProperty(target,key){ 31 | if(key.indexOf('_')>-1){ 32 | delete target[key]; 33 | return true; 34 | }else{ 35 | return target[key] 36 | } 37 | }, 38 | // 拦截Object.keys,Object.getOwnPropertySymbols,Object.getOwnPropertyNames 39 | ownKeys(target){ 40 | return Object.keys(target).filter(item=>item!='time') 41 | } 42 | }); 43 | 44 | console.log('get',monitor.time); 45 | 46 | monitor.time='2018'; 47 | monitor.name='mukewang'; 48 | console.log('set',monitor.time,monitor); 49 | 50 | console.log('has','name' in monitor,'time' in monitor); 51 | 52 | // delete monitor.time; 53 | // console.log('delete',monitor); 54 | // 55 | // delete monitor._r; 56 | // console.log('delete',monitor); 57 | console.log('ownKeys',Object.keys(monitor)); 58 | 59 | } 60 | 61 | { 62 | let obj={ 63 | time:'2017-03-11', 64 | name:'net', 65 | _r:123 66 | }; 67 | 68 | console.log('Reflect get',Reflect.get(obj,'time')); 69 | Reflect.set(obj,'name','mukewang'); 70 | console.log(obj); 71 | console.log('has',Reflect.has(obj,'name')); 72 | } 73 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson12.js: -------------------------------------------------------------------------------- 1 | { 2 | // 基本定义和生成实例 3 | class Parent{ 4 | constructor(name='mukewang'){ 5 | this.name=name; 6 | } 7 | } 8 | let v_parent=new Parent('v'); 9 | console.log('构造函数和实例',v_parent); 10 | } 11 | 12 | { 13 | // 继承 14 | class Parent{ 15 | constructor(name='mukewang'){ 16 | this.name=name; 17 | } 18 | } 19 | 20 | class Child extends Parent{ 21 | 22 | } 23 | 24 | console.log('继承',new Child()); 25 | } 26 | 27 | { 28 | // 继承传递参数 29 | class Parent{ 30 | constructor(name='mukewang'){ 31 | this.name=name; 32 | } 33 | } 34 | 35 | class Child extends Parent{ 36 | constructor(name='child'){ 37 | super(name); 38 | this.type='child'; 39 | } 40 | } 41 | 42 | console.log('继承传递参数',new Child('hello')); 43 | } 44 | 45 | { 46 | // getter,setter 47 | class Parent{ 48 | constructor(name='mukewang'){ 49 | this.name=name; 50 | } 51 | 52 | get longName(){ 53 | return 'mk'+this.name 54 | } 55 | 56 | set longName(value){ 57 | this.name=value; 58 | } 59 | } 60 | 61 | let v=new Parent(); 62 | console.log('getter',v.longName); 63 | v.longName='hello'; 64 | console.log('setter',v.longName); 65 | } 66 | 67 | { 68 | // 静态方法 69 | class Parent{ 70 | constructor(name='mukewang'){ 71 | this.name=name; 72 | } 73 | 74 | static tell(){ 75 | console.log('tell'); 76 | } 77 | } 78 | 79 | Parent.tell(); 80 | 81 | } 82 | 83 | { 84 | // 静态属性 85 | class Parent{ 86 | constructor(name='mukewang'){ 87 | this.name=name; 88 | } 89 | 90 | static tell(){ 91 | console.log('tell'); 92 | } 93 | } 94 | 95 | Parent.type='test'; 96 | 97 | console.log('静态属性',Parent.type); 98 | 99 | 100 | } 101 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson13.js: -------------------------------------------------------------------------------- 1 | { 2 | // 基本定义 3 | let ajax=function(callback){ 4 | console.log('执行'); 5 | setTimeout(function () { 6 | callback&&callback.call() 7 | }, 1000); 8 | }; 9 | ajax(function(){ 10 | console.log('timeout1'); 11 | }) 12 | } 13 | 14 | { 15 | let ajax=function(){ 16 | console.log('执行2'); 17 | return new Promise(function(resolve,reject){ 18 | setTimeout(function () { 19 | resolve() 20 | }, 1000); 21 | }) 22 | }; 23 | 24 | ajax().then(function(){ 25 | console.log('promise','timeout2'); 26 | }) 27 | } 28 | 29 | { 30 | let ajax=function(){ 31 | console.log('执行3'); 32 | return new Promise(function(resolve,reject){ 33 | setTimeout(function () { 34 | resolve() 35 | }, 1000); 36 | }) 37 | }; 38 | 39 | ajax() 40 | .then(function(){ 41 | return new Promise(function(resolve,reject){ 42 | setTimeout(function () { 43 | resolve() 44 | }, 2000); 45 | }); 46 | }) 47 | .then(function(){ 48 | console.log('timeout3'); 49 | }) 50 | } 51 | 52 | { 53 | let ajax=function(num){ 54 | console.log('执行4'); 55 | return new Promise(function(resolve,reject){ 56 | if(num>5){ 57 | resolve() 58 | }else{ 59 | throw new Error('出错了') 60 | } 61 | }) 62 | } 63 | 64 | ajax(6).then(function(){ 65 | console.log('log',6); 66 | }).catch(function(err){ 67 | console.log('catch',err); 68 | }); 69 | 70 | ajax(3).then(function(){ 71 | console.log('log',3); 72 | }).catch(function(err){ 73 | console.log('catch',err); 74 | }); 75 | } 76 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson14.js: -------------------------------------------------------------------------------- 1 | { 2 | let arr=['hello','world']; 3 | let map=arr[Symbol.iterator](); 4 | console.log(map.next()); 5 | console.log(map.next()); 6 | console.log(map.next()); 7 | } 8 | 9 | { 10 | let obj={ 11 | start:[1,3,2], 12 | end:[7,9,8], 13 | [Symbol.iterator](){ 14 | let self=this; 15 | let index=0; 16 | let arr=self.start.concat(self.end); 17 | let len=arr.length; 18 | return { 19 | next(){ 20 | if(index3})); 42 | console.log([1,2,3,4,5,6].findIndex(function(item){return item>3})); 43 | } 44 | 45 | { 46 | console.log('number',[1,2,NaN].includes(1)); 47 | console.log('number',[1,2,NaN].includes(NaN)); 48 | } 49 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson7.js: -------------------------------------------------------------------------------- 1 | { 2 | function test(x, y = 'world'){ 3 | console.log('默认值',x,y); 4 | } 5 | test('hello'); 6 | test('hello','kill'); 7 | } 8 | 9 | { 10 | let x='test'; 11 | function test2(x,y=x){ 12 | console.log('作用域',x,y); 13 | } 14 | test2('kill'); 15 | } 16 | 17 | { 18 | function test3(...arg){ 19 | for(let v of arg){ 20 | console.log('rest',v); 21 | } 22 | } 23 | test3(1,2,3,4,'a'); 24 | } 25 | 26 | { 27 | console.log(...[1,2,4]); 28 | console.log('a',...[1,2,4]); 29 | } 30 | 31 | { 32 | let arrow = v => v*2; 33 | let arrow2 = () => 5; 34 | console.log('arrow',arrow(3)); 35 | console.log(arrow2()); 36 | 37 | } 38 | 39 | { 40 | function tail(x){ 41 | console.log('tail',x); 42 | } 43 | function fx(x){ 44 | return tail(x) 45 | } 46 | fx(123) 47 | } 48 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson8.js: -------------------------------------------------------------------------------- 1 | { 2 | // 简洁表示法 3 | let o=1; 4 | let k=2; 5 | let es5={ 6 | o:o, 7 | k:k 8 | }; 9 | let es6={ 10 | o, 11 | k 12 | }; 13 | console.log(es5,es6); 14 | 15 | let es5_method={ 16 | hello:function(){ 17 | console.log('hello'); 18 | } 19 | }; 20 | let es6_method={ 21 | hello(){ 22 | console.log('hello'); 23 | } 24 | }; 25 | console.log(es5_method.hello(),es6_method.hello()); 26 | } 27 | 28 | { 29 | // 属性表达式 30 | let a='b'; 31 | let es5_obj={ 32 | a:'c', 33 | b:'c' 34 | }; 35 | 36 | let es6_obj={ 37 | [a]:'c' 38 | } 39 | 40 | console.log(es5_obj,es6_obj); 41 | 42 | } 43 | 44 | { 45 | // 新增API 46 | console.log('字符串',Object.is('abc','abc'),'abc'==='abc'); 47 | console.log('数组',Object.is([],[]),[]===[]); 48 | 49 | console.log('拷贝',Object.assign({a:'a'},{b:'b'})); 50 | 51 | let test={k:123,o:456}; 52 | for(let [key,value] of Object.entries(test)){ 53 | console.log([key,value]); 54 | } 55 | } 56 | 57 | { 58 | // 扩展运算符 59 | // let {a,b,...c}={a:'test',b:'kill',c:'ddd',d:'ccc'}; 60 | // c={ 61 | // c:'ddd', 62 | // d:'ccc' 63 | // } 64 | } 65 | -------------------------------------------------------------------------------- /resource/app/js/class/lesson9.js: -------------------------------------------------------------------------------- 1 | { 2 | // 声明 3 | let a1=Symbol(); 4 | let a2=Symbol(); 5 | console.log(a1===a2); 6 | let a3=Symbol.for('a3'); 7 | let a4=Symbol.for('a3'); 8 | console.log(a3===a4); 9 | } 10 | 11 | { 12 | let a1=Symbol.for('abc'); 13 | let obj={ 14 | [a1]:'123', 15 | 'abc':345, 16 | 'c':456 17 | }; 18 | console.log('obj',obj); 19 | 20 | for(let [key,value] of Object.entries(obj)){ 21 | console.log('let of',key,value); 22 | } 23 | 24 | Object.getOwnPropertySymbols(obj).forEach(function(item){ 25 | console.log(obj[item]); 26 | }) 27 | 28 | Reflect.ownKeys(obj).forEach(function(item){ 29 | console.log('ownkeys',item,obj[item]); 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /resource/app/js/class/test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/class/test.js -------------------------------------------------------------------------------- /resource/app/js/index.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import Lottery from './lottery'; 3 | -------------------------------------------------------------------------------- /resource/app/js/lottery.js: -------------------------------------------------------------------------------- 1 | import './lottery/base.js'; 2 | import './lottery/timer.js'; 3 | import './lottery/calculate.js'; 4 | import './lottery/interface.js'; 5 | -------------------------------------------------------------------------------- /resource/app/js/lottery/base.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/base.js -------------------------------------------------------------------------------- /resource/app/js/lottery/calculate.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/calculate.js -------------------------------------------------------------------------------- /resource/app/js/lottery/interface.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/interface.js -------------------------------------------------------------------------------- /resource/app/js/lottery/timer.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/timer.js -------------------------------------------------------------------------------- /resource/app/views/error.ejs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/views/error.ejs -------------------------------------------------------------------------------- /resource/app/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ES6实战 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 |
      20 |
      21 |
      22 |
      23 | 26 |

      11选5 **

      27 |
        28 |
      • 购彩剩余时间:
      • 29 |
      • 30 |
      • 31 | 销售:9:00~22:00(78期) 10分钟开奖 返奖59% 32 |
      • 33 |
      34 | 暂停销售 35 |
      36 |
      37 | 58 |
      59 |
      60 | 61 |
      62 | 73 |
      74 | 75 | 76 |
      77 | 78 |
      79 |
      80 |
      81 |
      82 |

      玩法提示:从01~11中任选5个或多个号码,所选号码与开奖号码相同,即中奖540

      83 |
      84 |
      85 |
      86 |

      87 | 88 | 选号区 至少选5个 89 | 90 | 操作区 快捷选号 91 |

      92 |
      93 |
      94 |
      95 |
      96 |
      97 | 号码 98 | 遗漏 99 |
      100 |
      101 |
      102 |
        103 |
      • 010
      • 104 |
      • 020
      • 105 |
      • 035
      • 106 |
      • 041
      • 107 |
      • 051
      • 108 |
      • 062
      • 109 |
      • 070
      • 110 |
      • 083
      • 111 |
      • 090
      • 112 |
      • 101
      • 113 |
      • 110
      • 114 |
      115 |
      116 |
      117 |
      118 |
      119 | 127 |
      128 |
      129 |
      130 |
      131 |
      132 |

      您选了 0 注,共 0

      133 |
      134 |
      135 |
      136 |
      137 |
      138 |
      139 |
      140 | 141 | 清空选号 142 |
      143 |
      144 |
      145 |
      146 |
        147 |
        148 |
        149 |
        150 | 156 |
        157 |
        158 |
        159 |
        160 |
        161 |
        162 | 您选了 0 注, 倍投 倍,共 0 元 163 |
        164 |
        165 |
        166 |
        167 | 168 |
        169 |
        170 | 171 | 172 |
        173 |
        174 |
        175 |

        11选5 第 022478 期 开奖

        176 |
        177 |
          178 |
        • 09
        • 179 |
        • 02
        • 180 |
        • 01
        • 181 |
        • 07
        • 182 |
        • 11
        • 183 |
        184 |
        185 |

        今天已售78期,还剩0期

        186 |
        187 |
        188 |
        189 | 190 | 191 | 192 | 193 | 194 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
        期号开奖号码 195 | 大小比 196 | 奇偶比 197 |
        02247809 02 01 07 113:24:1
        208 |
        209 |
        210 | 211 |
        212 |
        213 |
        214 |
        215 |
        216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /resource/gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | import requireDir from 'require-dir'; 2 | 3 | requireDir('./tasks'); 4 | -------------------------------------------------------------------------------- /resource/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "es6", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "babel-core": "^6.24.0", 13 | "babel-loader": "^6.4.1", 14 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 15 | "babel-polyfill": "^6.23.0", 16 | "babel-preset-env": "^1.2.2", 17 | "babel-preset-es2015": "^6.24.0", 18 | "connect-livereload": "^0.6.0", 19 | "del": "^2.2.2", 20 | "gulp": "^3.9.1", 21 | "gulp-concat": "^2.6.1", 22 | "gulp-if": "^2.0.2", 23 | "gulp-live-server": "0.0.30", 24 | "gulp-livereload": "^3.8.1", 25 | "gulp-plumber": "^1.1.0", 26 | "gulp-rename": "^1.2.2", 27 | "gulp-sequence": "^0.4.6", 28 | "gulp-uglify": "^2.1.0", 29 | "gulp-util": "^3.0.8", 30 | "require-dir": "^0.3.1", 31 | "vinyl-named": "^1.1.0", 32 | "webpack": "^2.2.1", 33 | "webpack-stream": "^3.2.0", 34 | "yargs": "^7.0.2" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resource/server/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | var favicon = require('serve-favicon'); 4 | var logger = require('morgan'); 5 | var cookieParser = require('cookie-parser'); 6 | var bodyParser = require('body-parser'); 7 | 8 | var routes = require('./routes/index'); 9 | var users = require('./routes/users'); 10 | 11 | var app = express(); 12 | 13 | // view engine setup 14 | app.set('views', path.join(__dirname, 'views')); 15 | app.set('view engine', 'ejs'); 16 | 17 | // uncomment after placing your favicon in /public 18 | //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 19 | app.use(logger('dev')); 20 | app.use(bodyParser.json()); 21 | app.use(bodyParser.urlencoded({ extended: false })); 22 | app.use(cookieParser()); 23 | app.use(express.static(path.join(__dirname, 'public'))); 24 | app.use(require('connect-livereload')()); 25 | app.use('/', routes); 26 | app.use('/users', users); 27 | 28 | // catch 404 and forward to error handler 29 | app.use(function(req, res, next) { 30 | var err = new Error('Not Found'); 31 | err.status = 404; 32 | next(err); 33 | }); 34 | 35 | // error handlers 36 | 37 | // development error handler 38 | // will print stacktrace 39 | if (app.get('env') === 'development') { 40 | app.use(function(err, req, res, next) { 41 | res.status(err.status || 500); 42 | res.render('error', { 43 | message: err.message, 44 | error: err 45 | }); 46 | }); 47 | } 48 | 49 | // production error handler 50 | // no stacktraces leaked to user 51 | app.use(function(err, req, res, next) { 52 | res.status(err.status || 500); 53 | res.render('error', { 54 | message: err.message, 55 | error: {} 56 | }); 57 | }); 58 | 59 | 60 | module.exports = app; 61 | -------------------------------------------------------------------------------- /resource/server/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('server:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '3000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /resource/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.13.2", 10 | "cookie-parser": "~1.3.5", 11 | "debug": "~2.2.0", 12 | "ejs": "~2.3.3", 13 | "express": "~4.13.1", 14 | "morgan": "~1.6.1", 15 | "serve-favicon": "~2.3.0" 16 | }, 17 | "devDependencies": { 18 | "mockjs": "^1.0.1-beta3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resource/server/public/css/reset.css: -------------------------------------------------------------------------------- 1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,audio,canvas,details,figcaption,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video{margin:0;padding:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,th,var,optgroup{font-style:normal;font-weight:normal}ins{text-decoration:none}li{list-style:none}table{font-size:inherit;font:100%;border-collapse:collapse;border-spacing:0}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}legend{color:#000}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}input,button,textarea,select{margin:0;*font-size:100%;line-height:1.2}a img,img{-ms-interpolation-mode:bicubic}sub,sup{vertical-align:baseline}article,aside,dialog,figure,footer,header,hgroup,nav,section,blockquote{display:block}pre{white-space:pre-wrap;word-wrap:break-word} 2 | -------------------------------------------------------------------------------- /resource/server/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var mockjs = require('mockjs'); 3 | var router = express.Router(); 4 | 5 | 6 | var makeIssue=function(){ 7 | var date = new Date(); 8 | var first_issue_date=new Date(); 9 | first_issue_date.setHours(9); 10 | first_issue_date.setMinutes(10); 11 | first_issue_date.setSeconds(0); 12 | var end_issue_date=new Date(first_issue_date.getTime()+77*10*60*1000); 13 | 14 | 15 | 16 | var cur_issue,end_time,state; 17 | // 正常销售 18 | if(date.getTime()-first_issue_date.getTime()>0&&date.getTime()-end_issue_date.getTime()<0){ 19 | var cur_issue_date=new Date(); 20 | cur_issue_date.setHours(9); 21 | cur_issue_date.setMinutes(0); 22 | cur_issue_date.setSeconds(0); 23 | var minus_time=date.getTime()-cur_issue_date.getTime(); 24 | var h=Math.ceil(minus_time/1000/60/10); 25 | var end_date=new Date(cur_issue_date.getTime()+1000*60*10*h); 26 | end_time=end_date.getTime(); 27 | cur_issue=[end_date.getFullYear(),('0'+(end_date.getMonth()+1)).slice(-2),('0'+end_date.getDate()).slice(-2),('0'+h).slice(-2)].join(''); 28 | }else{ 29 | // 今天销售已截止 30 | first_issue_date.setDate(first_issue_date.getDate()+1); 31 | end_time=first_issue_date.getTime(); 32 | cur_issue=[first_issue_date.getFullYear(),('0'+(first_issue_date.getMonth()+1)).slice(-2),('0'+first_issue_date.getDate()).slice(-2),'01'].join(''); 33 | } 34 | 35 | var cur_date=new Date(); 36 | if(end_time-cur_date.getTime()>1000*60*2){ 37 | state='正在销售' 38 | }else{ 39 | state='开奖中' 40 | } 41 | return { 42 | issue:cur_issue, 43 | state:state, 44 | end_time:end_time 45 | } 46 | } 47 | /* GET home page. */ 48 | router.get('/', function (req, res, next) { 49 | res.render('index', { 50 | title: 'Express' 51 | }); 52 | }); 53 | 54 | // get omit 55 | router.get('/get/omit', function (req, res, next) { 56 | res.json(mockjs.mock({ 57 | 'data|11': [/[1-9]{1,3}|0/], 58 | 'issue':/[1-9]{8}/ 59 | })) 60 | }); 61 | 62 | // get opencode 63 | router.get('/get/opencode', function (req, res, next) { 64 | var issue=makeIssue().issue; 65 | var data=mockjs.mock({ 66 | 'data': [/[1-3]/,/[4-5]/,/[6-7]/,/[8-9]/,/1[0-1]/] 67 | }).data; 68 | res.json({ 69 | issue:issue, 70 | data:data 71 | }) 72 | }); 73 | 74 | 75 | // get state 76 | router.get('/get/state',function(req,res,next){ 77 | var state=makeIssue(); 78 | console.log(state); 79 | res.json(state) 80 | }); 81 | 82 | 83 | module.exports = router; 84 | -------------------------------------------------------------------------------- /resource/server/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /resource/server/views/error.ejs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/server/views/error.ejs -------------------------------------------------------------------------------- /resource/server/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ES6实战 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 |
        20 |
        21 |
        22 |
        23 | 26 |

        11选5 **

        27 |
          28 |
        • 购彩剩余时间:
        • 29 |
        • 30 |
        • 31 | 销售:9:00~22:00(78期) 10分钟开奖 返奖59% 32 |
        • 33 |
        34 | 暂停销售 35 |
        36 |
        37 | 58 |
        59 |
        60 | 61 |
        62 | 73 |
        74 | 75 | 76 |
        77 | 78 |
        79 |
        80 |
        81 |
        82 |

        玩法提示:从01~11中任选5个或多个号码,所选号码与开奖号码相同,即中奖540

        83 |
        84 |
        85 |
        86 |

        87 | 88 | 选号区 至少选5个 89 | 90 | 操作区 快捷选号 91 |

        92 |
        93 |
        94 |
        95 |
        96 |
        97 | 号码 98 | 遗漏 99 |
        100 |
        101 |
        102 |
          103 |
        • 010
        • 104 |
        • 020
        • 105 |
        • 035
        • 106 |
        • 041
        • 107 |
        • 051
        • 108 |
        • 062
        • 109 |
        • 070
        • 110 |
        • 083
        • 111 |
        • 090
        • 112 |
        • 101
        • 113 |
        • 110
        • 114 |
        115 |
        116 |
        117 |
        118 |
        119 | 127 |
        128 |
        129 |
        130 |
        131 |
        132 |

        您选了 0 注,共 0

        133 |
        134 |
        135 |
        136 |
        137 |
        138 |
        139 |
        140 | 141 | 清空选号 142 |
        143 |
        144 |
        145 |
        146 |
          147 |
          148 |
          149 |
          150 | 156 |
          157 |
          158 |
          159 |
          160 |
          161 |
          162 | 您选了 0 注, 倍投 倍,共 0 元 163 |
          164 |
          165 |
          166 |
          167 | 168 |
          169 |
          170 | 171 | 172 |
          173 |
          174 |
          175 |

          11选5 第 022478 期 开奖

          176 |
          177 |
            178 |
          • 09
          • 179 |
          • 02
          • 180 |
          • 01
          • 181 |
          • 07
          • 182 |
          • 11
          • 183 |
          184 |
          185 |

          今天已售78期,还剩0期

          186 |
          187 |
          188 |
          189 | 190 | 191 | 192 | 193 | 194 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
          期号开奖号码 195 | 大小比 196 | 奇偶比 197 |
          02247809 02 01 07 113:24:1
          208 |
          209 |
          210 | 211 |
          212 |
          213 |
          214 |
          215 |
          216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /resource/tasks/browser.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpif from 'gulp-if'; 3 | import gutil from 'gulp-util'; 4 | import args from './util/args'; 5 | 6 | gulp.task('browser',(cb)=>{ 7 | if(!args.watch) return cb(); 8 | gulp.watch('app/**/*.js',['scripts']); 9 | gulp.watch('app/**/*.ejs',['pages']); 10 | gulp.watch('app/**/*.css',['css']); 11 | }); 12 | -------------------------------------------------------------------------------- /resource/tasks/build.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpSequence from 'gulp-sequence'; 3 | 4 | gulp.task('build',gulpSequence('clean','css','pages','scripts',['browser','serve'])); 5 | -------------------------------------------------------------------------------- /resource/tasks/clean.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import del from 'del'; 3 | import args from './util/args'; 4 | 5 | gulp.task('clean',()=>{ 6 | return del(['server/public','server/views']) 7 | }) 8 | -------------------------------------------------------------------------------- /resource/tasks/css.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpif from 'gulp-if'; 3 | import livereload from 'gulp-livereload'; 4 | import args from './util/args'; 5 | 6 | gulp.task('css',()=>{ 7 | return gulp.src('app/**/*.css') 8 | .pipe(gulp.dest('server/public')) 9 | 10 | }) 11 | -------------------------------------------------------------------------------- /resource/tasks/default.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | 3 | gulp.task('default',['build']); 4 | -------------------------------------------------------------------------------- /resource/tasks/pages.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpif from 'gulp-if'; 3 | import livereload from 'gulp-livereload'; 4 | import args from './util/args'; 5 | 6 | gulp.task('pages',()=>{ 7 | return gulp.src('app/**/*.ejs') 8 | .pipe(gulp.dest('server')) 9 | .pipe(gulpif(args.watch,livereload())) 10 | }) 11 | -------------------------------------------------------------------------------- /resource/tasks/scripts.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpif from 'gulp-if'; 3 | import concat from 'gulp-concat'; 4 | import webpack from 'webpack'; 5 | import gulpWebpack from 'webpack-stream'; 6 | import named from 'vinyl-named'; 7 | import livereload from 'gulp-livereload'; 8 | import plumber from 'gulp-plumber'; 9 | import rename from 'gulp-rename'; 10 | import uglify from 'gulp-uglify'; 11 | import {log,colors} from 'gulp-util'; 12 | import args from './util/args'; 13 | 14 | gulp.task('scripts',()=>{ 15 | return gulp.src(['app/js/index.js']) 16 | .pipe(plumber({ 17 | errorHandle:function(){ 18 | 19 | } 20 | })) 21 | .pipe(named()) 22 | .pipe(gulpWebpack({ 23 | module:{ 24 | loaders:[{ 25 | test:/\.js$/, 26 | loader:'babel' 27 | }] 28 | } 29 | }),null,(err,stats)=>{ 30 | log(`Finished '${colors.cyan('scripts')}'`,stats.toString({ 31 | chunks:false 32 | })) 33 | }) 34 | .pipe(gulp.dest('server/public/js')) 35 | .pipe(rename({ 36 | basename:'cp', 37 | extname:'.min.js' 38 | })) 39 | .pipe(uglify({compress:{properties:false},output:{'quote_keys':true}})) 40 | .pipe(gulp.dest('server/public/js')) 41 | .pipe(gulpif(args.watch,livereload())) 42 | }) 43 | -------------------------------------------------------------------------------- /resource/tasks/server.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import gulpif from 'gulp-if'; 3 | import liveserver from 'gulp-live-server'; 4 | import args from './util/args'; 5 | 6 | gulp.task('serve',(cb)=>{ 7 | if(!args.watch) return cb(); 8 | 9 | var server = liveserver.new(['--harmony','server/bin/www']); 10 | server.start(); 11 | 12 | gulp.watch(['server/public/**/*.js','server/views/**/*.ejs'],function(file){ 13 | server.notify.apply(server,[file]); 14 | }) 15 | 16 | gulp.watch(['server/routes/**/*.js','server/app.js'],function(){ 17 | server.start.bind(server)() 18 | }); 19 | }) 20 | -------------------------------------------------------------------------------- /resource/tasks/util/args.js: -------------------------------------------------------------------------------- 1 | import yargs from 'yargs'; 2 | 3 | const args = yargs 4 | 5 | .option('production',{ 6 | boolean:true, 7 | default:false, 8 | describe:'min all scripts' 9 | }) 10 | 11 | .option('watch',{ 12 | boolean:true, 13 | default:false, 14 | describe:'watch all files' 15 | }) 16 | 17 | .option('verbose',{ 18 | boolean:true, 19 | default:false, 20 | describe:'log' 21 | }) 22 | 23 | .option('sourcemaps',{ 24 | describe:'force the creation of sroucemaps' 25 | }) 26 | 27 | .option('port',{ 28 | string:true, 29 | default:8080, 30 | describe:'server port' 31 | }) 32 | 33 | .argv 34 | 35 | export default args; 36 | -------------------------------------------------------------------------------- /server/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | var favicon = require('serve-favicon'); 4 | var logger = require('morgan'); 5 | var cookieParser = require('cookie-parser'); 6 | var bodyParser = require('body-parser'); 7 | 8 | var index = require('./routes/index'); 9 | var users = require('./routes/users'); 10 | 11 | var app = express(); 12 | 13 | // view engine setup 14 | app.set('views', path.join(__dirname, 'views')); 15 | app.set('view engine', 'ejs'); 16 | 17 | // uncomment after placing your favicon in /public 18 | //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 19 | app.use(logger('dev')); 20 | app.use(bodyParser.json()); 21 | app.use(bodyParser.urlencoded({ extended: false })); 22 | app.use(cookieParser()); 23 | app.use(express.static(path.join(__dirname, 'public'))); 24 | app.use(require('connect-livereload')()); 25 | app.use('/', index); 26 | app.use('/users', users); 27 | 28 | // catch 404 and forward to error handler 29 | app.use(function(req, res, next) { 30 | var err = new Error('Not Found'); 31 | err.status = 404; 32 | next(err); 33 | }); 34 | 35 | // error handler 36 | app.use(function(err, req, res, next) { 37 | // set locals, only providing error in development 38 | res.locals.message = err.message; 39 | res.locals.error = req.app.get('env') === 'development' ? err : {}; 40 | 41 | // render the error page 42 | res.status(err.status || 500); 43 | res.render('error'); 44 | }); 45 | 46 | module.exports = app; 47 | -------------------------------------------------------------------------------- /server/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('server:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '3000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.17.1", 10 | "cookie-parser": "~1.4.3", 11 | "debug": "~2.6.3", 12 | "ejs": "~2.5.6", 13 | "express": "~4.15.2", 14 | "morgan": "~1.8.1", 15 | "serve-favicon": "~2.4.2" 16 | }, 17 | "devDependencies": { 18 | "mockjs": "^1.0.1-beta3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /server/public/css/myreset.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8";blockquote,body,button,dd,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,input,lengend,li,ol,p,pre,td,textarea,th,ul{margin:0;padding:0}ol,ul{list-style:none}a{text-decoration:none}q:after,q:before{content:''}legend{color:#000}button,textarea{font-size:100%;border:0}fieldset,img{border:0}table{border-collapse:collapse;border-spacing:0}.fl{float:left}.fr{float:right}.clearfix:after{display:block;clear:both;content:"";visibility:hidden;height:0}.clearfix{zoom:1}::selection{background-color:#b3d4fc;text-shadow:none}.browser-up{padding:1rem;background:#ccc;text-align:center} -------------------------------------------------------------------------------- /server/public/img/100x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/server/public/img/100x100.png -------------------------------------------------------------------------------- /server/public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/server/public/img/favicon.ico -------------------------------------------------------------------------------- /server/public/js/calc.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) 10 | /******/ return installedModules[moduleId].exports; 11 | 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ exports: {}, 15 | /******/ id: moduleId, 16 | /******/ loaded: false 17 | /******/ }; 18 | 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | 22 | /******/ // Flag the module as loaded 23 | /******/ module.loaded = true; 24 | 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | 29 | 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | 36 | /******/ // __webpack_public_path__ 37 | /******/ __webpack_require__.p = ""; 38 | 39 | /******/ // Load entry module and return exports 40 | /******/ return __webpack_require__(0); 41 | /******/ }) 42 | /************************************************************************/ 43 | /******/ ([ 44 | /* 0 */ 45 | /***/ (function(module, exports, __webpack_require__) { 46 | 47 | module.exports = __webpack_require__(4); 48 | 49 | 50 | /***/ }), 51 | /* 1 */, 52 | /* 2 */, 53 | /* 3 */, 54 | /* 4 */ 55 | /***/ (function(module, exports) { 56 | 57 | 'use strict'; 58 | 59 | Object.defineProperty(exports, "__esModule", { 60 | value: true 61 | }); 62 | 63 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 64 | 65 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 66 | 67 | // 计算模块 68 | // 您选了15注,共30元,若中奖,奖金:6元至60元,您将盈利-24元至30元 69 | 70 | var Calc = function () { 71 | function Calc() { 72 | _classCallCheck(this, Calc); 73 | } 74 | 75 | _createClass(Calc, [{ 76 | key: 'calcCount', 77 | 78 | 79 | /** 80 | * 当前选中的注数 81 | * @param {number} active 当前选中的号码的个数 82 | * @param {string} type 当前选中的玩法类型,如:r3(任三) 83 | * @return {number} 注数 84 | */ 85 | value: function calcCount(active, type) { 86 | var count = 0; 87 | // type_list 是一个 Map 数据结构 88 | var exist = this.type_list.has(type); 89 | // 生成一个长度为 active 的数组,并全部填充 0 90 | var arr = new Array(active).fill(0); 91 | 92 | if (exist && type.at(0) === 'r') { 93 | // 取 rx 后面的 x 94 | count = Calc.combine(arr, type.split('')[1]).length; 95 | } 96 | return count; 97 | } 98 | 99 | /** 100 | * 计算奖金范围 101 | * @param {number} active 当前选中的号码的个数 102 | * @param {string} type 当前选中的玩法类型,如:r3(任三) 103 | * @return {array} [min, max] 104 | */ 105 | 106 | }, { 107 | key: 'calcBonus', 108 | value: function calcBonus(active, type) { 109 | var self = this; 110 | var type_split = type.split(''); // ['r', '3'] 111 | // string 隐式转换成 number 112 | var arr = new Array(type_split[1] * 1).fill(0); 113 | var min = void 0, 114 | max = void 0; 115 | 116 | if (type_split[0] === 'r') { 117 | // 最小命中数 118 | var min_active = active - 6; 119 | 120 | if (min_active > 0) { 121 | if (min_active - type_split[1] >= 0) { 122 | arr = new Array(min_active).fill(0); 123 | min = Calc.combine(arr, type_split[1]).length; 124 | } else { 125 | // 是否是‘任6 7 8’ 126 | if (type_split[1] - 5 > 0 && active - type_split[1] >= 0) { 127 | arr = new Array(active - 5).fill(0); 128 | min = Calc.combine(arr, type_split[1] - 5).length; 129 | } else { 130 | min = active - type_split[1] > 1 ? 1 : 0; 131 | } 132 | } 133 | } else { 134 | min = active - type_split[1] > -1 ? 1 : 0; 135 | } 136 | 137 | // 最大命中数 138 | var max_active = Math.min(active, 5); 139 | 140 | if (type_split[1] - 5 > 0) { 141 | if (active - type_split[1] >= 0) { 142 | arr = new Array(active - 5).fill(0); 143 | min = Calc.combine(arr, type_split[1] - 5).length; 144 | } else { 145 | max = 0; 146 | } 147 | } else if (type_split[1] - 5 < 0) { 148 | arr = new Array(Math.min(active, 5)).fill(0); 149 | min = Calc.combine(arr, type_split[1]).length; 150 | } else { 151 | max = 1; 152 | } 153 | } 154 | return [min, max].map(function (item) { 155 | return item * self.type_list.get(type.bonus); 156 | }); 157 | } 158 | }], [{ 159 | key: 'combine', 160 | 161 | /** 162 | * 排列组合运算 163 | * @param {array} arr 选号列表,如:[01, 02, 03, 04] 164 | * @param {number} size 玩法后缀,如:3 165 | * @return {number} 注数 166 | */ 167 | value: function combine(arr, size) { 168 | // 保存最后各种组合的结果 169 | var allResult = []; 170 | 171 | // restlt 初始为 [] 172 | (function f(arr, size, restlt) { 173 | var arrLen = arr.length; 174 | 175 | if (arrLen < size) { 176 | return; 177 | } 178 | if (arrLen === size) { 179 | allResult.push([].concat(restlt, arr)); // [01, 02, 03] 180 | } else { 181 | // 不断增加新的数组 182 | for (var i = 0; i < arrLen; i++) { 183 | // 保存上次运行结果 184 | var newResult = [].concat(result); 185 | newResult.push(arr[i]); 186 | 187 | // 如果选择的是‘任一’,则结束计算 188 | if (size === 1) { 189 | allResult.push(newResult); 190 | } else { 191 | // 保存上次运行结果 192 | var newArr = [].concat(result); 193 | // 重点!截取数组片段 194 | newArr.splice(0, i + 1); 195 | // 递归 196 | f(newArr, size - 1, newResult); 197 | } 198 | } 199 | } 200 | })(arr, size, []); 201 | 202 | return allResult; 203 | } 204 | }]); 205 | 206 | return Calc; 207 | }(); 208 | 209 | exports.default = Calc; 210 | 211 | /***/ }) 212 | /******/ ]); -------------------------------------------------------------------------------- /server/public/js/cp.min.js: -------------------------------------------------------------------------------- 1 | !function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={"exports":{},"id":o,"loaded":!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};t.m=e,t.c=n,t.p="",t(0)}({"0":function(e,t,n){e.exports=n(304)},"304":function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{"value":!0});var o=function(){function e(e,t){for(var n=0;n0)n.call(r);else{var u=e-o,a=Math.floor(u/864e5),i=Math.floor((u-864e5*a)/36e5),l=Math.floor((u-864e5*a-36e5*i)/6e4),c=Math.floor((u-864e5*a-36e5*i-6e4*l)/1e3),f=[];a>0&&f.push(a+"天"),(i>0||f.length>0)&&f.push(i+"小时"),(l>0||f.length>0)&&f.push(l+"分钟"),(c>0||f.length>0)&&f.push(c+"秒"),r.last_time=f.join(""),t.call(r,f.join("")),setTimeout(function(){r.countDown(e,t,n)},1e3)}}}]),e}();t.default=r}}); -------------------------------------------------------------------------------- /server/public/js/time.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) 10 | /******/ return installedModules[moduleId].exports; 11 | 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ exports: {}, 15 | /******/ id: moduleId, 16 | /******/ loaded: false 17 | /******/ }; 18 | 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | 22 | /******/ // Flag the module as loaded 23 | /******/ module.loaded = true; 24 | 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | 29 | 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | 36 | /******/ // __webpack_public_path__ 37 | /******/ __webpack_require__.p = ""; 38 | 39 | /******/ // Load entry module and return exports 40 | /******/ return __webpack_require__(0); 41 | /******/ }) 42 | /************************************************************************/ 43 | /******/ ({ 44 | 45 | /***/ 0: 46 | /***/ (function(module, exports, __webpack_require__) { 47 | 48 | module.exports = __webpack_require__(304); 49 | 50 | 51 | /***/ }), 52 | 53 | /***/ 304: 54 | /***/ (function(module, exports) { 55 | 56 | 'use strict'; 57 | 58 | Object.defineProperty(exports, "__esModule", { 59 | value: true 60 | }); 61 | 62 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 63 | 64 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 65 | 66 | // 时间模块 67 | 68 | var Time = function () { 69 | function Time() { 70 | _classCallCheck(this, Time); 71 | } 72 | 73 | _createClass(Time, [{ 74 | key: 'countDown', 75 | 76 | /** 77 | * 倒计时 78 | * @param {Number} end 截止时间 79 | * @param {[type]} update 时间更新的回调 80 | * @param {[type]} handle 结束回调 81 | * @return {[type]} [description] 82 | */ 83 | value: function countDown(end, update, handle) { 84 | // now 1498917683022 85 | // end 1498917826710 86 | var now = new Date().getTime(); 87 | var self = this; 88 | 89 | if (now - end > 0) { 90 | handle.call(self); 91 | } else { 92 | // 剩余时间 93 | var last_time = end - now; 94 | 95 | var d_to_ms = 24 * 60 * 60 * 1000; 96 | var h_to_ms = 60 * 60 * 1000; 97 | var m_to_ms = 60 * 1000; 98 | var s_to_ms = 1000; 99 | 100 | var d = Math.floor(last_time / d_to_ms); 101 | var h = Math.floor((last_time - d * d_to_ms) / h_to_ms); 102 | var m = Math.floor((last_time - d * d_to_ms - h * h_to_ms) / m_to_ms); 103 | var s = Math.floor((last_time - d * d_to_ms - h * h_to_ms - m * m_to_ms) / s_to_ms); 104 | 105 | var arr = []; 106 | 107 | if (d > 0) { 108 | arr.push(d + '\u5929'); 109 | } 110 | if (h > 0 || arr.length > 0) { 111 | arr.push(h + '\u5C0F\u65F6'); 112 | } 113 | if (m > 0 || arr.length > 0) { 114 | arr.push(m + '\u5206\u949F'); 115 | } 116 | if (s > 0 || arr.length > 0) { 117 | arr.push(s + '\u79D2'); 118 | } 119 | 120 | self.last_time = arr.join(''); 121 | update.call(self, arr.join('')); 122 | 123 | setTimeout(function () { 124 | self.countDown(end, update, handle); 125 | }, 1000); 126 | } 127 | } 128 | }]); 129 | 130 | return Time; 131 | }(); 132 | 133 | exports.default = Time; 134 | 135 | /***/ }) 136 | 137 | /******/ }); -------------------------------------------------------------------------------- /server/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var mockjs = require('mockjs'); 3 | var router = express.Router(); 4 | 5 | var makeIssue = function() { 6 | var date = new Date(); 7 | // first_issue_date 每天的第一期 8 | // end_issue_date 每天的最后一期 9 | var first_issue_date = new Date(); 10 | first_issue_date.setHours(9); 11 | first_issue_date.setMinutes(10); 12 | first_issue_date.setSeconds(0); 13 | var end_issue_date = new Date(first_issue_date.getTime() + 77 * 10 * 60 * 1000); 14 | 15 | var cur_issue, end_time, state; 16 | 17 | // 正常销售 18 | if (date.getTime() - first_issue_date.getTime() > 0 && date.getTime() - end_issue_date.getTime() < 0) { 19 | // cur_issue_date 当前期号 20 | var cur_issue_date = new Date(); 21 | cur_issue_date.setHours(9); 22 | cur_issue_date.setMinutes(0); 23 | cur_issue_date.setSeconds(0); 24 | 25 | var minus_time = date.getTime() - cur_issue_date.getTime(); 26 | var h = Math.ceil(minus_time / 1000 / 60 / 10); 27 | var end_date = new Date(cur_issue_date.getTime() + 1000 * 60 * 10 * h); 28 | end_time = end_date.getTime(); 29 | cur_issue = [end_date.getFullYear(), ('0' + (end_date.getMonth() + 1)).slice(-2), ('0' + end_date.getDate()).slice(-2), ('0' + h).slice(-2)].join(''); 30 | } else { 31 | // 今天销售已截止 32 | first_issue_date.setDate(first_issue_date.getDate() + 1); 33 | end_time = first_issue_date.getTime(); 34 | cur_issue = [first_issue_date.getFullYear(), ('0' + (first_issue_date.getMonth() + 1)).slice(-2), ('0' + first_issue_date.getDate()).slice(-2), '01'].join(''); 35 | } 36 | 37 | var cur_date = new Date(); 38 | if (end_time - cur_date.getTime() > 1000 * 60 * 2) { 39 | state = '正在销售'; 40 | } else { 41 | state = '开奖中'; 42 | } 43 | return { 44 | issue: cur_issue, 45 | state: state, 46 | end_time: end_time 47 | }; 48 | }; 49 | 50 | /* GET home page. */ 51 | router.get('/', function(req, res, next) { 52 | res.render('index', { 53 | title: 'Express' 54 | }); 55 | }); 56 | 57 | // get omit 58 | router.get('/get/omit', function(req, res, next) { 59 | res.json(mockjs.mock({ 60 | 'data|11': [/[1-9]{1,3}|0/], 61 | 'issue': /[1-9]{8}/ 62 | })); 63 | }); 64 | 65 | // get opencode 66 | router.get('/get/opencode', function(req, res, next) { 67 | var issue = makeIssue().issue; 68 | var data = mockjs.mock({ 69 | 'data': [/[1-3]/, /[4-5]/, /[6-7]/, /[8-9]/, /1[0-1]/] 70 | }).data; 71 | res.json({ 72 | issue: issue, 73 | data: data 74 | }); 75 | }); 76 | 77 | // get state 78 | router.get('/get/state', function(req, res, next) { 79 | var state = makeIssue(); 80 | // console.log(state); 81 | res.json(state); 82 | }); 83 | 84 | 85 | module.exports = router; 86 | -------------------------------------------------------------------------------- /server/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /server/views/error.ejs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/server/views/error.ejs -------------------------------------------------------------------------------- /server/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 彩票项目(11选5) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 35 | 36 |
          37 |
          38 |
          39 |
          40 | 43 |

          11选5 **

          44 |
            45 |
          • 购彩剩余时间:
          • 46 |
          • 47 |
          • 48 | 销售:9:00~22:00(78期) 10分钟开奖 返奖59% 49 |
          • 50 |
          51 | 暂停销售 52 |
          53 |
          54 | 75 |
          76 |
          77 | 78 |
          79 | 90 |
          91 | 92 | 93 |
          94 | 95 |
          96 |
          97 |
          98 |
          99 |

          玩法提示:从01~11中任选5个或多个号码,所选号码与开奖号码相同,即中奖540

          100 |
          101 |
          102 |
          103 |

          104 | 105 | 选号区 至少选5个 106 | 107 | 操作区 快捷选号 108 |

          109 |
          110 |
          111 |
          112 |
          113 |
          114 | 号码 115 | 遗漏 116 |
          117 |
          118 |
          119 |
            120 |
          • 010
          • 121 |
          • 020
          • 122 |
          • 035
          • 123 |
          • 041
          • 124 |
          • 051
          • 125 |
          • 062
          • 126 |
          • 070
          • 127 |
          • 083
          • 128 |
          • 090
          • 129 |
          • 101
          • 130 |
          • 110
          • 131 |
          132 |
          133 |
          134 |
          135 |
          136 | 144 |
          145 |
          146 |
          147 |
          148 |
          149 |

          您选了 0 注,共 0

          150 |
          151 |
          152 |
          153 |
          154 |
          155 |
          156 |
          157 | 158 | 清空选号 159 |
          160 |
          161 |
          162 |
          163 |
            164 |
            165 |
            166 |
            167 | 173 |
            174 |
            175 |
            176 |
            177 |
            178 |
            179 | 您选了 0 注, 倍投 倍,共 0 元 180 |
            181 |
            182 |
            183 |
            184 | 185 |
            186 |
            187 | 188 | 189 |
            190 |
            191 |
            192 |

            11选5 第 022478 期 开奖

            193 |
            194 |
              195 |
            • 09
            • 196 |
            • 02
            • 197 |
            • 01
            • 198 |
            • 07
            • 199 |
            • 11
            • 200 |
            201 |
            202 |

            今天已售78期,还剩0期

            203 |
            204 |
            205 |
            206 | 207 | 208 | 209 | 210 | 211 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 |
            期号开奖号码 212 | 大小比 213 | 奇偶比 214 |
            02247809 02 01 07 113:24:1
            225 |
            226 |
            227 | 228 |
            229 |
            230 |
            231 |
            232 |
            233 | 234 | 235 | 236 | 237 | -------------------------------------------------------------------------------- /tasks/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | // Enforcing options 3 | // http://jshint.com/docs/options/#enforcing-options 4 | 5 | "esversion": 6, 6 | "eqeqeq": true 7 | // "sub": true, 8 | // "laxbreak": true, 9 | // "laxcomma": true, 10 | // "regexp": true, 11 | // "asi": true, 12 | // "browser": true, 13 | // "loopfunc": true, 14 | // "expr": true, 15 | // "jquery": true, 16 | // "node": true, 17 | // "es5": true, 18 | // "esnext": true, 19 | // "bitwise": true, 20 | // "curly": true, 21 | // "immed": true, 22 | // "latedef": false, 23 | // "expr": true, 24 | // "eqnull": false, 25 | // "newcap": true, 26 | // "noarg": true, 27 | // "undef": true, 28 | // "proto": true, 29 | // "strict": false, 30 | // "smarttabs": true, 31 | // "forin": true, 32 | // "nonbsp": true, 33 | // "nonew": true, 34 | // "unused": true, 35 | } 36 | -------------------------------------------------------------------------------- /tasks/browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 浏览器热更新监听 4 | * 当 app/js 变化时,启动 task/scripts.js 5 | * 当 app/css 变化时,启动 task/styles.js 6 | * 当 app/views 变化时,启动 task/pages.js 7 | */ 8 | 9 | import gulp from 'gulp'; 10 | // gulp 判断语句 11 | import gulpif from 'gulp-if'; 12 | // 浏览器热更新 13 | import livereload from 'gulp-livereload'; 14 | // 命令行输出 15 | import util from 'gulp-util'; 16 | // 对命令行参数进行解析 17 | import args from './util/args'; 18 | 19 | // 使用 gulp 创建一个任务 20 | gulp.task('browser', (cb) => { 21 | if (!args.watch) { 22 | return cb(); 23 | } 24 | 25 | // 热更新 26 | gulp.watch(['app/**/*.js'], ['scripts']); 27 | gulp.watch(['app/**/*.css'], ['styles']); 28 | gulp.watch(['app/**/*.ejs'], ['pages']); 29 | }); 30 | -------------------------------------------------------------------------------- /tasks/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 设置 gulp task 的顺序 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // 删除命令 8 | import gulpSequence from 'gulp-sequence'; 9 | // 设置 gulp task 的顺序 10 | 11 | // 使用 gulp 创建一个任务 12 | gulp.task('build', gulpSequence('clean', 'styles', 'pages', 'scripts', ['browser', 'serve'])); 13 | -------------------------------------------------------------------------------- /tasks/clean.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 清空指定文件夹里的文件 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // 删除命令 8 | import del from 'del'; 9 | // 对命令行参数进行解析 10 | import args from './util/args'; 11 | 12 | // 使用 gulp 创建一个任务 13 | gulp.task('clean', () => { 14 | return del(['server/public', 'server/views']); 15 | }); 16 | -------------------------------------------------------------------------------- /tasks/default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 默认文件 4 | * 执行:gulp 5 | */ 6 | 7 | import gulp from 'gulp'; 8 | 9 | // 使用 gulp 创建一个任务 10 | gulp.task('default', ['build']); 11 | -------------------------------------------------------------------------------- /tasks/pages.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 处理模板 views 信息 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // gulp 判断语句 8 | import gulpif from 'gulp-if'; 9 | // 浏览器热更新 10 | import livereload from 'gulp-livereload'; 11 | // 对命令行参数进行解析 12 | import args from './util/args'; 13 | 14 | // 使用 gulp 创建一个任务 15 | gulp.task('pages', () => { 16 | return gulp.src('app/**/*.ejs') 17 | // 文件存放路径 18 | .pipe(gulp.dest('server')) 19 | // 热更新,若命令行中有 watch 这个参数才执行 20 | .pipe(gulpif(args.watch, livereload())); 21 | }); 22 | -------------------------------------------------------------------------------- /tasks/scripts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 处理 js 代码 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // gulp 判断语句 8 | import gulpif from 'gulp-if'; 9 | // 字符串拼接 10 | import concat from 'gulp-concat'; 11 | // 构建 12 | import webpack from 'webpack'; 13 | // 基于流的构建 14 | import gulpWebpack from 'webpack-stream'; 15 | // 处理文件信息流 16 | import plumber from 'gulp-plumber'; 17 | // 文件命名 18 | import named from 'vinyl-named'; 19 | // 文件重命名 20 | import rename from 'gulp-rename'; 21 | // 浏览器热更新 22 | import livereload from 'gulp-livereload'; 23 | // css、js压缩 24 | import uglify from 'gulp-uglify'; 25 | // 命令行输出 26 | import { log, colors } from 'gulp-util'; 27 | // 对命令行参数进行解析 28 | import args from './util/args'; 29 | 30 | // 使用 gulp 创建一个任务 31 | gulp.task('scripts', () => { 32 | return gulp.src('app/js/*.js') 33 | // 错误日志检查处理 34 | .pipe(plumber({ 35 | errorHandle: function() { 36 | 37 | } 38 | })) 39 | // 文件命名 40 | .pipe(named()) 41 | // 遇到 js 文件时,用 babel 处理 42 | // npm install babel-loader babel-core babel-preset-env --save-dev 43 | .pipe(gulpWebpack({ 44 | module: { 45 | loaders: [{ 46 | test: /\.js$/, 47 | loader: 'babel' 48 | }] 49 | } 50 | }), null, (err, stats) => { 51 | log(`Finished '${colors.cyan('scripts')}'`, stats.toString({ 52 | chunks: false 53 | })); 54 | }) 55 | // 文件存放路径 56 | .pipe(gulp.dest('server/public/js')) 57 | // 备份并重命名 58 | .pipe(rename({ 59 | basename: 'cp', 60 | extname: '.min.js' 61 | })) 62 | // 压缩 63 | .pipe(uglify({ 64 | compress: { 65 | properties: false 66 | }, 67 | output: { 68 | 'quote_keys': true 69 | } 70 | })) 71 | // 文件存放路径 72 | .pipe(gulp.dest('server/public/js')) 73 | // 热更新,若命令行中有 watch 这个参数才执行 74 | .pipe(gulpif(args.watch, livereload())); 75 | }); 76 | -------------------------------------------------------------------------------- /tasks/server.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 处理服务器的脚本 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // gulp 判断语句 8 | import gulpif from 'gulp-if'; 9 | // 启动服务器 10 | import liveserver from 'gulp-live-server'; 11 | // 对命令行参数进行解析 12 | import args from './util/args'; 13 | 14 | // 使用 gulp 创建一个任务 15 | gulp.task('serve', (cb) => { 16 | // 若命令行不处于监听状态,返回 17 | // if (!args.watch) { 18 | // return cb(); 19 | // } 20 | 21 | // 创建一个服务器并启动 22 | var server = liveserver.new(['--harmony', 'server/bin/www']); 23 | server.start(); 24 | 25 | // 热更新 26 | gulp.watch(['server/public/**/*.js', 'server/public/**/*.css', 'server/views/*.ejs'], (file) => { 27 | server.notify.apply(server, [file]); 28 | }); 29 | 30 | // 需要重启服务器才能更新 31 | gulp.watch(['server/routes/**/*.js', 'server/app.js'], () => { 32 | server.start.bind(server)(); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /tasks/styles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp 自动化配置 3 | * 处理 css 文件 4 | */ 5 | 6 | import gulp from 'gulp'; 7 | // gulp 判断语句 8 | import gulpif from 'gulp-if'; 9 | // 浏览器热更新 10 | import livereload from 'gulp-livereload'; 11 | // 对命令行参数进行解析 12 | import args from './util/args'; 13 | 14 | // 使用 gulp 创建一个任务 15 | gulp.task('styles', () => { 16 | return gulp.src('app/**/*.css') 17 | // 文件存放路径 18 | .pipe(gulp.dest('server/public')) 19 | // 热更新,若命令行中有 watch 这个参数才执行 20 | .pipe(gulpif(args.watch, livereload())); 21 | }); 22 | -------------------------------------------------------------------------------- /tasks/util/args.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 对命令行参数进行解析 3 | */ 4 | 5 | // node.js 命令行框架 6 | import yargs from 'yargs'; 7 | 8 | const args = yargs 9 | .option('production', { 10 | // 生产环境,默认关闭 11 | boolean: true, 12 | default: false, 13 | describe: 'min all scripts' 14 | }) 15 | .option('watch', { 16 | // 监听开发环境中的文件,自动更新 17 | boolean: true, 18 | default: false, 19 | describe: 'min all files' 20 | }) 21 | .option('verbose', { 22 | // 输出命令行执行日志 23 | boolean: true, 24 | default: false, 25 | describe: 'log' 26 | }) 27 | .option('sourcemaps', { 28 | // 压缩 29 | describe: 'force the creation of sourcemaps' 30 | }) 31 | .option('port', { 32 | // 服务器端口 33 | string: true, 34 | default: 8080, 35 | describe: 'server port' 36 | }) 37 | .argv; 38 | 39 | export default args; 40 | --------------------------------------------------------------------------------