particulars.vue 12 KB

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