shuifeiL.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view>
  3. <view :class="['info', equipInfo.is_online == 1 ? 'on' : 'off']">
  4. <view class=""> 设备ID:{{ equipInfo.device_id }} </view>
  5. <view class="">
  6. 设备名称:{{
  7. equipInfo.device_name == '' ? '无' : equipInfo.device_name
  8. }}水肥机
  9. </view>
  10. <view class=""> 设备类型:{{ equipInfo.dver_num }} </view>
  11. <view class=""> 设备地址:{{ equipInfo.city }} </view>
  12. </view>
  13. <view class="infoText">设备变量</view>
  14. <view class="realtime">
  15. <scroll-view scroll-top="0" scroll-x="true" class="scroll-X">
  16. <table class="table">
  17. <tr class="tr">
  18. <th class="th" v-for="(item, index) in thdata" :key="'a' + index">
  19. {{ item }}
  20. </th>
  21. </tr>
  22. <tr
  23. class="tr"
  24. v-for="(items, indexs) in statusList"
  25. :key="'b' + indexs"
  26. v-if="statusList.length > 0"
  27. >
  28. <td class="td">{{ items.d_id }}</td>
  29. <td class="td">{{ items.name }}</td>
  30. <td class="td">
  31. <u-button type="success" size="mini" @click="goHistory(items)"
  32. >历史记录</u-button
  33. >
  34. </td>
  35. </tr>
  36. <tr class="tr" v-else>
  37. <td class="td" v-for="item in 4">暂无数据</td>
  38. </tr>
  39. </table>
  40. </scroll-view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. equipInfo: {},
  49. statusList: [],
  50. thdata: ['变量ID', '变量名称', '操作'],
  51. };
  52. },
  53. methods: {
  54. copy(item) {
  55. uni.setClipboardData({
  56. data: item.imei || item.device_id,
  57. success: function () {
  58. console.log('success');
  59. },
  60. });
  61. },
  62. goHistory(items) {
  63. uni.navigateTo({
  64. url: `./history?device_id=${items.d_id}&type=${items.types}`,
  65. });
  66. },
  67. async geDetail() {
  68. const res = await this.$myRequest({
  69. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fertilizer_list',
  70. data: {
  71. content: this.equipInfo.device_id,
  72. },
  73. });
  74. if (res.data.length > 0) {
  75. this.equipInfo = res.data[0];
  76. }
  77. },
  78. async geList() {
  79. const res = await this.$myRequest({
  80. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fertilizer_data_list',
  81. data: {
  82. device_id: this.equipInfo.device_id,
  83. },
  84. });
  85. if (res.length > 0) {
  86. this.statusList = res;
  87. }
  88. },
  89. },
  90. onLoad(option) {
  91. var times = new Date();
  92. this.date =
  93. times.getFullYear() +
  94. 1 +
  95. '-' +
  96. Number(times.getMonth() + 1) +
  97. '-' +
  98. times.getDate();
  99. this.equipInfo = JSON.parse(option.detail);
  100. this.geDetail();
  101. this.geList();
  102. },
  103. };
  104. </script>
  105. <style lang="less">
  106. page {
  107. padding: 20rpx;
  108. box-sizing: border-box;
  109. .infoText {
  110. color: #0dc6b6;
  111. }
  112. .info {
  113. padding: 20rpx 40rpx;
  114. color: #fff;
  115. line-height: 50rpx;
  116. font-size: 26rpx;
  117. background-size: 100% auto;
  118. background-repeat: no-repeat;
  119. background-color: #0dc6b6;
  120. background-position: top left;
  121. box-sizing: border-box;
  122. width: 100%;
  123. margin-bottom: 20rpx;
  124. .tishi {
  125. width: 28rpx;
  126. height: 28rpx;
  127. margin: 0rpx 0 0 20rpx;
  128. }
  129. }
  130. .on {
  131. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png');
  132. }
  133. .off {
  134. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png');
  135. }
  136. .caobox {
  137. display: flex;
  138. flex-wrap: wrap;
  139. text-align: center;
  140. font-size: 28rpx;
  141. color: #666;
  142. line-height: 50rpx;
  143. image {
  144. width: 52rpx;
  145. }
  146. .caobox_item {
  147. padding: 20rpx 0;
  148. box-sizing: border-box;
  149. flex-basis: 25%;
  150. }
  151. }
  152. .realtime {
  153. display: flex;
  154. flex-wrap: wrap;
  155. width: 100%;
  156. box-shadow: 0 0 10rpx #bcb9ca;
  157. margin: 20rpx auto 30rpx;
  158. .scroll-X {
  159. width: 95%;
  160. margin: 20rpx auto;
  161. .tr {
  162. display: flex;
  163. overflow: hidden;
  164. .th,
  165. .td {
  166. display: inline-block;
  167. padding: 5rpx;
  168. width: 300rpx;
  169. text-align: center;
  170. height: 52rpx;
  171. line-height: 52rpx;
  172. border: 2rpx solid #f1f1f1;
  173. }
  174. }
  175. .tr:nth-child(2n-1) {
  176. background-color: #f5fff8;
  177. }
  178. .tr:first-child {
  179. background-color: #57c878;
  180. color: #fff;
  181. }
  182. }
  183. }
  184. }
  185. .btn-box {
  186. text-align: center;
  187. padding: 20rpx 30rpx;
  188. }
  189. ::v-deep .u-calendar__action {
  190. display: flex;
  191. justify-content: space-around;
  192. .u-calendar__action__text {
  193. line-height: 25px;
  194. }
  195. }
  196. </style>