geomagnetismLock.vue 13 KB

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