Skip to content

Commit

Permalink
feat: done
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 12, 2024
1 parent eaba58f commit 6e8340c
Show file tree
Hide file tree
Showing 28 changed files with 397 additions and 147 deletions.
77 changes: 74 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,62 @@ log-lottery是一个可配置可定制化的抽奖应用,炫酷3D球体,可
## 功能描述

- 🕍 炫酷3D球体,年会抽奖必备,开箱即用
- 🧿 持久化存储,数据不丢失
- 🎁 奖品奖项配置
- 👱 抽奖名单设置管理
- 🛞 界面信息自定义
- 🎼 图片、背景音乐管理,使用本地存储
- 🎼 播放背景音乐
- 💾 图片、背景音乐管理,使用本地存储,有默认资源可直接使用
- 🖼️ excel表格导入人员名单、抽奖结果使用excel导出
- 🎈 临时增加抽奖
- 🎈 可增加临时抽奖

## 详细介绍

### 配置参与人员

于人员配置管理界面下载excel模板,按要求填好数据后导入即可。

### 配置奖项

于奖项配置管理界面添加奖项后,自定义修改名称、抽取人数、是否全员参加、图片显示。

### 界面配置

可自定义配置标题、列数、卡片颜色、首页图案等。

### 图片和音乐管理

上传图片或音乐即可,数据使用indexdb在浏览器本地进行存储。

## 预览

首页

![image_home](./static/images/home.png)

