1
0

globalConfiguration.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. const state = {
  2. reportAndError: {
  3. boolean: false,
  4. content: '网络开了会儿小差, 请刷新重试下哦~',
  5. },
  6. tabBarBoolean: false,
  7. systemInfo: {
  8. SDKVersion: "",
  9. batteryLevel: 0,
  10. brand: "",
  11. errMsg: "",
  12. fontSizeSetting: 0,
  13. language: "0",
  14. model: "",
  15. pixelRatio: 0,
  16. platform: "",
  17. safeArea: {
  18. bottom: 0,
  19. height: 0,
  20. left: 0,
  21. right: 0,
  22. top: 0,
  23. width: 0,
  24. },
  25. screenHeight: 0,
  26. screenWidth: 0,
  27. statusBarHeight: 0,
  28. system: "",
  29. version: "",
  30. windowHeight: 0,
  31. windowWidth: 0,
  32. },
  33. tabBarHeight: 0,
  34. iphone: false,
  35. iphoneHeight: 0,
  36. promptBox: {
  37. text: '',
  38. show: false,
  39. call: -1,
  40. },
  41. imageWidth: 0,
  42. };
  43. const getters = {
  44. reportAndErrorObj(state) {
  45. return state.reportAndError;
  46. }
  47. };
  48. const mutations = {
  49. reportAndErrorObj(state, data) {
  50. state.reportAndError = data;
  51. },
  52. reportAndErrorB(state, data) {
  53. state.reportAndError.boolean = data;
  54. },
  55. setTabBarBoolean(state, data) {
  56. let pages = getCurrentPages();
  57. let currPage = null;
  58. if (pages.length) {
  59. currPage = pages[pages.length - 1];
  60. }
  61. let currentRoute = undefined;
  62. // #ifndef MP-TOUTIAO
  63. currentRoute = `/${currPage.route.split("?")[0]}`;
  64. // #endif
  65. // #ifdef MP-TOUTIAO
  66. currentRoute = `/${currPage.__route__.split("?")[0]}`;
  67. // #endif
  68. for (let i = 0; i < data.length; i++) {
  69. if(currentRoute.includes(data[i].url.split('?')[0])) {
  70. return state.tabBarBoolean = true;
  71. }
  72. }
  73. return state.tabBarBoolean = false;
  74. },
  75. setSystemInfo(state, data) {
  76. state.systemInfo = data;
  77. state.imageWidth = data.windowWidth;
  78. },
  79. setPromptBox(state, data) {
  80. state.promptBox = data;
  81. },
  82. setPromptBoxCall(state, data) {
  83. state.promptBox.call = data;
  84. },
  85. setHeight(state, data) {
  86. state.tabBarHeight = data;
  87. },
  88. setiPhoneHeight(state, data) {
  89. state.iphoneHeight = data;
  90. },
  91. setiPhoneBoolean(state, data) {
  92. state.iphone = data;
  93. },
  94. setImageWidth(state, data) {
  95. state.imageWidth = state.systemInfo.windowWidth - (state.systemInfo.windowWidth / 750) * data;
  96. }
  97. };
  98. const actions = {
  99. setImageWidth(content, data) {
  100. content.commit('setImageWidth', data);
  101. },
  102. reportAndErrorObj(content, data) {
  103. content.commit('reportAndErrorObj', data);
  104. },
  105. reportAndErrorB(content, data) {
  106. content.commit('reportAndErrorB', data);
  107. },
  108. setTabBarBoolean(content, data) {
  109. content.commit('setTabBarBoolean', data);
  110. },
  111. setSystemInfo(content, data) {
  112. content.commit('setSystemInfo', data);
  113. },
  114. setHeight(content, data) {
  115. content.commit('setHeight', data);
  116. },
  117. setiPhoneBoolean(content, data) {
  118. content.commit('setiPhoneBoolean', data);
  119. },
  120. setPromptBox(content, data) {
  121. content.commit('setPromptBox', data);
  122. },
  123. setPromptBoxCall(content,data) {
  124. content.commit('setPromptBoxCall', data);
  125. },
  126. setiPhoneHeight(content, data) {
  127. content.commit('setiPhoneHeight', data);
  128. }
  129. };
  130. export default {
  131. namespaced:true,
  132. state,
  133. getters,
  134. mutations,
  135. actions
  136. };