getoutpage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="">
  3. <view class="car-info u-flex">
  4. <view class="car-info-img">
  5. <u-image :src="leaveDetail.vehicleImage||vehicleImage" mode="aspectFit" width="100%" height="100%"></u-image>
  6. </view>
  7. <view class="car-info-text u-flex-1">
  8. <view class="text-item">
  9. <view class="car">{{ leaveDetail.vehicleNo }}</view>
  10. <view class="position">车位:{{leaveDetail.spaceName}}</view>
  11. </view>
  12. <!-- <view class="text-item" style="color: #3192FB;">临时卡</view> -->
  13. <!-- <view class="text-item u-flex u-flex u-row-between">
  14. <view class="">余额:<span class="balance">暂无</span></view>
  15. <view class="recharge" @click="$refs.uToast.show({title: '建设中'})">充值</view>
  16. </view> -->
  17. <view class="text-item">类型:{{leaveDetail.vehicleType|filterCarType}}</view>
  18. </view>
  19. </view>
  20. <view class="parking-info">
  21. <view class="parking-info-item">进场时间:{{leaveDetail.inTime}}</view>
  22. <view class="parking-info-item">出场时间:{{leaveDetail.outTime}}</view>
  23. <view class="parking-info-item">停车时长:{{leaveDetail.duration}}</view>
  24. <view class="parking-info-item">本次应收:<span class="u-type-primary">{{leaveDetail.payAmount}}元</span></view>
  25. <view class="parking-info-item u-flex u-row-between" @click="goOwelist">
  26. <view class="">
  27. 历史欠费:<span class="u-type-warning">{{leaveDetail.oweAmount}}元</span>
  28. </view>
  29. <u-icon name="arrow-right" color="#7B7B7B" size="28"></u-icon>
  30. </view>
  31. </view>
  32. <view class="bottom-btn-wrap">
  33. <view class="bottom-btn-box u-flex">
  34. <view class="bottom-btn bg-blue" @click="handleOut">出场</view>
  35. <view class="bottom-btn bg-gray" @click="onCancel()">取消</view>
  36. </view>
  37. </view>
  38. <!-- 订单细节 -->
  39. <u-popup class="popup orderDetails" v-model="detailModel.show" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  40. <view class="popup-title">温馨提示</view>
  41. <view class="details-body">
  42. <dl><dt>停车时长:</dt> <dd>{{leaveDetail.duration}}</dd></dl>
  43. <dl><dt>车辆类型:</dt> <dd>{{leaveDetail.vehicleType|filterCarType}}</dd></dl>
  44. <dl><dt>本次应收:</dt> <dd class="u-type-primary">{{leaveDetail.payAmount}}元</dd></dl>
  45. <dl><dt>历史欠费:</dt> <dd class="u-type-warning">{{leaveDetail.oweAmount}}元</dd></dl>
  46. <view class="tip">
  47. 你是否将该车辆出场,如果是请缴费,否则点击取消!
  48. </view>
  49. </view>
  50. <view class="details-footer u-flex u-row-between">
  51. <u-button type="primary" :disabled="detailModel.payAllbtn" @click="onPayAll(leaveDetail.oweAmount)">全部缴费</u-button>
  52. <u-button type="warning" :disabled="detailModel.payOnebtn" @click="onPayThis(leaveDetail.payAmount)">本次缴费</u-button>
  53. <view class="details-footer-btn bg-gray" @click="onPayCancel">取消</view>
  54. </view>
  55. </u-popup>
  56. <!-- 支付方式 -->
  57. <u-popup class="popup payway-popup" v-model="showPayway" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  58. <view class="popup-title">支付方式</view>
  59. <view class="popup-body u-flex u-row-between">
  60. <view class="payway-item" @click="cashPay()">
  61. <u-image src="/static/img/payway-xj.png" width="143" height="143"></u-image>
  62. <!-- <view class="icon-wrap">
  63. <u-icon name="rmb-circle-fill" color="#FFC02D" size="66"></u-icon>
  64. </view> -->
  65. 现金支付
  66. </view>
  67. <view class="payway-item" @click="scanPay()">
  68. <u-image src="/static/img/payway-scan.png" width="143" height="143"></u-image>
  69. <!-- <view class="icon-wrap">
  70. <u-icon name="scan" color="#FFC02D" size="66"></u-icon>
  71. </view> -->
  72. 扫码收费
  73. </view>
  74. <view class="payway-item" @click="qrPay">
  75. <u-image src="/static/img/payway-qr.png" width="143" height="143"></u-image>
  76. <!-- <view class="icon-wrap">
  77. <u-icon name="rmb-circle-fill" color="#FFC02D" size="66"></u-icon>
  78. </view> -->
  79. 收款码
  80. </view>
  81. </view>
  82. <view class="popup-footer payway-popup-footer">
  83. <view class="payway-popup-btn" @click="closePayway">关闭</view>
  84. </view>
  85. </u-popup>
  86. <u-popup class="popup qrcode-popup" v-model="showQrcode" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  87. <tki-qrcode
  88. ref="qrcode"
  89. cid="tki-qrcode-canvas"
  90. :val="qrcontent"
  91. :size="200"
  92. unit="px"
  93. background="#000000"
  94. foreground="#ffffff"
  95. pdground="#ffffff"
  96. :iconSize="40"
  97. :onval="true"
  98. :loadMake="false"
  99. :usingComponents="true"
  100. :showLoading="false"
  101. loadingText="loadingText"
  102. />
  103. <view class="qrcode-popup-btn" @click="hideQrcode">关闭</view>
  104. </u-popup>
  105. <u-popup class="popup cashPay-popup" v-model="showCash" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  106. <view class="popup-title">本次收到缴费</view>
  107. <view class="popup-body u-flex">
  108. <view class="u-flex-1 ">您确认已收取现金<span style="color: red;">{{paymoney}}</span>元吗?</view>
  109. <!-- <view class="u-flex-1 change">找零{{changeMoney}}元</view> -->
  110. </view>
  111. <view class="popup-footer u-flex">
  112. <view class="popup-btn1" ><u-button type="primary" @click="consfimPayway">确认</u-button> </view>
  113. <view class="popup-btn2" ><u-button type="primary" :plain="true"@click="closecashPayway">关闭</u-button> </view>
  114. </view>
  115. </u-popup>
  116. <u-toast ref="uToast" />
  117. </view>
  118. </template>
  119. <script>
  120. //#ifdef APP-PLUS
  121. let speak = uni.requireNativePlugin("SpeechPlug");
  122. let device = uni.requireNativePlugin("DeviceInfo");
  123. let ALog = uni.requireNativePlugin("AndroidLog")
  124. //#endif
  125. import tkiQrcode from "tki-qrcode";
  126. export default {
  127. components:{
  128. tkiQrcode
  129. },
  130. data() {
  131. return {
  132. paymoney:'',
  133. change:'',
  134. price:'',
  135. // cashMoney:'',
  136. showCash:false,
  137. speakParkOut:'',
  138. vehicleImage:'/static/img/default-car.png',
  139. showOrderDetails:false,//是否线上订单细节
  140. leaveDetail:[],
  141. orderID:'',
  142. orderInTime:'',
  143. orderOutTime:'',
  144. orderSpaceName:'',
  145. orderVehicleNo:'',
  146. totalAmount:'',
  147. oweAmount:'',
  148. duration:'',
  149. vehicleType:0,
  150. payStatus:null,
  151. showPayway:false,
  152. payParams:{
  153. orderList:[],
  154. code:'',
  155. cashMoney:'',
  156. },
  157. showQrcode:false,
  158. qrcontent:'',
  159. timer: null, // 定时器
  160. detailModel:{
  161. show: false,
  162. payAllbtn: false,
  163. payOnebtn: false
  164. }
  165. }
  166. },
  167. onLoad(page) {
  168. this.orderID = page.orderID;
  169. this.orderInTime = page.orderInTime;
  170. this.orderOutTime = page.orderOutTime;
  171. this.orderSpaceName = page.orderSpaceName;
  172. this.orderVehicleNo = page.orderVehicleNo;
  173. // #ifdef APP-PLUS
  174. // this.speaks(this.orderVehicleNo);
  175. // #endif
  176. uni.getStorage({
  177. key:'speakData',
  178. success: (res) => {
  179. this.speakParkOut = res.data.switchVal4;
  180. },
  181. fail: (err) => {
  182. }
  183. })
  184. },
  185. onShow() {
  186. this.handleEntranceOutDetail();
  187. },
  188. computed:{
  189. changeMoney(){
  190. if(this.payParams.cashMoney>this.price){
  191. return this.payParams.cashMoney-this.price
  192. }else{
  193. return 0
  194. }
  195. }
  196. },
  197. methods:{
  198. closecashPayway(){
  199. this.showCash = false;
  200. },
  201. cashPay(){
  202. this.showCash = true;
  203. },
  204. consfimPayway(){
  205. if(this.payParams.cashMoney<this.price){
  206. this.$refs.uToast.show({
  207. title: '缴费金额小于需支付金额,不能支付',
  208. type: 'error',
  209. });
  210. }else{
  211. this.$u.api.cashPay(this.payParams)
  212. .then(res=>{
  213. uni.showLoading({
  214. title: '查询支付状态中'
  215. });
  216. this.timer = setInterval(() => {
  217. this.handlePayQuery(res.data.polyOrderId)
  218. }, 3000);
  219. }).catch(err=>{
  220. this.$refs.uToast.show({
  221. title: err.msg,
  222. type: 'error',
  223. });
  224. });
  225. }
  226. },
  227. onCancel(){
  228. // this.$u.route({
  229. // type: 'redirectTo',
  230. // url: 'pages/getout/getout'
  231. // })
  232. uni.navigateBack({
  233. delta: 1
  234. });
  235. },
  236. onPayCancel(){
  237. // this.$u.route({
  238. // type: 'redirectTo',
  239. // url: '/pages/getout/getout'
  240. // })
  241. uni.navigateBack({
  242. delta: 1
  243. });
  244. },
  245. speaks(msg){
  246. speak?.speakAction(msg)
  247. },
  248. handleEntranceOutDetail(){
  249. this.$u.api.entranceOutDetail({spaceId:this.orderID})
  250. .then(res=>{
  251. this.leaveDetail = res.data;
  252. this.price = res.data.payAmount;
  253. }).catch(err=>{
  254. this.$refs.uToast.show({
  255. title: err.msg,
  256. type: 'error',
  257. });
  258. });
  259. },
  260. handleOut(res){
  261. let that = this;
  262. this.$u.api.getOut({spaceId:this.orderID})
  263. .then(res=>{
  264. //1、当前订单金额和历史缴费金额都为0 --无需缴费--跳转
  265. if(that.leaveDetail.oweAmount == 0 && res.data.payAmount == 0){
  266. that.$refs.uToast.show({
  267. title: '金额为0无需支付',
  268. type: 'success',
  269. url:'pages/getout/getout'
  270. });
  271. }else if (that.leaveDetail.oweAmount == 0 && res.data.payAmount > 0){
  272. that.detailModel.show = true;
  273. that.detailModel.payAllbtn = true;
  274. that.detailModel.payOnebtn = false;
  275. }else if (that.leaveDetail.oweAmount > 0 && res.data.payAmount == 0){
  276. that.detailModel.show = true;
  277. that.detailModel.payOnebtn = true;
  278. that.detailModel.payAllbtn = false;
  279. }else {
  280. that.detailModel.show = true;
  281. that.detailModel.payOnebtn = false;
  282. that.detailModel.payAllbtn = false;
  283. }
  284. //#ifdef APP-PLUS
  285. if(this.speakParkOut==true||this.speakParkOut==''){
  286. that.speaks(res.data.speak);
  287. }
  288. device.print(res.data.print);
  289. //#endif
  290. }).catch(err=>{
  291. this.$refs.uToast.show({
  292. title: err.msg,
  293. type: 'error',
  294. });
  295. console.log('getOut ',err)
  296. });
  297. },
  298. async onPayThis(money){
  299. this.paymoney = money;
  300. this.detailModel.show = false;
  301. this.showPayway = true;
  302. this.payParams.orderList.push(this.leaveDetail.orderId);
  303. // await this.confirmOut();
  304. },
  305. async onPayAll(money){
  306. this.paymoney = money;
  307. this.detailModel.show = false;
  308. this.showPayway = true;
  309. this.payParams.orderList.push(this.leaveDetail.orderId);
  310. this.leaveDetail.oweList.forEach(item=>{
  311. this.payParams.orderList.push(item.orderId);
  312. });
  313. // await this.confirmOut();
  314. },
  315. closePayway(){
  316. this.showPayway = false;
  317. },
  318. scanPay(){
  319. setTimeout(() =>{
  320. uni.scanCode({
  321. onlyFromCamera: true,
  322. scanType:['barCode','qrCode'],
  323. success: (res) => {
  324. console.log(res)
  325. this.payParams.code = res.result;
  326. this.$u.api.gzbankSwept(this.payParams)
  327. .then(res=>{
  328. // 启动定时器查询订单状态
  329. uni.showLoading({
  330. title: '查询支付状态中'
  331. });
  332. this.timer = setInterval(() => {
  333. this.handlePayQuery(res.data.polyOrderId)
  334. }, 3000);
  335. }).catch(err=>{
  336. //#ifdef APP-PLUS
  337. plus.nativeUI.toast(err.msg);
  338. //#endif
  339. });
  340. },
  341. fail:function(err){
  342. //#ifdef APP-PLUS
  343. plus.nativeUI.toast('扫码失败');
  344. ALog.info({msg:'条码类型:err' + err});
  345. //#endif
  346. }
  347. });
  348. },2000)
  349. },
  350. qrPay(){
  351. console.log('this.payParams',this.payParams);
  352. this.$u.api.gzbankPolypay(this.payParams)
  353. .then(res=>{
  354. // this.$refs.uToast.show({
  355. // title: res.msg,
  356. // type: 'success',
  357. // });
  358. this.showPayway = false;
  359. this.showQrcode = true;
  360. setTimeout(()=>{
  361. this.qrcontent = res.data.qrCodeUrl;
  362. },500)
  363. // 启动定时器查询订单状态
  364. uni.showLoading({
  365. title: '等待支付中'
  366. });
  367. this.timer = setInterval(() => {
  368. this.handlePayQuery(res.data.polyOrderId)
  369. }, 3000);
  370. console.log('gzbankPolypay',res)
  371. }).catch(err=>{
  372. this.$refs.uToast.show({
  373. title: err.msg,
  374. type: 'error',
  375. });
  376. console.log('gzbankPolypay ',err)
  377. });
  378. },
  379. hideQrcode(){
  380. this.showQrcode = false;
  381. this.$u.route({
  382. url: 'pages/getout/getout',
  383. });
  384. },
  385. confirmOut(){
  386. this.$u.api.getOut({spaceId:this.orderID})
  387. .then(res=>{
  388. //#ifdef APP-PLUS
  389. if(this.speakParkOut==true||this.speakParkOut==''){
  390. this.speaks(res.data.speak);
  391. }
  392. device.print(res.data.print);
  393. //#endif
  394. console.log('getOut',res)
  395. }).catch(err=>{
  396. this.$refs.uToast.show({
  397. title: err.msg,
  398. type: 'error',
  399. });
  400. console.log('getOut ',err)
  401. });
  402. },
  403. handlePayQuery(polyOrderId){
  404. this.$u.api.payQuery({polyOrderId:polyOrderId})
  405. .then(res=>{
  406. // this.$refs.uToast.show({
  407. // title: res.msg,
  408. // type: 'success',
  409. // });
  410. // 支付成功后的页面跳转
  411. if (res.data.payStatus==1) {
  412. uni.hideLoading();
  413. clearInterval(this.timer)
  414. uni.showToast({
  415. title: '支付成功',
  416. duration: 3000,
  417. success() {
  418. uni.redirectTo({
  419. url: '/pages/getout/getout'
  420. });
  421. }
  422. });
  423. // this.$refs.uToast.show({
  424. // title:'支付成功',
  425. // type: 'success',
  426. // url:'pages/getout/getout',
  427. // // params: {
  428. // // vehicleNo:this.orderVehicleNo,
  429. // // },
  430. // duration:3000
  431. // });
  432. };
  433. console.log('handlePayQuery',res)
  434. }).catch(err=>{
  435. this.$refs.uToast.show({
  436. title: err.msg,
  437. type: 'error',
  438. });
  439. console.log('handlePayQuery ',err)
  440. });
  441. },
  442. goOwelist(){
  443. this.$u.route({
  444. url: 'pages/owelist/owelist',
  445. params: {
  446. orderID: this.orderID
  447. }
  448. });
  449. },
  450. timeago(inTime,outTime){
  451. var time_start = new Date(inTime.replace(/-/g,'/'));
  452. var time_end = new Date(outTime.replace(/-/g,'/'));
  453. var clock_start = time_start.getTime();
  454. var clock_end = time_end.getTime();
  455. // console.log('currentTime',this.currentTime)
  456. const formatNumber = (num) => {
  457. num = num.toString()
  458. return num[1] ? num : '0' + num
  459. };
  460. var i_total_secs = Math.round(clock_end - clock_start);
  461. //计算出相差天数
  462. var days = Math.floor(i_total_secs / (24 * 3600 * 1000))
  463. //计算出小时数
  464. var leave1 = i_total_secs % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  465. var hours = Math.floor(i_total_secs / (3600 * 1000))
  466. //计算相差分钟数
  467. var leave2 = i_total_secs % (3600 * 1000) //计算小时数后剩余的毫秒数
  468. var minutes = Math.floor(leave2 / (60 * 1000))
  469. //计算相差秒数
  470. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  471. var seconds = Math.round(leave3 / 1000)
  472. hours = formatNumber(hours);
  473. minutes = formatNumber(minutes);
  474. seconds = formatNumber(seconds);
  475. // console.log(days + '天' + hours + '个小时' + minutes + '分钟' + seconds + '秒');
  476. // this.frontDuration = hours + ':' + minutes + ':' + seconds;
  477. return hours + ':' + minutes + ':' + seconds
  478. }
  479. },
  480. computed:{
  481. frontDuration:function(){
  482. return this.timeago(this.orderInTime,this.orderOutTime)
  483. }
  484. }
  485. }
  486. </script>
  487. <style lang="scss">
  488. @import "./getoutpage.scss";
  489. </style>