getoutpage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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">全部缴费</u-button>
  52. <u-button type="warning" :disabled="detailModel.payOnebtn" @click="onPayThis">本次缴费</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">
  108. <u-input v-model="payParams.cashMoney" type="number" :border="true" :clearable="false" placeholder="请输入本次收到的金额(元)" />
  109. </view>
  110. <view class="popup-footer u-flex">
  111. <view class="popup-btn1" ><u-button type="primary" @click="consfimPayway">确认</u-button> </view>
  112. <view class="popup-btn2" ><u-button type="primary" :plain="true"@click="closecashPayway">关闭</u-button> </view>
  113. </view>
  114. </u-popup>
  115. <u-toast ref="uToast" />
  116. </view>
  117. </template>
  118. <script>
  119. //#ifdef APP-PLUS
  120. let speak = uni.requireNativePlugin("SpeechPlug");
  121. let device = uni.requireNativePlugin("DeviceInfo");
  122. let ALog = uni.requireNativePlugin("AndroidLog")
  123. //#endif
  124. import tkiQrcode from "tki-qrcode";
  125. export default {
  126. components:{
  127. tkiQrcode
  128. },
  129. data() {
  130. return {
  131. // cashMoney:'',
  132. showCash:false,
  133. speakParkOut:'',
  134. vehicleImage:'/static/img/default-car.png',
  135. showOrderDetails:false,//是否线上订单细节
  136. leaveDetail:[],
  137. orderID:'',
  138. orderInTime:'',
  139. orderOutTime:'',
  140. orderSpaceName:'',
  141. orderVehicleNo:'',
  142. totalAmount:'',
  143. oweAmount:'',
  144. duration:'',
  145. vehicleType:0,
  146. payStatus:null,
  147. showPayway:false,
  148. payParams:{
  149. orderList:[],
  150. code:'',
  151. cashMoney:'',
  152. },
  153. showQrcode:false,
  154. qrcontent:'',
  155. timer: null, // 定时器
  156. detailModel:{
  157. show: false,
  158. payAllbtn: false,
  159. payOnebtn: false
  160. }
  161. }
  162. },
  163. onLoad(page) {
  164. this.orderID = page.orderID;
  165. this.orderInTime = page.orderInTime;
  166. this.orderOutTime = page.orderOutTime;
  167. this.orderSpaceName = page.orderSpaceName;
  168. this.orderVehicleNo = page.orderVehicleNo;
  169. // #ifdef APP-PLUS
  170. // this.speaks(this.orderVehicleNo);
  171. // #endif
  172. uni.getStorage({
  173. key:'speakData',
  174. success: (res) => {
  175. this.speakParkOut = res.data.switchVal4;
  176. },
  177. fail: (err) => {
  178. }
  179. })
  180. },
  181. onShow() {
  182. this.handleEntranceOutDetail();
  183. },
  184. methods:{
  185. closecashPayway(){
  186. this.showCash = false;
  187. },
  188. cashPay(){
  189. this.showCash = true;
  190. },
  191. consfimPayway(){
  192. if(this.payParams.cashMoney==this.payTipsItem.price){
  193. this.$u.api.cashPay(this.payParams)
  194. .then(res=>{
  195. uni.showLoading({
  196. title: '查询支付状态中'
  197. });
  198. this.timer = setInterval(() => {
  199. this.handlePayQuery(res.data.polyOrderId)
  200. }, 3000);
  201. this.$u.route({
  202. url: 'pages/getout/getout',
  203. });
  204. }).catch(err=>{
  205. this.$refs.uToast.show({
  206. title: err.msg,
  207. type: 'error',
  208. });
  209. });
  210. }else{
  211. this.$refs.uToast.show({
  212. title: '缴费金额小于需支付金额,不能支付',
  213. type: 'error',
  214. });
  215. }
  216. },
  217. onCancel(){
  218. // this.$u.route({
  219. // type: 'redirectTo',
  220. // url: 'pages/getout/getout'
  221. // })
  222. uni.navigateBack({
  223. delta: 1
  224. });
  225. },
  226. onPayCancel(){
  227. // this.$u.route({
  228. // type: 'redirectTo',
  229. // url: '/pages/getout/getout'
  230. // })
  231. uni.navigateBack({
  232. delta: 1
  233. });
  234. },
  235. speaks(msg){
  236. speak?.speakAction(msg)
  237. },
  238. handleEntranceOutDetail(){
  239. this.$u.api.entranceOutDetail({spaceId:this.orderID})
  240. .then(res=>{
  241. this.leaveDetail = res.data;
  242. }).catch(err=>{
  243. this.$refs.uToast.show({
  244. title: err.msg,
  245. type: 'error',
  246. });
  247. });
  248. },
  249. handleOut(res){
  250. let that = this;
  251. this.$u.api.getOut({spaceId:this.orderID})
  252. .then(res=>{
  253. //1、当前订单金额和历史缴费金额都为0 --无需缴费--跳转
  254. if(that.leaveDetail.oweAmount == 0 && res.data.payAmount == 0){
  255. that.$refs.uToast.show({
  256. title: '金额为0无需支付',
  257. type: 'success',
  258. url:'pages/getout/getout'
  259. });
  260. }else if (that.leaveDetail.oweAmount == 0 && res.data.payAmount > 0){
  261. that.detailModel.show = true;
  262. that.detailModel.payAllbtn = true;
  263. that.detailModel.payOnebtn = false;
  264. }else if (that.leaveDetail.oweAmount > 0 && res.data.payAmount == 0){
  265. that.detailModel.show = true;
  266. that.detailModel.payOnebtn = true;
  267. that.detailModel.payAllbtn = false;
  268. }else {
  269. that.detailModel.show = true;
  270. that.detailModel.payOnebtn = false;
  271. that.detailModel.payAllbtn = false;
  272. }
  273. //#ifdef APP-PLUS
  274. if(this.speakParkOut==true||this.speakParkOut==''){
  275. that.speaks(res.data.speak);
  276. }
  277. device.print(res.data.print);
  278. //#endif
  279. }).catch(err=>{
  280. this.$refs.uToast.show({
  281. title: err.msg,
  282. type: 'error',
  283. });
  284. console.log('getOut ',err)
  285. });
  286. },
  287. async onPayThis(){
  288. this.detailModel.show = false;
  289. this.showPayway = true;
  290. this.payParams.orderList.push(this.leaveDetail.orderId);
  291. // await this.confirmOut();
  292. },
  293. async onPayAll(){
  294. this.detailModel.show = false;
  295. this.showPayway = true;
  296. this.payParams.orderList.push(this.leaveDetail.orderId);
  297. this.leaveDetail.oweList.forEach(item=>{
  298. this.payParams.orderList.push(item.orderId);
  299. });
  300. // await this.confirmOut();
  301. },
  302. closePayway(){
  303. this.showPayway = false;
  304. },
  305. scanPay(){
  306. setTimeout(() =>{
  307. uni.scanCode({
  308. onlyFromCamera: true,
  309. scanType:['barCode','qrCode'],
  310. success: (res) => {
  311. console.log(res)
  312. this.payParams.code = res.result;
  313. this.$u.api.gzbankSwept(this.payParams)
  314. .then(res=>{
  315. // 启动定时器查询订单状态
  316. uni.showLoading({
  317. title: '查询支付状态中'
  318. });
  319. this.timer = setInterval(() => {
  320. this.handlePayQuery(res.data.polyOrderId)
  321. }, 3000);
  322. }).catch(err=>{
  323. //#ifdef APP-PLUS
  324. plus.nativeUI.toast(err.msg);
  325. //#endif
  326. });
  327. },
  328. fail:function(err){
  329. //#ifdef APP-PLUS
  330. plus.nativeUI.toast('扫码失败');
  331. ALog.info({msg:'条码类型:err' + err});
  332. //#endif
  333. }
  334. });
  335. },2000)
  336. },
  337. qrPay(){
  338. console.log('this.payParams',this.payParams);
  339. this.$u.api.gzbankPolypay(this.payParams)
  340. .then(res=>{
  341. // this.$refs.uToast.show({
  342. // title: res.msg,
  343. // type: 'success',
  344. // });
  345. this.showPayway = false;
  346. this.showQrcode = true;
  347. setTimeout(()=>{
  348. this.qrcontent = res.data.qrCodeUrl;
  349. },500)
  350. // 启动定时器查询订单状态
  351. uni.showLoading({
  352. title: '等待支付中'
  353. });
  354. this.timer = setInterval(() => {
  355. this.handlePayQuery(res.data.polyOrderId)
  356. }, 3000);
  357. console.log('gzbankPolypay',res)
  358. }).catch(err=>{
  359. this.$refs.uToast.show({
  360. title: err.msg,
  361. type: 'error',
  362. });
  363. console.log('gzbankPolypay ',err)
  364. });
  365. },
  366. hideQrcode(){
  367. this.showQrcode = false;
  368. this.$u.route({
  369. url: 'pages/getout/getout',
  370. });
  371. },
  372. confirmOut(){
  373. this.$u.api.getOut({spaceId:this.orderID})
  374. .then(res=>{
  375. //#ifdef APP-PLUS
  376. if(this.speakParkOut==true||this.speakParkOut==''){
  377. this.speaks(res.data.speak);
  378. }
  379. device.print(res.data.print);
  380. //#endif
  381. console.log('getOut',res)
  382. }).catch(err=>{
  383. this.$refs.uToast.show({
  384. title: err.msg,
  385. type: 'error',
  386. });
  387. console.log('getOut ',err)
  388. });
  389. },
  390. handlePayQuery(polyOrderId){
  391. this.$u.api.payQuery({polyOrderId:polyOrderId})
  392. .then(res=>{
  393. // this.$refs.uToast.show({
  394. // title: res.msg,
  395. // type: 'success',
  396. // });
  397. // 支付成功后的页面跳转
  398. if (res.data.payStatus==1) {
  399. uni.hideLoading();
  400. clearInterval(this.timer)
  401. this.$refs.uToast.show({
  402. title:'支付成功',
  403. type: 'success',
  404. url:'pages/getout/getout',
  405. // params: {
  406. // vehicleNo:this.orderVehicleNo,
  407. // },
  408. duration:10000
  409. });
  410. };
  411. console.log('handlePayQuery',res)
  412. }).catch(err=>{
  413. this.$refs.uToast.show({
  414. title: err.msg,
  415. type: 'error',
  416. });
  417. console.log('handlePayQuery ',err)
  418. });
  419. },
  420. goOwelist(){
  421. this.$u.route({
  422. url: 'pages/owelist/owelist',
  423. params: {
  424. orderID: this.orderID
  425. }
  426. });
  427. },
  428. timeago(inTime,outTime){
  429. var time_start = new Date(inTime.replace(/-/g,'/'));
  430. var time_end = new Date(outTime.replace(/-/g,'/'));
  431. var clock_start = time_start.getTime();
  432. var clock_end = time_end.getTime();
  433. // console.log('currentTime',this.currentTime)
  434. const formatNumber = (num) => {
  435. num = num.toString()
  436. return num[1] ? num : '0' + num
  437. };
  438. var i_total_secs = Math.round(clock_end - clock_start);
  439. //计算出相差天数
  440. var days = Math.floor(i_total_secs / (24 * 3600 * 1000))
  441. //计算出小时数
  442. var leave1 = i_total_secs % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  443. var hours = Math.floor(i_total_secs / (3600 * 1000))
  444. //计算相差分钟数
  445. var leave2 = i_total_secs % (3600 * 1000) //计算小时数后剩余的毫秒数
  446. var minutes = Math.floor(leave2 / (60 * 1000))
  447. //计算相差秒数
  448. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  449. var seconds = Math.round(leave3 / 1000)
  450. hours = formatNumber(hours);
  451. minutes = formatNumber(minutes);
  452. seconds = formatNumber(seconds);
  453. // console.log(days + '天' + hours + '个小时' + minutes + '分钟' + seconds + '秒');
  454. // this.frontDuration = hours + ':' + minutes + ':' + seconds;
  455. return hours + ':' + minutes + ':' + seconds
  456. }
  457. },
  458. computed:{
  459. frontDuration:function(){
  460. return this.timeago(this.orderInTime,this.orderOutTime)
  461. }
  462. }
  463. }
  464. </script>
  465. <style lang="scss">
  466. @import "./getoutpage.scss";
  467. </style>