rotationflow.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <view class="rotationflow">
  3. <custom-card>
  4. <block slot="backText">自动控制</block>
  5. </custom-card>
  6. <view class="rotationflow-top">
  7. <view class="rotationflow-top-list">
  8. <image :src="autoBtn" class="rotate-autoBtn" />
  9. <image :src="rotate" class="rotate-rotate" />
  10. <image :src="water" class="rotate-water" />
  11. <view class="rotationflow-time">
  12. <view class="rotationflow-time-title" style="font-size: 28px">{{
  13. currentFq.name || '--'
  14. }}</view>
  15. <!-- <view class="rotationflow-time-content"> {{ time }}</view> -->
  16. <view class="rotationflow-time-label">{{ label }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="rotationflow-middle">
  21. <view
  22. class="rotationflow-middle-item"
  23. v-for="item in list"
  24. :key="item.label"
  25. >
  26. <view class="rotationflow-middle-item-value">{{ item.value }}</view>
  27. <view class="rotationflow-middle-item-title">{{
  28. item.sfDisplayname || item.sfName
  29. }}</view>
  30. </view>
  31. </view>
  32. <view class="rotationflow-content">
  33. <view class="rotationflow-content-top">
  34. <view
  35. :class="
  36. tktype == '1'
  37. ? 'rotationflow-content-top-title'
  38. : 'rotationflow-content-top-title-rever'
  39. "
  40. >
  41. {{ tktype == '1' ? '灌溉' : '水肥' }}
  42. </view>
  43. <view class="rotationflow-content-top-desc">已选灌区</view>
  44. </view>
  45. <view class="rotationflow-content-list">
  46. <view class="rotationflow-content-list-wrapper" v-if="tktype == 1">
  47. <view class="rotationflow-content-num">
  48. <view class="rotationflow-content-num-title"
  49. >轮灌次数:{{ currentFq.lgcs || 0 }}</view
  50. >
  51. <view class="rotationflow-content-num-title"
  52. >轮灌间隔:{{ currentFq.lgjg || 0 }} 分钟</view
  53. >
  54. </view>
  55. </view>
  56. <view class="rotationflow-content-list-wrapper" v-else>
  57. <view class="rotationflow-content-num">
  58. <view class="rotationflow-content-num-title"
  59. >轮灌次数:{{ currentFq.lgcs || 0 }}</view
  60. >
  61. <view class="rotationflow-content-num-title"
  62. >肥前水:{{ currentFq.fqcx || 0 }} 分钟</view
  63. > </view
  64. ><view class="rotationflow-content-num">
  65. <view class="rotationflow-content-num-title"
  66. >轮灌间隔:{{ currentFq.lgjg || 0 }} 分钟</view
  67. >
  68. <view class="rotationflow-content-num-title"
  69. >肥后水:{{ currentFq.fhcx || 0 }} 分钟</view
  70. > </view
  71. ><view class="rotationflow-content-num">
  72. <view class="rotationflow-content-num-title"
  73. >模式选择:{{ getsfmode(currentFq.sfmode) }}</view
  74. >
  75. <view class="rotationflow-content-num-title"></view>
  76. </view>
  77. </view>
  78. <view
  79. class="rotationflow-content-list-item"
  80. v-for="(item, index) in fqList"
  81. :class="item.value === '2' ? 'haveYet' : ''"
  82. :key="index"
  83. >
  84. <view
  85. class="rotationflow-content-list-item-title"
  86. :class="
  87. item.value === '1' ? 'rotationflow-content-list-item-current' : ''
  88. "
  89. >{{ item.name }}</view
  90. >
  91. <view
  92. class="rotationflow-content-list-item-desc"
  93. :class="
  94. item.value === '1' ? 'rotationflow-content-list-item-current' : ''
  95. "
  96. >{{ item.value == '2' ? '已灌溉' : item.ggsj + '分钟' }}</view
  97. >
  98. </view>
  99. </view>
  100. </view>
  101. <view class="rotationflow-footer">
  102. <view class="rotationflow-footer-item" @click="rotationflowEnd"
  103. >结束灌溉</view
  104. >
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import rotate from './assets/rotate.png';
  110. import water from './assets/water.png';
  111. import autoBtn from './assets/autoBtn.png';
  112. import json from './test.js';
  113. export default {
  114. name: 'rotationflow',
  115. data() {
  116. return {
  117. rotate,
  118. water,
  119. autoBtn,
  120. time: '-',
  121. list: [],
  122. timer: null,
  123. devBid: '',
  124. tktype: 1,
  125. lgcs: 0,
  126. lgjg: 0,
  127. fqList: [],
  128. currentFq: {},
  129. label: '灌溉中.',
  130. devName: '',
  131. devStatus: '',
  132. };
  133. },
  134. components: {},
  135. methods: {
  136. formartTime(time) {
  137. if (!time) {
  138. return '-';
  139. }
  140. let hours = time * 60 * 1000;
  141. let h = Math.floor(hours / (60 * 60 * 1000));
  142. let m = Math.floor((hours % (60 * 60 * 1000)) / (60 * 1000));
  143. let s = Math.floor(((hours % (60 * 60 * 1000)) % (60 * 1000)) / 1000);
  144. this.time = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}:${
  145. s < 10 ? '0' + s : s
  146. }`;
  147. },
  148. setTime(time) {
  149. if (!time) {
  150. return '-';
  151. }
  152. let hours = time * 60 * 1000;
  153. this.timer = setInterval(() => {
  154. if (hours <= 0) {
  155. clearInterval(this.timer);
  156. return;
  157. }
  158. hours -= 1000;
  159. let h = Math.floor(hours / (60 * 60 * 1000));
  160. let m = Math.floor((hours % (60 * 60 * 1000)) / (60 * 1000));
  161. let s = Math.floor(((hours % (60 * 60 * 1000)) % (60 * 1000)) / 1000);
  162. this.time = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}:${
  163. s < 10 ? '0' + s : s
  164. }`;
  165. }, 1000);
  166. },
  167. getsfmode(m) {
  168. const mode = String(m);
  169. switch (mode) {
  170. case '1':
  171. return '定时';
  172. case '2':
  173. return '定量';
  174. case '3':
  175. return 'EC调配';
  176. case '4':
  177. return '混肥比例';
  178. default:
  179. return '-';
  180. }
  181. },
  182. async getRunStatus() {
  183. const res = await this.$myRequest({
  184. url: '/api/v2/iot/mobile/device/sf/zsrf/task/run/status/',
  185. method: 'post',
  186. data: {
  187. devBid: this.devBid,
  188. },
  189. });
  190. const data = res || {};
  191. if (data.status === undefined || data.status / 1 !== 1) {
  192. clearInterval(this.timer);
  193. clearInterval(this.labelTimer);
  194. clearInterval(this.taskTimer);
  195. uni.showLoading({
  196. title: '灌溉任务已结束',
  197. });
  198. setTimeout(() => {
  199. uni.hideLoading();
  200. uni.redirectTo({
  201. url: `/pages/cb/shuifeizsFirst/shuifeizs?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  202. });
  203. }, 1000);
  204. return;
  205. }
  206. this.list = data?.sensorList || [];
  207. this.tktype = data?.tktype;
  208. this.lgjg = data?.lgjg || 0;
  209. this.lgcs = data?.lgcs || 0;
  210. this.fqList = data?.fqList || [];
  211. // value 0 未灌溉 1 灌溉中 2 灌溉完成
  212. this.fqList.forEach((item) => {
  213. if (item.value === '1') {
  214. this.currentFq = item;
  215. }
  216. });
  217. this.formartTime(this.currentFq.lgjg);
  218. // this.setTime(this.currentFq.lgjg);
  219. },
  220. rotationflowEnd() {
  221. const payload = {
  222. devBid: this.devBid,
  223. tkid: 0,
  224. status: 0,
  225. tktype: this.tktype,
  226. };
  227. this.postTaskCtl(payload);
  228. },
  229. async postTaskCtl(payload) {
  230. uni.showLoading({
  231. title: '正在执行',
  232. });
  233. const res = await this.$myRequest({
  234. url: '/api/v2/iot/mobile/device/sf/zsrf/task/ctl/',
  235. method: 'post',
  236. data: payload,
  237. header: {
  238. 'Content-Type': 'application/json',
  239. },
  240. });
  241. uni.hideLoading();
  242. if (res.code === '000000') {
  243. uni.showToast({
  244. title: '操作成功',
  245. });
  246. setTimeout(() => {
  247. uni.navigateTo({
  248. url: `/pages/cb/shuifeizsFirst/shuifeizs?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  249. });
  250. }, 1000);
  251. } else {
  252. uni.showToast({
  253. icon: 'none',
  254. title: res.msg,
  255. });
  256. }
  257. },
  258. },
  259. onLoad(options) {
  260. const { devBid, devName, devStatus } = options;
  261. this.devBid = devBid;
  262. this.devName = devName;
  263. this.devStatus = devStatus;
  264. this.getRunStatus();
  265. this.labelTimer = setInterval(() => {
  266. if (this.label === '灌溉中.') {
  267. this.label = '灌溉中..';
  268. } else if (this.label === '灌溉中..') {
  269. this.label = '灌溉中...';
  270. } else {
  271. this.label = '灌溉中.';
  272. }
  273. }, 500);
  274. this.taskTimer = setInterval(() => {
  275. this.getRunStatus();
  276. }, 30000);
  277. },
  278. onUnload() {
  279. clearInterval(this.timer);
  280. clearInterval(this.labelTimer);
  281. clearInterval(this.taskTimer);
  282. },
  283. beforeDestroy() {
  284. if (this.timer) {
  285. clearInterval(this.timer);
  286. }
  287. if (this.taskTimer) {
  288. clearInterval(this.taskTimer);
  289. }
  290. if (this.labelTimer) {
  291. clearInterval(this.labelTimer);
  292. }
  293. },
  294. };
  295. </script>
  296. <style scoped lang="scss">
  297. uni-page-body,
  298. uni-page-wrapper {
  299. position: relative;
  300. height: 100%;
  301. }
  302. @keyframes rotate {
  303. 0% {
  304. transform: rotate(0deg);
  305. }
  306. 100% {
  307. transform: rotate(360deg);
  308. }
  309. }
  310. .rotationflow {
  311. background: linear-gradient(
  312. 180deg,
  313. #f5f6fa00 0%,
  314. #f5f6fa 23.64%,
  315. #f5f6fa 100%
  316. ),
  317. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  318. width: 100%;
  319. height: calc(100vh - 100rpx);
  320. overflow: hidden;
  321. overflow-y: scroll;
  322. margin-bottom: 140rpx;
  323. position: relative;
  324. .rotationflow-top {
  325. height: 500rpx;
  326. width: 100%;
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. .rotationflow-top-list {
  331. display: flex;
  332. position: relative;
  333. align-items: center;
  334. justify-content: center;
  335. width: 100%;
  336. height: 100%;
  337. .rotate-autoBtn {
  338. position: absolute;
  339. width: 360rpx;
  340. height: 360rpx;
  341. z-index: 1;
  342. }
  343. .rotate-rotate {
  344. position: absolute;
  345. width: 320rpx;
  346. height: 320rpx;
  347. left: 215rpx;
  348. top: 92rpx;
  349. z-index: 2;
  350. // 循环滚动
  351. animation: rotate 20s linear infinite;
  352. }
  353. .rotate-water {
  354. position: absolute;
  355. width: 550rpx;
  356. height: 600rpx;
  357. margin-left: 220rpx;
  358. margin-top: 100rpx;
  359. }
  360. .rotationflow-time {
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. justify-content: center;
  365. position: relative;
  366. z-index: 3;
  367. top: -5rpx;
  368. .rotationflow-time-title {
  369. width: 200rpx;
  370. color: #042118;
  371. text-align: center;
  372. font-family: 'Source Han Sans CN VF';
  373. font-size: 32rpx;
  374. font-weight: 500;
  375. }
  376. .rotationflow-time-content {
  377. width: 200rpx;
  378. color: #042118;
  379. font-family: 'Source Han Sans CN VF';
  380. font-size: 40rpx;
  381. font-weight: 700;
  382. margin: 8rpx 0;
  383. text-align: center;
  384. }
  385. .rotationflow-time-label {
  386. width: 140rpx;
  387. color: #687a74;
  388. text-align: left;
  389. font-family: 'Source Han Sans CN VF';
  390. font-size: 32rpx;
  391. font-weight: 400;
  392. }
  393. }
  394. }
  395. }
  396. .rotationflow-middle {
  397. display: flex;
  398. padding: 0 48rpx;
  399. margin: 32rpx 0;
  400. .rotationflow-middle-item {
  401. width: 25%;
  402. text-align: center;
  403. .rotationflow-middle-item-value {
  404. color: #042118;
  405. font-family: 'Source Han Sans CN VF';
  406. font-size: 32rpx;
  407. font-weight: 500;
  408. }
  409. .rotationflow-middle-item-title {
  410. color: #687a74;
  411. font-family: 'Source Han Sans CN VF';
  412. font-size: 28rpx;
  413. font-style: normal;
  414. font-weight: 400;
  415. line-height: normal;
  416. // 超出隐藏
  417. white-space: nowrap;
  418. text-overflow: ellipsis;
  419. overflow: hidden;
  420. }
  421. }
  422. }
  423. .rotationflow-content {
  424. border-bottom: none;
  425. position: relative;
  426. overflow: hidden;
  427. background-color: #fff;
  428. border-radius: 16rpx;
  429. padding: 32rpx;
  430. width: calc(100% - 128rpx);
  431. margin-left: 32rpx;
  432. margin-bottom: 140rpx;
  433. &::before {
  434. position: absolute;
  435. content: '';
  436. top: 0;
  437. left: 0;
  438. right: 0;
  439. bottom: 0;
  440. background-size: cover;
  441. }
  442. .rotationflow-content-top {
  443. display: flex;
  444. .rotationflow-content-top-title {
  445. border-radius: 8rpx;
  446. background: #1890ff1a;
  447. color: #1890ff;
  448. font-family: 'Source Han Sans CN VF';
  449. font-size: 28rpx;
  450. font-style: normal;
  451. font-weight: 400;
  452. line-height: normal;
  453. padding: 4rpx 16rpx;
  454. }
  455. .rotationflow-content-top-title-rever {
  456. border-radius: 8rpx;
  457. background: #f3a72f1a;
  458. color: #f3a72f;
  459. font-family: 'Source Han Sans CN VF';
  460. font-size: 28rpx;
  461. font-style: normal;
  462. font-weight: 400;
  463. line-height: normal;
  464. padding: 4rpx 16rpx;
  465. }
  466. .rotationflow-content-top-desc {
  467. color: #333333;
  468. font-family: 'Source Han Sans CN VF';
  469. font-size: 28rpx;
  470. font-weight: 700;
  471. margin-left: 16rpx;
  472. }
  473. }
  474. .rotationflow-content-list {
  475. width: 100%;
  476. .rotationflow-content-list-wrapper {
  477. width: 100%;
  478. border-radius: 8rpx;
  479. background: #f5f6fa;
  480. padding: 8rpx 0;
  481. margin-top: 16rpx;
  482. }
  483. .rotationflow-content-num {
  484. display: flex;
  485. padding: 8rpx 16rpx;
  486. .rotationflow-content-num-title {
  487. width: 50%;
  488. color: #687a74;
  489. font-family: 'Source Han Sans CN VF';
  490. font-size: 28rpx;
  491. font-style: normal;
  492. font-weight: 400;
  493. margin: 0 8rpx;
  494. }
  495. }
  496. .rotationflow-content-list-item {
  497. display: flex;
  498. justify-content: space-between;
  499. margin: 16rpx 0;
  500. color: #042118;
  501. text-align: right;
  502. font-family: 'Source Han Sans CN VF';
  503. font-size: 28rpx;
  504. font-weight: 400;
  505. .rotationflow-content-list-item-desc {
  506. }
  507. .rotationflow-content-list-item-current {
  508. color: #14a478;
  509. }
  510. }
  511. .haveYet {
  512. color: #9ba6a3;
  513. text-align: right;
  514. font-family: 'Source Han Sans CN VF';
  515. font-size: 28rpx;
  516. font-weight: 400;
  517. }
  518. .currentYet {
  519. color: #14a478;
  520. text-align: right;
  521. font-family: 'Source Han Sans CN VF';
  522. font-size: 28rpx;
  523. font-weight: 400;
  524. }
  525. }
  526. }
  527. .rotationflow-footer {
  528. position: fixed;
  529. width: 100%;
  530. bottom: 0;
  531. left: 0;
  532. display: flex;
  533. height: 128rpx;
  534. align-items: center;
  535. background: #fff;
  536. box-shadow: 0 -4rpx 8rpx 0 #00000026;
  537. z-index: 9999;
  538. .rotationflow-footer-item {
  539. width: calc(100% - 64rpx);
  540. margin: 0 32rpx;
  541. text-align: center;
  542. font-size: 32rpx;
  543. height: 80rpx;
  544. line-height: 80rpx;
  545. color: #ffffff;
  546. font-family: 'PingFang SC';
  547. font-size: 32rpx;
  548. font-weight: 500;
  549. border-radius: 16rpx;
  550. background: #ff3546;
  551. }
  552. }
  553. }
  554. </style>