66db8a26216a7be847247bbb5c93ce349de101d1.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. noRoll:false,// 禁止背景滚动
  23. playAlias:JSON.parse(publicFun.getItem('playAlias')),//玩法别名
  24. homeRollBall:'',//首页滚球数据
  25. }
  26. /**
  27. * 实时监听state里面值的变法(最新变法)
  28. */
  29. const getters={
  30. getNoRoll(state){
  31. return state.noRoll
  32. },
  33. getGameRatio(state){
  34. return state.gameRatio;
  35. },
  36. getActivity(state){
  37. return state.activity;
  38. },
  39. getBallId(state){
  40. return state.ballId;
  41. },
  42. getShow(state){
  43. return state.show;
  44. },
  45. getIsShow(state){
  46. return state.isShow;
  47. },
  48. getRgShow(state){
  49. return state.rgShow;
  50. },
  51. getMatchId(state){
  52. return state.macth_id;
  53. },
  54. getBetting(state){
  55. return state.betting;
  56. },
  57. getIsBetting(state){
  58. return state.isBetting;
  59. },
  60. getDeleteType(state){
  61. return state.deleteType;
  62. },
  63. getToken(state){
  64. return state.token;
  65. },
  66. getLimit(state){
  67. return state.limit;
  68. },
  69. getHeadTitle(state){
  70. return state.headTitle;
  71. },
  72. getPlayAlias(state){
  73. return state.playAlias;
  74. },
  75. getHomeRollBall(state){
  76. return state.homeRollBall;
  77. },
  78. }
  79. /**
  80. * 设置对外可调用的方法
  81. */
  82. const mutations = {
  83. newNoRoll(state,val){
  84. state.noRoll = val
  85. },
  86. newGameRatio(state,val){
  87. //publicFun.getCache('activity')
  88. state.gameRatio = val;
  89. },
  90. newActivity(state,val){
  91. state.activity = val;
  92. publicFun.setItem('activity',val)
  93. },
  94. newBallId(state,val){
  95. state.ballId = val;
  96. publicFun.setItem('ballId',val)
  97. },
  98. newShow(state,val){
  99. state.show = val;
  100. },
  101. newisShow(state,val){
  102. state.isShow = val;
  103. },
  104. newRgShow(state,val){
  105. state.rgShow = val;
  106. },
  107. newMacth_id(state,val){
  108. state.macth_id = val;
  109. publicFun.setItem('macth_id',val);
  110. },
  111. newBetting(state,val){
  112. let index =0;
  113. if(val){
  114. val.forEach(e=> {
  115. index += e.data.length
  116. });
  117. }
  118. state.betting = val;
  119. publicFun.setItem('betting',val);
  120. state.limit =index;
  121. publicFun.setItem('limit',index);
  122. },
  123. newIsBetting(state,val){
  124. state.isBetting = val;
  125. publicFun.setItem('isBetting',val);
  126. },
  127. newToken(state,val){
  128. state.token = val;
  129. publicFun.setItem('token',val);
  130. },
  131. newDeleteType(state,val){
  132. state.deleteType = val;
  133. },
  134. newLimit(state,val){
  135. state.limit = val;
  136. publicFun.setItem('limit',val);
  137. },
  138. newHeadTitle(state,val){
  139. state.headTitle = val;
  140. publicFun.setItem('headTitle',val);
  141. },
  142. newPlayAlias(state,val){
  143. state.playAlias = val;
  144. publicFun.setItem('playAlias',val);
  145. },
  146. newHomeRollBall(state,val){
  147. state.homeRollBall = val;
  148. },
  149. }
  150. /**
  151. * 这里面的方法是用来异步触发mutations里面的方法
  152. */
  153. const actions={
  154. GETGAMERATIO(context,val){
  155. context.commit('newGameRatio',val)
  156. },
  157. GETACTIVITY(context,val){
  158. context.commit('newActivity',val);
  159. },
  160. GET_BALL_ID(context,val){
  161. context.commit('newBallId',val);
  162. },
  163. GETSHOW(context,val){
  164. context.commit('newShow',val)
  165. },
  166. GET_ISSHOW(context,val){
  167. context.commit('newisShow',val)
  168. },
  169. GETRGSHOW(context,val){
  170. context.commit('newRgShow',val)
  171. },
  172. MACTH_ID(context,val){
  173. context.commit('newMacth_id',val)
  174. },
  175. BETTING(context,val){
  176. context.commit('newBetting',val)
  177. },
  178. ISBETTING(context,val){
  179. context.commit('newIsBetting',val)
  180. },
  181. DEL_TYPE(context,val){
  182. context.commit('newDeleteType',val)
  183. },
  184. SET_TOKEN(context,val){
  185. context.commit('newToken',val)
  186. },
  187. SET_LIMIT(context,val){
  188. context.commit('newLimit',val)
  189. },
  190. SET_HEADTITLE(context,val){
  191. context.commit('newHeadTitle',val)
  192. },
  193. SET_NOROLL(context,val){
  194. context.commit('newNoRoll',val)
  195. },
  196. SET_PLAYALIAS(context,val){
  197. context.commit('newPlayAlias',val)
  198. },
  199. SET_HOMEROLLBALL(context,val){
  200. context.commit('newHomeRollBall',val)
  201. },
  202. }
  203. const store =new Vuex.Store({
  204. state,
  205. getters,
  206. mutations,
  207. actions
  208. });
  209. export default store;