particulars.vue 13 KB

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