particulars.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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="http://www.hnyfwlw.com:8006/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="'http://www.hnyfwlw.com:8006/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="'http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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="http://www.hnyfwlw.com:8006/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. // this.Chistory(this.equipInfo.device_id)
  170. },
  171. async getSim(d_id) {
  172. const res = await this.$myRequest({
  173. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_sim',
  174. data: {
  175. d_id: d_id,
  176. }
  177. })
  178. console.log(res)
  179. if(res != null){
  180. this.simdata = res.data.card_list[0]
  181. this.usedBeliel = (this.simdata.data_plan-this.simdata.data_balance)/ this.simdata.data_plan *100
  182. this.residueBeliel = this.simdata.data_balance/this.simdata.data_plan * 100
  183. this.simTF = true
  184. }else{
  185. this.simTF = false
  186. }
  187. },
  188. async getworm(data,info) {
  189. const res = await this.$myRequest({
  190. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_set_lure',
  191. data: data
  192. })
  193. console.log(res)
  194. if(res.code == 200){
  195. uni.showToast({
  196. title: "设置成功",
  197. icon: "none"
  198. })
  199. if(data.expire_time){
  200. this.yxendtime = info
  201. }else if(data.pest_name){
  202. this.newState.decoy = info
  203. }else if(data.addtime){
  204. this.yxchangetime = info
  205. }
  206. }
  207. },
  208. toggle(){
  209. uni.navigateTo({
  210. url:"./historydatas?device_id="+this.equipInfo.device_id + "&d_id=" + this.equipInfo.d_id
  211. })
  212. },
  213. addxy(){
  214. this.yxShow =true
  215. this.decoy = this.newState.decoy
  216. },
  217. yxSubmit(){
  218. if(this.decoy == ""){
  219. this.xyErr = "请填写害虫名称"
  220. }else{
  221. this.xyErr = ""
  222. var obj = {
  223. d_id: this.equipInfo.d_id,
  224. pest_name:this.decoy
  225. }
  226. this.getworm(obj,this.decoy)
  227. console.log(this.decoy)
  228. this.yxShow =false
  229. }
  230. },
  231. timeChange(e){
  232. console.log(e)
  233. var obj = {
  234. d_id: this.equipInfo.d_id,
  235. addtime:+new Date(e.result)/1000
  236. }
  237. this.getworm(obj,e.result)
  238. },
  239. timeChangetwo(e){
  240. console.log(e)
  241. var obj = {
  242. d_id: this.equipInfo.d_id,
  243. expire_time:+new Date(e.result)/1000
  244. }
  245. this.getworm(obj,e.result)
  246. },
  247. copy(item){
  248. console.log(item)
  249. uni.setClipboardData({
  250. data: item,
  251. success: function () {
  252. console.log('success');
  253. }
  254. });
  255. },
  256. repairs(){
  257. uni.navigateTo({
  258. url: "../../afterSale/addafter?device_id="+ this.newState.device_id +"&device_type="+ 10
  259. })
  260. },
  261. async Chistory(device_id) { //历史数据列表折线图
  262. this.dataloadingtf = true
  263. const res = await this.$myRequest({
  264. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_line_chart',
  265. data: {
  266. device_id: device_id,
  267. // start_time: Math.floor(+new Date/1000 - 24*60*60),
  268. // end_time: Math.floor(+new Date/1000),
  269. status: "pest"
  270. }
  271. })
  272. if(res.data[0]){
  273. //***********************************************************
  274. // if(this.newState.decoy=="草地贪夜蛾"){
  275. // this.trapnum = 0
  276. // }else{
  277. this.trapnum = res.data[0].pest_num
  278. // }
  279. }
  280. }
  281. },
  282. onLoad(option) {
  283. this.equipInfo = JSON.parse(option.info)
  284. if (!this.equipInfo.device_id) {
  285. this.equipInfo.device_id = this.equipInfo.imei
  286. }
  287. console.log(this.equipInfo)
  288. this.getState(this.equipInfo.d_id)
  289. if (this.equipInfo.type != 21) {
  290. // this.getSim(this.equipInfo.d_id)
  291. }
  292. var times = new Date()
  293. this.date = times.getFullYear()+1 + "-" + Number(times.getMonth()+1) + "-" + times.getDate()
  294. console.log(this.date)
  295. // uni.getStorage({ 待开发
  296. // key:"jurisdiction",
  297. // success:(res)=>{
  298. // console.log(JSON.parse(res.data))
  299. // let items = JSON.parse(res.data).filter((item)=>{
  300. // return item.purview_name == "测报系统"
  301. // })
  302. // let items2 = items[0].children.filter((item)=>{
  303. // return item.purview_name == "性诱2.0"
  304. // })
  305. // console.log(items2)
  306. // },
  307. // })
  308. }
  309. }
  310. </script>
  311. <style lang="scss">
  312. .info {
  313. padding: 20rpx 40rpx;
  314. color: #fff;
  315. line-height: 50rpx;
  316. font-size: 26rpx;
  317. background-size: 100% auto;
  318. background-repeat: no-repeat;
  319. background-color: #0DC6B6;
  320. background-position: top left;
  321. box-sizing: border-box;
  322. width: 95%;
  323. margin: 0 auto;
  324. p:first-child{
  325. font-size: 32rpx;
  326. }
  327. .expiretishi{
  328. font-size: 24rpx;
  329. color: #FF0000;
  330. }
  331. .tishi{
  332. width: 28rpx;
  333. height: 28rpx;
  334. margin: 0rpx 0 0 20rpx;
  335. }
  336. .fillin{
  337. display: flex;
  338. input{
  339. width: 200rpx;
  340. font-size: 24rpx;
  341. height: 50rpx;
  342. line-height: 50rpx;
  343. text-indent: 1em;
  344. }
  345. }
  346. }
  347. .on {
  348. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png')
  349. }
  350. .off {
  351. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png')
  352. }
  353. .control {
  354. width: 90%;
  355. display: flex;
  356. text-align: center;
  357. box-sizing: border-box;
  358. margin: 30rpx auto;
  359. .control_item {
  360. width: 120rpx;
  361. height: 120rpx;
  362. margin-right: 40rpx;
  363. image {
  364. width: 70rpx;
  365. height: 70rpx;
  366. }
  367. p {
  368. font-size: 24rpx;
  369. }
  370. }
  371. }
  372. .realtime{
  373. width: 95%;
  374. margin: 0rpx auto;
  375. .realtime_title{
  376. font-size: 32rpx;
  377. display: flex;
  378. justify-content: space-between;
  379. font-weight: 700;
  380. .span{
  381. color: #6e6c76;
  382. font-size: 24rpx;
  383. display: flex;
  384. justify-content: space-between;
  385. margin-top: 12rpx;
  386. }
  387. }
  388. .realtime_text{
  389. margin-top: 20rpx;
  390. display: flex;
  391. justify-content: space-between;
  392. flex-wrap: wrap;
  393. .realtime_item{
  394. width: 48%;
  395. height: 100rpx;
  396. display: flex;
  397. box-shadow: 0 0 10rpx #bcb9ca;
  398. margin-top: 20rpx;
  399. padding: 20rpx 0;
  400. image{
  401. width: 60rpx;
  402. height: 60rpx;
  403. margin: 20rpx 20rpx 20rpx 40rpx;
  404. }
  405. .text{
  406. padding: 10rpx 0 10rpx 30rpx;
  407. }
  408. }
  409. }
  410. }
  411. .sim{
  412. width: 95%;
  413. margin: 40rpx auto;
  414. .sim_title{
  415. font-size: 32rpx;
  416. font-weight: 700;
  417. }
  418. .sim_text{
  419. box-shadow: 0 0 10rpx #bcb9ca;
  420. padding: 30rpx;
  421. margin-top: 40rpx;
  422. .p{
  423. margin-top: 20rpx;
  424. }
  425. .sim_plan{
  426. display: flex;
  427. margin-top: 20rpx;
  428. .sim_plan_text{
  429. width: 60%;
  430. height: 16rpx;
  431. background-color: #cccccc;
  432. border-radius:8rpx ;
  433. margin: 10rpx 20rpx 0 0;
  434. p{
  435. height: 16rpx;
  436. background-color: #0dc6b6;
  437. border-radius:8rpx ;
  438. }
  439. }
  440. }
  441. }
  442. }
  443. .btn-box {
  444. text-align: center;
  445. padding: 20rpx 30rpx;
  446. }
  447. /deep/.u-calendar__action{
  448. display: flex;
  449. justify-content: space-around;
  450. .u-calendar__action__text{
  451. line-height: 25px;
  452. }
  453. }
  454. </style>