nlNewXy.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view>
  3. <view :class="['info', equipInfo.status == 1 ? 'on' : 'off']">
  4. <view class="" @click="copy(equipInfo)">
  5. 设备ID:{{ showId }}
  6. <image
  7. :src="$imageURL+'/bigdata_app/image/environment/fuzhi.png'"
  8. mode=""
  9. class="tishi"
  10. >
  11. </image>
  12. </view>
  13. <view class="">
  14. 设备名称:{{
  15. equipInfo.device_name == '' ? '无' : equipInfo.device_name
  16. }}
  17. </view>
  18. <view class=""> 设备类型:性诱监测 </view>
  19. <view class="">
  20. 最新上报时间:{{ equipInfo.uptime || equipInfo.uptime | timeFormat }}
  21. </view>
  22. <view class=""> 设备地址:{{ equipInfo.address }} </view>
  23. <view class="" @click="setdecoy">
  24. 诱芯名称:{{ equipInfo.decoy }}
  25. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  26. </view>
  27. <view class="" @click="setdecoy">
  28. 诱芯到期时间:{{ equipInfo.xy_expire }}
  29. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  30. </view>
  31. </view>
  32. <u-popup v-model="yxShow" mode="center" width="600rpx">
  33. <u-field
  34. label="害虫名称"
  35. label-width="240"
  36. required
  37. :error-message="xyErr"
  38. v-model="decoy"
  39. class="field"
  40. :field-style="fieldstyle"
  41. placeholder="请填写害虫名称"
  42. >
  43. </u-field>
  44. <u-field
  45. label="诱芯到期时间"
  46. label-width="240"
  47. required
  48. :error-message="xyErrtime"
  49. v-model="decoytime"
  50. @click="settime"
  51. class="field"
  52. :field-style="fieldstyle"
  53. placeholder="请填写到期时间"
  54. >
  55. </u-field>
  56. <view class="" style="text-align: center; color: #fa3534">
  57. {{ tishitext }}
  58. </view>
  59. <view class="btn-box">
  60. <u-button @click="yxSubmit" size="mini" type="success" class="box-item"
  61. >确定</u-button
  62. >
  63. </view>
  64. </u-popup>
  65. <u-calendar
  66. v-model="tiemshow"
  67. mode="date"
  68. :max-date="date"
  69. @change="tiemchange"
  70. range-color="#999"
  71. btn-type="success"
  72. active-bg-color="#0BBC58"
  73. range-bg-color="rgba(11,188,88,0.13)"
  74. ></u-calendar>
  75. <view class="caobox">
  76. <view class="caobox_item" v-if="$QueryPermission(358)" @click="toset">
  77. <image
  78. :src="$imageURL+'/bigdata_app/image/cb/4.png'"
  79. mode="widthFix"
  80. ></image>
  81. <view class=""> 设备控制 </view>
  82. </view>
  83. <view class="caobox_item" v-if="$QueryPermission(359)" @click="tohis">
  84. <image
  85. :src="$imageURL+'/bigdata_app/image/cb/2.png'"
  86. mode="widthFix"
  87. ></image>
  88. <view class=""> 历史数据 </view>
  89. </view>
  90. </view>
  91. <view class="realtime">
  92. <view class="realtime_title">
  93. <p>实时数据</p>
  94. </view>
  95. <view class="realtime_text">
  96. <view class="realtime_item">
  97. <image
  98. :src="$imageURL+'/bigdata_app/image/cb/xy2.0/wendu.png'"
  99. mode=""
  100. ></image>
  101. <view class="text">
  102. <p>环境温度</p>
  103. <p>{{ at }}℃</p>
  104. </view>
  105. </view>
  106. <view class="realtime_item">
  107. <image
  108. :src="$imageURL+'/bigdata_app/image/cb/xy2.0/shidu.png'"
  109. mode=""
  110. ></image>
  111. <view class="text">
  112. <p>环境湿度</p>
  113. <p>{{ ah }}</p>
  114. </view>
  115. </view>
  116. <view class="realtime_item">
  117. <image
  118. :src="$imageURL+'/bigdata_app/image/cb/xy2.0/tianqi.png'"
  119. mode=""
  120. ></image>
  121. <view class="text">
  122. <p>天气</p>
  123. <p>{{ wea }}</p>
  124. </view>
  125. </view>
  126. <view class="realtime_item">
  127. <image
  128. :src="$imageURL+'/bigdata_app/image/cb/xy2.0/xiayu.png'"
  129. mode=""
  130. ></image>
  131. <view class="text">
  132. <p>是否下雨</p>
  133. <p>{{ rain }}</p>
  134. </view>
  135. </view>
  136. <view class="realtime_item">
  137. <image
  138. :src="$imageURL+'/bigdata_app/image/cb/xy2.0/yujing.png'"
  139. mode=""
  140. ></image>
  141. <view class="text">
  142. <p>诱虫次数</p>
  143. <p>{{ wormnum }}</p>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. </template>
  150. <script>
  151. export default {
  152. data() {
  153. return {
  154. showId: '',
  155. baseimei: '',
  156. equipInfo: {},
  157. trapnum: 1,
  158. at: '',
  159. ah: '',
  160. wind: '',
  161. wea: '',
  162. rain: '',
  163. wormnum: '',
  164. decoy: '',
  165. xyErr: '',
  166. xyErrtime: '',
  167. decoytime: '',
  168. yxShow: false,
  169. tiemshow: false,
  170. date: '',
  171. fieldstyle: {
  172. //输入框样式
  173. border: '2rpx solid #f6f6f6',
  174. 'border-radius': '24px',
  175. 'padding-left': '20rpx',
  176. 'background-color': '#f6f6f6',
  177. },
  178. tishitext: '',
  179. };
  180. },
  181. methods: {
  182. toset() {
  183. uni.navigateTo({
  184. url:
  185. './thxyset?device_id=' +
  186. this.equipInfo.imei || this.equipInfo.device_id || this.equipInfo.id +
  187. '&d_id=' +
  188. this.equipInfo.d_id +
  189. '&dtype=' +
  190. this.equipInfo.dtype +
  191. '&device_name=' +
  192. this.equipInfo.device_name || this.equipInfo.name,
  193. });
  194. },
  195. tohis() {
  196. uni.navigateTo({
  197. url:
  198. './thxyhisdata?device_id=' +
  199. this.equipInfo.imei || this.equipInfo.device_id || this.equipInfo.id +
  200. '&d_id=' +
  201. this.equipInfo.d_id,
  202. });
  203. },
  204. copy(item) {
  205. console.log(item);
  206. uni.setClipboardData({
  207. data: item.imei || item.device_id || item.id,
  208. success: function () {
  209. console.log('success');
  210. },
  211. });
  212. },
  213. async getbaseinfo() {
  214. const res = await this.$myRequest({
  215. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_list',
  216. data: {
  217. device_id: this.baseimei,
  218. device_type_id: '29',
  219. page: '1',
  220. page_size: '10',
  221. },
  222. });
  223. console.log(res.data[0]);
  224. this.equipInfo = res.data[0];
  225. this.getweather();
  226. this.getworm();
  227. },
  228. async getweather() {
  229. const res = await this.$myRequest({
  230. url: '/api/api_gateway?method=device.device_manage.weathers',
  231. data: {
  232. lng: Number(this.equipInfo.lng),
  233. lat: Number(this.equipInfo.lat),
  234. },
  235. });
  236. console.log(res);
  237. // this.
  238. if (res[0]) {
  239. this.wea = res[0].wea;
  240. this.rain = res[0].wea.indexOf('雨') == -1 ? '否' : '是';
  241. this.ah = res[0].ah;
  242. this.at = res[0].at;
  243. } else {
  244. this.wea = '暂无';
  245. this.rain = '暂无';
  246. }
  247. },
  248. async getworm() {
  249. const res = await this.$myRequest({
  250. url: '/api/api_gateway?method=forecast.worm_lamp.xycb_pest_chart_new',
  251. data: {
  252. d_id: this.equipInfo.d_id,
  253. start_time: Math.floor(+new Date() / 1000 - 30 * 24 * 60 * 60),
  254. end_time: Math.floor(+new Date() / 1000),
  255. device_type_id: '29',
  256. years: new Date().getFullYear(),
  257. },
  258. });
  259. console.log(res);
  260. this.wormnum = res.total_num[new Date().getFullYear()];
  261. },
  262. setdecoy() {
  263. this.decoy = this.equipInfo.decoy;
  264. this.decoytime = this.equipInfo.xy_expire;
  265. this.yxShow = true;
  266. },
  267. settime() {
  268. console.log(12);
  269. this.tiemshow = true;
  270. },
  271. tiemchange(e) {
  272. console.log(e);
  273. this.decoytime = e.result;
  274. },
  275. async yxSubmit() {
  276. var time = Math.floor(+new Date(this.decoytime) / 1000);
  277. console.log(time);
  278. if (this.decoy == '') {
  279. this.tishitext = '请填写诱芯名称';
  280. return;
  281. } else if (isNaN(time)) {
  282. this.tishitext = '请填写诱芯到期时间';
  283. return;
  284. }
  285. this.tishitext = '';
  286. const res = await this.$myRequest({
  287. url: '/api/api_gateway?method=forecast.worm_lamp.set_decopy',
  288. data: {
  289. decoy: this.decoy,
  290. device_id: this.equipInfo.imei || this.equipInfo.device_id || this.equipInfo.id,
  291. device_type_id: '29',
  292. expire_time: time,
  293. },
  294. });
  295. console.log(res);
  296. if (res.status) {
  297. uni.showToast({
  298. title: '设置成功',
  299. icon: 'none',
  300. });
  301. this.yxShow = false;
  302. this.getbaseinfo();
  303. }
  304. },
  305. },
  306. onLoad(option) {
  307. var times = new Date();
  308. this.date =
  309. times.getFullYear() +
  310. 1 +
  311. '-' +
  312. Number(times.getMonth() + 1) +
  313. '-' +
  314. times.getDate();
  315. this.baseimei = option.imei || option.device_id || option.id || '无';
  316. this.showId = option.showId;
  317. // console.log(this.equipInfo)
  318. this.getbaseinfo();
  319. },
  320. };
  321. </script>
  322. <style lang="less">
  323. page {
  324. padding: 20rpx;
  325. box-sizing: border-box;
  326. .info {
  327. padding: 20rpx 40rpx;
  328. color: #fff;
  329. line-height: 50rpx;
  330. font-size: 26rpx;
  331. background-size: 100% auto;
  332. background-repeat: no-repeat;
  333. background-color: #0dc6b6;
  334. background-position: top left;
  335. box-sizing: border-box;
  336. width: 100%;
  337. .tishi {
  338. width: 28rpx;
  339. height: 28rpx;
  340. margin: 0rpx 0 0 20rpx;
  341. }
  342. }
  343. .on {
  344. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/onBg.png');
  345. }
  346. .off {
  347. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/offBg.png');
  348. }
  349. .caobox {
  350. display: flex;
  351. flex-wrap: wrap;
  352. text-align: center;
  353. font-size: 28rpx;
  354. color: #666;
  355. line-height: 50rpx;
  356. image {
  357. width: 52rpx;
  358. }
  359. .caobox_item {
  360. padding: 20rpx 0;
  361. box-sizing: border-box;
  362. flex-basis: 25%;
  363. }
  364. }
  365. .realtime {
  366. width: 95%;
  367. margin: 0rpx auto;
  368. .realtime_title {
  369. font-size: 32rpx;
  370. display: flex;
  371. justify-content: space-between;
  372. font-weight: 700;
  373. .span {
  374. color: #6e6c76;
  375. font-size: 24rpx;
  376. display: flex;
  377. justify-content: space-between;
  378. margin-top: 12rpx;
  379. }
  380. }
  381. .realtime_text {
  382. margin-top: 20rpx;
  383. display: flex;
  384. justify-content: space-between;
  385. flex-wrap: wrap;
  386. .realtime_item {
  387. width: 48%;
  388. height: 100rpx;
  389. display: flex;
  390. box-shadow: 0 0 10rpx #bcb9ca;
  391. margin-top: 20rpx;
  392. padding: 20rpx 0;
  393. image {
  394. width: 60rpx;
  395. height: 60rpx;
  396. margin: 20rpx 20rpx 20rpx 40rpx;
  397. }
  398. .text {
  399. padding: 10rpx 0 10rpx 30rpx;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. .btn-box {
  406. text-align: center;
  407. padding: 20rpx 30rpx;
  408. }
  409. ::v-deep .u-calendar__action {
  410. display: flex;
  411. justify-content: space-around;
  412. .u-calendar__action__text {
  413. line-height: 25px;
  414. }
  415. }
  416. </style>