getoutpage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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="openPage('pages/getout/getout')">取消</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.totalAmount}}元</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. <!-- <view class="details-footer-btn details-footer-btn--blue" @click="payAll">全部缴费</view>
  52. <view class="details-footer-btn details-footer-btn--yellow" @click="payThis">本次缴费</view>
  53. -->
  54. <u-button type="primary" :disabled="detailModel.payAllbtn" @click="payAll">全部缴费</u-button>
  55. <u-button type="warning" :disabled="detailModel.payOnebtn" @click="payThis">本次缴费</u-button>
  56. <view class="details-footer-btn bg-gray" @click="openPage('pages/getout/getout')">取消</view>
  57. </view>
  58. </u-popup>
  59. <!-- 支付方式 -->
  60. <u-popup class="popup payway-popup" v-model="showPayway" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  61. <view class="popup-title">支付方式</view>
  62. <view class="popup-body u-flex u-row-between">
  63. <view class="payway-item" @click="$refs.uToast.show({title: '暂不支持'})">
  64. <u-image src="/static/img/payway-xj.png" width="143" height="143"></u-image>
  65. <!-- <view class="icon-wrap">
  66. <u-icon name="rmb-circle-fill" color="#FFC02D" size="66"></u-icon>
  67. </view> -->
  68. 现金支付
  69. </view>
  70. <view class="payway-item" @click="scanPay">
  71. <u-image src="/static/img/payway-scan.png" width="143" height="143"></u-image>
  72. <!-- <view class="icon-wrap">
  73. <u-icon name="scan" color="#FFC02D" size="66"></u-icon>
  74. </view> -->
  75. 扫码收费
  76. </view>
  77. <view class="payway-item" @click="qrPay">
  78. <u-image src="/static/img/payway-qr.png" width="143" height="143"></u-image>
  79. <!-- <view class="icon-wrap">
  80. <u-icon name="rmb-circle-fill" color="#FFC02D" size="66"></u-icon>
  81. </view> -->
  82. 收款码
  83. </view>
  84. </view>
  85. <view class="popup-footer payway-popup-footer">
  86. <view class="payway-popup-btn" @click="closePayway">关闭</view>
  87. </view>
  88. </u-popup>
  89. <u-popup class="popup qrcode-popup" v-model="showQrcode" :mask-close-able="false" mode="center" border-radius="20" width="90%">
  90. <tki-qrcode
  91. ref="qrcode"
  92. cid="tki-qrcode-canvas"
  93. :val="qrcontent"
  94. :size="200"
  95. unit="px"
  96. background="#000000"
  97. foreground="#ffffff"
  98. pdground="#ffffff"
  99. :iconSize="40"
  100. :onval="true"
  101. :loadMake="false"
  102. :usingComponents="true"
  103. :showLoading="false"
  104. loadingText="loadingText"
  105. />
  106. <view class="qrcode-popup-btn" @click="hideQrcode">关闭</view>
  107. </u-popup>
  108. <u-toast ref="uToast" />
  109. </view>
  110. </template>
  111. <script>
  112. //#ifdef APP-PLUS
  113. let speak = uni.requireNativePlugin("SpeechPlug");
  114. let device = uni.requireNativePlugin("DeviceInfo");
  115. let ALog = uni.requireNativePlugin("AndroidLog")
  116. //#endif
  117. import tkiQrcode from "tki-qrcode";
  118. export default {
  119. components:{
  120. tkiQrcode
  121. },
  122. data() {
  123. return {
  124. vehicleImage:'/static/img/default-car.png',
  125. showOrderDetails:false,//是否线上订单细节
  126. leaveDetail:[],
  127. orderID:'',
  128. orderInTime:'',
  129. orderOutTime:'',
  130. orderSpaceName:'',
  131. orderVehicleNo:'',
  132. totalAmount:'',
  133. oweAmount:'',
  134. duration:'',
  135. vehicleType:0,
  136. payStatus:null,
  137. showPayway:false,
  138. payParams:{
  139. orderList:[],
  140. code:''
  141. },
  142. showQrcode:false,
  143. qrcontent:'',
  144. timer: null, // 定时器
  145. detailModel:{
  146. show: false,
  147. payAllbtn: true,
  148. payOnebtn: true
  149. }
  150. }
  151. },
  152. onLoad(page) {
  153. this.orderID = page.orderID;
  154. this.orderInTime = page.orderInTime;
  155. this.orderOutTime = page.orderOutTime;
  156. this.orderSpaceName = page.orderSpaceName;
  157. this.orderVehicleNo = page.orderVehicleNo;
  158. // #ifdef APP-PLUS
  159. this.speaks(this.orderVehicleNo);
  160. // #endif
  161. },
  162. onShow() {
  163. this.handleEntranceOutDetail();
  164. },
  165. methods:{
  166. openPage(path) {
  167. console.log('path',path);
  168. this.$u.route({
  169. url: path
  170. })
  171. },
  172. speaks(msg){
  173. speak?.speakAction(msg)
  174. },
  175. handleEntranceOutDetail(){
  176. this.$u.api.entranceOutDetail({spaceId:this.orderID})
  177. .then(res=>{
  178. this.leaveDetail = res.data;
  179. }).catch(err=>{
  180. this.$refs.uToast.show({
  181. title: err.msg,
  182. type: 'error',
  183. });
  184. });
  185. },
  186. handleOut(res){
  187. let that = this;
  188. // this.showOrderDetails = true;
  189. this.$u.api.getOut({spaceId:this.orderID})
  190. .then(res=>{
  191. //1、当前订单金额和历史缴费金额都为0 --无需缴费--跳转
  192. // ALog.info({msg: that.leaveDetail.oweAmount});
  193. // ALog.info({msg: res.data.payAmount});
  194. debugger
  195. if(that.leaveDetail.oweAmount == 0 && res.data.payAmount == 0){
  196. that.$refs.uToast.show({
  197. title: '金额为0无需支付',
  198. type: 'success',
  199. url:'pages/getout/getout'
  200. });
  201. }else if (that.leaveDetail.oweAmount == 0 && res.data.payAmount > 0){
  202. that.detailModel.show = true;
  203. that.detailModel.payAllbtn = false;
  204. that.detailModel.payOnebtn = true;
  205. }else if (that.leaveDetail.oweAmount > 0 && res.data.payAmount == 0){
  206. that.detailModel.show = true;
  207. that.detailModel.payOnebtn = false;
  208. that.detailModel.payAllbtn = true;
  209. }else {
  210. that.detailModel.show = true;
  211. that.detailModel.payOnebtn = true;
  212. that.detailModel.payAllbtn = true;
  213. }
  214. //#ifdef APP-PLUS
  215. that.speaks(res.data.speak);
  216. device.print(res.data.print);
  217. //#endif
  218. console.log('getOut',res)
  219. }).catch(err=>{
  220. this.$refs.uToast.show({
  221. title: err.msg,
  222. type: 'error',
  223. });
  224. console.log('getOut ',err)
  225. });
  226. },
  227. async payThis(){
  228. // this.showOrderDetails = false;
  229. this.detailModel.show = false;
  230. this.showPayway = true;
  231. this.payParams.orderList.push(this.leaveDetail.orderId);
  232. // await this.confirmOut();
  233. },
  234. async payAll(){
  235. // this.showOrderDetails = false;
  236. this.detailModel.show = false;
  237. this.showPayway = true;
  238. this.payParams.orderList.push(this.leaveDetail.orderId);
  239. this.leaveDetail.oweList.forEach(item=>{
  240. this.payParams.orderList.push(item.orderId);
  241. });
  242. // await this.confirmOut();
  243. },
  244. closePayway(){
  245. this.showPayway = false;
  246. },
  247. scanPay(){
  248. console.log('this.payParams',this.payParams);
  249. uni.scanCode({
  250. onlyFromCamera: true,
  251. success: (res) => {
  252. //#ifdef APP-PLUS
  253. ALog.info({msg:'条码内容:' + res.result});
  254. //#endif
  255. this.payParams.code = res.result;
  256. this.$u.api.gzbankSwept(this.payParams)
  257. .then(res=>{
  258. //#ifdef APP-PLUS
  259. // plus.nativeUI.toast(res.msg);
  260. //#endif
  261. // 启动定时器查询订单状态
  262. uni.showLoading({
  263. title: '查询支付状态中'
  264. });
  265. this.timer = setInterval(() => {
  266. this.handlePayQuery(res.data.polyOrderId)
  267. }, 3000);
  268. }).catch(err=>{
  269. //#ifdef APP-PLUS
  270. plus.nativeUI.toast(err.msg);
  271. //#endif
  272. });
  273. // console.log('条码类型:' + res.scanType);
  274. // console.log('条码内容:' + res.result);
  275. },
  276. fail:function(err){
  277. //#ifdef APP-PLUS
  278. plus.nativeUI.toast('扫码失败');
  279. ALog.info({msg:'条码类型:err' + err});
  280. //#endif
  281. }
  282. });
  283. },
  284. qrPay(){
  285. console.log('this.payParams',this.payParams);
  286. this.$u.api.gzbankPolypay(this.payParams)
  287. .then(res=>{
  288. // this.$refs.uToast.show({
  289. // title: res.msg,
  290. // type: 'success',
  291. // });
  292. this.showPayway = false;
  293. this.showQrcode = true;
  294. setTimeout(()=>{
  295. this.qrcontent = res.data.qrCodeUrl;
  296. },500)
  297. // 启动定时器查询订单状态
  298. uni.showLoading({
  299. title: '等待支付中'
  300. });
  301. this.timer = setInterval(() => {
  302. this.handlePayQuery(res.data.polyOrderId)
  303. }, 3000);
  304. console.log('gzbankPolypay',res)
  305. }).catch(err=>{
  306. this.$refs.uToast.show({
  307. title: err.msg,
  308. type: 'error',
  309. });
  310. console.log('gzbankPolypay ',err)
  311. });
  312. },
  313. hideQrcode(){
  314. this.showQrcode = false;
  315. this.$u.route({
  316. url: 'pages/getout/getout',
  317. });
  318. },
  319. confirmOut(){
  320. this.$u.api.getOut({spaceId:this.orderID})
  321. .then(res=>{
  322. //#ifdef APP-PLUS
  323. this.speaks(res.data.speak);
  324. device.print(res.data.print);
  325. //#endif
  326. console.log('getOut',res)
  327. }).catch(err=>{
  328. this.$refs.uToast.show({
  329. title: err.msg,
  330. type: 'error',
  331. });
  332. console.log('getOut ',err)
  333. });
  334. },
  335. handlePayQuery(polyOrderId){
  336. this.$u.api.payQuery({polyOrderId:polyOrderId})
  337. .then(res=>{
  338. // this.$refs.uToast.show({
  339. // title: res.msg,
  340. // type: 'success',
  341. // });
  342. // 支付成功后的页面跳转
  343. if (res.data.payStatus==1) {
  344. uni.hideLoading();
  345. clearInterval(this.timer)
  346. this.$refs.uToast.show({
  347. title:'支付成功',
  348. type: 'success',
  349. url:'pages/getout/getout',
  350. // params: {
  351. // vehicleNo:this.orderVehicleNo,
  352. // },
  353. duration:10000
  354. });
  355. };
  356. console.log('handlePayQuery',res)
  357. }).catch(err=>{
  358. this.$refs.uToast.show({
  359. title: err.msg,
  360. type: 'error',
  361. });
  362. console.log('handlePayQuery ',err)
  363. });
  364. },
  365. goOwelist(){
  366. this.$u.route({
  367. url: 'pages/owelist/owelist',
  368. params: {
  369. orderID: this.orderID
  370. }
  371. });
  372. },
  373. timeago(inTime,outTime){
  374. var time_start = new Date(inTime.replace(/-/g,'/'));
  375. var time_end = new Date(outTime.replace(/-/g,'/'));
  376. var clock_start = time_start.getTime();
  377. var clock_end = time_end.getTime();
  378. // console.log('currentTime',this.currentTime)
  379. const formatNumber = (num) => {
  380. num = num.toString()
  381. return num[1] ? num : '0' + num
  382. };
  383. var i_total_secs = Math.round(clock_end - clock_start);
  384. //计算出相差天数
  385. var days = Math.floor(i_total_secs / (24 * 3600 * 1000))
  386. //计算出小时数
  387. var leave1 = i_total_secs % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  388. var hours = Math.floor(i_total_secs / (3600 * 1000))
  389. //计算相差分钟数
  390. var leave2 = i_total_secs % (3600 * 1000) //计算小时数后剩余的毫秒数
  391. var minutes = Math.floor(leave2 / (60 * 1000))
  392. //计算相差秒数
  393. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  394. var seconds = Math.round(leave3 / 1000)
  395. hours = formatNumber(hours);
  396. minutes = formatNumber(minutes);
  397. seconds = formatNumber(seconds);
  398. // console.log(days + '天' + hours + '个小时' + minutes + '分钟' + seconds + '秒');
  399. // this.frontDuration = hours + ':' + minutes + ':' + seconds;
  400. return hours + ':' + minutes + ':' + seconds
  401. }
  402. },
  403. computed:{
  404. frontDuration:function(){
  405. return this.timeago(this.orderInTime,this.orderOutTime)
  406. }
  407. }
  408. }
  409. </script>
  410. <style lang="scss">
  411. @import "./getoutpage.scss";
  412. </style>