detail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="greenhouse-page">
  3. <custom-card>
  4. <block slot="backText">
  5. <view class="greenhouse-top__title">
  6. {{ dataSource.devName }}
  7. </view> </block
  8. ><view slot="right">
  9. <view class="ntoNative" @tap="toNavigation">
  10. <image :src="location" class="icon"></image>
  11. </view>
  12. </view>
  13. </custom-card>
  14. <view class="greenhouse-top">
  15. <device-card :dataSource="dataSource" />
  16. </view>
  17. <view class="greenhouse-bottom">
  18. <!-- <Element /> -->
  19. <view class="greenhouse-bottom-header">
  20. 卷膜控制
  21. <u-icon name="reload" class="reload" @click="reloadHandler" />
  22. </view>
  23. <operation-card
  24. @run-status="runStatusHandler"
  25. @close-status="closeStatusHandler"
  26. @change-click="changeClickHandler"
  27. v-for="(item, index) in juanmoList"
  28. :key="index"
  29. :dourceData="item"
  30. />
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import Element from './components/element.vue';
  36. import deviceCard from './components/DeviceCard.vue';
  37. import OperationCard from './components/OperationCard.vue';
  38. export default {
  39. components: {
  40. Element,
  41. deviceCard,
  42. OperationCard,
  43. },
  44. data() {
  45. return {
  46. location:
  47. 'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/location.svg',
  48. juanmoList: [],
  49. dataSource: {
  50. devStatus: '1',
  51. devStatusName: '在线',
  52. devName: '-',
  53. devCode: '-',
  54. devUpdateddate: '-',
  55. devProvincealign: '-',
  56. },
  57. };
  58. },
  59. methods: {
  60. init() {
  61. this.getDpdevicedpkzgjuanmoList();
  62. this.getDataSource();
  63. },
  64. async reloadHandler() {
  65. const res = await this.$myRequest({
  66. url: '/api/v2/iot/mobile/device/dpkzg/refresh/',
  67. method: 'post',
  68. data: {
  69. devBid: this.devBid,
  70. },
  71. });
  72. uni.showToast({
  73. title: res?.msg || '',
  74. icon: 'none',
  75. duration: 3000,
  76. });
  77. this.getDpdevicedpkzgjuanmoList();
  78. },
  79. changeClickHandler(prop) {
  80. const { type, dourceData } = prop;
  81. const payload = {
  82. code: dourceData.code,
  83. type: 'juanmo',
  84. op_type: 'run_model',
  85. value: type === 'auto' ? '1' : '0',
  86. };
  87. this.optDevctl(payload);
  88. },
  89. async optDevctl(payload) {
  90. const res = await this.$myRequest({
  91. url: '/api/v2/iot/mobile/device/dpkzg/devctl/',
  92. method: 'post',
  93. data: {
  94. devBid: this.devBid,
  95. data: payload,
  96. },
  97. header: {
  98. 'Content-Type': 'application/json',
  99. },
  100. });
  101. // 提示
  102. uni.showToast({
  103. title: res?.msg || '',
  104. icon: 'none',
  105. duration: 3000,
  106. });
  107. this.getDpdevicedpkzgjuanmoList();
  108. },
  109. async getDataSource() {
  110. const res = await this.$myRequest({
  111. url: '/api/v2/iot/mobile/device/dpkzg/info/',
  112. method: 'post',
  113. data: {
  114. devBid: this.devBid,
  115. },
  116. });
  117. this.dataSource = res;
  118. },
  119. runStatusHandler(dourceData) {
  120. if (dourceData.down_status === '0' && dourceData.up_status === '1') {
  121. this.$set(dourceData, 'up_status', '0');
  122. }
  123. this.$set(
  124. dourceData,
  125. 'down_status',
  126. dourceData.down_status === '1' ? '0' : '1'
  127. );
  128. const payload = {
  129. code: dourceData.code,
  130. type: 'juanmo',
  131. op_type: 'down',
  132. value: dourceData.down_status,
  133. };
  134. this.optDevctl(payload);
  135. },
  136. closeStatusHandler(dourceData) {
  137. if (dourceData.up_status === '0' && dourceData.down_status === '1') {
  138. this.$set(dourceData, 'down_status', '0');
  139. }
  140. this.$set(
  141. dourceData,
  142. 'up_status',
  143. dourceData.up_status === '1' ? '0' : '1'
  144. );
  145. const payload = {
  146. code: dourceData.code,
  147. type: 'juanmo',
  148. op_type: 'up',
  149. value: dourceData.up_status,
  150. };
  151. this.optDevctl(payload);
  152. },
  153. toNavigation() {
  154. const roundedLongitude =
  155. this.dataSource.devLngalign || this.dataSource.devLng;
  156. const roundedLatitude =
  157. this.dataSource.devLatalign || this.dataSource.devLat;
  158. if (!roundedLongitude) {
  159. uni.showToast({
  160. title: '当前设备无定位信息',
  161. icon: 'none',
  162. duration: 3000,
  163. });
  164. return;
  165. }
  166. if (
  167. plus.runtime.isApplicationExist({
  168. pname: 'com.autonavi.minimap',
  169. action: 'iosamap://',
  170. })
  171. ) {
  172. let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
  173. plus.runtime.openURL(url);
  174. } else if (
  175. plus.runtime.isApplicationExist({
  176. pname: 'com.baidu.BaiduMap',
  177. action: 'baidumap://',
  178. })
  179. ) {
  180. let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
  181. plus.runtime.openURL(url);
  182. } else {
  183. uni.showToast({
  184. title: '当前未安装 高德地图或百度地图 无法导航',
  185. icon: 'none',
  186. duration: 3000,
  187. });
  188. }
  189. },
  190. // 获取卷膜设备列表
  191. async getDpdevicedpkzgjuanmoList(tf) {
  192. const res = await this.$myRequest({
  193. url: '/api/v2/iot/mobile/device/dpkzg/juanmo/list/',
  194. method: 'post',
  195. data: {
  196. pageSize: this.size,
  197. pageNum: this.page,
  198. devBid: this.devBid,
  199. },
  200. });
  201. this.juanmoList = res;
  202. },
  203. },
  204. onLoad(query) {
  205. this.devBid = query.devBid;
  206. this.devBid && this.init();
  207. },
  208. };
  209. </script>
  210. <style scoped lang="scss">
  211. uni-page-body {
  212. position: relative;
  213. height: 100%;
  214. }
  215. .icon {
  216. width: 40rpx;
  217. height: 40rpx;
  218. }
  219. .greenhouse-page {
  220. background: linear-gradient(
  221. 180deg,
  222. #ffffff00 0%,
  223. #eff2fa 23.64%,
  224. #eff2fa 100%
  225. ),
  226. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  227. height: 100%;
  228. width: 100%;
  229. overflow-x: hidden;
  230. overflow-y: scroll;
  231. .greenhouse-top {
  232. text-align: center;
  233. margin: 0 auto;
  234. margin-top: 18rpx;
  235. padding: 0 30rpx;
  236. }
  237. .greenhouse-bottom {
  238. width: calc(100% - 128rpx);
  239. padding: 32rpx 32rpx 1rpx 32rpx;
  240. background: #ffffff;
  241. border-radius: 16rpx;
  242. margin: 0 auto;
  243. margin-top: 32rpx;
  244. .greenhouse-bottom-header {
  245. display: flex;
  246. justify-content: space-between;
  247. color: #042118;
  248. font-family: 'Source Han Sans CN VF';
  249. font-size: 28rpx;
  250. font-weight: 700;
  251. margin-bottom: 24rpx;
  252. .reload {
  253. color: #14a478;
  254. font-size: 38rpx;
  255. font-weight: 700;
  256. }
  257. }
  258. }
  259. }
  260. </style>