index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="app-container">
  3. <view
  4. v-if="iframeloading"
  5. class="loadding-box"
  6. :style="{
  7. height: wvHeight + 'px',
  8. width: wvWidth + 'px',
  9. marginTop: wvTop + 'px',
  10. border: 'none',
  11. }"
  12. >
  13. <u-loading-icon></u-loading-icon>
  14. </view>
  15. <iframe
  16. v-if="PageCur == 'tun2D'"
  17. ref="iframe"
  18. src="http://182.92.126.35:8098/"
  19. @load="viewLoad"
  20. :style="{
  21. height: wvHeight + 'px',
  22. width: wvWidth + 'px',
  23. marginTop: wvTop + 'px',
  24. border: 'none',
  25. background: '#000',
  26. }"
  27. ></iframe>
  28. <Device
  29. v-show="PageCur == 'device'"
  30. :style="{ marginTop: wvTop + 20 + 'px' }"
  31. ></Device>
  32. <filecenter :cur="PageCur" v-show="PageCur == 'filecenter'"></filecenter>
  33. <warndata v-show="PageCur == 'warndata'" :cur="PageCur"></warndata>
  34. <gasreport :cur="PageCur" v-show="PageCur == 'gasreport'"></gasreport>
  35. <user :cur="PageCur" v-show="PageCur == 'user'"></user>
  36. <u-tabbar
  37. :value="PageCur"
  38. @change="NavChange"
  39. :fixed="true"
  40. :placeholder="true"
  41. :safeAreaInsetBottom="true"
  42. >
  43. <u-tabbar-item
  44. v-show="menus.device != null"
  45. text="设备中心"
  46. name="device"
  47. icon="calendar"
  48. ></u-tabbar-item>
  49. <u-tabbar-item
  50. v-show="menus.warndata != null"
  51. text="预警分析"
  52. name="warndata"
  53. icon="plus-circle"
  54. ></u-tabbar-item>
  55. <u-tabbar-item
  56. v-show="menus.filecenter != null"
  57. text="文件共享"
  58. name="filecenter"
  59. icon="file-text"
  60. ></u-tabbar-item>
  61. <u-tabbar-item
  62. v-show="menus.gasreport != null"
  63. text="瓦斯日报"
  64. name="gasreport"
  65. icon="bell"
  66. ></u-tabbar-item>
  67. <u-tabbar-item text="我的" name="user" icon="bell"></u-tabbar-item>
  68. </u-tabbar>
  69. </view>
  70. </template>
  71. <script>
  72. import { nextTick } from "vue";
  73. import Device from "../device/index.vue";
  74. export default {
  75. components: {
  76. Device,
  77. },
  78. data() {
  79. return {
  80. isLandScape: "",
  81. PageCur: "device",
  82. tun3DPage: null,
  83. wvHeight: getApp().globalData.windowHeight,
  84. wvWidth: getApp().globalData.windowWidth,
  85. wvTop: 0,
  86. iframeloading: false,
  87. menus: {},
  88. };
  89. },
  90. computed: {
  91. permission: function () {
  92. var data = uni.getStorageSync("menuPermission");
  93. console.log(JSON.stringify(data), "data");
  94. if (data == null || data == "" || data.length == 0) {
  95. data = [
  96. {
  97. redirect: null,
  98. path: "/device",
  99. ver: null,
  100. component: "device",
  101. route: "1",
  102. meta: {
  103. keepAlive: false,
  104. des: null,
  105. internalOrExternal: false,
  106. componentName: "device",
  107. title: "设备中心",
  108. },
  109. name: "device",
  110. id: "1862300062379954178",
  111. },
  112. {
  113. redirect: null,
  114. path: "/warndata",
  115. ver: null,
  116. component: "warndata",
  117. route: "1",
  118. meta: {
  119. keepAlive: false,
  120. des: null,
  121. internalOrExternal: false,
  122. componentName: "warndata",
  123. title: "预警分析",
  124. },
  125. name: "warndata",
  126. id: "1862301272310829057",
  127. },
  128. {
  129. redirect: null,
  130. path: "/filecenter",
  131. ver: null,
  132. component: "filecenter",
  133. route: "1",
  134. meta: {
  135. keepAlive: false,
  136. des: null,
  137. internalOrExternal: false,
  138. componentName: "filecenter",
  139. title: "文件共享中心",
  140. },
  141. name: "filecenter",
  142. id: "1862301712700166146",
  143. },
  144. {
  145. redirect: null,
  146. path: "/gasreport",
  147. ver: null,
  148. component: "gasreport",
  149. route: "1",
  150. meta: {
  151. keepAlive: false,
  152. des: null,
  153. internalOrExternal: false,
  154. componentName: "gasreport",
  155. title: "瓦斯上报",
  156. },
  157. name: "gasreport",
  158. id: "1862302433877184513",
  159. },
  160. ];
  161. }
  162. for (var i = 0; i < data.length; i++) {
  163. this.menus[data[i].component] = data[i].component;
  164. }
  165. return data;
  166. },
  167. },
  168. watch: {
  169. permission: {
  170. handler(newV, oldV) {
  171. debugger;
  172. if (newV != null && newV != "") this.PageCur = newV[0].component;
  173. },
  174. immediate: true,
  175. },
  176. },
  177. onLoad() {
  178. this.changeWV();
  179. },
  180. mounted() {},
  181. onShow() {
  182. // this.changeWV()
  183. },
  184. onResize() {
  185. this.changeWV();
  186. },
  187. methods: {
  188. NavChange: function (e) {
  189. this.PageCur = e;
  190. if (e == "tun2D") {
  191. // this.changeWV()
  192. this.iframeloading = true;
  193. }
  194. },
  195. viewLoad(event) {
  196. const _this = this;
  197. setTimeout(() => {
  198. _this.iframeloading = false;
  199. }, 2000);
  200. },
  201. changeWV() {
  202. const _this = this;
  203. uni.getSystemInfo({
  204. // 获取当前设备的具体信息
  205. success: (sysinfo) => {
  206. if (sysinfo.windowWidth > sysinfo.windowHeight) {
  207. // 横屏
  208. _this.isLandScape = true;
  209. } else {
  210. // 竖屏
  211. _this.isLandScape = false;
  212. }
  213. _this.wvTop = _this.isLandScape ? 0 : sysinfo.statusBarHeight + 20;
  214. _this.wvHeight = _this.isLandScape
  215. ? sysinfo.windowHeight - sysinfo.statusBarHeight - 20
  216. : sysinfo.windowHeight -
  217. sysinfo.statusBarHeight -
  218. sysinfo.statusBarHeight -
  219. 38;
  220. _this.wvWidth = _this.isLandScape
  221. ? sysinfo.windowWidth
  222. : sysinfo.windowWidth;
  223. console.log("屏幕模式--->", _this.isLandScape ? "横屏" : "竖屏");
  224. console.log(_this.wvTop, _this.wvWidth, _this.wvHeight);
  225. },
  226. });
  227. },
  228. },
  229. };
  230. </script>
  231. <style>
  232. .app-container {
  233. width: 100%;
  234. height: 100%;
  235. }
  236. .loadding-box {
  237. position: absolute;
  238. display: flex;
  239. justify-content: center;
  240. align-items: center;
  241. }
  242. </style>