basefacility.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="基地设备"></uni-nav-bar>
  7. </view>
  8. <view class="ass_list">
  9. <view class="equipment" v-for="(items,indexs) in assignments" :key="items.id" v-if="tishiTF"
  10. @click="skip(items)">
  11. <view class="equipment_top">
  12. <image :src="$imageURL+'/bigdata_app/image/fourMoodBase/'+items.equip_type+'.png'" mode=""
  13. class="equipment_top_img"></image>
  14. <span class="equipment_top_name">{{items.type_name}}</span>
  15. </view>
  16. <view class="equipment_bot">
  17. <p class="equipment_bot_id">设备ID:{{items.device_id}}</p>
  18. <p class="equipment_bot_name">设备名称:{{items.device_name}}</p>
  19. <view v-if="items.is_online==1" class="equipment_state">在线</view>
  20. <view v-else class="equipment_state2">离线</view>
  21. </view>
  22. </view>
  23. <view class="tishi" v-if="!tishiTF">
  24. 暂无数据
  25. </view>
  26. </view>
  27. </view>
  28. <view class="top" v-if="isTop" @click="top">
  29. <image :src="$imageURL+ '/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. base_id: "",
  38. assignments: [],
  39. images: [{
  40. path: "/image/fourMoodBase/1.png",
  41. id: 3
  42. }, {
  43. path: "/image/fourMoodBase/5.png",
  44. id: 5
  45. }, {
  46. path: "/image/fourMoodBase/2.png",
  47. id: 6
  48. }, {
  49. path: "/image/fourMoodBase/4.png",
  50. id: 3
  51. }, {
  52. path: "/image/fourMoodBase/qxz.png",
  53. id: 5
  54. }, {
  55. path: "/image/fourMoodBase/jk.png",
  56. id: 6
  57. }, {
  58. path: "/image/fourMoodBase/bzy.png",
  59. id: 7
  60. }, {
  61. path: "/image/fourMoodBase/10.png",
  62. id: 10
  63. }],
  64. tishiTF: false,
  65. isTop: false
  66. }
  67. },
  68. methods: {
  69. async ybase(id) { //获取分布位置
  70. const res = await this.$myRequest({
  71. url: '/api/api_gateway?method=base.bases.base_map_list',
  72. data: {
  73. base_id: id
  74. }
  75. })
  76. this.assignments = res
  77. console.log(this.assignments)
  78. if (this.assignments.length == 0) {
  79. this.tishiTF = false
  80. } else {
  81. this.tishiTF = true
  82. }
  83. },
  84. async camera() { //设备列表
  85. const res = await this.$myRequest({
  86. url: '/api/api_gateway?method=camera.camera_manage.list_camera',
  87. data: {
  88. page_size: 1,
  89. }
  90. })
  91. this.accessToken = res.accessToken
  92. },
  93. clickLeft() {
  94. uni.navigateBack({
  95. delta: 1
  96. })
  97. },
  98. top() {
  99. uni.pageScrollTo({
  100. scrollTop: 0,
  101. duration: 500
  102. })
  103. },
  104. async skip(items) {
  105. console.log(items)
  106. var item = JSON.stringify(items)
  107. switch (items.equip_type) {
  108. case 5:
  109. const res = await this.$myRequest({
  110. url: '/api/api_gateway?method=weather.weather.qxz_page',
  111. data: {
  112. page: 1,
  113. device_status: '',
  114. page_size: 10,
  115. device_id: items.device_id,
  116. },
  117. })
  118. let item = {
  119. ...items
  120. }
  121. if (res.nums == 1) {
  122. item = {
  123. ...items,
  124. ...res.ids[0]
  125. }
  126. }
  127. uni.navigateTo({
  128. url: "../environment/equipment?shebei=" + JSON.stringify(item)
  129. })
  130. break
  131. case 6:
  132. uni.navigateTo({
  133. url: "/pages/webview?device_id=" + items.device_id + "&accessToken=" + uni
  134. .getStorageSync('session_key')
  135. })
  136. break
  137. case 43:
  138. const resFm = await this.$myRequest({
  139. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  140. data: {
  141. device_type_id: 43,
  142. page: 1,
  143. page_size: "10",
  144. device_id: items.device_id,
  145. }
  146. })
  147. let item43 = {
  148. ...items
  149. }
  150. if (resFm.counts == 1) {
  151. item43 = {
  152. ...items,
  153. ...resFm.data[0]
  154. }
  155. }
  156. uni.navigateTo({
  157. url: "../fmSys/details?info=" + JSON.stringify(item43)
  158. })
  159. break;
  160. case 44:
  161. uni.navigateTo({
  162. url: "/pages/webview?device_id=" + items.device_id + "&accessToken=" + uni
  163. .getStorageSync('session_key') + '&type=dgp'
  164. })
  165. break
  166. case 10:
  167. uni.navigateTo({
  168. url: '/pages/cb/xy2.0/particulars?info=' + item
  169. });
  170. break
  171. case 26:
  172. case 11:
  173. const res26 = await this.$myRequest({
  174. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  175. data: {
  176. device_type_id: items.equip_type,
  177. page: 1,
  178. page_size: "10",
  179. device_id: items.device_id,
  180. }
  181. })
  182. let item26 = {
  183. ...items
  184. }
  185. if (res26.counts == 1) {
  186. item26 = {
  187. ...items,
  188. ...res26.data[0]
  189. }
  190. }
  191. uni.navigateTo({
  192. url: '../disease/cmb?shebei=' + JSON.stringify(item26),
  193. });
  194. break;
  195. case 45:
  196. const res45 = await this.$myRequest({
  197. url: '/api/api_gateway?method=weather.weather.shang_qing_qxz_page',
  198. data: {
  199. page: 1,
  200. page_size: "10",
  201. device_id: items.device_id,
  202. }
  203. })
  204. let item45 = {
  205. ...items
  206. }
  207. if (res45.nums == 1) {
  208. item45 = {
  209. ...items,
  210. ...res45.ids[0]
  211. }
  212. }
  213. uni.navigateTo({
  214. url: "../environment/equipment?shebei=" + JSON.stringify(item45)
  215. })
  216. break;
  217. default:
  218. const resDefault = await this.$myRequest({
  219. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  220. data: {
  221. device_type_id: items.equip_type,
  222. page: 1,
  223. page_size: "10",
  224. device_id: items.device_id,
  225. }
  226. })
  227. let itemDefault = {
  228. ...items
  229. }
  230. if (resDefault.counts == 1) {
  231. itemDefault = {
  232. ...items,
  233. ...resDefault.data[0]
  234. }
  235. }
  236. uni.navigateTo({
  237. url: '/pages/cb/equip-detail/equip-detail?info=' + JSON.stringify(itemDefault)
  238. });
  239. break
  240. }
  241. }
  242. },
  243. onLoad(option) {
  244. console.log('加载了', option)
  245. this.base_id = option.id
  246. this.ybase(option.id)
  247. this.camera()
  248. },
  249. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  250. if (e.scrollTop > 200) { //距离大于200时显示
  251. this.isTop = true
  252. } else { //距离小于200时隐藏
  253. this.isTop = false
  254. }
  255. },
  256. }
  257. </script>
  258. <style lang="scss">
  259. .ass_list {
  260. position: absolute;
  261. top: 54px;
  262. width: 100%;
  263. margin-bottom: 40px;
  264. .tishi {
  265. width: 100%;
  266. text-align: center;
  267. height: 100rpx;
  268. line-height: 100rpx;
  269. font-size: 36rpx;
  270. }
  271. .equipment {
  272. width: 90%;
  273. margin: 20rpx auto;
  274. box-shadow: 0 0 10rpx #bcb9ca;
  275. padding: 20rpx 30rpx;
  276. box-sizing: border-box;
  277. .equipment_top {
  278. height: 60rpx;
  279. width: 100%;
  280. border-bottom: 1px solid #dfe5ec;
  281. position: relative;
  282. .equipment_top_img {
  283. width: 40rpx;
  284. height: 40rpx;
  285. position: absolute;
  286. }
  287. .equipment_top_name {
  288. font-size: 28rpx;
  289. margin-left: 60rpx;
  290. }
  291. }
  292. .equipment_bot {
  293. padding: 30rpx 0;
  294. position: relative;
  295. .equipment_bot_id {
  296. font-weight: 700;
  297. font-size: 15px;
  298. margin-bottom: 16rpx;
  299. }
  300. .equipment_bot_name {
  301. font-size: 13px;
  302. }
  303. .equipment_state {
  304. position: absolute;
  305. top: 20rpx;
  306. right: 0;
  307. width: 100rpx;
  308. height: 100rpx;
  309. text-align: center;
  310. line-height: 100rpx;
  311. color: #42b983;
  312. }
  313. .equipment_state2 {
  314. position: absolute;
  315. top: 20rpx;
  316. right: 0;
  317. width: 100rpx;
  318. height: 100rpx;
  319. text-align: center;
  320. line-height: 100rpx;
  321. color: #ff5951;
  322. }
  323. }
  324. }
  325. }
  326. .top {
  327. position: fixed;
  328. right: 30px;
  329. bottom: 100px;
  330. z-index: 100;
  331. image {
  332. width: 100rpx;
  333. height: 100rpx;
  334. }
  335. }
  336. </style>