index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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="
  48. PageCur === 'device'
  49. ? '/static/navIcon/device-active.png'
  50. : '/static/navIcon/device.png'
  51. "
  52. ></u-tabbar-item>
  53. <u-tabbar-item
  54. v-show="menus.warndata != null"
  55. text="预警分析"
  56. name="warndata"
  57. :icon="
  58. PageCur === 'warndata'
  59. ? '/static/navIcon/yjfx-active.png'
  60. : '/static/navIcon/yjfx.png'
  61. "
  62. ></u-tabbar-item>
  63. <u-tabbar-item
  64. v-show="menus.filecenter != null"
  65. text="文件共享"
  66. name="filecenter"
  67. :icon="
  68. PageCur === 'filecenter'
  69. ? '/static/navIcon/file-active.png'
  70. : '/static/navIcon/file.png'
  71. "
  72. ></u-tabbar-item>
  73. <u-tabbar-item
  74. v-show="menus.gasreport != null"
  75. text="瓦斯日报"
  76. name="gasreport"
  77. :icon="
  78. PageCur === 'gasreport'
  79. ? '/static/navIcon/gas-active.png'
  80. : '/static/navIcon/gas.png'
  81. "
  82. ></u-tabbar-item>
  83. <u-tabbar-item
  84. text="我的"
  85. name="user"
  86. :icon="
  87. PageCur === 'user'
  88. ? '/static/navIcon/user-active.png'
  89. : '/static/navIcon/user.png'
  90. "
  91. ></u-tabbar-item>
  92. </u-tabbar>
  93. </view>
  94. </template>
  95. <script>
  96. import { nextTick } from "vue";
  97. import Device from "../device/index.vue";
  98. export default {
  99. components: {
  100. Device,
  101. },
  102. data() {
  103. return {
  104. isLandScape: "",
  105. PageCur: "device",
  106. tun3DPage: null,
  107. wvHeight: getApp().globalData.windowHeight,
  108. wvWidth: getApp().globalData.windowWidth,
  109. wvTop: 0,
  110. iframeloading: false,
  111. menus: {},
  112. };
  113. },
  114. computed: {
  115. permission: function () {
  116. var data = uni.getStorageSync("menuPermission");
  117. console.log(JSON.stringify(data), "data");
  118. if (data == null || data == "" || data.length == 0) {
  119. data = [
  120. {
  121. redirect: null,
  122. path: "/device",
  123. ver: null,
  124. component: "device",
  125. route: "1",
  126. meta: {
  127. keepAlive: false,
  128. des: null,
  129. internalOrExternal: false,
  130. componentName: "device",
  131. title: "设备中心",
  132. },
  133. name: "device",
  134. id: "1862300062379954178",
  135. },
  136. {
  137. redirect: null,
  138. path: "/warndata",
  139. ver: null,
  140. component: "warndata",
  141. route: "1",
  142. meta: {
  143. keepAlive: false,
  144. des: null,
  145. internalOrExternal: false,
  146. componentName: "warndata",
  147. title: "预警分析",
  148. },
  149. name: "warndata",
  150. id: "1862301272310829057",
  151. },
  152. {
  153. redirect: null,
  154. path: "/filecenter",
  155. ver: null,
  156. component: "filecenter",
  157. route: "1",
  158. meta: {
  159. keepAlive: false,
  160. des: null,
  161. internalOrExternal: false,
  162. componentName: "filecenter",
  163. title: "文件共享中心",
  164. },
  165. name: "filecenter",
  166. id: "1862301712700166146",
  167. },
  168. {
  169. redirect: null,
  170. path: "/gasreport",
  171. ver: null,
  172. component: "gasreport",
  173. route: "1",
  174. meta: {
  175. keepAlive: false,
  176. des: null,
  177. internalOrExternal: false,
  178. componentName: "gasreport",
  179. title: "瓦斯上报",
  180. },
  181. name: "gasreport",
  182. id: "1862302433877184513",
  183. },
  184. ];
  185. }
  186. for (var i = 0; i < data.length; i++) {
  187. this.menus[data[i].component] = data[i].component;
  188. }
  189. return data;
  190. },
  191. },
  192. watch: {
  193. permission: {
  194. handler(newV, oldV) {
  195. debugger;
  196. if (newV != null && newV != "") this.PageCur = newV[0].component;
  197. },
  198. immediate: true,
  199. },
  200. },
  201. onLoad() {
  202. this.changeWV();
  203. },
  204. mounted() {},
  205. onShow() {
  206. // this.changeWV()
  207. },
  208. onResize() {
  209. this.changeWV();
  210. },
  211. methods: {
  212. NavChange: function (e) {
  213. this.PageCur = e;
  214. if (e == "tun2D") {
  215. // this.changeWV()
  216. this.iframeloading = true;
  217. }
  218. },
  219. viewLoad(event) {
  220. const _this = this;
  221. setTimeout(() => {
  222. _this.iframeloading = false;
  223. }, 2000);
  224. },
  225. changeWV() {
  226. const _this = this;
  227. uni.getSystemInfo({
  228. // 获取当前设备的具体信息
  229. success: (sysinfo) => {
  230. if (sysinfo.windowWidth > sysinfo.windowHeight) {
  231. // 横屏
  232. _this.isLandScape = true;
  233. } else {
  234. // 竖屏
  235. _this.isLandScape = false;
  236. }
  237. _this.wvTop = _this.isLandScape ? 0 : sysinfo.statusBarHeight + 20;
  238. _this.wvHeight = _this.isLandScape
  239. ? sysinfo.windowHeight - sysinfo.statusBarHeight - 20
  240. : sysinfo.windowHeight -
  241. sysinfo.statusBarHeight -
  242. sysinfo.statusBarHeight -
  243. 38;
  244. _this.wvWidth = _this.isLandScape
  245. ? sysinfo.windowWidth
  246. : sysinfo.windowWidth;
  247. console.log("屏幕模式--->", _this.isLandScape ? "横屏" : "竖屏");
  248. console.log(_this.wvTop, _this.wvWidth, _this.wvHeight);
  249. },
  250. });
  251. },
  252. },
  253. };
  254. </script>
  255. <style>
  256. .app-container {
  257. width: 100%;
  258. height: 100%;
  259. }
  260. .loadding-box {
  261. position: absolute;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. }
  266. </style>