detail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. <operation-card
  20. @run-status="runStatusHandler"
  21. @close-status="closeStatusHandler"
  22. v-for="(item, index) in juanmoList"
  23. :key="index"
  24. :dourceData="item"
  25. />
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import location from './assets/location.svg';
  31. import Element from './components/element.vue';
  32. import deviceCard from './components/DeviceCard.vue';
  33. import OperationCard from './components/OperationCard.vue';
  34. export default {
  35. components: {
  36. Element,
  37. deviceCard,
  38. OperationCard,
  39. },
  40. data() {
  41. return {
  42. location,
  43. juanmoList: [],
  44. dataSource: {
  45. devStatus: '1',
  46. devStatusName: '在线',
  47. devName: '-',
  48. devCode: '-',
  49. devUpdateddate: '-',
  50. devProvincealign: '-',
  51. },
  52. };
  53. },
  54. methods: {
  55. init() {
  56. this.getDpdevicedpkzgjuanmoList();
  57. this.getDataSource();
  58. },
  59. async optDevctl(payload) {
  60. const res = await this.$myRequest({
  61. url: '/api/v2/iot/mobile/device/dpkzg/devctl/',
  62. method: 'post',
  63. data: {
  64. devBid: this.devBid,
  65. data: payload,
  66. },
  67. header: {
  68. 'Content-Type': 'application/json',
  69. },
  70. });
  71. // 提示
  72. uni.showToast({
  73. title: res?.msg || '',
  74. icon: 'none',
  75. duration: 3000,
  76. });
  77. },
  78. async getDataSource() {
  79. const res = await this.$myRequest({
  80. url: '/api/v2/iot/mobile/device/dpkzg/info/',
  81. method: 'post',
  82. data: {
  83. devBid: this.devBid,
  84. },
  85. });
  86. this.dataSource = res;
  87. },
  88. runStatusHandler(dourceData) {
  89. if (dourceData.down_status === '0' && dourceData.up_status === '1') {
  90. this.$set(dourceData, 'up_status', '0');
  91. }
  92. this.$set(
  93. dourceData,
  94. 'down_status',
  95. dourceData.down_status === '1' ? '0' : '1'
  96. );
  97. const payload = {
  98. code: dourceData.code,
  99. type: 'juanmo',
  100. op_type: 'down',
  101. value: dourceData.down_status,
  102. };
  103. this.optDevctl(payload);
  104. },
  105. closeStatusHandler(dourceData) {
  106. if (dourceData.up_status === '0' && dourceData.down_status === '1') {
  107. this.$set(dourceData, 'down_status', '0');
  108. }
  109. this.$set(
  110. dourceData,
  111. 'up_status',
  112. dourceData.up_status === '1' ? '0' : '1'
  113. );
  114. const payload = {
  115. code: dourceData.code,
  116. type: 'juanmo',
  117. op_type: 'up',
  118. value: dourceData.up_status,
  119. };
  120. this.optDevctl(payload);
  121. },
  122. toNavigation() {
  123. const roundedLongitude =
  124. this.dataSource.devLngalign || this.dataSource.devLng;
  125. const roundedLatitude =
  126. this.dataSource.devLatalign || this.dataSource.devLat;
  127. if (!roundedLongitude) {
  128. uni.showToast({
  129. title: '当前设备无定位信息',
  130. icon: 'none',
  131. duration: 3000,
  132. });
  133. return;
  134. }
  135. if (
  136. plus.runtime.isApplicationExist({
  137. pname: 'com.autonavi.minimap',
  138. action: 'iosamap://',
  139. })
  140. ) {
  141. let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
  142. plus.runtime.openURL(url);
  143. } else if (
  144. plus.runtime.isApplicationExist({
  145. pname: 'com.baidu.BaiduMap',
  146. action: 'baidumap://',
  147. })
  148. ) {
  149. let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
  150. plus.runtime.openURL(url);
  151. } else {
  152. uni.showToast({
  153. title: '当前未安装 高德地图或百度地图 无法导航',
  154. icon: 'none',
  155. duration: 3000,
  156. });
  157. }
  158. },
  159. // 获取卷膜设备列表
  160. async getDpdevicedpkzgjuanmoList(tf) {
  161. const res = await this.$myRequest({
  162. url: '/api/v2/iot/mobile/device/dpkzg/juanmo/list/',
  163. method: 'post',
  164. data: {
  165. pageSize: this.size,
  166. pageNum: this.page,
  167. devBid: this.devBid,
  168. },
  169. });
  170. this.juanmoList = res;
  171. },
  172. },
  173. onLoad(query) {
  174. this.devBid = query.devBid;
  175. this.devBid && this.init();
  176. },
  177. };
  178. </script>
  179. <style scoped lang="scss">
  180. uni-page-body {
  181. position: relative;
  182. height: 100%;
  183. }
  184. .icon {
  185. width: 40rpx;
  186. height: 40rpx;
  187. }
  188. .greenhouse-page {
  189. background: linear-gradient(
  190. 180deg,
  191. #ffffff00 0%,
  192. #eff2fa 23.64%,
  193. #eff2fa 100%
  194. ),
  195. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  196. height: 100%;
  197. width: 100%;
  198. overflow-x: hidden;
  199. overflow-y: scroll;
  200. .greenhouse-top {
  201. text-align: center;
  202. margin: 0 auto;
  203. margin-top: 18rpx;
  204. padding: 0 30rpx;
  205. }
  206. .greenhouse-bottom {
  207. width: calc(100% - 128rpx);
  208. padding: 32rpx 32rpx 1rpx 32rpx;
  209. background: #ffffff;
  210. border-radius: 16rpx;
  211. margin: 0 auto;
  212. margin-top: 32rpx;
  213. }
  214. }
  215. </style>