wenshizs.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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" @navigation="toNavigation" />
  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. uni.openLocation({
  163. latitude: Number(roundedLatitude || 0),
  164. longitude: Number(roundedLongitude || 0),
  165. name: '',
  166. address: '',
  167. scale: 18, // 地图缩放级别
  168. success: () => console.log('导航启动成功'),
  169. fail: (err) => console.error('导航失败:', err),
  170. });
  171. // if (!roundedLongitude) {
  172. // uni.showToast({
  173. // title: '当前设备无定位信息',
  174. // icon: 'none',
  175. // duration: 3000,
  176. // });
  177. // return;
  178. // }
  179. // if (
  180. // plus.runtime.isApplicationExist({
  181. // pname: 'com.autonavi.minimap',
  182. // action: 'iosamap://',
  183. // })
  184. // ) {
  185. // let url = `amapuri://route/plan?sourceApplication=yourAppName&dlat=${roundedLatitude}&dlon=${roundedLongitude}&dev=0&t=0&style=0&start=&auto=1&rtdType=1&coordinate=wgs84`;
  186. // plus.runtime.openURL(url);
  187. // } else if (
  188. // plus.runtime.isApplicationExist({
  189. // pname: 'com.baidu.BaiduMap',
  190. // action: 'baidumap://',
  191. // })
  192. // ) {
  193. // let url = `baidumap://map/direction?destination=${roundedLongitude},${roundedLatitude}&mode=navigation&output=html&coord_type=wgs84`;
  194. // plus.runtime.openURL(url);
  195. // } else {
  196. // uni.showToast({
  197. // title: '当前未安装 高德地图或百度地图 无法导航',
  198. // icon: 'none',
  199. // duration: 3000,
  200. // });
  201. // }
  202. },
  203. // 获取卷膜设备列表
  204. async getDpdevicedpkzgjuanmoList(tf) {
  205. const res = await this.$myRequest({
  206. url: '/api/v2/iot/mobile/device/dpkzg/juanmo/list/',
  207. method: 'post',
  208. data: {
  209. pageSize: this.size,
  210. pageNum: this.page,
  211. devBid: this.devBid,
  212. },
  213. });
  214. this.juanmoList = res;
  215. },
  216. },
  217. onLoad(query) {
  218. this.devBid = query.devBid;
  219. this.devBid && this.init();
  220. },
  221. };
  222. </script>
  223. <style scoped lang="scss">
  224. uni-page-body {
  225. position: relative;
  226. height: 100%;
  227. }
  228. .icon {
  229. width: 40rpx;
  230. height: 40rpx;
  231. }
  232. .greenhouse-page {
  233. background: linear-gradient(
  234. 180deg,
  235. #ffffff00 0%,
  236. #eff2fa 23.64%,
  237. #eff2fa 100%
  238. ),
  239. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  240. min-height: 100vh;
  241. width: 100%;
  242. overflow-x: hidden;
  243. overflow-y: scroll;
  244. .greenhouse-top {
  245. text-align: center;
  246. margin: 0 auto;
  247. margin-top: 18rpx;
  248. padding: 0 30rpx;
  249. }
  250. .greenhouse-bottom {
  251. width: calc(100% - 128rpx);
  252. padding: 32rpx 32rpx 1rpx 32rpx;
  253. background: #ffffff;
  254. border-radius: 16rpx;
  255. margin: 0 auto;
  256. margin-top: 32rpx;
  257. .greenhouse-bottom-header {
  258. display: flex;
  259. justify-content: space-between;
  260. color: #042118;
  261. font-family: 'Source Han Sans CN VF';
  262. font-size: 28rpx;
  263. font-weight: 700;
  264. margin-bottom: 24rpx;
  265. .reload {
  266. color: #14a478;
  267. font-size: 38rpx;
  268. font-weight: 700;
  269. }
  270. }
  271. }
  272. }
  273. </style>