Coder Social home page Coder Social logo

lottery's Introduction

抽奖

该抽奖程序 每次可以抽取多个不同奖品。

直接使用linuxmac

  • 运行脚本build.sh

在项目的release文件夹下执行

  • 生成demo数据 ./app --demo
  • 初始化数据库 ./app --init
  • 执行 ./app
  • 然后用 chrome 打开 http://localhost:14422/ 即可。 windowlinux下 按F11全屏, mac好像是 cmd + shift + f全屏

操作说明

在浏览器查看使用说明即可

二次开发

LinuxMac 执行:

go run main.go
# 新开终端
cd web-src
cnpm install # npm install
cnpm start # npm start

编译

运行脚本build.sh

该脚本不提供 maclinux的跨平台编译。

由于本程序使用了 sqlite3 如果需要跨系统编译需要gcc,或者 通过修改 database/init.go第9行第22行替换成mysql来避免使用gcc编译】

动画配置

参数定义在: web-src/lib/game.tsIAnimationIEndingAnimation 参数配置在: web-src/Lottery.tsxcomponentDidMountnew GameScreen

使用IDE搜索即可找到具体代码

配置文件说明

用户池 配置

修改文件 lottery/conf/user.json

[
    {
        "name": "用户名",
        "avatar":"头像",
        "uuid":"用户唯一标识",
        "pool": "用户池" // 抽奖时 有多个用户池,可选,默认为
    },
    // ...
]

奖品列表 配置

修改文件 lottery/conf/award.json

[
    {
        "id": 1 , // 奖品id,不重复
        "name": "奖品名称",
        "avatar":"奖品图片",
    },
    {
        "id": 2 , 
        "name": "...",
        "avatar":"...",
    }
    // ...
]

抽奖配置

文件 setting.json 放在lottery/conf/setting.json

抽奖将按配置依次进行。

[
    // 第一条配置表示,第一轮 从用户池1 抽取 奖品1 10个,奖品2 5个
    {
        "pool":"用户池1", //可选
        "rule":[{
            "award_id": 1, // 奖品id, 请用 奖品配置 award.json 里面的id,
            "count": 10, // 抽多少个奖品,如果每轮抽奖有多个奖品,数组里面填多个奖品的抽奖数量,
        },
        {
            "award_id": 2, // 奖品id, 请用 奖品配置 award.json 里面的id, 如果每轮抽奖有多个奖品,数组里面填多个id
            "count": 5, // 抽多少个奖品,如果每轮抽奖有多个奖品,数组里面填多个奖品的抽奖数量, 
        }]
    },
    // 第二条配置表示,第二轮 从用户池2 抽取 奖品3 20个
    {
        "pool":"用户池2",
        "rule":[{
            "award_id": 3, 
            "count": 20,
        }]
    }
]

修改好配置后执行 ./app --init 重新初始化数据库

License

MIT

打赏

如果对你有帮助,可以请喝咖啡。【请备注github帐户】

lottery's People

Contributors

flyflyknife avatar huyinghuan avatar iruxu 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

Watchers

 avatar  avatar  avatar  avatar

lottery's Issues

需求-1

可中奖用户数据池

标识 描述 备注
A 所有参与投票的用户并有在直播现场的 team_vote_log
B 所有百强榜队员并有在直播现场的 team_race
C 所有通关的团队 team_race
D 所有竞猜正确的推栏用户 team_guess_record

滚屏内容

标识 描述 结束时同时显示
个人 用户头像 用户昵称
团队 团队队徽 团队名称

所有奖品项:(类似VIP系统里的商品项)

编号 描述 份数 数据池 红包封面
1 8.88元红包 10*10 A 玩家芸生
2 16.88元红包 10*10 A 山居数码
3 18.88元红包 10*10 A 配装器
4 28.88元红包 10*10 A 蝶恋花·一醉江湖团队
5 68.88元红包 10*5 A 天鹅坪·樽前团队
6 88.88元红包 10*5 A JX3BOX魔盒
7 醒魂香实物 1*3 B
8 山居数码实物 1*3 B
9 15元通宝 10*3 D
10 30元通宝 10*3 B
11 腾讯VIP年卡 1*5 C
12 年卡一张 1 B

红包累计发出:15240(注意留存excel需要公示)

直播现场

1、关注微信公众号
2、绑定网站账号,建立关系
3、回复“抽奖”进入A奖池

抽奖效果调整

1.调整下落速度

目前的下落速度可以减慢约20%,目前太快。

2. 头像需要增大一倍

滚屏时可适量减少数目,一次最多只会产生10个中奖用户,可以分2行。

3.停止时需要显示名称

最终抽出来之后,头像下面最好能同时显示昵称或团队名称,主持人需要念出来。

报错

如何解决运行后TypeError: Cannot read property 'map' of null

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.