547244cfcf1858b5f556562921faf566434ed6bf.svn-base 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.getItem('activity'),//活动类别
  11. ballId:publicFun.getItem('ballId'),//球类Id
  12. show:'',//Loading组件的状态显隐
  13. isShow:false,//登录按钮点击显示登录页
  14. rgShow:false,//注册组件显示
  15. macth_id:publicFun.getItem('macth_id'),//赛事id
  16. betting:JSON.parse(publicFun.getItem('betting')),//投注数据
  17. isBetting:publicFun.getItem('isBetting'),//是否展示投注窗口
  18. deleteType:'',//投注框数据删除id或类型
  19. token:'',//用户凭证
  20. limit:publicFun.getItem('limit'),//限制投注窗投注数量
  21. headTitle:JSON.parse(publicFun.getItem('headTitle')),//头部导航数据信息
  22. // 禁止背景滚动
  23. noRoll:false,
  24. }
  25. /**
  26. * 实时监听state里面值的变法(最新变法)
  27. */
  28. const getters={
  29. getNoRoll(state){
  30. return state.noRoll
  31. },
  32. getGameRatio(state){
  33. return state.gameRatio;
  34. },
  35. getActivity(state){
  36. return state.activity;
  37. },
  38. getBallId(state){
  39. return state.ballId;
  40. },
  41. getShow(state){
  42. return state.show;
  43. },
  44. getIsShow(state){
  45. return state.isShow;
  46. },
  47. getRgShow(state){
  48. return state.rgShow;
  49. },
  50. getMatchId(state){
  51. return state.macth_id;
  52. },
  53. getBetting(state){
  54. return state.betting;
  55. },
  56. getIsBetting(state){
  57. return state.isBetting;
  58. },
  59. getDeleteType(state){
  60. return state.deleteType;
  61. },
  62. getToken(state){
  63. return state.token;
  64. },
  65. getLimit(state){
  66. return state.limit;
  67. },
  68. getHeadTitle(state){
  69. return state.headTitle;
  70. }
  71. }
  72. /**
  73. * 设置对外可调用的方法
  74. */
  75. const mutations = {
  76. newNoRoll(state,val){
  77. state.noRoll = val
  78. },
  79. newGameRatio(state,val){
  80. //publicFun.getCache('activity')
  81. state.gameRatio = val;
  82. },
  83. newActivity(state,val){
  84. state.activity = val;
  85. publicFun.setItem('activity',val)
  86. },
  87. newBallId(state,val){
  88. state.ballId = val;
  89. publicFun.setItem('ballId',val)
  90. },
  91. newShow(state,val){
  92. state.show = val;
  93. },
  94. newisShow(state,val){
  95. state.isShow = val;
  96. },
  97. newRgShow(state,val){
  98. state.rgShow = val;
  99. },
  100. newMacth_id(state,val){
  101. state.macth_id = val;
  102. publicFun.setItem('macth_id',val);
  103. },
  104. newBetting(state,val){
  105. let index =0;
  106. if(val){
  107. val.forEach(e=> {
  108. index += e.data.length
  109. });
  110. }
  111. state.betting = val;
  112. publicFun.setItem('betting',val);
  113. state.limit =index;
  114. publicFun.setItem('limit',index);
  115. },
  116. newIsBetting(state,val){
  117. state.isBetting = val;
  118. publicFun.setItem('isBetting',val);
  119. },
  120. newToken(state,val){
  121. state.token = val;
  122. publicFun.setItem('token',val);
  123. },
  124. newDeleteType(state,val){
  125. state.deleteType = val;
  126. },
  127. newLimit(state,val){
  128. state.limit = val;
  129. publicFun.setItem('limit',val);
  130. },
  131. newHeadTitle(state,val){
  132. state.headTitle = val;
  133. publicFun.setItem('headTitle',val);
  134. },
  135. }
  136. /**
  137. * 这里面的方法是用来异步触发mutations里面的方法
  138. */
  139. const actions={
  140. GETGAMERATIO(context,val){
  141. context.commit('newGameRatio',val)
  142. },
  143. GETACTIVITY(context,val){
  144. context.commit('newActivity',val);
  145. },
  146. GET_BALL_ID(context,val){
  147. context.commit('newBallId',val);
  148. },
  149. GETSHOW(context,val){
  150. context.commit('newShow',val)
  151. },
  152. GET_ISSHOW(context,val){
  153. context.commit('newisShow',val)
  154. },
  155. GETRGSHOW(context,val){
  156. context.commit('newRgShow',val)
  157. },
  158. MACTH_ID(context,val){
  159. context.commit('newMacth_id',val)
  160. },
  161. BETTING(context,val){
  162. context.commit('newBetting',val)
  163. },
  164. ISBETTING(context,val){
  165. context.commit('newIsBetting',val)
  166. },
  167. DEL_TYPE(context,val){
  168. context.commit('newDeleteType',val)
  169. },
  170. SET_TOKEN(context,val){
  171. context.commit('newToken',val)
  172. },
  173. SET_LIMIT(context,val){
  174. context.commit('newLimit',val)
  175. },
  176. SET_HEADTITLE(context,val){
  177. context.commit('newHeadTitle',val)
  178. },
  179. SET_NOROLL(context,val){
  180. context.commit('newNoRoll',val)
  181. }
  182. }
  183. const store =new Vuex.Store({
  184. state,
  185. getters,
  186. mutations,
  187. actions
  188. });
  189. export default store;