Code Monkey home page Code Monkey logo

lottery-2016's Introduction

NOTE 建议使用这个,更完善 更符合现在的浏览器

https://github.com/JX3BOX/lottery

芒果TV 2016 年会抽奖


声明: 该代码使用nodejs, coffee, sqlite3 运行于linux, mac. 该代码没有经过window测试. 不对任何windows平台bug进行修复.

该代码实际跑12米 * 5 米在屏幕上,分辨率为1080P(1920 * 1080)

该程序已完工.完工日期大概为2016.2.1 [补充实际完成于2.2]

GO! GO! Go!

Prepare

  1. 安装coffee和node-dev
npm install -g coffee-script
  1. 准备员工照片. 尺寸为300 * 300, 文件名格式为 "工号_姓名.png" 如 "001_张三.jpg"(jpg或png都可以).这个用来初始话员工数据库.放在同一个文件夹下.

Download & Run

  1. clone 本仓库或者下载源码解压得到文件夹 lottery-2016

  2. 找到文件 config.coffee

修改配置

config =
  ...
  ...
  img_source: '/home/ec/document/2016'
  ...

img_source 使用绝对路径指向员工照片的文件.

  1. 找到文件init-data.coffee

取消最后三行注释后运行:(注意:以下命令均在项目文件夹下进行)

coffee init-data.coffee

进行数据初始化.初始化完成后将会在项目目录下出现db.sqlite这个就是数据库了.需要重复测试抽奖可以备份该文件,进行覆盖即可.

  1. 运行
npm start

打开浏览器

http://localhost:3000

然后进行抽奖设置,和奖品设置即可.

如果抽奖需要混合奖品(非单一)可以根据数据库将奖品命名为:

 mix_(奖品数据库id-名称-数量)_(奖品数据库id-名称-数量)_...

例如:

mix_(28-温情家庭礼包-10)_(29-富士拍立得-10)_(30-芒果小觅-10)

另外记得修改html,增加与抽奖数量有关的抽奖结果模版。static/lottery-start.html 具体查看issue #1

<!--4*4+3*3+3*3=34-->
  <script type="text/x-handlebars-template" id="lotteryListTemplate_34">
    <div class="allbox b433">
      {{#each list}}
      <div class="prize ul{{count}}">
        <span class="z1"><i class="w-thing" style="background: url('award/{{award_id}}.png') bottom center no-repeat;"></i>{{award_name}}</span>
        <ul>
          {{#each luckyList}}
          <li><img src="avatar/{{num}}.jpg"> <span>{{name}}</span><i>{{num}}</i></li>
          {{/each}}
        </ul>
      </div>
      {{/each}}
    </div>
  </script>

Thanks

LICENSE

MIT

lottery-2016's People

Contributors

huyinghuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lottery-2016's Issues

项目启动报错

SyntaxError: Invalid regular expression: /^\api\lottery(?:([^\/]+?))/?$/: Unmatched ')'
at new RegExp (:null:null)
at pathtoRegexp (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_path-to-regexp@0.1.7@path-to-regexp\index.js:128:10)
at new Layer (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_express@4.16.3@express\lib\router\layer.js:45:17)
at Function.route (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_express@4.16.3@express\lib\router\index.js:494:15)
at new Router (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_water-pit@0.0.4@water-pit\lib\router.js:16:14)
at Waterpit.initRouter (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_water-pit@0.0.4@water-pit\lib\index.js:25:22)
at new Waterpit (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_water-pit@0.0.4@water-pit\lib\index.js:16:12)
at Object. (C:\Users\elfaz\Documents\GitHub\lottery-2016\app.coffee:12:9)
at Object. (C:\Users\elfaz\Documents\GitHub\lottery-2016\app.coffee:1:1)
at Module._compile (module.js:652:30)
at loadFile (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_coffee-script@1.12.7@coffee-script\lib\coffee-script\register.js:16:19)
at Object.nodeDevHook [as .coffee] (C:\Users\elfaz\AppData\Roaming\npm\node_modules\node-dev\lib\hook.js:61:7)
at Module.load (C:\Users\elfaz\Documents\GitHub\lottery-2016\node_modules_coffee-script@1.12.7@coffee-script\lib\coffee-script\register.js:45:36)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\elfaz\AppData\Roaming\npm\node_modules\node-dev\lib\wrap.js:73:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3

[ERROR] 11:06:35 SyntaxError
--- Update table award begin...
--- Update table employee begin...
--- Update table lottery begin...

运行环境配置问题 TypeError: Cannot read property 'replace' of undefined

尝试按照Readme中的指导说明在一台全新的 ubuntu 16.04.1-desktop-amd64 中操作。
并按照提示安装了
sudo apt-get install npm
sudo npm install node-dev -g
sudo npm install coffee-script -g
vi config.coffee
vi init-data.coffee
sudo ln /usr/bin/nodejs /usr/bin/node
npm install fs-extra
npm install lodash
npm install coal
npm install sqlite3

初始化的时候提示错误
xiang@xiang:~/lottery-2016-master$ coffee init-data.coffee
Create award begin !
Create employee begin !
Create award success !
Create lottery begin !
Create employee success !
Create lottery success !
/home/xiang/lottery-2016-master/init-data.coffee:29
num = num.replace(/\s/g, "");
^
TypeError: Cannot read property 'replace' of undefined
at /home/xiang/lottery-2016-master/init-data.coffee:29:18
at FSReqWrap.oncomplete (fs.js:82:15)

当我尝试注释掉 # num = num.replace(/\s/g, "") 继续初始化,提示照片插入失败
xiang@xiang:~/lottery-2016-master$ coffee init-data.coffee
--- Update table award begin...
--- Update table employee begin...
--- Update table lottery begin...
--- Update table award finish.
--- Update table lottery finish.
--- Update table employee finish.
error! zhang3.jpg
本次插入0
所有数据插入成功!
[ { 'count(*)': 1 } ]

然后通过网页开始抽奖的时候自然不显示头像,也没有气球, 按回车也没有停止的反应。
不知道如何能够解决以上问题。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.