checkin.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.isResv
  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. } else {
  71. info.isMainCustomer = false
  72. }
  73. info.userName = this.checkinInfo[i].name
  74. info.userId = this.checkinInfo[i].idNumber
  75. info.faceData = this.checkinInfo[i].faceData
  76. info.userPhone = this.checkinInfo[i].phone
  77. info.address = this.checkinInfo[i].address
  78. info.race = this.checkinInfo[i].nation
  79. info.userGender = this.checkinInfo[i].sex === '男' ? 1 : 2
  80. info.birth = this.checkinInfo[i].birth
  81. info.issuingAuthority = this.checkinInfo[i].issuingAuthority
  82. info.issuingDate = this.checkinInfo[i].issuingDate
  83. info.expiryDate = this.checkinInfo[i].expiryDate
  84. let res = await uni.$http.post('/checkin', info)
  85. console.log(res)
  86. if (res.data.code == 200 && res.data.success === true) {
  87. checkinResult[i] = true
  88. console.log('checkinResult[' + i + '] = true')
  89. }
  90. }
  91. console.log(checkinResult)
  92. let falsePos = checkinResult.indexOf(false)
  93. if (falsePos < 0) {
  94. this.result = true
  95. this.countDownTimer = setInterval(() => {
  96. this.time--
  97. if (this.time === 0) {
  98. clearInterval(this.countDownTimer)
  99. this.gotoHome()
  100. }
  101. }, 1000)
  102. } else {
  103. let failName = this.checkinInfo[falsePos].name
  104. uni.showModal({
  105. showCancel: false,
  106. content: '办理失败,请至 订单->已入住 处重新办理;若仍失败,请至联系前台',
  107. success: (res) => {
  108. if (res.confirm) {
  109. uni.switchTab({
  110. url: '/pages/home/home'
  111. })
  112. }
  113. }
  114. })
  115. // uni.$showMsg('顾客' + failName + '办理失败!')
  116. }
  117. } finally {
  118. uni.hideLoading()
  119. }
  120. },
  121. gotoHome() {
  122. uni.switchTab({
  123. url: '/pages/home/home'
  124. })
  125. }
  126. },
  127. async onLoad() {
  128. await this.checkin()
  129. },
  130. // #ifdef MP-WEIXIN
  131. onShareAppMessage(info) {
  132. return {
  133. title: '源享住',
  134. path: 'pages/login/login',
  135. imageUrl: "/static/logo.png"
  136. }
  137. }
  138. // #endif
  139. }
  140. </script>
  141. <style lang="scss">
  142. .tip-area {
  143. padding-top: 160rpx;
  144. .u-image {
  145. margin: 40rpx auto;
  146. }
  147. }
  148. .btn-container {
  149. margin: 200rpx 30rpx;
  150. }
  151. </style>