parkingLock.vue 14 KB

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