particulars.vue 11 KB

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