checkin.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view>
  3. <view class="top">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <NavigateBar title="支付结果" control="home" bgcolor="#a09cc4"></NavigateBar>
  6. <!-- #endif -->
  7. <!-- #ifdef MP-ALIPAY -->
  8. <NavigateBar title="支付结果" bgcolor="#a09cc4"></NavigateBar>
  9. <!-- #endif -->
  10. </view>
  11. <view v-if="result">
  12. <view class="tip-area">
  13. <u-image :src="successPicPath" width="200rpx" height="200rpx"></u-image>
  14. <u-text text="支付成功,祝您入住愉快!" color="#666666" size="20" bold align="center"></u-text>
  15. </view>
  16. <view class="btn-container">
  17. <u-button :text="buttonText" color="#9e97c3" @click="gotoHome"></u-button>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import moment from 'moment'
  24. import {
  25. mapState,
  26. mapMutations
  27. } from 'vuex'
  28. import NavigateBar from "../../components/navigateBar/navigate-bar.vue";
  29. export default {
  30. components: {
  31. NavigateBar
  32. },
  33. data() {
  34. return {
  35. result: false,
  36. successPicPath: '/static/success.png',
  37. time: 3
  38. }
  39. },
  40. computed: {
  41. ...mapState('m_user', ['userInfo']),
  42. ...mapState('m_business', ['checkinInfo', 'currentHotel', 'order']),
  43. buttonText() {
  44. return '确认(' + this.time + ')'
  45. }
  46. },
  47. methods: {
  48. ...mapMutations('m_business', ['updateCheckinInfo']),
  49. async checkin() {
  50. try {
  51. uni.showLoading({
  52. title: "正在办理入住...",
  53. })
  54. let info = {
  55. hotelId: this.currentHotel.hotelId,
  56. building: this.order.building,
  57. floorId: this.order.floor,
  58. roomId: this.order.room,
  59. startTime: moment(new Date()).format('YYMMDDHHmmss'),
  60. endTime: moment(this.order.endTime).format('YYMMDDHHmmss'),
  61. cardId: '0',
  62. userType: 1,
  63. orderId: this.order.orderId,
  64. isResv: this.order.orderSource !== 'MINI_APP'
  65. }
  66. let checkinResult = new Array(this.checkinInfo.length).fill(false)
  67. for (let i = 0; i < this.checkinInfo.length; i++) {
  68. if (i == 0) {
  69. info.isMainCustomer = true
  70. info.totalCustomerNum = this.checkinInfo.length
  71. } else {
  72. info.isMainCustomer = false
  73. }
  74. info.userName = this.checkinInfo[i].name
  75. info.userId = this.checkinInfo[i].idNumber
  76. info.faceData = this.checkinInfo[i].faceData
  77. info.userPhone = this.checkinInfo[i].phone
  78. info.address = this.checkinInfo[i].address
  79. info.race = this.checkinInfo[i].nation
  80. info.userGender = this.checkinInfo[i].sex === '男' ? 1 : 2
  81. info.birth = this.checkinInfo[i].birth
  82. info.issuingAuthority = this.checkinInfo[i].issuingAuthority
  83. info.issuingDate = this.checkinInfo[i].issuingDate
  84. info.expiryDate = this.checkinInfo[i].expiryDate
  85. let res = await uni.$http.post('/checkin', info)
  86. console.log(res)
  87. if (res.data.code == 200 && res.data.success === true) {
  88. checkinResult[i] = true
  89. console.log('checkinResult[' + i + '] = true')
  90. }
  91. }
  92. console.log(checkinResult)
  93. let falsePos = checkinResult.indexOf(false)
  94. if (falsePos < 0) {
  95. this.result = true
  96. this.countDownTimer = setInterval(() => {
  97. this.time--
  98. if (this.time === 0) {
  99. clearInterval(this.countDownTimer)
  100. this.gotoHome()
  101. }
  102. }, 1000)
  103. } else {
  104. let failName = this.checkinInfo[falsePos].name
  105. uni.showModal({
  106. showCancel: false,
  107. content: '办理失败,请重新选择订单',
  108. success: (res) => {
  109. if (res.confirm) {
  110. uni.switchTab({
  111. url: '/pages/home/home'
  112. })
  113. }
  114. }
  115. })
  116. // uni.$showMsg('顾客' + failName + '办理失败!')
  117. }
  118. } finally {
  119. uni.hideLoading()
  120. }
  121. },
  122. gotoHome() {
  123. clearInterval(this.countDownTimer)
  124. uni.switchTab({
  125. url: '/pages/home/home'
  126. })
  127. }
  128. },
  129. async onLoad() {
  130. await this.checkin()
  131. },
  132. // #ifdef MP-WEIXIN
  133. onShareAppMessage(info) {
  134. return {
  135. title: '源享住',
  136. path: 'pages/login/login',
  137. imageUrl: "/static/logo.png"
  138. }
  139. }
  140. // #endif
  141. }
  142. </script>
  143. <style lang="scss">
  144. .tip-area {
  145. padding-top: 160rpx;
  146. .u-image {
  147. margin: 40rpx auto;
  148. }
  149. }
  150. .btn-container {
  151. margin: 200rpx 30rpx;
  152. }
  153. </style>