parkingLock.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. this.show = true
  253. this.getOrderDetails(this.orderId)
  254. }, 2000)
  255. } else {
  256. this.show = false
  257. }
  258. },
  259. onHide() {
  260. if (this.timer) {
  261. clearInterval(this.timer)
  262. }
  263. if (this.timer1) {
  264. clearInterval(this.timer1)
  265. }
  266. },
  267. methods: {
  268. radioGroupChange(e) {
  269. this.newPlateNumber = e
  270. },
  271. // 获取车辆列表
  272. handlegetMycars() {
  273. let that = this;
  274. this.$u.api.getMycars()
  275. .then(res => {
  276. if (res.code === 200) {
  277. this.groupList = res.data.rows;
  278. this.radiogroupList = res.data.rows;
  279. this.$nextTick(() => {
  280. // dom元素更新后执行,因此这里能正确打印更改之后的值
  281. console.log(that.$refs.refValue.init()) // 改变了的值
  282. })
  283. } else {
  284. this.$refs.uToast.show({
  285. title: res.msg,
  286. type: 'error'
  287. })
  288. }
  289. })
  290. .catch(err => {
  291. this.$refs.uToast.show({
  292. title: '操作失败!',
  293. type: 'error'
  294. })
  295. });
  296. },
  297. //更换车牌信息
  298. changevehicleNo() {
  299. this.ShowchangevehicleNo = true;
  300. this.handlegetMycars();
  301. },
  302. // 添加车辆
  303. handleAddCar() {
  304. if (!this.$u.test.carNo(this.newPlateNumber)) {
  305. this.$refs.uToast.show({
  306. title: '请正确填写车牌号',
  307. type: 'error',
  308. });
  309. return
  310. }
  311. let param = {
  312. orderId: this.orderId,
  313. vehicleNo: this.newPlateNumber,
  314. vehicleColor: this.vehicleColor,
  315. };
  316. let that = this;
  317. this.$u.api.bindVehicleNo(param)
  318. .then(res => {
  319. if (res.code === 200) {
  320. this.$refs.uToast.show({
  321. title: res.msg,
  322. type: 'success',
  323. });
  324. that.getOrderDetails(that.orderId);
  325. that.ShowchangevehicleNo = false;
  326. } else {
  327. this.$refs.uToast.show({
  328. title: res.msg,
  329. type: 'error',
  330. });
  331. }
  332. })
  333. .catch(err => {
  334. this.$refs.uToast.show({
  335. title: '操作失败!',
  336. type: 'error',
  337. });
  338. });
  339. },
  340. //新增车牌
  341. addvehicleNo() {
  342. this.ShowaddvehicleNo = true;
  343. },
  344. // 点击输入框
  345. messageInputClick() {
  346. this.keyboardshow = true;
  347. },
  348. // 按键被点击(点击退格键不会触发此事件)
  349. keyboardChange(val) {
  350. // 将每次按键的值拼接到value变量中,注意+=写法
  351. this.newPlateNumber += val;
  352. },
  353. // 退格键被点击
  354. backspace() {
  355. // 删除value的最后一个字符
  356. if (this.newPlateNumber.length) this.newPlateNumber = this.newPlateNumber.substr(0, this.newPlateNumber
  357. .length - 1);
  358. },
  359. // 键盘输入完成后确认
  360. keyboardConfirm() {
  361. this.colorShow = true;
  362. },
  363. // 确认颜色
  364. confirmColor(e) {
  365. this.vehicleColor = this.colorList[e].colorCode;
  366. },
  367. payMoney() {
  368. this.payWayPop = true
  369. },
  370. // 查询订单信息
  371. getOrderDetails(id) {
  372. // uni.showLoading({
  373. // title: '订单查询中'
  374. // });
  375. this.$u.api.getOrderDetail({
  376. id: id
  377. }).then(res => {
  378. console.log(res)
  379. if (res.code === 200) {
  380. // 获取页面完整url
  381. const local = window.location.href
  382. // 获取url后面的参数
  383. const locationLocaturl = window.location.search;
  384. // 截取url中的isBack
  385. let isBack = getUrlParams(local, "isBack");
  386. console.log('isBack', isBack);
  387. console.log('isBack', isBack == null || isBack != '1');
  388. // 如果没有isBack,则去请求
  389. if (!isBack) {
  390. // uni.hideLoading();
  391. this.show = false
  392. clearInterval(this.timer1)
  393. }
  394. this.orderInfo = res.data
  395. if (res.data.payStatus === 1) {
  396. // uni.hideLoading();
  397. this.show = false
  398. clearInterval(this.timer1)
  399. this.checkEqupment()
  400. }
  401. }
  402. }).catch(() => {
  403. this.$refs.uToast.show({
  404. title: '程序错误!订单Id:' + id,
  405. type: 'error',
  406. });
  407. })
  408. },
  409. // 检测设备
  410. checkEqupment() {
  411. this.timer = setInterval(() => {
  412. this.getEqumentStatus(this.deviceNo)
  413. }, 1000)
  414. },
  415. // 查询设备状态
  416. getEqumentStatus(orderNo) {
  417. console.log(orderNo)
  418. this.$u.api.getEquomentInfo({
  419. orderNo: orderNo
  420. })
  421. .then(res => {
  422. if (res.code === 200) {
  423. console.log(res.data)
  424. if (res.data.deviceStatus === 0) {
  425. this.parkingLockStatus = 4
  426. clearInterval(this.timer)
  427. } else if (res.data.deviceStatus === 1 || res.data.deviceStatus === 5) {
  428. this.parkingLockStatus = 2
  429. } else if (res.data.deviceStatus === 6) {
  430. this.parkingLockStatus = 3
  431. }
  432. }
  433. }).catch(() => {
  434. this.$refs.uToast.show({
  435. title: '程序错误!订单编号:' + orderNo,
  436. type: 'error',
  437. });
  438. })
  439. },
  440. // 返回首页
  441. cancel() {
  442. uni.switchTab({
  443. url: '/pages/index/index'
  444. })
  445. },
  446. closePaymentMethod() {
  447. this.payWayPop = false
  448. }
  449. }
  450. }
  451. </script>
  452. <style lang="scss" scoped>
  453. @import './parkingLock.scss';
  454. </style>