particulars.vue 15 KB

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