elevatorControl.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view>
  3. <view class="have-reservation" v-if="Object.keys(checkinInfo).length > 0">
  4. <view class="checkin-info" :style="{width: diaplayWidth}">
  5. <view class="checkin-info--title">
  6. {{ checkinInfo.hotelName }}
  7. </view>
  8. <view class="checkin-info--desc">
  9. <view class="card-item" v-if="checkinInfo.building">
  10. <view class="card-item-left">
  11. <text>所属楼栋:</text>
  12. </view>
  13. <text>{{ checkinInfo.building }}</text>
  14. </view>
  15. <view class="card-item">
  16. <view class="card-item-left">
  17. <text>所在楼层:</text>
  18. </view>
  19. <text>{{ checkinInfo.floor }}</text>
  20. </view>
  21. <view class="card-item">
  22. <view class="card-item-left">
  23. <text>房间信息:</text>
  24. </view>
  25. <text>{{ checkinInfo.room }}</text>
  26. </view>
  27. <view class="card-item">
  28. <view class="card-item-left">
  29. <text>起始时间:</text>
  30. </view>
  31. <text>{{ formatDateTime(checkinInfo.startTime) }}\n</text>
  32. </view>
  33. <view class="card-item">
  34. <view class="card-item-left">
  35. <text>结束时间:</text>
  36. </view>
  37. <text>{{ formatDateTime(checkinInfo.endTime) }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="qrcode" :style="{width:qrCodeWidth, height:qrCodeWidth, display:showQRCode ? '' : 'none' }" >
  42. <img style="width: 100%; height: 100%;" :src="getUrl()"/>
  43. </view>
  44. </view>
  45. <view v-else class="not-reservation">
  46. <text class="tip">您还未入住</text>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { mapState } from "vuex";
  52. import {
  53. getCheckinInfo,
  54. getElevatorQRCode
  55. } from "../../utils/api";
  56. import moment from "moment";
  57. import { QRCodeSVG } from '../../utils/qrCode/qrcode/src/index';
  58. import svgToDataURL from "svg-to-dataurl";
  59. import { YUN_XIANG_ZHU} from "../../static/yun_xiang_zhuBase64"
  60. export default {
  61. data() {
  62. return {
  63. checkinInfo: {},
  64. qrCodeDate:"",
  65. qrCode:"",
  66. diaplayWidth:"",
  67. qrCodeWidth: "",
  68. showQRCode:false
  69. }
  70. },
  71. computed:{
  72. ...mapState("m_business",["currentHotelId"]),
  73. ...mapState("m_user", ["userInfo"])
  74. },
  75. methods:{
  76. getUrl(){
  77. return svgToDataURL(this.qrCode)
  78. },
  79. formatDateTime(dateTime) {
  80. return moment(dateTime).format("YYYY年MM月DD日 HH时mm分");
  81. }
  82. },
  83. async onLoad(){
  84. const info = await getCheckinInfo({
  85. userIdNumber: this.userInfo.idNumber,
  86. hotelId: this.currentHotelId,
  87. status: 1,
  88. pageNo: 1,
  89. pageSize: 1,
  90. })
  91. // console.log("getCheckinInfo", info);
  92. if (!info.data.data.records.length) {
  93. console.log("未查询到入住记录");
  94. return
  95. }
  96. this.checkinInfo = info.data.data.records[0];
  97. // console.log("入住记录", this.checkinInfo);
  98. const qrCodeMsg = await getElevatorQRCode({
  99. hotelId: this.currentHotelId,
  100. building: 1,
  101. floor: this.checkinInfo.floor,
  102. customerId: this.checkinInfo.customerUserId,
  103. customerType: 1,
  104. status: 1,
  105. activeTime: this.checkinInfo.endTime
  106. })
  107. // console.log("qrCodeMsg", qrCodeMsg);
  108. if (!qrCodeMsg.data.success) {
  109. console.log("获取梯控二维码data数据失败", qrCodeMsg.data);
  110. return
  111. }
  112. this.qrCodeDate = qrCodeMsg.data.data.data
  113. console.log("获取qrCodeDate", this.qrCodeDate);
  114. // #ifdef MP-WEIXIN
  115. const wxSystemInfo = await wx.getSystemInfo()
  116. // console.log("systeminfo", systemInfo.screenWidth);
  117. this.diaplayWidth = (wxSystemInfo.screenWidth - 40).toFixed() + "px"
  118. this.qrCodeWidth = (wxSystemInfo.screenWidth * 3 / 5).toFixed() + "px"
  119. // #endif
  120. // #ifdef MP-ALIPAY
  121. let alipaySystemInfo = await wx.getSystemInfo()
  122. alipaySystemInfo = alipaySystemInfo[1].screen
  123. console.log("alipaySystemInfo",alipaySystemInfo);
  124. this.diaplayWidth = (alipaySystemInfo.width - 40).toFixed() + "px"
  125. this.qrCodeWidth = (alipaySystemInfo.width * 3 / 5).toFixed() + "px"
  126. // #endif
  127. // console.log("qrcodr", this.qrCodeDate);
  128. this.$nextTick(() => {
  129. const qrSvg = new QRCodeSVG(
  130. this.qrCodeDate,
  131. {
  132. padding: 0,
  133. image: {
  134. source: YUN_XIANG_ZHU,
  135. width: '40%',
  136. height: '40%',
  137. x: 'center',
  138. y: 'center',
  139. border: 1
  140. },
  141. level: "Q"
  142. }
  143. )
  144. this.qrCode = qrSvg.toString()
  145. this.showQRCode = true
  146. })
  147. },
  148. }
  149. </script>
  150. <style lang="scss">
  151. page {
  152. margin: 0;
  153. padding: 0;
  154. .have-reservation{
  155. height: 100%;
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. margin-top: 10rpx;
  160. .checkin-info{
  161. height: 100%;
  162. display: flex;
  163. flex-direction: column;
  164. justify-content: center;
  165. margin: 10rpx 20rpx;
  166. padding: 10rpx 20rpx;
  167. background-color: #ffffff;
  168. border-radius: 10rpx;
  169. .checkin-info--title {
  170. margin: 10rpx 20rpx;
  171. padding-bottom: 10rpx;
  172. border-bottom: 2px solid #f5f5f5;
  173. font-size: 34rpx;
  174. }
  175. .checkin-info--desc {
  176. margin: 0 20rpx;
  177. font-size: 30rpx;
  178. color: #6a6a82;
  179. .card-item {
  180. margin-top: 4rpx;
  181. margin-bottom: 4rpx;
  182. display: flex;
  183. .card-item-left {
  184. width: 160rpx;
  185. }
  186. }
  187. }
  188. }
  189. .qrcode{
  190. display: flex;
  191. margin: 10rpx 20rpx;
  192. padding: 10rpx 20rpx;
  193. background: #ffffff;
  194. border-radius: 10rpx;
  195. }
  196. }
  197. .not-reservation {
  198. display: flex;
  199. justify-content: center;
  200. height: 100%;
  201. text-align: center;
  202. vertical-align: 100rpx;
  203. .tip {
  204. padding-top: 40%;
  205. }
  206. }
  207. }
  208. </style>