home.vue 12 KB

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