home.vue 14 KB

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