feat: feat
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,25 +1,26 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defaultMusicList,defaultImageList } from './data'
|
||||
// import { IPrizeConfig } from '@/types/prizeConfig';
|
||||
import {IMusic,IImage} from '@/types/storeType';
|
||||
// import { IPrizeConfig } from '@/types/storeType';
|
||||
export const useGlobalConfig = defineStore('global', {
|
||||
state() {
|
||||
return {
|
||||
globalConfig: {
|
||||
rowCount: 12,
|
||||
rowCount: 17,
|
||||
isSHowPrizeList:true,
|
||||
topTitle:'大明内阁六部御前奏对',
|
||||
theme: {
|
||||
name: 'dark',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: 'rgba(0, 255, 255)',
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor:'#ECB1AC',
|
||||
textSize: 30
|
||||
},
|
||||
musicList: defaultMusicList,
|
||||
imageList:defaultImageList,
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList:defaultImageList as IImage[],
|
||||
},
|
||||
currentMusic: {
|
||||
item:defaultMusicList[0],
|
||||
@@ -122,7 +123,7 @@ export const useGlobalConfig = defineStore('global', {
|
||||
this.globalConfig.theme.textSize = textSize;
|
||||
},
|
||||
// 添加音乐
|
||||
addMusic(music: any) {
|
||||
addMusic(music: IMusic) {
|
||||
// 验证音乐是否已存在,看name字段
|
||||
for (let i = 0; i < this.globalConfig.musicList.length; i++) {
|
||||
if (this.globalConfig.musicList[i].name === music.name) {
|
||||
@@ -141,7 +142,7 @@ export const useGlobalConfig = defineStore('global', {
|
||||
}
|
||||
},
|
||||
// 设置当前播放音乐
|
||||
setCurrentMusic(musicItem: any,paused:boolean=true) {
|
||||
setCurrentMusic(musicItem: IMusic,paused:boolean=true) {
|
||||
this.currentMusic={
|
||||
item:musicItem,
|
||||
paused:paused,
|
||||
@@ -149,14 +150,14 @@ export const useGlobalConfig = defineStore('global', {
|
||||
},
|
||||
// 重置音乐列表
|
||||
resetMusicList() {
|
||||
this.globalConfig.musicList = defaultMusicList;
|
||||
this.globalConfig.musicList = defaultMusicList as IMusic[];
|
||||
},
|
||||
// 清空音乐列表
|
||||
clearMusicList() {
|
||||
this.globalConfig.musicList = [];
|
||||
this.globalConfig.musicList = [] as IMusic[];
|
||||
},
|
||||
// 添加图片
|
||||
addImage(image:any){
|
||||
addImage(image:IImage){
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].name === image.name) {
|
||||
return;
|
||||
@@ -175,11 +176,11 @@ export const useGlobalConfig = defineStore('global', {
|
||||
},
|
||||
// 重置图片列表
|
||||
resetImageList() {
|
||||
this.globalConfig.imageList = defaultImageList;
|
||||
this.globalConfig.imageList = defaultImageList as IImage[];
|
||||
},
|
||||
// 清空图片列表
|
||||
clearImageList() {
|
||||
this.globalConfig.imageList = [];
|
||||
this.globalConfig.imageList = [] as IImage[]
|
||||
},
|
||||
// 设置是否显示奖品列表
|
||||
setIsShowPrizeList(isShowPrizeList: boolean) {
|
||||
@@ -202,11 +203,11 @@ export const useGlobalConfig = defineStore('global', {
|
||||
textSize: 30
|
||||
|
||||
},
|
||||
musicList: defaultMusicList,
|
||||
imageList:defaultImageList,
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList:defaultImageList as IImage[],
|
||||
},
|
||||
this.currentMusic= {
|
||||
item:defaultMusicList[0],
|
||||
item:defaultMusicList[0] as IMusic,
|
||||
paused:true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { IPersonConfig } from '@/types/personConfig';
|
||||
import { IPrizeConfig } from '@/types/prizeConfig';
|
||||
import {defaultPersonList} from './data'
|
||||
import { IPersonConfig } from '@/types/storeType';
|
||||
import { IPrizeConfig } from '@/types/storeType';
|
||||
import { defaultPersonList } from './data'
|
||||
export const usePersonConfig = defineStore('person', {
|
||||
state() {
|
||||
return {
|
||||
personConfig: {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
// alreadyPersonList: [] as IPersonConfig[],
|
||||
// notPersonList: [] as IPersonConfig[],
|
||||
tableRowCount: 12,
|
||||
showField: [] as any[]
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -29,20 +26,16 @@ export const usePersonConfig = defineStore('person', {
|
||||
return item.isWin === true;
|
||||
});
|
||||
},
|
||||
// 获取中奖人员详情
|
||||
getAlreadyPersonDetail(state) {
|
||||
return state.personConfig.alreadyPersonList
|
||||
},
|
||||
// 获取未中奖人员名单
|
||||
getNotPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item.isWin === false;
|
||||
});
|
||||
},
|
||||
// 获取table列数
|
||||
getTableRowCount(state) {
|
||||
return state.personConfig.tableRowCount;
|
||||
},
|
||||
// 获取要展示那些字段
|
||||
getShowField(state) {
|
||||
return state.personConfig.showField;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 添加未中奖人员
|
||||
@@ -61,59 +54,77 @@ export const usePersonConfig = defineStore('person', {
|
||||
}
|
||||
personList.forEach((person: IPersonConfig) => {
|
||||
this.personConfig.allPersonList.map((item: IPersonConfig) => {
|
||||
if (item.id === person.id&&prize!=null) {
|
||||
if (item.id === person.id && prize != null) {
|
||||
item.isWin = true
|
||||
item.prizeName = prize.name
|
||||
// person.isWin = true
|
||||
item.prizeName += prize.name
|
||||
// person.prizeName += prize.name
|
||||
item.prizeTime = new Date().toString()
|
||||
// person.prizeTime = new Date().toString()
|
||||
}
|
||||
});
|
||||
console.log('person;;',person)
|
||||
this.personConfig.alreadyPersonList.push(person);
|
||||
});
|
||||
},
|
||||
// 从已中奖移动到未中奖
|
||||
moveAlreadyToNot(person: IPersonConfig) {
|
||||
if (person.id != undefined || person.id != null) {
|
||||
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=''
|
||||
|
||||
return
|
||||
}
|
||||
if (person.id == undefined || person.id == null) {
|
||||
return
|
||||
}
|
||||
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 = ''
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
for(let i=0;i<alreadyPersonListLength;i++){
|
||||
this.personConfig.alreadyPersonList=this.personConfig.alreadyPersonList.filter((item:IPersonConfig)=>{
|
||||
return 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);
|
||||
}
|
||||
},
|
||||
// 删除所有人员
|
||||
deleteAllPerson() {
|
||||
this.personConfig.allPersonList = [];
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
|
||||
// 重置所有人员
|
||||
// 删除所有人员
|
||||
resetPerson() {
|
||||
this.personConfig.allPersonList = [];
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
// 重置已中奖人员
|
||||
resetAlreadyPerson() {
|
||||
// 把已中奖人员合并到未中奖人员,要验证是否已存在
|
||||
this.personConfig.allPersonList.forEach((item: IPersonConfig) => {
|
||||
item.isWin = false;
|
||||
item.isWin = false;
|
||||
item.prizeName = '';
|
||||
item.prizeTime = '';
|
||||
});
|
||||
this.personConfig.alreadyPersonList=[];
|
||||
},
|
||||
setDefaultPersonList() {
|
||||
this.personConfig.allPersonList = defaultPersonList;
|
||||
this.personConfig.alreadyPersonList=[];
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.personConfig = {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
tableRowCount: 12,
|
||||
showField: [] as string[]
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { IPrizeConfig } from '@/types/prizeConfig';
|
||||
import { IPrizeConfig } from '@/types/storeType';
|
||||
import { defaultPrizeList } from './data';
|
||||
export const usePrizeConfig = defineStore('prize', {
|
||||
state() {
|
||||
@@ -71,11 +71,11 @@ return state.prizeConfig.prizeList;
|
||||
},
|
||||
// 删除全部奖项
|
||||
deleteAllPrizeConfig() {
|
||||
this.prizeConfig.prizeList = [];
|
||||
this.prizeConfig.prizeList = [] as IPrizeConfig[];
|
||||
},
|
||||
// 设置当前奖项
|
||||
setCurrentPrize(prizeConfigItem: IPrizeConfig) {
|
||||
this.prizeConfig.currentPrize = prizeConfigItem;
|
||||
this.prizeConfig.currentPrize = prizeConfigItem
|
||||
},
|
||||
// 重置所有配置
|
||||
resetDefault() {
|
||||
@@ -97,7 +97,7 @@ return state.prizeConfig.prizeList;
|
||||
isShow: true,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
},
|
||||
} as IPrizeConfig
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user