import Vue from 'vue'; import Vuex from 'vuex'; import publicFun from '@/assets/publicFunction'; Vue.use(Vuex); /** * 设置全局访问的state对象 */ const state={ gameRatio:'', //玩法比率数据 activity:publicFun.getItem('activity'),//活动类别 ballId:publicFun.getItem('ballId'),//球类Id show:'',//Loading组件的状态显隐 isShow:false,//登录按钮点击显示登录页 rgShow:false,//注册组件显示 macth_id:publicFun.getItem('macth_id'),//赛事id betting:JSON.parse(publicFun.getItem('betting')),//投注数据 isBetting:publicFun.getItem('isBetting'),//是否展示投注窗口 deleteType:'',//投注框数据删除id或类型 token:'',//用户凭证 limit:publicFun.getItem('limit'),//限制投注窗投注数量 headTitle:JSON.parse(publicFun.getItem('headTitle')),//头部导航数据信息 noRoll:false,// 禁止背景滚动 playAlias:JSON.parse(publicFun.getItem('playAlias')),//玩法别名 homeRollBall:'',//首页滚球数据 limitingCond:{},//下注上下限条件 "lower_limit": 10,"upper_limit": 10000 messageDetail:JSON.parse(publicFun.getItem('messageDetail')) } /** * 实时监听state里面值的变法(最新变法) */ const getters={ getNoRoll(state){ return state.noRoll }, getGameRatio(state){ return state.gameRatio; }, getActivity(state){ return state.activity; }, getBallId(state){ return state.ballId; }, getShow(state){ return state.show; }, getIsShow(state){ return state.isShow; }, getRgShow(state){ return state.rgShow; }, getMatchId(state){ return state.macth_id; }, getBetting(state){ return state.betting; }, getIsBetting(state){ return state.isBetting; }, getDeleteType(state){ return state.deleteType; }, getToken(state){ return state.token; }, getLimit(state){ return state.limit; }, getHeadTitle(state){ return state.headTitle; }, getPlayAlias(state){ return state.playAlias; }, getHomeRollBall(state){ return state.homeRollBall; }, getLimitingCond(state){ state.limitingCond }, getMessageDetail(state){ return state.messageDetail } } /** * 设置对外可调用的方法 */ const mutations = { newNoRoll(state,val){ state.noRoll = val }, newGameRatio(state,val){ //publicFun.getCache('activity') state.gameRatio = val; }, newActivity(state,val){ state.activity = val; publicFun.setItem('activity',val) }, newBallId(state,val){ state.ballId = val; publicFun.setItem('ballId',val) }, newShow(state,val){ state.show = val; }, newisShow(state,val){ state.isShow = val; }, newRgShow(state,val){ state.rgShow = val; }, newMacth_id(state,val){ state.macth_id = val; publicFun.setItem('macth_id',val); }, newBetting(state,val){ let index =0; if(val){ val.forEach(e=> { index += e.data.length }); } state.betting = val; publicFun.setItem('betting',val); state.limit =index; publicFun.setItem('limit',index); }, newIsBetting(state,val){ state.isBetting = val; publicFun.setItem('isBetting',val); }, newToken(state,val){ state.token = val; publicFun.setItem('token',val); }, newDeleteType(state,val){ state.deleteType = val; }, newLimit(state,val){ state.limit = val; publicFun.setItem('limit',val); }, newHeadTitle(state,val){ state.headTitle = val; publicFun.setItem('headTitle',val); }, newPlayAlias(state,val){ state.playAlias = val; publicFun.setItem('playAlias',val); }, newHomeRollBall(state,val){ state.homeRollBall = val; }, newLimitingCond(state,val){ state.limitingCond = val; // console.log(val); publicFun.setItem('limitingCond',val) }, newMessageDetail(state,val){ state.messageDetail = val; publicFun.setItem('messageDetail',val) }, } /** * 这里面的方法是用来异步触发mutations里面的方法 */ const actions={ GETGAMERATIO(context,val){ context.commit('newGameRatio',val) }, GETACTIVITY(context,val){ context.commit('newActivity',val); }, GET_BALL_ID(context,val){ context.commit('newBallId',val); }, GETSHOW(context,val){ context.commit('newShow',val) }, GET_ISSHOW(context,val){ context.commit('newisShow',val) }, GETRGSHOW(context,val){ context.commit('newRgShow',val) }, MACTH_ID(context,val){ context.commit('newMacth_id',val) }, BETTING(context,val){ context.commit('newBetting',val) }, ISBETTING(context,val){ context.commit('newIsBetting',val) }, DEL_TYPE(context,val){ context.commit('newDeleteType',val) }, SET_TOKEN(context,val){ context.commit('newToken',val) }, SET_LIMIT(context,val){ context.commit('newLimit',val) }, SET_HEADTITLE(context,val){ context.commit('newHeadTitle',val) }, SET_NOROLL(context,val){ context.commit('newNoRoll',val) }, SET_PLAYALIAS(context,val){ context.commit('newPlayAlias',val) }, SET_HOMEROLLBALL(context,val){ context.commit('newHomeRollBall',val) }, SET_LIMITINGCOND(context,val){ context.commit('newLimitingCond',val) }, SET_MESSAGEDETAIl(context,val){ context.commit('newMessageDetail',val) } } const store =new Vuex.Store({ state, getters, mutations, actions }); export default store;