nlNewXy.vue 8.9 KB

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