b7386e8f770eed2a4dd01d5ba11029c5e1389e74.svn-base 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. token:'',
  20. }
  21. /**
  22. * 实时监听state里面值的变法(最新变法)
  23. */
  24. const getters={
  25. getGameRatio(state){
  26. return state.gameRatio;
  27. },
  28. getActivity(state){
  29. return state.activity;
  30. },
  31. getBallId(state){
  32. return state.ballId;
  33. },
  34. getShow(state){
  35. return state.show;
  36. },
  37. getIsShow(state){
  38. return state.isShow;
  39. },
  40. getRgShow(state){
  41. return state.rgShow;
  42. },
  43. getMatchId(state){
  44. return state.macth_id;
  45. },
  46. getBetting(state){
  47. return state.betting;
  48. },
  49. getIsBetting(state){
  50. return state.isBetting;
  51. },
  52. getDeleteType(state){
  53. return state.deleteType;
  54. },
  55. getToken(state){
  56. return state.token;
  57. }
  58. }
  59. /**
  60. * 设置对外可调用的方法
  61. */
  62. const mutations = {
  63. newGameRatio(state,val){
  64. //publicFun.getCache('activity')
  65. state.gameRatio = val;
  66. },
  67. newActivity(state,val){
  68. state.activity = val;
  69. publicFun.setCache('activity',val)
  70. },
  71. newBallId(state,val){
  72. state.ballId = val;
  73. publicFun.setCache('ballId',val)
  74. },
  75. newShow(state,val){
  76. state.show = val;
  77. },
  78. newisShow(state,val){
  79. state.isShow = val;
  80. },
  81. newRgShow(state,val){
  82. state.rgShow = val;
  83. },
  84. newMacth_id(state,val){
  85. state.macth_id = val;
  86. publicFun.setCache('macth_id',val);
  87. },
  88. newBetting(state,val){
  89. state.betting = val;
  90. publicFun.setCache('betting',val);
  91. },
  92. newIsBetting(state,val){
  93. state.isBetting = val;
  94. publicFun.setCache('isBetting',val);
  95. },
  96. newToken(state,val){
  97. state.token = val;
  98. // publicFun.setItem('token',val);
  99. },
  100. newDeleteType(state,val){
  101. state.deleteType = val;
  102. },
  103. }
  104. /**
  105. * 这里面的方法是用来异步触发mutations里面的方法
  106. */
  107. const actions={
  108. GETGAMERATIO(context,val){
  109. context.commit('newGameRatio',val)
  110. },
  111. GETACTIVITY(context,val){
  112. context.commit('newActivity',val);
  113. },
  114. GET_BALL_ID(context,val){
  115. context.commit('newBallId',val);
  116. },
  117. GETSHOW(context,val){
  118. context.commit('newShow',val)
  119. },
  120. GET_ISSHOW(context,val){
  121. context.commit('newisShow',val)
  122. },
  123. GETRGSHOW(context,val){
  124. context.commit('newRgShow',val)
  125. },
  126. MACTH_ID(context,val){
  127. context.commit('newMacth_id',val)
  128. },
  129. BETTING(context,val){
  130. context.commit('newBetting',val)
  131. },
  132. ISBETTING(context,val){
  133. context.commit('newIsBetting',val)
  134. },
  135. DEL_TYPE(context,val){
  136. context.commit('newDeleteType',val)
  137. },
  138. SET_TOKEN(context,val){
  139. context.commit('newToken',val)
  140. }
  141. }
  142. const store =new Vuex.Store({
  143. state,
  144. getters,
  145. mutations,
  146. actions
  147. });
  148. export default store;