rotationflow.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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.lgjg + '分钟' }}</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(mode) {
  168. switch (mode) {
  169. case '0':
  170. return '定时';
  171. case '1':
  172. return '定量';
  173. case '2':
  174. return 'EC调配';
  175. case '3':
  176. return '混肥比例';
  177. default:
  178. return '-';
  179. }
  180. },
  181. async getRunStatus() {
  182. const res = await this.$myRequest({
  183. url: '/api/v2/iot/mobile/device/sf/zsrf/task/run/status/',
  184. method: 'post',
  185. data: {
  186. devBid: this.devBid,
  187. },
  188. });
  189. const data = res || {};
  190. if (data.status === undefined || data.status / 1 !== 1) {
  191. clearInterval(this.timer);
  192. clearInterval(this.labelTimer);
  193. clearInterval(this.taskTimer);
  194. uni.showLoading({
  195. title: '灌溉任务已结束',
  196. });
  197. setTimeout(() => {
  198. uni.hideLoading();
  199. uni.redirectTo({
  200. url: `/pages/cb/shuifeizs/detail?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  201. });
  202. }, 1000);
  203. return;
  204. }
  205. this.list = data?.sensorList || [];
  206. this.tktype = data?.tktype;
  207. this.lgjg = data?.lgjg || 0;
  208. this.lgcs = data?.lgcs || 0;
  209. this.fqList = data?.fqList || [];
  210. // value 0 未灌溉 1 灌溉中 2 灌溉完成
  211. this.fqList.forEach((item) => {
  212. if (item.value === '1') {
  213. this.currentFq = item;
  214. }
  215. });
  216. this.formartTime(this.currentFq.lgjg);
  217. // this.setTime(this.currentFq.lgjg);
  218. },
  219. rotationflowEnd() {
  220. const payload = {
  221. devBid: this.devBid,
  222. tkid: 0,
  223. status: 0,
  224. tktype: this.tktype,
  225. };
  226. this.postTaskCtl(payload);
  227. },
  228. async postTaskCtl(payload) {
  229. uni.showLoading({
  230. title: '正在执行',
  231. });
  232. const res = await this.$myRequest({
  233. url: '/api/v2/iot/mobile/device/sf/zsrf/task/ctl/',
  234. method: 'post',
  235. data: payload,
  236. header: {
  237. 'Content-Type': 'application/json',
  238. },
  239. });
  240. uni.hideLoading();
  241. if (res.code === '000000') {
  242. uni.showToast({
  243. title: '操作成功',
  244. });
  245. setTimeout(() => {
  246. uni.navigateTo({
  247. url: `/pages/cb/shuifeizs/detail?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  248. });
  249. }, 1000);
  250. } else {
  251. uni.showToast({
  252. icon: 'none',
  253. title: res.msg,
  254. });
  255. }
  256. },
  257. },
  258. onLoad(options) {
  259. const { devBid, devName, devStatus } = options;
  260. this.devBid = devBid;
  261. this.devName = devName;
  262. this.devStatus = devStatus;
  263. this.getRunStatus();
  264. this.labelTimer = setInterval(() => {
  265. if (this.label === '灌溉中.') {
  266. this.label = '灌溉中..';
  267. } else if (this.label === '灌溉中..') {
  268. this.label = '灌溉中...';
  269. } else {
  270. this.label = '灌溉中.';
  271. }
  272. }, 500);
  273. this.taskTimer = setInterval(() => {
  274. this.getRunStatus();
  275. }, 30000);
  276. },
  277. onUnload() {
  278. clearInterval(this.timer);
  279. clearInterval(this.labelTimer);
  280. clearInterval(this.taskTimer);
  281. },
  282. beforeDestroy() {
  283. if (this.timer) {
  284. clearInterval(this.timer);
  285. }
  286. if (this.taskTimer) {
  287. clearInterval(this.taskTimer);
  288. }
  289. if (this.labelTimer) {
  290. clearInterval(this.labelTimer);
  291. }
  292. },
  293. };
  294. </script>
  295. <style scoped lang="scss">
  296. uni-page-body,
  297. uni-page-wrapper {
  298. position: relative;
  299. height: 100%;
  300. }
  301. @keyframes rotate {
  302. 0% {
  303. transform: rotate(0deg);
  304. }
  305. 100% {
  306. transform: rotate(360deg);
  307. }
  308. }
  309. .rotationflow {
  310. background: linear-gradient(
  311. 180deg,
  312. #f5f6fa00 0%,
  313. #f5f6fa 23.64%,
  314. #f5f6fa 100%
  315. ),
  316. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  317. width: 100%;
  318. height: calc(100% - 140rpx);
  319. overflow: hidden;
  320. overflow-y: scroll;
  321. margin-bottom: 140rpx;
  322. .rotationflow-top {
  323. height: 500rpx;
  324. width: 100%;
  325. display: flex;
  326. justify-content: center;
  327. align-items: center;
  328. .rotationflow-top-list {
  329. display: flex;
  330. position: relative;
  331. align-items: center;
  332. justify-content: center;
  333. width: 100%;
  334. height: 100%;
  335. .rotate-autoBtn {
  336. position: absolute;
  337. width: 360rpx;
  338. height: 360rpx;
  339. z-index: 1;
  340. }
  341. .rotate-rotate {
  342. position: absolute;
  343. width: 320rpx;
  344. height: 320rpx;
  345. left: 215rpx;
  346. top: 92rpx;
  347. z-index: 2;
  348. // 循环滚动
  349. animation: rotate 20s linear infinite;
  350. }
  351. .rotate-water {
  352. position: absolute;
  353. width: 550rpx;
  354. height: 600rpx;
  355. margin-left: 220rpx;
  356. margin-top: 100rpx;
  357. }
  358. .rotationflow-time {
  359. display: flex;
  360. flex-direction: column;
  361. align-items: center;
  362. justify-content: center;
  363. position: relative;
  364. z-index: 3;
  365. top: -5rpx;
  366. .rotationflow-time-title {
  367. width: 200rpx;
  368. color: #042118;
  369. text-align: center;
  370. font-family: 'Source Han Sans CN VF';
  371. font-size: 32rpx;
  372. font-weight: 500;
  373. }
  374. .rotationflow-time-content {
  375. width: 200rpx;
  376. color: #042118;
  377. font-family: 'Source Han Sans CN VF';
  378. font-size: 40rpx;
  379. font-weight: 700;
  380. margin: 8rpx 0;
  381. text-align: center;
  382. }
  383. .rotationflow-time-label {
  384. width: 100rpx;
  385. color: #687a74;
  386. text-align: left;
  387. font-family: 'Source Han Sans CN VF';
  388. font-size: 24rpx;
  389. font-weight: 400;
  390. }
  391. }
  392. }
  393. }
  394. .rotationflow-middle {
  395. display: flex;
  396. padding: 0 32rpx;
  397. margin: 32rpx 0;
  398. .rotationflow-middle-item {
  399. width: 25%;
  400. text-align: center;
  401. .rotationflow-middle-item-value {
  402. color: #042118;
  403. font-family: 'Source Han Sans CN VF';
  404. font-size: 32rpx;
  405. font-weight: 500;
  406. }
  407. .rotationflow-middle-item-title {
  408. color: #687a74;
  409. font-family: 'Source Han Sans CN VF';
  410. font-size: 28rpx;
  411. font-style: normal;
  412. font-weight: 400;
  413. line-height: normal;
  414. // 超出隐藏
  415. white-space: nowrap;
  416. text-overflow: ellipsis;
  417. overflow: hidden;
  418. }
  419. }
  420. }
  421. .rotationflow-content {
  422. border-bottom: none;
  423. position: relative;
  424. overflow: hidden;
  425. background-color: #fff;
  426. border-radius: 16rpx;
  427. padding: 32rpx;
  428. width: calc(100% - 64rpx);
  429. margin-left: 32rpx;
  430. margin-bottom: 140rpx;
  431. &::before {
  432. position: absolute;
  433. content: '';
  434. top: 0;
  435. left: 0;
  436. right: 0;
  437. bottom: 0;
  438. background-size: cover;
  439. }
  440. .rotationflow-content-top {
  441. display: flex;
  442. .rotationflow-content-top-title {
  443. border-radius: 8rpx;
  444. background: #1890ff1a;
  445. color: #1890ff;
  446. font-family: 'Source Han Sans CN VF';
  447. font-size: 28rpx;
  448. font-style: normal;
  449. font-weight: 400;
  450. line-height: normal;
  451. padding: 4rpx 16rpx;
  452. }
  453. .rotationflow-content-top-title-rever {
  454. border-radius: 8rpx;
  455. background: #f3a72f1a;
  456. color: #f3a72f;
  457. font-family: 'Source Han Sans CN VF';
  458. font-size: 28rpx;
  459. font-style: normal;
  460. font-weight: 400;
  461. line-height: normal;
  462. padding: 4rpx 16rpx;
  463. }
  464. .rotationflow-content-top-desc {
  465. color: #333333;
  466. font-family: 'Source Han Sans CN VF';
  467. font-size: 28rpx;
  468. font-weight: 700;
  469. margin-left: 16rpx;
  470. }
  471. }
  472. .rotationflow-content-list {
  473. width: 100%;
  474. .rotationflow-content-list-wrapper {
  475. width: 100%;
  476. border-radius: 8rpx;
  477. background: #f5f6fa;
  478. padding: 8rpx 0;
  479. margin-top: 16rpx;
  480. }
  481. .rotationflow-content-num {
  482. display: flex;
  483. padding: 8rpx 16rpx;
  484. .rotationflow-content-num-title {
  485. width: 50%;
  486. color: #687a74;
  487. font-family: 'Source Han Sans CN VF';
  488. font-size: 28rpx;
  489. font-style: normal;
  490. font-weight: 400;
  491. margin: 0 8rpx;
  492. }
  493. }
  494. .rotationflow-content-list-item {
  495. display: flex;
  496. justify-content: space-between;
  497. margin-top: 8rpx;
  498. color: #042118;
  499. text-align: right;
  500. font-family: 'Source Han Sans CN VF';
  501. font-size: 28rpx;
  502. font-weight: 400;
  503. .rotationflow-content-list-item-desc {
  504. margin-right: 32rpx;
  505. }
  506. .rotationflow-content-list-item-current {
  507. color: #14a478;
  508. }
  509. }
  510. .haveYet {
  511. color: #9ba6a3;
  512. text-align: right;
  513. font-family: 'Source Han Sans CN VF';
  514. font-size: 28rpx;
  515. font-weight: 400;
  516. }
  517. .currentYet {
  518. color: #14a478;
  519. text-align: right;
  520. font-family: 'Source Han Sans CN VF';
  521. font-size: 28rpx;
  522. font-weight: 400;
  523. }
  524. }
  525. }
  526. .rotationflow-footer {
  527. position: fixed;
  528. width: 100%;
  529. bottom: 0;
  530. left: 0;
  531. display: flex;
  532. height: 128rpx;
  533. align-items: center;
  534. background: #fff;
  535. box-shadow: 0 -4rpx 8rpx 0 #00000026;
  536. .rotationflow-footer-item {
  537. width: calc(100% - 64rpx);
  538. margin: 0 32rpx;
  539. text-align: center;
  540. font-size: 32rpx;
  541. height: 80rpx;
  542. line-height: 80rpx;
  543. color: #ffffff;
  544. font-family: 'PingFang SC';
  545. font-size: 32rpx;
  546. font-weight: 500;
  547. border-radius: 16rpx;
  548. background: #ff3546;
  549. }
  550. }
  551. }
  552. </style>