nlNewXy.vue 9.0 KB

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