detail.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. page: 1,
  58. size: 99999,
  59. };
  60. },
  61. methods: {
  62. init() {
  63. this.getDpdevicedpkzgjuanmoList();
  64. this.getDataSource();
  65. },
  66. async reloadHandler() {
  67. const res = await this.$myRequest({
  68. url: '/api/v2/iot/mobile/device/dpkzg/refresh/',
  69. method: 'post',
  70. data: {
  71. devBid: this.devBid,
  72. },
  73. });
  74. uni.showToast({
  75. title: res?.msg || '',
  76. icon: 'none',
  77. duration: 3000,
  78. });
  79. this.getDpdevicedpkzgjuanmoList();
  80. },
  81. changeClickHandler(prop) {
  82. const { type, dourceData } = prop;
  83. const payload = {
  84. code: dourceData.code,
  85. type: 'juanmo',
  86. op_type: 'run_model',
  87. value: type === 'auto' ? '1' : '0',
  88. };
  89. this.optDevctl(payload);
  90. },
  91. async optDevctl(payload) {
  92. const res = await this.$myRequest({
  93. url: '/api/v2/iot/mobile/device/dpkzg/devctl/',
  94. method: 'post',
  95. data: {
  96. devBid: this.devBid,
  97. data: payload,
  98. },
  99. header: {
  100. 'Content-Type': 'application/json',
  101. },
  102. });
  103. // 提示
  104. uni.showToast({
  105. title: res?.msg || '',
  106. icon: 'none',
  107. duration: 3000,
  108. });
  109. setTimeout(() => {
  110. this.getDpdevicedpkzgjuanmoList();
  111. }, 1000);
  112. },
  113. async getDataSource() {
  114. const res = await this.$myRequest({
  115. url: '/api/v2/iot/mobile/device/dpkzg/info/',
  116. method: 'post',
  117. data: {
  118. devBid: this.devBid,
  119. },
  120. });
  121. this.dataSource = res;
  122. },
  123. runStatusHandler(dourceData) {
  124. if (dourceData.down_status === '0' && dourceData.up_status === '1') {
  125. this.$set(dourceData, 'up_status', '0');
  126. }
  127. this.$set(
  128. dourceData,
  129. 'down_status',
  130. dourceData.down_status === '1' ? '0' : '1'
  131. );
  132. const payload = {
  133. code: dourceData.code,
  134. type: 'juanmo',
  135. op_type: 'down',
  136. value: dourceData.down_status,
  137. };
  138. this.optDevctl(payload);
  139. },
  140. closeStatusHandler(dourceData) {
  141. if (dourceData.up_status === '0' && dourceData.down_status === '1') {
  142. this.$set(dourceData, 'down_status', '0');
  143. }
  144. this.$set(
  145. dourceData,
  146. 'up_status',
  147. dourceData.up_status === '1' ? '0' : '1'
  148. );
  149. const payload = {
  150. code: dourceData.code,
  151. type: 'juanmo',
  152. op_type: 'up',
  153. value: dourceData.up_status,
  154. };
  155. this.optDevctl(payload);
  156. },
  157. toNavigation() {
  158. const roundedLongitude =
  159. this.dataSource.devLngalign || this.dataSource.devLng;
  160. const roundedLatitude =
  161. this.dataSource.devLatalign || this.dataSource.devLat;
  162. if (!roundedLongitude) {
  163. uni.showToast({
  164. title: '当前设备无定位信息',
  165. icon: 'none',
  166. duration: 3000,
  167. });
  168. return;
  169. }
  170. if (
  171. plus.runtime.isApplicationExist({
  172. pname: 'com.autonavi.minimap',
  173. action: 'iosamap://',
  174. })
  175. ) {
  176. let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
  177. plus.runtime.openURL(url);
  178. } else if (
  179. plus.runtime.isApplicationExist({
  180. pname: 'com.baidu.BaiduMap',
  181. action: 'baidumap://',
  182. })
  183. ) {
  184. let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
  185. plus.runtime.openURL(url);
  186. } else {
  187. uni.showToast({
  188. title: '当前未安装 高德地图或百度地图 无法导航',
  189. icon: 'none',
  190. duration: 3000,
  191. });
  192. }
  193. },
  194. // 获取卷膜设备列表
  195. async getDpdevicedpkzgjuanmoList(tf) {
  196. const res = await this.$myRequest({
  197. url: '/api/v2/iot/mobile/device/dpkzg/juanmo/list/',
  198. method: 'post',
  199. data: {
  200. pageSize: this.size,
  201. pageNum: this.page,
  202. devBid: this.devBid,
  203. },
  204. });
  205. this.juanmoList = res;
  206. },
  207. },
  208. onLoad(query) {
  209. this.devBid = query.devBid;
  210. this.devBid && this.init();
  211. },
  212. };
  213. </script>
  214. <style scoped lang="scss">
  215. uni-page-body {
  216. position: relative;
  217. height: 100%;
  218. }
  219. .icon {
  220. width: 40rpx;
  221. height: 40rpx;
  222. }
  223. .greenhouse-page {
  224. background: linear-gradient(
  225. 180deg,
  226. #ffffff00 0%,
  227. #eff2fa 23.64%,
  228. #eff2fa 100%
  229. ),
  230. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  231. min-height: 100vh;
  232. width: 100%;
  233. overflow-x: hidden;
  234. overflow-y: scroll;
  235. .greenhouse-top {
  236. text-align: center;
  237. margin: 0 auto;
  238. margin-top: 18rpx;
  239. padding: 0 30rpx;
  240. }
  241. .greenhouse-bottom {
  242. width: calc(100% - 128rpx);
  243. padding: 32rpx 32rpx 1rpx 32rpx;
  244. background: #ffffff;
  245. border-radius: 16rpx;
  246. margin: 0 auto;
  247. margin-top: 32rpx;
  248. .greenhouse-bottom-header {
  249. display: flex;
  250. justify-content: space-between;
  251. color: #042118;
  252. font-family: 'Source Han Sans CN VF';
  253. font-size: 28rpx;
  254. font-weight: 700;
  255. margin-bottom: 24rpx;
  256. .reload {
  257. color: #14a478;
  258. font-size: 38rpx;
  259. font-weight: 700;
  260. }
  261. }
  262. }
  263. }
  264. </style>