index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <view class="index">
  3. <view class="header" @click="openInfoPopup">
  4. <view class="icon"></view>
  5. <view class="info">
  6. <view class="title">
  7. <text>{{body.stationName}}</text>
  8. <text class="right">{{date}}</text>
  9. </view>
  10. <view class="number">
  11. <text>{{body.deviceSn}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="header-banner">
  16. <swiper style="height: 56.25vw;" autoplay>
  17. <block v-for="(item, i) in headerBanner" :key="i">
  18. <swiper-item>
  19. <view class="banner-img" :style="getHeaderBannreStyle(item.image)"></view>
  20. <!-- <image class="" :src="item.image" mode="aspectFill"></image> -->
  21. </swiper-item>
  22. </block>
  23. </swiper>
  24. </view>
  25. <!-- <view class="center-banner">
  26. <swiper style="height: 40vw;" autoplay>
  27. <block v-for="(item, i) in centerBanner" :key="i">
  28. <swiper-item>
  29. <view class="banner-img" :style="getHeaderBannreStyle(item.image)"></view>
  30. </swiper-item>
  31. </block>
  32. </swiper>
  33. </view> -->
  34. <view class="btn-box">
  35. <!-- <view class="btn" v-if="body.scanImage">
  36. <image class="bg" :src="body.scanImage"></image>
  37. </view> -->
  38. <view class="btn" @click="bagStorage">
  39. <image class="bg" :src="require('../../static/images/icon-storage-bg.png')"></image>
  40. <!-- <image class="icon" :src="require('../../static/images/icon-storage.png')"></image>
  41. <view class="label">存物</view> -->
  42. </view>
  43. <!-- <view class="btn" v-if="body.takeImage">
  44. <image class="bg" :src="body.takeImage"></image>
  45. </view> -->
  46. <view class="btn" @click="fetchPacket">
  47. <image class="bg" :src="require('../../static/images/icon-fetch-bg.png')"></image>
  48. <!-- <image class="icon" :src="require('../../static/images/icon-fetch.png')"></image>
  49. <view class="label">取物</view> -->
  50. </view>
  51. </view>
  52. <image class="terms-icon" :src="require('../../static/images/icon-terms.png')" mode="aspectFill"></image>
  53. <!-- <view class="welcome">欢迎使用木桩储物柜</view> -->
  54. <uni-popup ref="statusPopup" type="center">
  55. <!-- :class="reportStatus.status == 1 ? 'success' : 'fail'" -->
  56. <view class="status-box">
  57. <!-- <image class="delete-icon" src="../../static/images/icon-delete.png" @click="closeStatusPopup"></image> -->
  58. <image class="icon" :src="require('../../static/images/icon-success.png')" v-if="reportStatus.status == 1"></image>
  59. <image class="icon" :src="require('../../static/images/icon-fail.png')" v-else></image>
  60. <view class="label">
  61. <text>{{reportStatus.msg}}</text>
  62. <!-- <text v-if="reportStatus.status == 1">开箱成功</text>
  63. <text v-if="reportStatus.status == 2">未找到该订单</text>
  64. <text v-if="reportStatus.status == 4">开箱失败</text> -->
  65. </view>
  66. <view class="clear-btn" @click="closeStatusPopup">知道了</view>
  67. </view>
  68. </uni-popup>
  69. <uni-popup ref="infoPopup" type="center">
  70. <view class="info-body">
  71. <image class="delete-icon-info" :src="require('../../static/images/icon-delete-info.png')" @click="deleteInfoPopup"></image>
  72. <view class="top">
  73. <view class="cell">
  74. <view class="label-box">
  75. <image class="icon" :src="require('../../static/images/icon-address.png')"></image>
  76. <text>柜机地址</text>
  77. </view>
  78. <view class="address">{{body.stationAddress}}</view>
  79. </view>
  80. <view class="line"></view>
  81. <view class="cell">
  82. <view class="label-box" @touchstart="startAdminLogin" @touchend="endAdminLogin">
  83. <image class="icon" :src="require('../../static/images/icon-sn.png')"></image>
  84. <text style="margin-right: 2.3vw;">柜机编号</text>
  85. <text style="color: #FFFFFF;">{{body.deviceSn}}</text>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="bottom">
  90. <view class="label-box">
  91. <view class="label">扫描下方二维码</view>
  92. <view class="message">获取木桩柜详细信息</view>
  93. </view>
  94. <view class="qrcode">
  95. <image :src="body.url"></image>
  96. </view>
  97. </view>
  98. </view>
  99. </uni-popup>
  100. <uni-popup ref="bindPopup" type="center">
  101. <view class="bind-body">
  102. <view class="title">绑定设备号</view>
  103. <view class="input-box">
  104. <!-- -->
  105. <input placeholder="请输入要绑定的设备号" placeholder-style="color: #B7B7B7" @input="changeBind" />
  106. </view>
  107. <view class="bind-btn" @click="bindDevice">绑定</view>
  108. </view>
  109. </uni-popup>
  110. </view>
  111. </template>
  112. <script>
  113. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  114. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  115. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  116. export default {
  117. data() {
  118. return {
  119. headerBanner: [],
  120. centerBanner: [],
  121. date: '',
  122. reportStatus: {},
  123. body: {},
  124. msg: '',
  125. timer: '',
  126. timer1: '',
  127. deviceSn: '',
  128. isNoBind: true
  129. }
  130. },
  131. onLoad() {
  132. const $this = this;
  133. setInterval(function() {
  134. let date = new Date();
  135. let y = date.getFullYear();
  136. let m = date.getMonth() + 1;
  137. let d = date.getDate();
  138. let h = date.getHours();
  139. let mm = date.getMinutes();
  140. $this.date =
  141. `${y}-${m > 9 ? m : '0' + m}-${d > 9 ? d : '0' + d} ${h > 9 ? h : '0' + h}:${mm > 9 ? mm : '0' + mm}`
  142. }, 1000)
  143. this.getHeaderBanner();
  144. this.getCenterBanner();
  145. // uni.removeStorageSync('sn');
  146. // uni.setStorageSync('sn', '862607052911665');
  147. let sn = uni.getStorageSync('sn');
  148. if (!sn) {
  149. plus.device.getInfo({
  150. success: function(e) {
  151. console.log('getDeviceInfo success: ', e.uuid);
  152. $this.$api.deviceGetDeviceSn({
  153. uuid: e.uuid
  154. }).then(res => {
  155. console.log('AAAA', res)
  156. $this.uuid = e.uuid;
  157. if (res.deviceSn) {
  158. uni.setStorageSync('sn', res.deviceSn);
  159. $this.getData()
  160. } else {
  161. $this.isNoBind = true
  162. }
  163. // $this.getStatus()
  164. }, err => {
  165. console.log("SASAERR", err)
  166. })
  167. },
  168. fail: function(e) {
  169. console.log('getDeviceInfo failed: ', e);
  170. }
  171. });
  172. } else {
  173. console.log("SSAASS")
  174. this.getData()
  175. }
  176. },
  177. onShow() {
  178. console.log("SA")
  179. clearInterval(this.timer);
  180. uni.setStorageSync('sn', '862607052911665')
  181. if (uni.getStorageSync('sn')) {
  182. // this.getStatus()
  183. }
  184. // const $this = this;
  185. // $this.$nextTick(function() {
  186. // $this.$refs.statusPopup.open()
  187. // setInterval(function() {
  188. // $this.$refs.statusPopup.close()
  189. // }, 10000)
  190. // })
  191. },
  192. onHide() {
  193. clearInterval(this.timer);
  194. },
  195. methods: {
  196. startAdminLogin() {
  197. this.adminTime = new Date().getTime();
  198. },
  199. endAdminLogin() {
  200. let lastTime = new Date().getTime();
  201. if (this.adminTime && (lastTime - this.adminTime > 4000)) {
  202. this.adminLogin();
  203. this.adminTime = 0;
  204. }
  205. },
  206. getHeaderBannreStyle(e) {
  207. return {
  208. backgroundImage: `url(${e})`
  209. }
  210. },
  211. getData() {
  212. let sn = uni.getStorageSync('sn');
  213. this.$api.deviceInfo({
  214. deviceSn: sn
  215. }).then(res => {
  216. this.body = res.data;
  217. })
  218. },
  219. closeStatusPopup() {
  220. const $this = this;
  221. clearInterval(this.timer1)
  222. $this.$nextTick(function() {
  223. $this.$refs.statusPopup.close()
  224. })
  225. },
  226. getStatus() {
  227. const $this = this;
  228. this.timer = setInterval(function() {
  229. let sn = uni.getStorageSync('sn');
  230. $this.$api.deviceReportStatus({
  231. deviceSn: sn
  232. }).then(res => {
  233. console.log(res);
  234. if (res.report) {
  235. console.log("@@@@", res);
  236. $this.reportStatus = res.report;
  237. clearTimeout(this.timer1);
  238. if (res.report.status == 3) {
  239. // uni.setStorageSync('timeoutOrder', res.order)
  240. uni.navigateTo({
  241. url: '/pages/order/details?orderSn=' + res.report.orderSn
  242. })
  243. } else {
  244. $this.$nextTick(function() {
  245. console.log("SSSS1")
  246. clearInterval(this.timer1)
  247. $this.$refs.statusPopup.close()
  248. $this.$refs.statusPopup.open()
  249. $this.hideStatus();
  250. })
  251. }
  252. }
  253. })
  254. }, 3000)
  255. },
  256. hideStatus() {
  257. const $this = this;
  258. this.timer1 = setTimeout(function() {
  259. clearInterval(this.timer1)
  260. $this.$nextTick(function() {
  261. $this.$refs.statusPopup.close()
  262. })
  263. }, 10000)
  264. },
  265. getHeaderBanner() {
  266. this.$api.bannerList({
  267. type: 2
  268. }).then(res => {
  269. console.log(res);
  270. this.headerBanner = res.data;
  271. })
  272. },
  273. getCenterBanner() {
  274. this.$api.bannerList({
  275. type: 3
  276. }).then(res => {
  277. console.log(res);
  278. this.centerBanner = res.data;
  279. })
  280. },
  281. bagStorage() {
  282. uni.navigateTo({
  283. url: '/pages/bagStorage/login'
  284. })
  285. },
  286. fetchPacket() {
  287. uni.navigateTo({
  288. url: '/pages/fetchPacket/index'
  289. })
  290. },
  291. openInfoPopup() {
  292. let sn = uni.getStorageSync('sn');
  293. if (!this.isNoBind) {
  294. this.$refs.infoPopup.open();
  295. } else {
  296. this.$refs.bindPopup.open();
  297. }
  298. },
  299. deleteInfoPopup() {
  300. const $this = this;
  301. $this.$nextTick(function() {
  302. $this.$refs.infoPopup.close()
  303. })
  304. },
  305. // 管理员登录
  306. adminLogin() {
  307. console.log("管理员登录")
  308. clearInterval(this.timer);
  309. uni.navigateTo({
  310. url: '/pages/admin/login'
  311. })
  312. },
  313. // 绑定设备号
  314. changeBind(e) {
  315. this.deviceSn = e.detail.value;
  316. },
  317. // 绑定设备号
  318. bindDevice() {
  319. uni.showLoading({
  320. title: '绑定中...'
  321. })
  322. this.$api.deviceBindDevice({
  323. uuid: this.uuid,
  324. deviceSn: this.deviceSn
  325. }).then(res => {
  326. uni.setStorageSync('sn', this.deviceSn);
  327. this.getData()
  328. this.$refs.bindPopup.close();
  329. uni.hideLoading()
  330. }, err => {
  331. uni.hideLoading()
  332. })
  333. }
  334. }
  335. }
  336. </script>
  337. <style lang="scss">
  338. .index {
  339. min-height: 100vh;
  340. background-color: #FFF;
  341. .header {
  342. display: flex;
  343. align-items: center;
  344. height: 10vw;
  345. padding: 0 4.2vw 0 2.1vw;
  346. background-color: #FFFFFF;
  347. .icon {
  348. width: 6.3vw;
  349. height: 6.3vw;
  350. border-radius: 50%;
  351. background-color: #FEE306;
  352. margin-right: 1.7vw;
  353. }
  354. .info {
  355. flex: 1;
  356. .title {
  357. display: flex;
  358. justify-content: space-between;
  359. font-size: 2.9vw;
  360. line-height: 2.9vw;
  361. }
  362. .number {
  363. display: flex;
  364. justify-content: space-between;
  365. margin-top: 1.5vw;
  366. font-size: 1.7vw;
  367. line-height: 1.7vw;
  368. }
  369. }
  370. }
  371. .header-banner {
  372. width: 100vw;
  373. height: 56.25vw;
  374. .banner-img {
  375. width: 100vw;
  376. height: 56.25vw;
  377. vertical-align: top;
  378. background-repeat: no-repeat;
  379. background-size: cover;
  380. }
  381. }
  382. .center-banner {
  383. // width: 100vw;
  384. height: 35vw;
  385. margin: 2.5vw 2.1vw;
  386. .banner-img {
  387. width: calc(100vw - 4.2vw);
  388. height: 35vw;
  389. border-radius: .8vw;
  390. vertical-align: top;
  391. background-repeat: no-repeat;
  392. background-size: cover;
  393. }
  394. }
  395. .btn-box {
  396. display: flex;
  397. align-items: center;
  398. justify-content: space-between;
  399. padding: 2.5vw 2.5vw;
  400. .btn {
  401. position: relative;
  402. display: flex;
  403. align-items: center;
  404. flex-direction: column;
  405. justify-content: center;
  406. width: 46.25vw;
  407. height: 70.4vw;
  408. .bg {
  409. position: absolute;
  410. top: 0;
  411. width: 46.25vw;
  412. height: 70.4vw;
  413. }
  414. .icon {
  415. position: relative;
  416. width: 19.2vw;
  417. height: 17.3vw;
  418. margin-bottom: 4.2vw;
  419. }
  420. .label {
  421. position: relative;
  422. color: #182B10;
  423. font-size: 6.3vw;
  424. }
  425. }
  426. }
  427. .terms-icon {
  428. width: 100vw;
  429. height: 38.96vw;
  430. vertical-align: top;
  431. }
  432. .status-box {
  433. position: relative;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. flex-direction: column;
  438. width: 77.6vw;
  439. min-height: 51.2vw;
  440. background-color: #FFFFFF;
  441. border-radius: 5vw;
  442. font-size: 4.2vw;
  443. padding: 10vw 0;
  444. .icon {
  445. width: 20vw;
  446. height: 20vw;
  447. margin-bottom: 6.8vw;
  448. }
  449. .clear-btn {
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. width: 31.1vw;
  454. height: 9.2vw;
  455. margin-top: 10.8vw;
  456. color: #FFFFFF;
  457. border-radius: 9.2vw;
  458. font-size: 3.9vw;
  459. background: linear-gradient(to bottom, #FEE704, #FDD001);
  460. }
  461. .label {
  462. padding: 0 10vw;
  463. text-align: center;
  464. }
  465. }
  466. .info-body {
  467. position: relative;
  468. border-radius: 8rpx;
  469. background-color: #FFFFFF;
  470. width: 72.9vw;
  471. .delete-icon-info {
  472. position: absolute;
  473. width: 7vw;
  474. height: 12.5vw;
  475. top: -12.5vw;
  476. right: 0;
  477. }
  478. .top {
  479. border-radius: 8rpx 8rpx 0 0;
  480. padding: 7.3vw 5.2vw 9.4vw;
  481. background: linear-gradient(to bottom, #FEE704, #FDD001);
  482. .cell {
  483. // min-height: 18.8vw;
  484. .label-box {
  485. display: flex;
  486. align-items: center;
  487. font-weight: 500;
  488. color: #B86000;
  489. font-size: 3.8vw;
  490. line-height: 3.8vw;
  491. .icon {
  492. width: 4.2vw;
  493. height: 4.2vw;
  494. margin-right: 1.9vw;
  495. }
  496. }
  497. .address {
  498. color: #B86000;
  499. font-size: 2.9vw;
  500. margin-top: 1.9vw;
  501. margin-left: 6.1vw;
  502. }
  503. }
  504. .line {
  505. margin: 5.8vw 0;
  506. height: 2rpx;
  507. background-color: #FFFFFF;
  508. opacity: .4;
  509. }
  510. }
  511. .bottom {
  512. display: flex;
  513. align-items: center;
  514. flex-direction: column;
  515. justify-content: center;
  516. height: 58.3vw;
  517. .label-box {
  518. text-align: center;
  519. padding: 1.7vw 1.7vw .8vw;
  520. border-radius: 4rpx;
  521. background-color: #F4F4F4;
  522. .label {
  523. font-size: 3.8vw;
  524. line-height: 3.8vw;
  525. margin-bottom: 1vw;
  526. }
  527. .message {
  528. color: #454545;
  529. font-size: 2.5vw;
  530. line-height: 2.5vw;
  531. }
  532. }
  533. .qrcode {
  534. display: flex;
  535. align-items: center;
  536. justify-content: center;
  537. width: 30vw;
  538. height: 30vw;
  539. border: 4rpx solid #999999;
  540. border-radius: 8rpx;
  541. margin-top: 1.5vw;
  542. image {
  543. width: 26.7vw;
  544. height: 26.7vw;
  545. }
  546. }
  547. }
  548. }
  549. .welcome {
  550. margin-top: 1.3vw;
  551. width: 100vw;
  552. text-align: center;
  553. font-size: 3.3vw;
  554. color: #444;
  555. }
  556. .bind-body {
  557. display: flex;
  558. align-items: center;
  559. flex-direction: column;
  560. width: 70vw;
  561. height: 60vw;
  562. background: #FFFFFF;
  563. border-radius: 3vw;
  564. .title {
  565. margin-top: 6.3vw;
  566. text-align: center;
  567. border-radius: 4rpx;
  568. background-color: #F4F4F4;
  569. }
  570. .input-box {
  571. padding: 4.3vw 0;
  572. margin: 4.3vw 4.3vw 0;
  573. border-bottom: 2rpx solid #999999;
  574. input {
  575. font-size: 4.3vw;
  576. }
  577. }
  578. .bind-btn {
  579. display: flex;
  580. align-items: center;
  581. justify-content: center;
  582. width: 50vw;
  583. height: 11.5vw;
  584. margin: 8.1vw 0;
  585. border-radius: 11.5vw;
  586. font-weight: 500;
  587. font-size: 4.3vw;
  588. background: linear-gradient(to right, #FEE704, #FDD001);
  589. }
  590. }
  591. }
  592. </style>