nlNewXy.vue 10 KB

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