hotelSelector.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="hotel-name">
  3. <view class="hotel-name--fix" :style="[fixStyle]"></view>
  4. <view class="hotel-name--content" :style="[hotelNameFontSize]">
  5. <text>{{ hotel.name }}</text>
  6. </view>
  7. <view class="hotel-name--fix" @click="gotoSelectHotel" id="changeHotel">
  8. <image src="/static/switch.svg" style="width: 30rpx; height: 30rpx;"></image>
  9. 切换
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. import {
  15. computed
  16. } from 'vue'
  17. import {
  18. useHotelStore
  19. } from '@/store/hotelStore.js'
  20. let hotel = useHotelStore().hotel
  21. let fixStyle = computed(() => {
  22. let style = {}
  23. if (hotel.hasOwnProperty('name') && hotel.name.length <= 14) return style
  24. style.display = "none"
  25. return style
  26. })
  27. let hotelNameFontSize = computed(() => {
  28. let style = {}
  29. if (hotel.hasOwnProperty('name') && hotel.name.length <= 14) return style
  30. style.fontSize = "30rpx"
  31. return style
  32. })
  33. function gotoSelectHotel() {
  34. uni.redirectTo({
  35. url: '/subpkg/selectHotel/selectHotel?source=home'
  36. })
  37. }
  38. </script>
  39. <style lang="scss">
  40. .hotel-name {
  41. margin: 20rpx 40rpx;
  42. display: flex;
  43. flex-direction: row;
  44. color: #ffffff;
  45. background-color: hsla(0, 100%, 0%, 0.5);
  46. padding: 20rpx 0;
  47. border-radius: 10rpx;
  48. transform: translateY(-80rpx);
  49. .hotel-name--fix {
  50. font-size: 20rpx;
  51. width: 100rpx;
  52. height: 100%;
  53. padding-right: 16rpx;
  54. display: flex;
  55. flex-direction: row;
  56. align-items: center;
  57. }
  58. .hotel-name--content {
  59. width: 100%;
  60. display: flex;
  61. align-items: center;
  62. justify-content: center;
  63. }
  64. }
  65. </style>