parkingLock.vue 13 KB

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