collect.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. <view class="noData" v-if="list.length === 0">
  30. <img lazy-load :lazy-load-margin="0" src="../../static/images/noData.png" />
  31. {{ noDataMsg }}
  32. </view>
  33. </scroll-view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. // 分段器当前激活索引
  41. activeCurrent: 0,
  42. // 分段器数组
  43. headerList: ['收藏', '住过'],
  44. // 列表数据
  45. list: [
  46. // {
  47. // id: 1,
  48. // imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  49. // name: '民宿名称',
  50. // rate: '5.0',
  51. // town: '宝峰镇',
  52. // price: 748,
  53. // msg: '超棒'
  54. // },
  55. // {
  56. // id: 2,
  57. // imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  58. // name: '开心民宿',
  59. // rate: '5.0',
  60. // town: '木叶村',
  61. // price: 999,
  62. // msg: '超棒'
  63. // },
  64. // {
  65. // id: 3,
  66. // imgUrl: 'https://img1.baidu.com/it/u=4085584268,3308739054&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
  67. // name: '快乐民宿',
  68. // rate: '5.0',
  69. // town: '砂隐村',
  70. // price: 888,
  71. // msg: '超棒'
  72. // }
  73. ],
  74. noDataMsg: '暂无收藏数据'
  75. }
  76. },
  77. methods: {
  78. // 切换分段器回调
  79. onClickItem(e) {
  80. if (this.current !== e.currentIndex) {
  81. this.current = e.currentIndex
  82. if (this.current === 0) {
  83. this.noDataMsg = '暂无收藏数据'
  84. } else {
  85. this.noDataMsg = '暂无住过数据'
  86. }
  87. }
  88. },
  89. // 列表下拉到底部回调
  90. handlePull() {
  91. console.log(111)
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .container {
  98. height: 100vh;
  99. background-color: #f2f3f5;
  100. overflow: hidden;
  101. .segmented {
  102. box-sizing: border-box;
  103. padding-bottom: 28rpx;
  104. height: 100rpx;
  105. background-color: #fff;
  106. }
  107. .body {
  108. box-sizing: border-box;
  109. padding: 20rpx 0;
  110. height: calc(100vh - 100rpx);
  111. .box {
  112. display: flex;
  113. align-items: center;
  114. padding: 0 20rpx;
  115. height: 207rpx;
  116. border-bottom: 1rpx solid #e5e5e5;
  117. background-color: #fff;
  118. img {
  119. width: 110rpx;
  120. height: 146rpx;
  121. border-radius: 10rpx;
  122. }
  123. .box_info {
  124. display: flex;
  125. flex-direction: column;
  126. justify-content: space-between;
  127. margin-top: -5rpx;
  128. margin-left: 20rpx;
  129. height: 146rpx;
  130. .info_name {
  131. font-size: 32rpx;
  132. font-weight: bold;
  133. }
  134. .info_rate {
  135. display: flex;
  136. font-size: 24rpx;
  137. .rate_num {
  138. padding: 4rpx 10rpx;
  139. color: #fff;
  140. border-radius: 32rpx 0 0 32rpx;
  141. background-color: #096562;
  142. }
  143. .rate_msg {
  144. padding: 4rpx 10rpx;
  145. color: #096562;
  146. border-radius: 0 32rpx 32rpx 0;
  147. background-color: #dff2f2;
  148. }
  149. }
  150. .info_town {
  151. color: #808080;
  152. font-size: 24rpx;
  153. }
  154. }
  155. .box_price {
  156. display: flex;
  157. align-items: flex-end;
  158. margin-left: auto;
  159. height: 146rpx;
  160. .price_icon {
  161. margin-bottom: 5rpx;
  162. color: #ff5733;
  163. font-size: 24rpx;
  164. }
  165. .price_num {
  166. color: #ff5733;
  167. font-size: 42rpx;
  168. }
  169. .price_msg {
  170. margin-left: 12rpx;
  171. margin-bottom: 5rpx;
  172. color: #808080;
  173. font-size: 24rpx;
  174. }
  175. }
  176. }
  177. .noData {
  178. display: flex;
  179. flex-direction: column;
  180. justify-content: center;
  181. align-items: center;
  182. padding-bottom: 20rpx;
  183. img {
  184. margin-top: 160rpx;
  185. width: 600rpx;
  186. height: 600rpx;
  187. }
  188. }
  189. }
  190. }
  191. </style>