globalConfiguration.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. mBarHeight: 44,
  34. tabBarHeight: 0,
  35. iphone: false,
  36. iphoneHeight: 0,
  37. promptBox: {
  38. text: '',
  39. show: false,
  40. call: -1,
  41. },
  42. imageWidth: 0,
  43. };
  44. const getters = {
  45. reportAndErrorObj(state) {
  46. return state.reportAndError;
  47. }
  48. };
  49. const mutations = {
  50. reportAndErrorObj(state, data) {
  51. state.reportAndError = data;
  52. },
  53. reportAndErrorB(state, data) {
  54. state.reportAndError.boolean = data;
  55. },
  56. setTabBarBoolean(state, data) {
  57. let pages = getCurrentPages();
  58. let currPage = null;
  59. if (pages.length) {
  60. currPage = pages[pages.length - 1];
  61. }
  62. let currentRoute = undefined;
  63. // #ifndef MP-TOUTIAO
  64. currentRoute = `/${currPage.route.split("?")[0]}`;
  65. // #endif
  66. // #ifdef MP-TOUTIAO
  67. currentRoute = `/${currPage.__route__.split("?")[0]}`;
  68. // #endif
  69. for (let i = 0; i < data.length; i++) {
  70. if(currentRoute.includes(data[i].url.split('?')[0])) {
  71. return state.tabBarBoolean = true;
  72. }
  73. }
  74. return state.tabBarBoolean = false;
  75. },
  76. setSystemInfo(state, data) {
  77. state.systemInfo = data;
  78. state.imageWidth = data.windowWidth;
  79. },
  80. setPromptBox(state, data) {
  81. state.promptBox = data;
  82. },
  83. setPromptBoxCall(state, data) {
  84. state.promptBox.call = data;
  85. },
  86. setHeight(state, data) {
  87. state.tabBarHeight = data;
  88. },
  89. setiPhoneHeight(state, data) {
  90. state.iphoneHeight = data;
  91. },
  92. setiPhoneBoolean(state, data) {
  93. state.iphone = data;
  94. },
  95. setImageWidth(state, data) {
  96. state.imageWidth = state.systemInfo.windowWidth - (state.systemInfo.windowWidth / 750) * data;
  97. }
  98. };
  99. const actions = {
  100. setImageWidth(content, data) {
  101. content.commit('setImageWidth', data);
  102. },
  103. reportAndErrorObj(content, data) {
  104. content.commit('reportAndErrorObj', data);
  105. },
  106. reportAndErrorB(content, data) {
  107. content.commit('reportAndErrorB', data);
  108. },
  109. setTabBarBoolean(content, data) {
  110. content.commit('setTabBarBoolean', data);
  111. },
  112. setSystemInfo(content, data) {
  113. content.commit('setSystemInfo', data);
  114. },
  115. setHeight(content, data) {
  116. content.commit('setHeight', data);
  117. },
  118. setiPhoneBoolean(content, data) {
  119. content.commit('setiPhoneBoolean', data);
  120. },
  121. setPromptBox(content, data) {
  122. content.commit('setPromptBox', data);
  123. },
  124. setPromptBoxCall(content,data) {
  125. content.commit('setPromptBoxCall', data);
  126. },
  127. setiPhoneHeight(content, data) {
  128. content.commit('setiPhoneHeight', data);
  129. }
  130. };
  131. export default {
  132. namespaced:true,
  133. state,
  134. getters,
  135. mutations,
  136. actions
  137. };