parkingLock.vue 15 KB

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