5785bc9c63958ab580b07e3cfbb7f009883374b6.svn-base 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import publicFun from '@/assets/publicFunction';
  4. Vue.use(Vuex);
  5. /**
  6. * 设置全局访问的state对象
  7. */
  8. const state={
  9. gameRatio:'', //玩法比率数据
  10. activity:publicFun.getCache('activity'),//活动类别
  11. ballId:publicFun.getCache('ballId'),//球类Id
  12. show:'',//Loading组件的状态显隐
  13. isShow:false,//登录按钮点击显示登录页
  14. rgShow:false,//注册组件显示
  15. macth_id:publicFun.getCache('macth_id'),//赛事id
  16. betting:JSON.parse(publicFun.getCache('betting')),//投注数据
  17. isBetting:publicFun.getCache('isBetting'),//是否展示投注窗口
  18. deleteType:'',//投注框数据删除id或类型
  19. }
  20. /**
  21. * 实时监听state里面值的变法(最新变法)
  22. */
  23. const getters={
  24. getGameRatio(state){
  25. return state.gameRatio;
  26. },
  27. getActivity(state){
  28. return state.activity;
  29. },
  30. getBallId(state){
  31. return state.ballId;
  32. },
  33. getShow(state){
  34. return state.show;
  35. },
  36. getRgShow(state){
  37. return state.rgShow;
  38. },
  39. getMatchId(state){
  40. return state.macth_id;
  41. },
  42. getBetting(state){
  43. return state.betting;
  44. },
  45. getIsBetting(state){
  46. return state.isBetting;
  47. },
  48. getDeleteType(state){
  49. return state.deleteType;
  50. }
  51. }
  52. /**
  53. * 设置对外可调用的方法
  54. */
  55. const mutations = {
  56. newGameRatio(state,val){
  57. //publicFun.getCache('activity')
  58. state.gameRatio = val;
  59. },
  60. newActivity(state,val){
  61. state.activity = val;
  62. publicFun.setCache('activity',val)
  63. },
  64. newBallId(state,val){
  65. state.ballId = val;
  66. publicFun.setCache('ballId',val)
  67. },
  68. newShow(state,val){
  69. state.show = val;
  70. },
  71. newisShow(state,val){
  72. state.isShow = val;
  73. },
  74. newRgShow(state,val){
  75. state.rgShow = val;
  76. },
  77. newMacth_id(state,val){
  78. state.macth_id = val;
  79. publicFun.setCache('macth_id',val);
  80. },
  81. newBetting(state,val){
  82. state.betting = val;
  83. publicFun.setCache('betting',val);
  84. },
  85. newIsBetting(state,val){
  86. state.isBetting = val;
  87. publicFun.setCache('isBetting',val);
  88. },
  89. newDeleteType(state,val){
  90. state.deleteType = val;
  91. },
  92. }
  93. /**
  94. * 这里面的方法是用来异步触发mutations里面的方法
  95. */
  96. const actions={
  97. GETGAMERATIO(context,val){
  98. context.commit('newGameRatio',val)
  99. },
  100. GETACTIVITY(context,val){
  101. context.commit('newActivity',val);
  102. },
  103. GET_BALL_ID(context,val){
  104. context.commit('newBallId',val);
  105. },
  106. GETSHOW(context,val){
  107. context.commit('newShow',val)
  108. },
  109. GET_ISSHOW(context,val){
  110. context.commit('newisShow',val)
  111. },
  112. GETRGSHOW(context,val){
  113. context.commit('newRgShow',val)
  114. },
  115. MACTH_ID(context,val){
  116. context.commit('newMacth_id',val)
  117. },
  118. BETTING(context,val){
  119. context.commit('newBetting',val)
  120. },
  121. ISBETTING(context,val){
  122. context.commit('newIsBetting',val)
  123. },
  124. DEL_TYPE(context,val){
  125. context.commit('newDeleteType',val)
  126. }
  127. }
  128. const store =new Vuex.Store({
  129. state,
  130. getters,
  131. mutations,
  132. actions
  133. });
  134. export default store;