particulars.vue 15 KB

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