particulars.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view>
  3. <view class="">
  4. <view :class="['info',equipInfo.is_online==1?'on':'off']">
  5. <p @click="copy(newState.device_id)">设备ID:{{newState.device_id}}<image :src="$imageURL+'/bigdata_app/image/environment/fuzhi.png'" mode="" class="tishi"></image></p>
  6. <p>设备名称:{{newState.device_name==""?"无":newState.device_name}}</p>
  7. <p>最新上报时间:{{newState.uptime | timeFormat}}</p>
  8. <p>最新地址:{{newState.addr}}</p>
  9. <p class="fillin" @click="addxy">测报害虫:<input type="text" v-model="newState.decoy" disabled v-if="newState.decoy"/><u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon></p>
  10. <p @click="glass_show=true">诱芯更换时间:<span style="margin:0 20rpx;">{{yxchangetime}}</span><u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon></p>
  11. <p @click="glass_showtwo=true">诱芯到期时间:<span style="margin:0 20rpx;">{{yxendtime}}</span><u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon></p>
  12. <u-calendar v-model="glass_show" mode="date" :max-date="date" @change="timeChange"></u-calendar>
  13. <u-calendar v-model="glass_showtwo" mode="date" :max-date="date" @change="timeChangetwo"></u-calendar>
  14. </view>
  15. <view class="control">
  16. <view class="control_item" @click="repairs">
  17. <image :src="$imageURL+'/bigdata_app'+'/image/environment/7.png'" mode=""></image>
  18. <p>一键报修</p>
  19. </view>
  20. <view class="control_item" @click="toggle" v-if="$QueryPermission(176)">
  21. <image :src="$imageURL+'/bigdata_app'+'/image/cb/2.png'" mode=""></image>
  22. <p>历史数据</p>
  23. </view>
  24. </view>
  25. <view class="realtime">
  26. <view class="realtime_title">
  27. <p>实时数据</p>
  28. </view>
  29. <view class="realtime_text">
  30. <view class="realtime_item">
  31. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/wendu.png'" mode=""></image>
  32. <view class="text">
  33. <p>环境温度</p>
  34. <p>{{newState.at}}℃</p>
  35. </view>
  36. </view>
  37. <view class="realtime_item">
  38. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/shidu.png'" mode=""></image>
  39. <view class="text">
  40. <p>环境湿度</p>
  41. <p>{{newState.ah}}%</p>
  42. </view>
  43. </view>
  44. <view class="realtime_item">
  45. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/tianqi.png'" mode=""></image>
  46. <view class="text">
  47. <p>天气</p>
  48. <p>{{newState.type}}</p>
  49. </view>
  50. </view>
  51. <view class="realtime_item">
  52. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/xiayu.png'" mode=""></image>
  53. <view class="text">
  54. <p>是否下雨</p>
  55. <p>{{newState.rain}}</p>
  56. </view>
  57. </view>
  58. <view class="realtime_item">
  59. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/fengxiang.png'" mode=""></image>
  60. <view class="text">
  61. <p>风力风向</p>
  62. <p>{{newState.wind}}</p>
  63. </view>
  64. </view>
  65. <view class="realtime_item">
  66. <image :src="$imageURL+'/bigdata_app/image/cb/xy2.0/yujing.png'" mode=""></image>
  67. <view class="text">
  68. <p>诱虫次数</p>
  69. <p>{{trapnum}}</p>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- <view class="sim" v-if="simTF && $QueryPermission(246)">
  75. <p class="sim_title">sim卡详情</p>
  76. <view class="sim_text">
  77. <p class="p">ICCID:{{simdata.iccid}}</p>
  78. <p class="p">状态:{{simstate[simdata.account_status]}}</p>
  79. <view class="sim_plan">
  80. 套餐流量:
  81. <view class="sim_plan_text">
  82. <p style="width: 100%;"></p>
  83. </view>
  84. {{simdata.data_plan.toFixed(2)}}MB
  85. </view>
  86. <view class="sim_plan">
  87. 已用流量:
  88. <view class="sim_plan_text">
  89. <p :style="{width:usedBeliel+'%'}"></p>
  90. </view>
  91. {{simdata.data_plan - simdata.data_balance.toFixed(2)}}MB
  92. </view>
  93. <view class="sim_plan">
  94. 剩余流量:
  95. <view class="sim_plan_text">
  96. <p :style="{width:residueBeliel+'%'}"></p>
  97. </view>
  98. {{simdata.data_balance.toFixed(2)}}MB
  99. </view>
  100. <p class="p">到期时间:{{simdata.expiry_date | timeFormat}}</p>
  101. </view>
  102. </view> -->
  103. <u-popup v-model="yxShow" mode="center" width="600rpx">
  104. <u-field label="害虫名称" label-width='240' required :error-message="xyErr" v-model="decoy" class="field" :field-style="fieldstyle" placeholder="请填写害虫名称">
  105. </u-field>
  106. <view class="btn-box">
  107. <u-button @click="yxSubmit" size="mini" type="success" class="box-item">确定</u-button>
  108. </view>
  109. </u-popup>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. export default {
  115. data() {
  116. return {
  117. equipInfo:[],
  118. newState:{},
  119. simdata:{},
  120. simstate:['未知','测试期','沉默期','使用中','停机','停机保号','预销号','销号'],
  121. usedBeliel:'',
  122. residueBeliel:"",
  123. simTF:false,
  124. expiretext:"",
  125. yxShow:false,
  126. xyErr:"",
  127. decoy:"",
  128. yxchangetime:0,//更换诱芯时间
  129. yxendtime:0,//诱芯到期时间
  130. glass_show:false,//更换诱芯时间选择
  131. glass_showtwo:false,//诱芯到期时间选择
  132. date:"",//日历可选最大时间
  133. fieldstyle:{//输入框样式
  134. border:"2rpx solid #f6f6f6",
  135. "border-radius":"24px",
  136. "padding-left":"20rpx",
  137. "background-color":"#f6f6f6"
  138. },
  139. trapnum:0
  140. }
  141. },
  142. methods: {
  143. async getState(d_id) {
  144. const res = await this.$myRequest({
  145. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_details',
  146. data: {
  147. d_id: d_id,
  148. }
  149. })
  150. this.newState = res[0]
  151. if(res[0].xy_expire_time==0){
  152. this.yxendtime = "暂无"
  153. }else{
  154. var times = new Date(res[0].xy_expire_time*1000)
  155. var month = times.getMonth()+1
  156. month = month<10?"0"+month:month
  157. var date = times.getDate()<10?"0"+times.getDate():times.getDate()
  158. this.yxendtime = times.getFullYear() + "-" + month + "-" + date
  159. }
  160. if(res[0].xy_uptime==0){
  161. this.yxendtime = "暂无"
  162. }else{
  163. var times = new Date(res[0].xy_uptime*1000)
  164. var month = times.getMonth()+1
  165. month = month<10?"0"+month:month
  166. var date = times.getDate()<10?"0"+times.getDate():times.getDate()
  167. this.yxchangetime = times.getFullYear() + "-" + month + "-" + date
  168. }
  169. },
  170. // async getSim(d_id) {
  171. // const res = await this.$myRequest({
  172. // url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_sim',
  173. // data: {
  174. // d_id: d_id,
  175. // }
  176. // })
  177. // console.log(res)
  178. // if(res.data != null){
  179. // this.simdata = res.data.card_list[0]
  180. // this.usedBeliel = (this.simdata.data_plan-this.simdata.data_balance)/ this.simdata.data_plan *100
  181. // this.residueBeliel = this.simdata.data_balance/this.simdata.data_plan * 100
  182. // this.simTF = true
  183. // }else{
  184. // this.simTF = false
  185. // }
  186. // },
  187. async getworm(data,info) {
  188. const res = await this.$myRequest({
  189. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_set_lure',
  190. data: data
  191. })
  192. console.log(res)
  193. if(res.code == 200){
  194. uni.showToast({
  195. title: "设置成功",
  196. icon: "none"
  197. })
  198. if(data.expire_time){
  199. this.yxendtime = info
  200. }else if(data.pest_name){
  201. this.newState.decoy = info
  202. }else if(data.addtime){
  203. this.yxchangetime = info
  204. }
  205. }
  206. },
  207. toggle(){
  208. uni.navigateTo({
  209. url:"./historydatas?device_id="+this.equipInfo.device_id + "&d_id=" + this.equipInfo.d_id
  210. })
  211. },
  212. addxy(){
  213. this.yxShow =true
  214. this.decoy = this.newState.decoy
  215. },
  216. yxSubmit(){
  217. if(this.decoy == ""){
  218. this.xyErr = "请填写害虫名称"
  219. }else{
  220. this.xyErr = ""
  221. var obj = {
  222. d_id: this.equipInfo.d_id,
  223. pest_name:this.decoy
  224. }
  225. this.getworm(obj,this.decoy)
  226. console.log(this.decoy)
  227. this.yxShow =false
  228. }
  229. },
  230. timeChange(e){
  231. console.log(e)
  232. var obj = {
  233. d_id: this.equipInfo.d_id,
  234. addtime:+new Date(e.result)/1000
  235. }
  236. this.getworm(obj,e.result)
  237. },
  238. timeChangetwo(e){
  239. console.log(e)
  240. var obj = {
  241. d_id: this.equipInfo.d_id,
  242. expire_time:+new Date(e.result)/1000
  243. }
  244. this.getworm(obj,e.result)
  245. },
  246. copy(item){
  247. console.log(item)
  248. uni.setClipboardData({
  249. data: item,
  250. success: function () {
  251. console.log('success');
  252. }
  253. });
  254. },
  255. repairs(){
  256. uni.navigateTo({
  257. url: "../../afterSale/addafter?device_id="+ this.newState.device_id +"&device_type="+ 10
  258. })
  259. },
  260. async Chistory(device_id) { //历史数据列表折线图
  261. this.dataloadingtf = true
  262. const res = await this.$myRequest({
  263. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_line_chart',
  264. data: {
  265. device_id: device_id,
  266. start_time: Math.floor(+new Date/1000 - 24*60*60),
  267. end_time: Math.floor(+new Date/1000),
  268. status: "pest"
  269. }
  270. })
  271. console.log(res)
  272. if(res.data[0]){
  273. this.trapnum = res.data[0].pest_num
  274. }
  275. }
  276. },
  277. onLoad(option) {
  278. this.equipInfo = JSON.parse(option.info)
  279. console.log(this.equipInfo)
  280. this.getState(this.equipInfo.d_id)
  281. // this.getSim(this.equipInfo.d_id)
  282. var times = new Date()
  283. this.date = times.getFullYear()+1 + "-" + Number(times.getMonth()+1) + "-" + times.getDate()
  284. console.log(this.date)
  285. this.Chistory(this.equipInfo.device_id)
  286. // uni.getStorage({ 待开发
  287. // key:"jurisdiction",
  288. // success:(res)=>{
  289. // console.log(JSON.parse(res.data))
  290. // let items = JSON.parse(res.data).filter((item)=>{
  291. // return item.purview_name == "测报系统"
  292. // })
  293. // let items2 = items[0].children.filter((item)=>{
  294. // return item.purview_name == "性诱2.0"
  295. // })
  296. // console.log(items2)
  297. // },
  298. // })
  299. }
  300. }
  301. </script>
  302. <style lang="scss">
  303. .info {
  304. padding: 20rpx 40rpx;
  305. color: #fff;
  306. line-height: 50rpx;
  307. font-size: 26rpx;
  308. background-size: 100% auto;
  309. background-repeat: no-repeat;
  310. background-color: #0DC6B6;
  311. background-position: top left;
  312. box-sizing: border-box;
  313. width: 95%;
  314. margin: 0 auto;
  315. p:first-child{
  316. font-size: 32rpx;
  317. }
  318. .expiretishi{
  319. font-size: 24rpx;
  320. color: #FF0000;
  321. }
  322. .tishi{
  323. width: 28rpx;
  324. height: 28rpx;
  325. margin: 0rpx 0 0 20rpx;
  326. }
  327. .fillin{
  328. display: flex;
  329. input{
  330. width: 200rpx;
  331. font-size: 24rpx;
  332. height: 50rpx;
  333. line-height: 50rpx;
  334. text-indent: 1em;
  335. }
  336. }
  337. }
  338. .on {
  339. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/onBg.png')
  340. }
  341. .off {
  342. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/offBg.png')
  343. }
  344. .control {
  345. width: 90%;
  346. display: flex;
  347. text-align: center;
  348. box-sizing: border-box;
  349. margin: 30rpx auto;
  350. .control_item {
  351. width: 120rpx;
  352. height: 120rpx;
  353. margin-right: 40rpx;
  354. image {
  355. width: 70rpx;
  356. height: 70rpx;
  357. }
  358. p {
  359. font-size: 24rpx;
  360. }
  361. }
  362. }
  363. .realtime{
  364. width: 95%;
  365. margin: 0rpx auto;
  366. .realtime_title{
  367. font-size: 36rpx;
  368. display: flex;
  369. justify-content: space-between;
  370. .span{
  371. color: #6e6c76;
  372. font-size: 24rpx;
  373. display: flex;
  374. justify-content: space-between;
  375. margin-top: 12rpx;
  376. }
  377. }
  378. .realtime_text{
  379. margin-top: 20rpx;
  380. display: flex;
  381. justify-content: space-between;
  382. flex-wrap: wrap;
  383. .realtime_item{
  384. width: 48%;
  385. height: 100rpx;
  386. display: flex;
  387. box-shadow: 0 0 10rpx #bcb9ca;
  388. margin-top: 20rpx;
  389. padding: 20rpx 0;
  390. image{
  391. width: 60rpx;
  392. height: 60rpx;
  393. margin: 20rpx 20rpx 20rpx 40rpx;
  394. }
  395. .text{
  396. padding: 10rpx 0 10rpx 30rpx;
  397. }
  398. }
  399. }
  400. }
  401. .sim{
  402. width: 95%;
  403. margin: 40rpx auto;
  404. .sim_title{
  405. font-size: 36rpx;
  406. }
  407. .sim_text{
  408. box-shadow: 0 0 10rpx #bcb9ca;
  409. padding: 30rpx;
  410. margin-top: 40rpx;
  411. .p{
  412. margin-top: 20rpx;
  413. }
  414. .sim_plan{
  415. display: flex;
  416. margin-top: 20rpx;
  417. .sim_plan_text{
  418. width: 60%;
  419. height: 16rpx;
  420. background-color: #cccccc;
  421. border-radius:8rpx ;
  422. margin: 10rpx 20rpx 0 0;
  423. p{
  424. height: 16rpx;
  425. background-color: #0dc6b6;
  426. border-radius:8rpx ;
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .btn-box {
  433. text-align: center;
  434. padding: 20rpx 30rpx;
  435. }
  436. /deep/.u-calendar__action{
  437. display: flex;
  438. justify-content: space-around;
  439. .u-calendar__action__text{
  440. line-height: 25px;
  441. }
  442. }
  443. </style>