collect.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="container">
  3. <!-- 分段器区域 -->
  4. <view class="segmented">
  5. <uni-segmented-control :current="activeCurrent" :values="headerList" style-type="text" active-color="#096562" @clickItem="onClickItem" />
  6. </view>
  7. <!-- 列表区域 -->
  8. <scroll-view class="body" scroll-y @scrolltolower="handlePull">
  9. <!-- 每一个盒子区域 -->
  10. <view class="box" v-for="item in list" :key="item.id">
  11. <!-- 民宿图片区域 -->
  12. <img mode="aspectFill" :src="item.imgUrl" />
  13. <!-- 民宿信息区域 -->
  14. <view class="box_info">
  15. <view class="info_name">{{ item.name }}</view>
  16. <view class="info_rate">
  17. <view class="rate_num">{{ item.rate }}</view>
  18. <view class="rate_msg">{{ item.msg }}</view>
  19. </view>
  20. <view class="info_town">{{ item.town }}</view>
  21. </view>
  22. <!-- 民宿价格区域 -->
  23. <view class="box_price">
  24. <view class="price_icon">¥</view>
  25. <view class="price_num">{{ item.price }}</view>
  26. <view class="price_msg">起</view>
  27. </view>
  28. </view>
  29. </scroll-view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. // 分段器当前激活索引
  37. activeCurrent: 0,
  38. // 分段器数组
  39. headerList: ['收藏', '住过'],
  40. // 列表数据
  41. list: [
  42. {
  43. id: 1,
  44. imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  45. name: '民宿名称',
  46. rate: '5.0',
  47. town: '宝峰镇',
  48. price: 748,
  49. msg: '超棒'
  50. },
  51. {
  52. id: 2,
  53. imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  54. name: '开心民宿',
  55. rate: '5.0',
  56. town: '木叶村',
  57. price: 999,
  58. msg: '超棒'
  59. },
  60. {
  61. id: 3,
  62. imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  63. name: '快乐民宿',
  64. rate: '5.0',
  65. town: '砂隐村',
  66. price: 888,
  67. msg: '超棒'
  68. }
  69. ]
  70. }
  71. },
  72. methods: {
  73. // 切换分段器回调
  74. onClickItem(e) {
  75. if (this.current !== e.currentIndex) {
  76. this.current = e.currentIndex
  77. }
  78. },
  79. // 列表下拉到底部回调
  80. handlePull() {
  81. console.log(111)
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .container {
  88. height: 100vh;
  89. background-color: #f2f3f5;
  90. overflow: hidden;
  91. .segmented {
  92. box-sizing: border-box;
  93. padding-bottom: 28rpx;
  94. height: 100rpx;
  95. background-color: #fff;
  96. }
  97. .body {
  98. box-sizing: border-box;
  99. padding: 20rpx 0;
  100. height: calc(100vh - 100rpx);
  101. .box {
  102. display: flex;
  103. align-items: center;
  104. padding: 0 20rpx;
  105. height: 207rpx;
  106. border-bottom: 1rpx solid #e5e5e5;
  107. background-color: #fff;
  108. img {
  109. width: 110rpx;
  110. height: 146rpx;
  111. border-radius: 10rpx;
  112. }
  113. .box_info {
  114. display: flex;
  115. flex-direction: column;
  116. justify-content: space-between;
  117. margin-top: -5rpx;
  118. margin-left: 20rpx;
  119. height: 146rpx;
  120. .info_name {
  121. font-size: 32rpx;
  122. font-weight: bold;
  123. }
  124. .info_rate {
  125. display: flex;
  126. font-size: 24rpx;
  127. .rate_num {
  128. padding: 4rpx 10rpx;
  129. color: #fff;
  130. border-radius: 32rpx 0 0 32rpx;
  131. background-color: #096562;
  132. }
  133. .rate_msg {
  134. padding: 4rpx 10rpx;
  135. color: #096562;
  136. border-radius: 0 32rpx 32rpx 0;
  137. background-color: #dff2f2;
  138. }
  139. }
  140. .info_town {
  141. color: #808080;
  142. font-size: 24rpx;
  143. }
  144. }
  145. .box_price {
  146. display: flex;
  147. align-items: flex-end;
  148. margin-left: auto;
  149. height: 146rpx;
  150. .price_icon {
  151. margin-bottom: 5rpx;
  152. color: #ff5733;
  153. font-size: 24rpx;
  154. }
  155. .price_num {
  156. color: #ff5733;
  157. font-size: 42rpx;
  158. }
  159. .price_msg {
  160. margin-left: 12rpx;
  161. margin-bottom: 5rpx;
  162. color: #808080;
  163. font-size: 24rpx;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </style>