![image_home_prize_list](./static//images/home_prizelist.png)

抽奖

![image_lottery](./static/images/lottery-enter.png)

![image_lottery_done](./static/images/lottery-done.png)

配置

![image_config_person_all](./static/images/config_personall.png)

![image_config_prize_list](./static/images/config_prize.png)

![image_config_view](./static/images/config-view.png)

![image_config_pattern](./static/images/config_pattern.png)

图片音乐配置

![image_config_img](./static/images/image_config.png)

![image_music](./static/images/music_music.png)

## 技术

Expand All @@ -30,9 +80,30 @@ log-lottery是一个可配置可定制化的抽奖应用,炫酷3D球体,可
- pinia
- daisyui

## 开发

安装依赖

```bash
pnpm i
```

开发运行

```bash
pnpm dev
```

打包

```bash
pnpm build
```

> 项目思路来源于 https://github.com/moshang-xc/lottery
## License

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2024-present log1997
Copyright (c) 2024-present log1997
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@vueuse/core": "^10.6.1",
"axios": "^1.6.1",
"canvas-confetti": "^1.9.2",
"dayjs": "^1.11.10",
"localforage": "^1.10.0",
"pinia": "^2.1.7",
"pinia-plugin-persist": "^1.0.0",
Expand Down
18 changes: 7 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/icons/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/store/data.ts

Large diffs are not rendered by default.

52 changes: 35 additions & 17 deletions src/store/personConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { defineStore } from 'pinia';
import { IPersonConfig } from '@/types/storeType';
import { IPrizeConfig } from '@/types/storeType';
import { defaultPersonList } from './data'
import { usePrizeConfig } from './prizeConfig';
import dayjs from 'dayjs'
export const usePersonConfig = defineStore('person', {
state() {
return {
Expand All @@ -18,7 +20,18 @@ export const usePersonConfig = defineStore('person', {
},
// 获取全部人员名单
getAllPersonList(state) {
return state.personConfig.allPersonList;
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
return item
});
},
// 获取未获此奖的人员名单
getNotThisPrizePersonList(state: any) {
const currentPrize = usePrizeConfig().prizeConfig.currentPrize;
const data = state.personConfig.allPersonList.filter((item: IPersonConfig) => {
return !item.prizeId.includes(currentPrize.id as string);
});

return data
},
// 获取已中奖人员名单
getAlreadyPersonList(state) {
Expand All @@ -28,7 +41,7 @@ export const usePersonConfig = defineStore('person', {
},
// 获取中奖人员详情
getAlreadyPersonDetail(state) {
return state.personConfig.alreadyPersonList
return state.personConfig.alreadyPersonList
},
// 获取未中奖人员名单
getNotPersonList(state) {
Expand Down Expand Up @@ -57,11 +70,14 @@ export const usePersonConfig = defineStore('person', {
if (item.id === person.id && prize != null) {
item.isWin = true
// person.isWin = true
item.prizeName += prize.name
item.prizeName.push(prize.name)
// person.prizeName += prize.name
item.prizeTime = new Date().toString()
item.prizeTime.push(dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'))
// person.prizeTime = new Date().toString()
item.prizeId.push(prize.id as string)
}

return item
});
this.personConfig.alreadyPersonList.push(person);
});
Expand All @@ -71,27 +87,28 @@ export const usePersonConfig = defineStore('person', {
if (person.id == undefined || person.id == null) {
return
}
const alreadyPersonListLength= this.personConfig.alreadyPersonList.length
const alreadyPersonListLength = this.personConfig.alreadyPersonList.length
for (let i = 0; i < this.personConfig.allPersonList.length; i++) {
if (person.id === this.personConfig.allPersonList[i].id) {
this.personConfig.allPersonList[i].isWin = false
this.personConfig.allPersonList[i].prizeName = ''
this.personConfig.allPersonList[i].prizeTime = ''
this.personConfig.allPersonList[i].prizeName = []
this.personConfig.allPersonList[i].prizeTime = []
this.personConfig.allPersonList[i].prizeId = []

return
break
}
}
for(let i=0;i<alreadyPersonListLength;i++){
this.personConfig.alreadyPersonList=this.personConfig.alreadyPersonList.filter((item:IPersonConfig)=>{
return item.id!==person.id
})
for (let i = 0; i < alreadyPersonListLength; i++) {
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) =>
item.id !== person.id
)
}
},
// 删除指定人员
deletePerson(person: IPersonConfig) {
if (person.id != undefined || person.id != null) {
this.personConfig.allPersonList = this.personConfig.allPersonList.filter((item: IPersonConfig) => item.id !== person.id);
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id!== person.id);
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id !== person.id);
}
},
// 删除所有人员
Expand All @@ -110,14 +127,15 @@ export const usePersonConfig = defineStore('person', {
// 把已中奖人员合并到未中奖人员,要验证是否已存在
this.personConfig.allPersonList.forEach((item: IPersonConfig) => {
item.isWin = false;
item.prizeName = '';
item.prizeTime = '';
item.prizeName = [];
item.prizeTime = [];
item.prizeId = []
});
this.personConfig.alreadyPersonList=[];
this.personConfig.alreadyPersonList = [];
},
setDefaultPersonList() {
this.personConfig.allPersonList = defaultPersonList;
this.personConfig.alreadyPersonList=[];
this.personConfig.alreadyPersonList = [];
},
// 重置所有配置
reset() {
Expand Down
82 changes: 77 additions & 5 deletions src/store/prizeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ export const usePrizeConfig = defineStore('prize', {
isShow: true,
isUsed: false,
frequency: 1,
} as IPrizeConfig,
temporaryPrize:{
id: '',
name: '',
sort: 0,
isAll: false,
count: 1,
isUsedCount:0,
picture: {
id: '-1',
name: '',
url: ''
},
desc: '',
isShow: false,
isUsed: false,
frequency: 1,
} as IPrizeConfig
}
};
Expand All @@ -45,6 +62,10 @@ return state.prizeConfig.prizeList;
getCurrentPrize(state) {
return state.prizeConfig.currentPrize;
},
// 获取临时的奖项
getTemporaryPrize(state){
return state.prizeConfig.temporaryPrize;
},

},
actions: {
Expand All @@ -62,12 +83,25 @@ return state.prizeConfig.prizeList;
},
// 更新奖项数据
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
const index = this.prizeConfig.prizeList.findIndex(item => item.id === prizeConfigItem.id);
this.prizeConfig.prizeList[index] = prizeConfigItem;
if(prizeConfigItem.isUsed&&index+1<this.prizeConfig.prizeList.length){
// const index = this.prizeConfig.prizeList.findIndex(item => item.id === prizeConfigItem.id);
// this.prizeConfig.prizeList[index] = prizeConfigItem;
// if(prizeConfigItem.isUsed&&index+1<this.prizeConfig.prizeList.length){
// // 设置下一个为currentPrize
// this.setCurrentPrize(this.prizeConfig.prizeList[index+1]);
// }
if(prizeConfigItem.isUsed&&this.prizeConfig.prizeList.length){
// 设置下一个为currentPrize
this.setCurrentPrize(this.prizeConfig.prizeList[index+1]);
for(let i=0;i<this.prizeConfig.prizeList.length;i++){
if(!this.prizeConfig.prizeList[i].isUsed){
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
break;
}
}
}
else{
return
}
this.resetTemporaryPrize()
},
// 删除全部奖项
deleteAllPrizeConfig() {
Expand All @@ -77,6 +111,43 @@ return state.prizeConfig.prizeList;
setCurrentPrize(prizeConfigItem: IPrizeConfig) {
this.prizeConfig.currentPrize = prizeConfigItem
},
// 设置临时奖项
setTemporaryPrize(prizeItem: IPrizeConfig) {
if(prizeItem.isShow==false){
for(let i=0;i<this.prizeConfig.prizeList.length;i++){
if(this.prizeConfig.prizeList[i].isUsed==false){
this.setCurrentPrize(this.prizeConfig.prizeList[i]);

break
}
}
this.resetTemporaryPrize()

return
}

this.prizeConfig.temporaryPrize = prizeItem
},
// 重置临时奖项
resetTemporaryPrize() {
this.prizeConfig.temporaryPrize = {
id: '',
name: '',
sort: 0,
isAll: false,
count: 1,
isUsedCount:0,
picture: {
id: '-1',
name: '',
url: ''
},
desc: '',
isShow: false,
isUsed: false,
frequency: 1,
} as IPrizeConfig;
},
// 重置所有配置
resetDefault() {
this.prizeConfig = {
Expand All @@ -97,7 +168,8 @@ return state.prizeConfig.prizeList;
isShow: true,
isUsed: false,
frequency: 1,
} as IPrizeConfig
} as IPrizeConfig,
temporaryPrize:{} as IPrizeConfig
}
}
},
Expand Down
1 change: 1 addition & 0 deletions src/style/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.element-card {
cursor: default;
text-align: center;
user-select: none;
.card-id {
position: absolute;
top: 20px;
Expand Down
Loading

0 comments on commit 6e8340c

Please sign in to comment.