home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view class="container">
  3. <view v-if="!menushow" class="main">
  4. <view class="u-page">
  5. <u-list :class="{ empty: curlist.length === 0 }">
  6. <template v-if="curlist.length > 0">
  7. <u-list-item
  8. class="itemback"
  9. v-for="(item, index) in curlist"
  10. :key="index"
  11. >
  12. <div @tap="openNewPage(item)">
  13. <u-row gutter="5" customStyle="margin-bottom: 10px">
  14. <u-col span="24">
  15. <image
  16. style="position: absolute; width: 18px; height: 18px"
  17. class="icon"
  18. :src="getIcon(TabCur)"
  19. alt="Icon"
  20. />
  21. <span class="title">{{ item.strinstallpos }}</span>
  22. </u-col>
  23. </u-row>
  24. <u-row gutter="5" customStyle="margin-bottom: 10px">
  25. <u-col span="3" style="margin-right: 5rpx">
  26. <div v-if="item.netStatus == 0" class="error-tag1">
  27. <image
  28. src="/static/model/connectFalse.svg"
  29. alt=""
  30. class="icon-style"
  31. />
  32. <span style="float: right">断开</span>
  33. </div>
  34. <div v-else class="success-tag">
  35. <image
  36. src="/static/model/connectTrue.svg"
  37. alt=""
  38. class="icon-style"
  39. />
  40. <span style="float: right">连接</span>
  41. </div>
  42. </u-col>
  43. <u-col span="4">
  44. <div v-if="item.warnFlag == 0" class="success-tag">
  45. <image
  46. src="/static/model/alarmTrue.svg"
  47. alt=""
  48. class="icon-style"
  49. />
  50. <span style="float: right">连接</span>
  51. </div>
  52. <div v-else class="error-tag">
  53. <image
  54. src="/static/model/alarmFalse.svg"
  55. alt=""
  56. class="icon-style"
  57. />
  58. <span style="float: right">断开</span>
  59. </div>
  60. </u-col>
  61. <u-col span="5">
  62. <u--text class="timetext" :text="item.readTime"></u--text>
  63. </u-col>
  64. </u-row>
  65. <view v-if="colums[TabCur + '_monitor'] != null">
  66. <view
  67. class="datacard"
  68. v-for="(showitem, index) in colums[TabCur + '_monitor']"
  69. :key="index"
  70. v-show="
  71. showitem.appShow == 1 &&
  72. showitem.monitorcode != 'strinstallpos' &&
  73. showitem.monitorcode != 'netStatus' &&
  74. showitem.monitorcode != 'warnFlag' &&
  75. showitem.monitorcode != 'readTime' &&
  76. showitem.monitorcode != ''
  77. "
  78. >
  79. <view
  80. :class="TabCur"
  81. style="padding-top: 10rpx; padding-bottom: 10rpx"
  82. >
  83. <view
  84. v-if="
  85. showitem.datatype == 1 &&
  86. showitem.monitorcode == 'doorUse'
  87. "
  88. class="demo-layout bg-purple-light"
  89. style="
  90. margin-top: 10rpx;
  91. color: #3787fe;
  92. font-size: 30rpx;
  93. margin-top: 5rpx;
  94. "
  95. >
  96. {{
  97. item[showitem.monitorcode] == "2"
  98. ? "行人"
  99. : item[showitem.monitorcode] == "1"
  100. ? "行车"
  101. : "-"
  102. }}
  103. </view>
  104. <view
  105. v-else-if="showitem.datatype == 1"
  106. class="demo-layout bg-purple-light"
  107. style="
  108. margin-top: 10rpx;
  109. color: #3787fe;
  110. font-size: 30rpx;
  111. margin-top: 5rpx;
  112. "
  113. >
  114. {{
  115. item[showitem.monitorcode] == null ||
  116. item[showitem.monitorcode] == ""
  117. ? "-"
  118. : item[showitem.monitorcode]
  119. }}
  120. </view>
  121. <view
  122. v-else-if="showitem.datatype == 2"
  123. class="demo-layout bg-purple-light"
  124. style="
  125. color: #3787fe;
  126. font-size: 30rpx;
  127. margin-top: 5rpx;
  128. "
  129. >
  130. {{
  131. item.readData[showitem.monitorcode] == null ||
  132. item.readData[showitem.monitorcode] == ""
  133. ? "-"
  134. : item.readData[showitem.monitorcode]
  135. }}
  136. </view>
  137. <view
  138. class="demo-layout bg-purple-light"
  139. style="
  140. margin-top: 6rpx;
  141. color: #677799;
  142. margin-bottom: 5rpx;
  143. "
  144. >
  145. {{ showitem.des }}
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. </div>
  151. </u-list-item>
  152. </template>
  153. <template v-else>
  154. <div class="empty-message">数据为空</div>
  155. </template>
  156. </u-list>
  157. </view>
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import api from "@/api/api";
  163. export default {
  164. data() {
  165. return {
  166. menushow: false,
  167. TabCur: "gate",
  168. curlist: [],
  169. deviceList: {},
  170. colums: {},
  171. typeList: [], //详情页展示数据
  172. };
  173. },
  174. props: ["showColum", "deviceType"],
  175. watch: {
  176. showColum(data) {
  177. this.colums = data;
  178. },
  179. deviceType: {
  180. async handler(data) {
  181. if (data) {
  182. this.TabCur = data;
  183. this.curlist = this.deviceList[this.TabCur];
  184. if (this.curlist == null) {
  185. this.curlist = [];
  186. }
  187. // 选择设备分类,重新获取数据
  188. await this.loadData(this.TabCur);
  189. this.$emit("setMenushow", {
  190. menushow: false,
  191. });
  192. }
  193. },
  194. immediate: true,
  195. },
  196. },
  197. created() {
  198. this.colums = this.showColum;
  199. },
  200. async mounted() {
  201. await this.loadData(this.TabCur);
  202. this.startTimer();
  203. },
  204. methods: {
  205. startTimer() {
  206. // 每隔一段时间执行某个操作
  207. this.timer = setInterval(async () => {
  208. // 执行定时任务
  209. await this.loadData(this.deviceType);
  210. console.log("定时任务执行中...");
  211. }, 5000);
  212. },
  213. stopTimer() {
  214. // 停止定时器
  215. clearInterval(this.timer);
  216. },
  217. getIcon(itemValue) {
  218. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  219. return "/static/sidebar/" + itemValue + ".svg";
  220. },
  221. getValueIcon(itemValue) {
  222. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  223. return "/static/sidebar/" + itemValue + ".svg";
  224. },
  225. loadData(type) {
  226. return new Promise((resolve, reject) => {
  227. api
  228. .getDeviceMonitor({
  229. devicetype: type,
  230. pagetype: "normal",
  231. filterParams: {},
  232. })
  233. .then((response) => {
  234. if (response.data.code == 200) {
  235. this.deviceList[type] = response.data.result.msgTxt[0].datalist;
  236. this.curlist = this.deviceList[type];
  237. this.curlist.forEach((item) => {
  238. if (item.readData.frontGateOpen == 1) {
  239. item.readData.frontGateOpen = "打开";
  240. } else {
  241. item.readData.frontGateOpen = "关闭";
  242. }
  243. if (item.readData.midGateOpen == 1) {
  244. item.readData.midGateOpen = "打开";
  245. } else {
  246. item.readData.midGateOpen = "关闭";
  247. }
  248. if (item.readData.rearGateOpen == 1) {
  249. item.readData.rearGateOpen = "打开";
  250. } else {
  251. item.readData.rearGateOpen = "关闭";
  252. }
  253. if (item.readData.midGateOpen == 1) {
  254. item.readData.midGateOpen = "打开";
  255. } else {
  256. item.readData.midGateOpen = "关闭";
  257. }
  258. });
  259. } else {
  260. resolve(response);
  261. }
  262. })
  263. .catch((error) => {
  264. console.log("catch===>response", response);
  265. reject(error);
  266. });
  267. });
  268. },
  269. devicemenuShow(e) {
  270. this.menushow = !this.menushow;
  271. },
  272. //获取app展示字段数据
  273. getShowList(type) {
  274. const params = {
  275. devicekind: type,
  276. pagetype: "detail",
  277. pageNo: 1,
  278. pageSize: 100,
  279. };
  280. return new Promise((resolve, reject) => {
  281. api
  282. .getShowColumList(params)
  283. .then((response) => {
  284. if (response.data.code == 200) {
  285. this.typeList = response.data.result.records;
  286. resolve(response);
  287. } else {
  288. resolve(response);
  289. }
  290. })
  291. .catch((error) => {
  292. reject(error);
  293. });
  294. });
  295. },
  296. openNewPage(params) {
  297. const reqData = {
  298. id: params.deviceID,
  299. name: params.strinstallpos,
  300. type: this.TabCur,
  301. };
  302. const reqparams = uni.$u.queryParams(reqData);
  303. this.getShowList(this.TabCur).then(() => {
  304. if (this.typeList.length > 0) {
  305. this.$destroy();
  306. uni.navigateTo({
  307. url: `/pages/home/detail/autodoor/autodoor${reqparams}`,
  308. });
  309. }
  310. });
  311. },
  312. },
  313. destroyed() {
  314. // 停止定时器
  315. this.stopTimer();
  316. },
  317. };
  318. </script>
  319. <style>
  320. .empty {
  321. background: url("/static/empty.png") no-repeat;
  322. background-size: 100% 50%;
  323. }
  324. .empty-message {
  325. display: flex;
  326. justify-content: center;
  327. align-items: center;
  328. font-size: 16px;
  329. line-height: 80vh;
  330. color: #333;
  331. }
  332. >>> .u-navbar--fixed {
  333. /* margin-top: 20px; */
  334. }
  335. .main {
  336. /* margin-top: 100rpx; */
  337. display: flex;
  338. flex-direction: column;
  339. }
  340. .card {
  341. background-color: #ffffff;
  342. margin: auto;
  343. margin-top: 20rpx;
  344. width: 10%;
  345. height: 280rpx;
  346. border: 1rpx solid #000000;
  347. border-radius: 20rpx;
  348. }
  349. .menupage {
  350. position: absolute;
  351. z-index: 2;
  352. width: 100%;
  353. }
  354. .timetext {
  355. text-align: right;
  356. float: right;
  357. }
  358. .itemback {
  359. padding: 20rpx;
  360. background-color: #ffffff;
  361. margin-bottom: 5rpx;
  362. }
  363. .datacard .content {
  364. width: 30rpx;
  365. height: 30rpx;
  366. left: 0rpx;
  367. top: 0rpx;
  368. position: absolute;
  369. }
  370. .datacard {
  371. border-radius: 10rpx;
  372. border: rgba(55, 135, 254, 0.28);
  373. width: 30%;
  374. margin: 1%;
  375. float: left;
  376. height: 105rpx;
  377. text-align: center;
  378. background: linear-gradient(
  379. to right,
  380. rgba(55, 135, 254, 0.08),
  381. rgba(4, 184, 255, 0.08),
  382. rgba(60, 161, 237, 0.08)
  383. );
  384. }
  385. .datacard .gate {
  386. background: linear-gradient(
  387. to right,
  388. rgba(75, 135, 254, 0.08),
  389. rgba(24, 184, 255, 0.08),
  390. rgba(80, 161, 237, 0.08)
  391. );
  392. }
  393. .datacard .window {
  394. background: linear-gradient(
  395. to right,
  396. rgba(55, 125, 254, 0.08),
  397. rgba(4, 164, 255, 0.08),
  398. rgba(60, 131, 237, 0.08)
  399. );
  400. }
  401. .datacard .windrect {
  402. background: linear-gradient(
  403. to right,
  404. rgba(85, 125, 254, 0.08),
  405. rgba(34, 164, 255, 0.08),
  406. rgba(90, 131, 237, 0.08)
  407. );
  408. }
  409. .error-tag {
  410. border-radius: 10%;
  411. display: inline-block;
  412. color: #e90000;
  413. line-height: 50rpx;
  414. font-size: 14px;
  415. text-align: center;
  416. float: left;
  417. width: 180rpx;
  418. height: 50rpx;
  419. padding-right: 30rpx;
  420. background-color: rgba(233, 0, 0, 0.2);
  421. }
  422. .error-tag1 {
  423. border-radius: 10%;
  424. display: inline-block;
  425. color: #696969;
  426. line-height: 50rpx;
  427. font-size: 14px;
  428. text-align: center;
  429. margin-top: 10rpx;
  430. float: left;
  431. width: 120rpx;
  432. height: 50rpx;
  433. background-color: rgba(105, 105, 105, 0.2);
  434. }
  435. .success-tag {
  436. border-radius: 10%;
  437. color: #42c000;
  438. line-height: 25px;
  439. font-size: 14px;
  440. width: 60px;
  441. height: 26px;
  442. padding-right: 15px;
  443. background-color: rgba(226, 250, 214);
  444. }
  445. .icon-style {
  446. margin: 7px;
  447. width: 14px;
  448. height: 14px;
  449. }
  450. .title {
  451. margin-left: 40rpx;
  452. float: left;
  453. font-size: 28rpx;
  454. font-weight: 400;
  455. }
  456. </style>