home.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="container">
  3. <!-- 搜索框区域 -->
  4. <uv-row custom-style="margin: 10px 0px" gutter="10">
  5. <picker @change="bindPickerChange" :value="placeIndex" :range="placeList">
  6. <view class="address">
  7. <view class="address_text">{{ placeList[placeIndex] }}</view>
  8. <img src="../../static/index/bottom.png" />
  9. </view>
  10. </picker>
  11. <view class="search">
  12. <view class="add">
  13. <image class="img" src="../../static/index/search.png" mode="aspectFit"></image>
  14. </view>
  15. <input class="inp" type="text" v-model="keywords" placeholder="请输入关键字搜索" />
  16. <view class="btnSearch" @click="searchHandler()">搜索</view>
  17. </view>
  18. </uv-row>
  19. <!-- 名宿列表区域 -->
  20. <view class="body">
  21. <!-- 每一个名宿区域 -->
  22. <view class="item" v-for="item in hotelList" :key="item.id" @click="goPageDetail(item)">
  23. <image class="item-img" :src="item.imgUrl" mode="scaleToFill"></image>
  24. <view class="descrition">
  25. <text class="title">{{ item.hotelName }}</text>
  26. <text class="type">{{ item.type }}</text>
  27. <text class="distance">距您直线{{ item.distance }}公里</text>
  28. <view class="detail">
  29. <img class="img" src="../../static/index/hotel.png" />
  30. <view class="price">
  31. <text class="txt1">¥{{ item.price }}</text>
  32. <text class="txt2">起</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. // 搜索框绑定数据
  45. keywords: '',
  46. // 名宿列表数组
  47. hotelList: [
  48. {
  49. id: 1,
  50. imgUrl: '../../static/search/img.png',
  51. hotelName: '双溪镇抱朴小院',
  52. type: '舒适型',
  53. distance: '7.2',
  54. price: 180,
  55. phone: '18320846714'
  56. },
  57. {
  58. id: 2,
  59. imgUrl: '../../static/index/banner.png',
  60. hotelName: '幸福乡宿',
  61. type: '舒适型',
  62. distance: '3.2',
  63. price: 190,
  64. phone: '18320846714'
  65. },
  66. {
  67. id: 3,
  68. imgUrl: '../../static/index/banner.png',
  69. hotelName: '健康乡宿',
  70. type: '舒适型',
  71. distance: '8.6',
  72. price: 150,
  73. phone: '18320846714'
  74. },
  75. {
  76. id: 4,
  77. imgUrl: '../../static/search/img.png',
  78. hotelName: '开心乡宿',
  79. type: '舒适型',
  80. distance: '6.2',
  81. price: 180,
  82. phone: '18320846714'
  83. },
  84. {
  85. id: 5,
  86. imgUrl: '../../static/index/banner.png',
  87. hotelName: '快乐乡宿',
  88. type: '舒适型',
  89. distance: '3.9',
  90. price: 280,
  91. phone: '18320846714'
  92. }
  93. ],
  94. // 地区数组
  95. placeList: ['靖安县', '宝峰镇', '三爪乡'],
  96. // 当前选择地区索引
  97. placeIndex: 0
  98. }
  99. },
  100. onLoad() {},
  101. methods: {
  102. // 搜索按钮点击回调
  103. searchHandler() {
  104. console.log(this.keywords)
  105. },
  106. // 点击每一个名宿卡片回调
  107. goPageDetail(item) {
  108. // console.log(item)
  109. const info = JSON.stringify(item)
  110. uni.navigateTo({
  111. url: `/pages/detail/detail?info=${info}`
  112. })
  113. },
  114. bindPickerChange(e) {
  115. console.log('picker发送选择改变,携带值为', e.detail.value)
  116. this.placeIndex = e.detail.value
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .container {
  123. display: flex;
  124. flex-direction: column;
  125. width: 750rpx;
  126. padding: 0 30rpx;
  127. box-sizing: border-box;
  128. background-color: #ebeced;
  129. .address {
  130. display: flex;
  131. width: 152rpx;
  132. font-size: 28rpx;
  133. .address_text {
  134. width: 104rpx;
  135. text-align: center;
  136. overflow: hidden;
  137. white-space: nowrap;
  138. text-overflow: ellipsis;
  139. }
  140. img {
  141. width: 48rpx;
  142. height: 48rpx;
  143. }
  144. }
  145. .search {
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. width: 538rpx;
  150. height: 80rpx;
  151. opacity: 1;
  152. border-radius: 70px;
  153. background-color: #fff;
  154. .add {
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. margin-left: 10rpx;
  159. width: 60rpx;
  160. font-size: 50rpx;
  161. height: 60rpx;
  162. line-height: 60rpx;
  163. color: rgba(30, 125, 251, 1);
  164. .img {
  165. width: 30rpx;
  166. height: 30rpx;
  167. }
  168. }
  169. .inp {
  170. height: 60rpx;
  171. line-height: 60rpx;
  172. flex-grow: 1;
  173. font-size: 28rpx;
  174. }
  175. .btnSearch {
  176. width: 100rpx;
  177. text-align: center;
  178. margin-right: 10rpx;
  179. height: 60rpx;
  180. line-height: 60rpx;
  181. opacity: 1;
  182. font-size: 28rpx;
  183. font-weight: 400;
  184. height: 2rem;
  185. color: #096562;
  186. }
  187. }
  188. .body {
  189. display: flex;
  190. justify-content: space-between;
  191. flex-wrap: wrap;
  192. .item {
  193. width: 335rpx;
  194. box-sizing: border-box;
  195. margin-bottom: 20rpx;
  196. .item-img {
  197. width: 100%;
  198. height: 223rpx;
  199. border-radius: 18rpx 18rpx 0 0;
  200. box-sizing: border-box;
  201. }
  202. .descrition {
  203. display: flex;
  204. flex-direction: column;
  205. width: 100%;
  206. border-radius: 0 0 18rpx 18rpx;
  207. box-sizing: border-box;
  208. background: rgba(255, 255, 255, 1);
  209. margin-top: -10rpx;
  210. .title {
  211. font-size: 28rpx;
  212. font-weight: 600;
  213. padding: 20rpx 20rpx 10rpx;
  214. color: rgba(0, 0, 0, 1);
  215. }
  216. .type {
  217. padding: 5rpx 20rpx;
  218. font-size: 24rpx;
  219. color: #a6a6a6;
  220. }
  221. .distance {
  222. padding: 10rpx 20rpx;
  223. font-size: 24rpx;
  224. color: #a6a6a6;
  225. }
  226. .detail {
  227. display: flex;
  228. flex-direction: row;
  229. justify-content: space-between;
  230. align-items: center;
  231. padding: 0 20rpx 20rpx 20rpx;
  232. color: rgba(0, 0, 0, 1);
  233. .img {
  234. width: 40rpx;
  235. height: 40rpx;
  236. }
  237. .price {
  238. .txt1 {
  239. font-size: 36rpx;
  240. font-weight: 600;
  241. color: rgba(255, 87, 51, 1);
  242. }
  243. .txt2 {
  244. font-size: 24rpx;
  245. font-weight: 400;
  246. color: #a6a6a6;
  247. }
  248. }
  249. .score {
  250. font-size: 24rpx;
  251. font-weight: 400;
  252. padding-top: 10rpx;
  253. color: rgba(166, 166, 166, 1);
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>