hotelImgList.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="hotelImgList">
  3. <view class="tab-box">
  4. <view class="tab" :class="[active === index?'active':'']" @click="handleTab(index)" v-for="(item,index) in pictures" :key="index">
  5. {{item.name}}({{item.list.length}})
  6. </view>
  7. </view>
  8. <view>
  9. <!-- <view class="sub-title" :id="'the-'+index">
  10. {{`${item.name}(${item.list.length || 0})`}}
  11. </view> -->
  12. <view class="img-box">
  13. <zs-img class="img" :src="item" width="340rpx" height="340rpx" radius="full" v-for="(item,index) in list" :key="index" @click.native="preview(index)"></zs-img>
  14. </view>
  15. </view>
  16. <view class="btn-box">
  17. <button class="btn" type="default" @click="goIntroduce">酒店介绍</button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. active:0,
  26. pictures:[]
  27. }
  28. },
  29. computed: {
  30. list() {
  31. if(this.pictures.length){
  32. console.log(this.pictures[this.active].list);
  33. return this.pictures[this.active].list
  34. }else{
  35. return []
  36. }
  37. }
  38. },
  39. methods: {
  40. preview(index){
  41. uni.previewImage({
  42. urls:this.list,
  43. current:index,
  44. indicator:'number'
  45. })
  46. },
  47. handleTab(key) {
  48. this.active = key
  49. uni.pageScrollTo({
  50. selector:`#the-${key}`
  51. })
  52. },
  53. goIntroduce(){
  54. uni.navigateTo({
  55. url:`./introduce?id=${this.hotelId}`
  56. })
  57. },
  58. },
  59. onLoad(options) {
  60. this.hotelId = options.id
  61. this.pictures = JSON.parse(uni.getStorageSync('hotelImgList'))
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .hotelImgList{
  67. padding: 20rpx 24rpx 200rpx;
  68. .tab-box{
  69. display: flex;
  70. overflow-x: auto;
  71. .tab{
  72. padding: 4rpx 24rpx;
  73. background: #F0F0F0;
  74. border-radius: 8rpx 8rpx 8rpx 8rpx;
  75. font-size: 24rpx;
  76. color: #222222;
  77. flex-shrink: 0;
  78. }
  79. .tab+.tab{
  80. margin-left: 16rpx;
  81. }
  82. .tab.active{
  83. background: #FDECE8;
  84. color: #EE4320;
  85. }
  86. }
  87. .sub-title{
  88. font-weight: 600;
  89. font-size: 28rpx;
  90. color: #222222;
  91. margin-top: 20rpx;
  92. }
  93. .img-box{
  94. display: flex;
  95. flex-wrap: wrap;
  96. justify-content: space-between;
  97. .img{
  98. margin-top: 20rpx;
  99. }
  100. }
  101. .btn-box{
  102. position: fixed;
  103. bottom: 0%;
  104. left: 0%;
  105. background: #fff;
  106. z-index: 2;
  107. width: 100%;
  108. height: 98rpx;
  109. line-height: 98rpx;
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. padding: 0 0 env(safe-area-inset-bottom);
  114. border-top: 1rpx solid #EEEEEE;
  115. .btn{
  116. width: 702rpx;
  117. height: 80rpx;
  118. line-height: 80rpx;
  119. text-align: center;
  120. border-radius: 40rpx 40rpx 40rpx 40rpx;
  121. font-weight: 600;
  122. font-size: 28rpx;
  123. background: #EE4320;
  124. color: #fff;
  125. }
  126. }
  127. }
  128. </style>