parkingLock.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <view class="parking-lock">
  3. <view class="Jump">
  4. <view class="Jump-btn" @click="jumpArrears">
  5. 欠费补缴
  6. </view>
  7. </view>
  8. <!-- 车位锁 -->
  9. <view class="parking-lock-box">
  10. <!-- 车位锁支付 -->
  11. <template v-if="parkingLockStatus === 1">
  12. <view class="parking-lock-pay">
  13. <view class="parking-lock-title">支付停车费</view>
  14. <view class="parking-lock-tips">请您确认停车费用,确认后请支付费用,结束停车。谢谢您的使用!</view>
  15. <view class="parking-lock-info">
  16. <view class="parking-lock-info-item">
  17. <view>停车场名称</view>
  18. <view>{{orderInfo.roadName}}</view>
  19. </view>
  20. <view class="parking-lock-info-item">
  21. <view>停车泊位</view>
  22. <view>{{orderInfo.spaceName}}</view>
  23. </view>
  24. <!-- <view class="parking-lock-info-item">
  25. <view>入场时间</view>
  26. <view>{{orderInfo.inTime}}</view>
  27. </view>
  28. <view class="parking-lock-info-item">
  29. <view>出场时间</view>
  30. <view>{{orderInfo.outTime}}</view>
  31. </view>
  32. <view class="parking-lock-info-item">
  33. <view>停车时长</view>
  34. <view>{{ orderInfo.duration || 0}}</view>
  35. </view>
  36. <view class="parking-lock-info-item">
  37. <view>免费时长</view>
  38. <view>{{ orderInfo.freeDuration || 0 }}</view>
  39. </view> -->
  40. <view class="parking-lock-info-item">
  41. <view>开始计费</view>
  42. <view>{{orderInfo.inTime}}</view>
  43. </view>
  44. <view class="parking-lock-info-item">
  45. <view>结束计费</view>
  46. <view>{{orderInfo.outTime}}</view>
  47. </view>
  48. <view class="parking-lock-info-item">
  49. <view>免费时长</view>
  50. <view>{{ orderInfo.freeDuration || '0天0时30分0秒' }}</view>
  51. <!-- <view>{{ '0天0时30分0秒' }}</view> -->
  52. </view>
  53. <view class="parking-lock-info-item">
  54. <view>计费时长</view>
  55. <view>{{orderInfo.calcDuration || 0}}</view>
  56. </view>
  57. <view class="parking-lock-info-item">
  58. <view>累计停车时长</view>
  59. <view>{{ orderInfo.duration || 0 }}</view>
  60. </view>
  61. <!-- <view class="parking-lock-info-item">
  62. <view>合计金额</view>
  63. <view>{{orderInfo.totalAmount}} 元</view>
  64. </view>
  65. <view class="parking-lock-info-item">
  66. <view>优惠金额</view>
  67. <view>{{orderInfo.preferentialAmount}} 元</view>
  68. </view> -->
  69. <view class="parking-lock-info-item">
  70. <view>应缴金额</view>
  71. <view class="really-money">{{orderInfo.payAmount || 0}} 元</view>
  72. </view>
  73. <view class="parking-lock-info-item">
  74. <view>订单编号</view>
  75. <view>{{orderInfo.orderId}}</view>
  76. </view>
  77. <!-- <view class="parking-lock-info-item" v-if="orderInfo.vehicleNo">
  78. <view>车牌信息</view>
  79. <view class="really-license">{{ orderInfo.vehicleNo }}</view>
  80. </view> -->
  81. <!-- <view class="parking-lock-info-item" v-if="orderInfo.vehicleNo==''">
  82. <view>车牌信息</view>
  83. <view class="really-license"><text class="really-license-txt" @click="addvehicleNo">添加车牌</text>
  84. </view>
  85. </view>
  86. <view class="parking-lock-info-item" v-else>
  87. <view>车牌信息</view>
  88. <view class="really-license">{{orderInfo.vehicleNo}} <text @click="changevehicleNo"
  89. class="really-license-txt1">更换</text></view>
  90. </view> -->
  91. </view>
  92. <view class="parking-lock-pay-btn">
  93. <button type="default" @click="payMoney">立即支付</button>
  94. </view>
  95. <!-- <view class="parking-lock-pay-attention">
  96. <text>
  97. 温馨提示:车牌信息可填可不填,如果您已通过本机号码办理了特定车或包月车业务,则需要输入车牌号,否则将按照常规收费标准进行收费。
  98. </text>
  99. </view> -->
  100. <view class="parking-lock-pay-attention">
  101. <text>
  102. 温馨提示:车辆计费前您有15分钟免费停车时长,15分钟过后则升板锁车开始计费。
  103. </text>
  104. </view>
  105. </view>
  106. </template>
  107. <!-- 车位锁开始状态 -->
  108. <template v-else-if="parkingLockStatus === 2">
  109. <view class="parking-lock-begin">
  110. <view class="parking-lock-begin-box">
  111. <view class="parking-lock-begin-bg">
  112. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  113. </view>
  114. </view>
  115. <view class="parking-lock-begin-info">车位锁正在动作,还未到位</view>
  116. </view>
  117. </template>
  118. <!-- 车位锁正在状态 -->
  119. <template v-else-if="parkingLockStatus === 3">
  120. <view class="parking-lock-loading">
  121. <view class="parking-lock-loading-box">
  122. <view class="parking-lock-loading-bg">
  123. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  124. </view>
  125. </view>
  126. <view class="parking-lock-loading-info">开锁中,请等待!</view>
  127. </view>
  128. </template>
  129. <!-- 开锁完成 -->
  130. <template v-else-if="parkingLockStatus === 4">
  131. <view class="parking-lock-success">
  132. <view class="parking-lock-success-box">
  133. <image src="../../static/img/parking-lock-achieve.png" mode=""></image>
  134. </view>
  135. <view class="parking-lock-success-info">开锁已完成</view>
  136. <view class="parking-lock-success-button">
  137. <button @click="cancel">返回</button>
  138. </view>
  139. </view>
  140. </template>
  141. <template v-else-if="parkingLockStatus === 5">
  142. <view class="parking-lock-pay">
  143. <view class="parking-lock-tips">{{tipsMsg}}</view>
  144. </view>
  145. </template>
  146. <!-- 支付方式 -->
  147. <PaymentMethod :payWayPop="payWayPop" :curOrderList="orderList" :deviceNo="deviceNo" :jumpUrl="jumpUrl"
  148. @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  149. <u-toast ref="uToast" />
  150. <u-popup v-model="show" mode="center" border-radius="14" width="200rpx" height="200rpx">
  151. <view class="loadingSelect">订单查询中...</view>
  152. <view class="spinner">
  153. <view class="rect1"></view>
  154. <view class="rect2"></view>
  155. <view class="rect3"></view>
  156. <view class="rect4"></view>
  157. <view class="rect5"></view>
  158. </view>
  159. </u-popup>
  160. <u-popup class="popup-vehicleNo" v-model="ShowaddvehicleNo" mode="center" border-radius="20" width="710rpx"
  161. height="auto">
  162. <view class="popup-vehicleNo-title">添加车牌</view>
  163. <view class="popup-vehicleNo-center"></view>
  164. <view class="popup-vehicleNo-content">
  165. <view class="new-plate-number">
  166. <view class="message-input-wrap" @click="messageInputClick">
  167. <u-message-input :maxlength="8" width="70" font-size="50" :disabled-keyboard="true"
  168. v-model="newPlateNumber"></u-message-input>
  169. </view>
  170. </view>
  171. </view>
  172. <view class="popup-vehicleNo-select">暂无绑定车牌</view>
  173. <view class="vehicleNo-btn">
  174. <u-button type="primary" @click="handleAddCar">确认</u-button>
  175. <u-button type="primary" plain @click="ShowaddvehicleNo=false">取消</u-button>
  176. </view>
  177. </u-popup>
  178. <u-popup class="popup-vehicleNo" v-model="ShowchangevehicleNo" mode="center" border-radius="20"
  179. width="710rpx" height="auto">
  180. <view class="popup-vehicleNo-title">更换车牌</view>
  181. <view class="popup-vehicleNo-center"></view>
  182. <view class="popup-vehicleNo-content">
  183. <view class="new-plate-number">
  184. <view class="message-input-wrap" @click="messageInputClick">
  185. <u-message-input :maxlength="8" width="70" font-size="50" :disabled-keyboard="true"
  186. v-model="newPlateNumber"></u-message-input>
  187. </view>
  188. </view>
  189. </view>
  190. <view class="popup-vehicleNo-select">
  191. <u-collapse ref="refValue">
  192. <u-collapse-item title="点击选择车牌" align="center">
  193. <u-cell-group>
  194. <u-cell-item :title="item.vehicleNo" v-for="(item, index) in groupList" :key="index"
  195. :arrow="false">
  196. <u-radio-group v-model="selectvalue" @change="radioGroupChange">
  197. <u-radio :name="item.vehicleNo" :key="index"></u-radio>
  198. </u-radio-group>
  199. </u-cell-item>
  200. </u-cell-group>
  201. </u-collapse-item>
  202. </u-collapse>
  203. </view>
  204. <view class="vehicleNo-btn">
  205. <u-button type="primary" @click="handleAddCar">确认</u-button>
  206. <u-button type="primary" plain @click="ShowchangevehicleNo=false">取消</u-button>
  207. </view>
  208. </u-popup>
  209. <u-action-sheet :list="colorList" @click="confirmColor" v-model="colorShow"></u-action-sheet>
  210. <u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @confirm="keyboardConfirm"
  211. @backspace="backspace" v-model="keyboardshow"></u-keyboard>
  212. </view>
  213. </view>
  214. </template>
  215. <script>
  216. import getUrlParams from "../../utils/getUrlParams.js";
  217. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  218. export default {
  219. components: {
  220. PaymentMethod
  221. },
  222. data() {
  223. return {
  224. selectvalue: null,
  225. groupList: [],
  226. radiogroupList: [],
  227. keyboardshow: false,
  228. colorShow: false,
  229. colorList: [{
  230. text: '蓝色',
  231. colorCode: 0
  232. }, {
  233. text: '黄色',
  234. colorCode: 1
  235. }, {
  236. text: '黑色',
  237. colorCode: 2
  238. }, {
  239. text: '白色',
  240. colorCode: 3
  241. }, {
  242. text: '绿色',
  243. colorCode: 4
  244. }, {
  245. text: '其他',
  246. colorCode: 99
  247. }],
  248. vehicleColor: 0,
  249. newPlateNumber: '',
  250. //更换车牌弹窗
  251. ShowchangevehicleNo: false,
  252. //添加车牌弹窗
  253. ShowaddvehicleNo: false,
  254. // 车位锁状态 1:支付 2:开始开锁 3:开锁中 4:开锁完成
  255. parkingLockStatus: 0,
  256. // 支付方式选择弹框
  257. payWayPop: false,
  258. // 订单编号
  259. orderList: [],
  260. // 提示信息
  261. tipsMsg: null,
  262. // 设备编号
  263. deviceNo: null,
  264. // 轮询
  265. timer: null,
  266. timer1: null,
  267. // 订单信息
  268. orderInfo: {},
  269. // 订单id
  270. orderId: null,
  271. // 重定向地址
  272. jumpUrl: location.href + '&isBack=1',
  273. show: true,
  274. isBack: '',
  275. polyOrderId: ''
  276. }
  277. },
  278. onLoad(page) {
  279. if (page.orderId) {
  280. this.getOrderDetails(page.orderId)
  281. this.orderList = []
  282. this.orderId = page.orderId
  283. this.orderList.push(page.orderId)
  284. this.deviceNo = page.deviceNo
  285. this.isBack = page?.isBack
  286. this.polyOrderId = page?.polyOrderId
  287. } else {
  288. this.tipsMsg = page.msg || '参数丢失!';
  289. this.parkingLockStatus = 5
  290. }
  291. },
  292. onShow() {
  293. if (this.orderId) {
  294. if (this.polyOrderId && this.isBack == 1) {
  295. this.timer1 = setInterval(() => {
  296. this.show = true
  297. this.handlePayStatus(this.polyOrderId)
  298. }, 2000)
  299. }
  300. } else {
  301. this.show = false
  302. }
  303. },
  304. onUnload() {
  305. if (this.timer) {
  306. clearInterval(this.timer)
  307. }
  308. if (this.timer1) {
  309. clearInterval(this.timer1)
  310. }
  311. },
  312. methods: {
  313. radioGroupChange(e) {
  314. this.newPlateNumber = e
  315. },
  316. // 获取车辆列表
  317. handlegetMycars() {
  318. let that = this;
  319. this.$u.api.getMycars()
  320. .then(res => {
  321. if (res.code === 200) {
  322. this.groupList = res.data.rows;
  323. this.radiogroupList = res.data.rows;
  324. this.$nextTick(() => {
  325. // dom元素更新后执行,因此这里能正确打印更改之后的值
  326. console.log(that.$refs.refValue.init()) // 改变了的值
  327. })
  328. } else {
  329. this.$refs.uToast.show({
  330. title: res.msg,
  331. type: 'error'
  332. })
  333. }
  334. })
  335. .catch(err => {
  336. this.$refs.uToast.show({
  337. title: '操作失败!',
  338. type: 'error'
  339. })
  340. });
  341. },
  342. //更换车牌信息
  343. changevehicleNo() {
  344. this.ShowchangevehicleNo = true;
  345. this.handlegetMycars();
  346. },
  347. // 添加车辆
  348. handleAddCar() {
  349. if (!this.$u.test.carNo(this.newPlateNumber)) {
  350. this.$refs.uToast.show({
  351. title: '请正确填写车牌号',
  352. type: 'error',
  353. });
  354. return
  355. }
  356. let param = {
  357. orderId: this.orderId,
  358. vehicleNo: this.newPlateNumber,
  359. vehicleColor: this.vehicleColor,
  360. };
  361. let that = this;
  362. this.$u.api.bindVehicleNo(param)
  363. .then(res => {
  364. if (res.code === 200) {
  365. this.$refs.uToast.show({
  366. title: res.msg,
  367. type: 'success',
  368. });
  369. that.getOrderDetails(that.orderId);
  370. that.ShowchangevehicleNo = false;
  371. } else {
  372. this.$refs.uToast.show({
  373. title: res.msg,
  374. type: 'error',
  375. });
  376. }
  377. })
  378. .catch(err => {
  379. this.$refs.uToast.show({
  380. title: '操作失败!',
  381. type: 'error',
  382. });
  383. });
  384. },
  385. //新增车牌
  386. addvehicleNo() {
  387. this.ShowaddvehicleNo = true;
  388. },
  389. // 点击输入框
  390. messageInputClick() {
  391. this.keyboardshow = true;
  392. },
  393. // 按键被点击(点击退格键不会触发此事件)
  394. keyboardChange(val) {
  395. // 将每次按键的值拼接到value变量中,注意+=写法
  396. this.newPlateNumber += val;
  397. },
  398. // 退格键被点击
  399. backspace() {
  400. // 删除value的最后一个字符
  401. if (this.newPlateNumber.length) this.newPlateNumber = this.newPlateNumber.substr(0, this.newPlateNumber
  402. .length - 1);
  403. },
  404. // 键盘输入完成后确认
  405. keyboardConfirm() {
  406. this.colorShow = true;
  407. },
  408. // 确认颜色
  409. confirmColor(e) {
  410. this.vehicleColor = this.colorList[e].colorCode;
  411. },
  412. /**
  413. * 反复查询支付状态
  414. * @param { String } orderId
  415. */
  416. handlePayStatus(orderId) {
  417. this.$u.api.getOrderInfo({
  418. orderId
  419. }).then(res => {
  420. if (res.code === 200) {
  421. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  422. this.show = false
  423. clearInterval(this.timer1);
  424. this.getOrderDetails(this.orderId)
  425. }
  426. } else {
  427. this.show = false
  428. clearInterval(this.timer1);
  429. this.$refs.uToast.show({
  430. title: res.msg,
  431. type: 'error',
  432. });
  433. }
  434. }).catch(() => {
  435. this.show = false
  436. clearInterval(this.timer1);
  437. })
  438. },
  439. jumpArrears() {
  440. uni.navigateTo({
  441. url: '../center/order/order?swiperIndex=2'
  442. })
  443. },
  444. payMoney() {
  445. this.payWayPop = true
  446. },
  447. // 查询订单信息
  448. getOrderDetails(id) {
  449. this.$u.api.getOrderDetail({
  450. id
  451. }).then(res => {
  452. if (res.code === 200 && res.data.id) {
  453. this.parkingLockStatus = 1
  454. // 获取页面完整url
  455. const local = window.location.href
  456. // 获取url后面的参数
  457. const locationLocaturl = window.location.search;
  458. // 截取url中的isBack
  459. let isBack = getUrlParams(local, "isBack");
  460. // 如果没有isBack,则去请求
  461. if (!isBack) {
  462. // uni.hideLoading();
  463. this.show = false
  464. clearInterval(this.timer1)
  465. }
  466. this.orderInfo = res.data
  467. if (res.data.payStatus === 1) {
  468. this.show = false
  469. clearInterval(this.timer1)
  470. this.checkEqupment()
  471. }
  472. } else {
  473. this.$refs.uToast.show({
  474. title: res.msg || '订单无数据',
  475. type: 'error',
  476. });
  477. this.show = false;
  478. if (this.timer1) {
  479. clearInterval(this.timer1)
  480. }
  481. }
  482. }).catch(() => {
  483. this.show = false;
  484. if (this.timer1) {
  485. clearInterval(this.timer1)
  486. }
  487. })
  488. },
  489. // 检测设备
  490. checkEqupment() {
  491. this.timer = setInterval(() => {
  492. this.getEqumentStatus(this.deviceNo)
  493. }, 1000)
  494. },
  495. // 查询设备状态
  496. getEqumentStatus(orderNo) {
  497. this.$u.api.getEquomentInfo({
  498. orderNo
  499. }).then(res => {
  500. if (res.code === 200) {
  501. if (res.data.deviceStatus == 0) {
  502. this.parkingLockStatus = 4
  503. clearInterval(this.timer)
  504. } else if (res.data.deviceStatus == 1 || res.data.deviceStatus == 5) {
  505. this.parkingLockStatus = 2
  506. } else if (res.data.deviceStatus == 6) {
  507. this.parkingLockStatus = 3
  508. }
  509. } else {
  510. clearInterval(this.timer)
  511. }
  512. }).catch(() => {
  513. clearInterval(this.timer)
  514. })
  515. },
  516. // 返回首页
  517. cancel() {
  518. uni.switchTab({
  519. url: '/pages/index/index'
  520. })
  521. },
  522. closePaymentMethod() {
  523. this.payWayPop = false
  524. }
  525. }
  526. }
  527. </script>
  528. <style lang="scss" scoped>
  529. @import './parkingLock.scss';
  530. .Jump {
  531. display: flex;
  532. justify-content: flex-end;
  533. background-color: #F6F6FF;
  534. &-btn {
  535. color: rgb(0, 140, 255);
  536. padding: 20rpx 30rpx;
  537. }
  538. }
  539. </style>