parkingLock.vue 13 KB

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