parkingLock.vue 14 KB

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