community.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="container">
  3. <!-- 搜索框区域 -->
  4. <view class="content">
  5. <uv-row custom-style="margin: 10px 0px" gutter="10">
  6. <picker @change="bindPickerChange" range-key="name" :value="placeIndex" :range="placeList">
  7. <view class="address">
  8. <view class="address_text">{{ placeList[placeIndex].name }}</view>
  9. <img src="../../static/index/bottom.png" />
  10. </view>
  11. </picker>
  12. <view class="search">
  13. <view class="add">
  14. <image class="img" src="../../static/index/search.png" mode="aspectFit"></image>
  15. </view>
  16. <input class="inp" type="text" v-model="keywords" placeholder="请输入关键字搜索" />
  17. <view class="btnSearch" @click="searchHandler">搜索</view>
  18. </view>
  19. </uv-row>
  20. </view>
  21. <!-- 分段器区域 -->
  22. <view class="control">
  23. <uni-segmented-control :current="current" :values="items" style-type="text" active-color="#096562" @clickItem="onClickItem" />
  24. </view>
  25. <!-- 数据列表区域 -->
  26. <scroll-view v-if="list.length" class="body" scroll-y @scrolltolower="handleTolower">
  27. <uv-waterfall ref="waterfall" v-model="list" :add-time="80" :left-gap="0" :right-gap="0" :column-gap="8" @changeList="changeList">
  28. <!-- 第一列数据 -->
  29. <template v-slot:list1>
  30. <!-- 为了磨平部分平台的BUG,必须套一层view -->
  31. <view>
  32. <view v-for="(item, index) in list1" :key="item.id" class="waterfall_item" @click="goPageDetail(item)">
  33. <img mode="aspectFill" class="item_cover" :src="item.coverImg" />
  34. <view class="item_desc">{{ item.hposition }}</view>
  35. <view class="item_info">
  36. <img mode="aspectFill" :src="item.coverImg" />
  37. <view class="text">{{ item.hotel_name }}</view>
  38. <img
  39. class="img"
  40. :src="item.is_collect_hotel ? '../../static/index/like-active.png' : '../../static/index/like.png'"
  41. @click.stop="handleClickLike(item)"
  42. />
  43. <view class="count">{{ item.roomNumber }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <!-- 第二列数据 -->
  49. <template v-slot:list2>
  50. <!-- 为了磨平部分平台的BUG,必须套一层view -->
  51. <view>
  52. <view v-for="(item, index) in list2" :key="item.id" class="waterfall_item" @click="goPageDetail(item)">
  53. <img mode="aspectFill" class="item_cover" :src="item.coverImg" />
  54. <view class="item_desc">{{ item.hposition }}</view>
  55. <view class="item_info">
  56. <img mode="aspectFill" :src="item.coverImg" />
  57. <view class="text">{{ item.hotel_name }}</view>
  58. <img
  59. class="img"
  60. :src="item.is_collect_hotel ? '../../static/index/like-active.png' : '../../static/index/like.png'"
  61. @click.stop="handleClickLike(item)"
  62. />
  63. <view class="count">{{ item.roomNumber }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. </uv-waterfall>
  69. </scroll-view>
  70. <!-- 没有数据时展示的区域 -->
  71. <view class="noData" v-if="!list.length">
  72. <img src="../../static/images/noData.png" />
  73. 暂无数据
  74. </view>
  75. <!-- 悬浮按钮区域 -->
  76. <uni-fab :pattern="pattern" horizontal="right" @fabClick="handleClickBtn"></uni-fab>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. // 悬浮按钮样式
  84. pattern: {
  85. buttonColor: '#096562'
  86. },
  87. keywords: '',
  88. // 当前选择地区索引
  89. placeIndex: 0,
  90. // 地区数组
  91. placeList: [
  92. {
  93. name: '靖安县'
  94. }
  95. ],
  96. // 分段器数组
  97. items: ['发现', '关注', '收藏'],
  98. // 当前索引
  99. current: 0,
  100. // 当前页
  101. page: 1,
  102. // 每页多少条
  103. rows: 6,
  104. // 总条数
  105. total: null,
  106. // 瀑布流全部数据
  107. list: [],
  108. // 瀑布流第一列数据
  109. list1: [],
  110. // 瀑布流第二列数据
  111. list2: []
  112. }
  113. },
  114. onLoad() {
  115. this.getHotelList()
  116. },
  117. methods: {
  118. // 获取列表数组
  119. async getHotelList() {
  120. const res = await this.$myRequest({
  121. url: '/mhotel/ahphomePage.action',
  122. data: {
  123. page: this.page,
  124. rows: this.rows,
  125. type: 3,
  126. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  127. }
  128. })
  129. // console.log(res)
  130. if (res.code === 200) {
  131. this.list = [...this.list, ...res.data.pageList]
  132. this.total = res.data.total
  133. }
  134. },
  135. changeList(e) {
  136. if (e.name === 'list1') {
  137. this.list1.push(e.value)
  138. } else {
  139. this.list2.push(e.value)
  140. }
  141. },
  142. // 点击爱心回调
  143. handleClickLike(item) {
  144. item.is_collect_hotel = !item.is_collect_hotel
  145. },
  146. // 点击悬浮按钮回调
  147. handleClickBtn() {
  148. uni.navigateTo({
  149. url: '/pages/send/send'
  150. })
  151. },
  152. // 搜索按钮点击回调
  153. searchHandler() {},
  154. // 选择地区时的回调
  155. bindPickerChange(e) {
  156. this.placeIndex = e.detail.value
  157. },
  158. // 分段器切换回调
  159. onClickItem(e) {
  160. this.current = e.currentIndex
  161. this.list = []
  162. this.$refs.waterfall.clear()
  163. this.list1 = []
  164. this.list2 = []
  165. this.page = 1
  166. if (this.current === 0) {
  167. this.getHotelList()
  168. }
  169. },
  170. // 页面触底回调
  171. handleTolower() {
  172. if (this.total > this.list.length) {
  173. this.page++
  174. this.getHotelList()
  175. } else {
  176. uni.showToast({
  177. title: '没有更多数据了',
  178. icon: 'none',
  179. maks: true
  180. })
  181. }
  182. },
  183. // 点击每一个推文回调
  184. goPageDetail(item) {
  185. uni.navigateTo({
  186. url: `/pages/tweetDetail/tweetDetail?id=${item.id}`
  187. })
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .container {
  194. display: flex;
  195. flex-direction: column;
  196. align-items: center;
  197. height: 100vh;
  198. overflow: hidden;
  199. background-color: #f7f7f7;
  200. .content {
  201. background-color: #f7f7f7;
  202. .address {
  203. display: flex;
  204. width: 152rpx;
  205. font-size: 28rpx;
  206. .address_text {
  207. width: 104rpx;
  208. text-align: center;
  209. overflow: hidden;
  210. white-space: nowrap;
  211. text-overflow: ellipsis;
  212. }
  213. img {
  214. width: 48rpx;
  215. height: 48rpx;
  216. }
  217. }
  218. .search {
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. width: 538rpx;
  223. height: 80rpx;
  224. opacity: 1;
  225. border-radius: 70px;
  226. background-color: #fff;
  227. .add {
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. margin-left: 10rpx;
  232. width: 60rpx;
  233. font-size: 50rpx;
  234. height: 60rpx;
  235. line-height: 60rpx;
  236. color: rgba(30, 125, 251, 1);
  237. .img {
  238. width: 30rpx;
  239. height: 30rpx;
  240. }
  241. }
  242. .inp {
  243. height: 60rpx;
  244. line-height: 60rpx;
  245. flex-grow: 1;
  246. font-size: 28rpx;
  247. }
  248. .btnSearch {
  249. width: 100rpx;
  250. text-align: center;
  251. margin-right: 10rpx;
  252. height: 60rpx;
  253. line-height: 60rpx;
  254. opacity: 1;
  255. font-size: 28rpx;
  256. font-weight: 400;
  257. height: 2rem;
  258. color: #096562;
  259. }
  260. }
  261. }
  262. .control {
  263. margin: 0 auto 20rpx;
  264. padding-bottom: 10rpx;
  265. width: 690rpx;
  266. height: 90rpx;
  267. border-radius: 8rpx;
  268. background-color: #fff;
  269. }
  270. .body {
  271. margin: auto;
  272. width: 690rpx;
  273. height: calc(100vh - 220rpx);
  274. .waterfall_item {
  275. overflow: hidden;
  276. margin-bottom: 20rpx;
  277. width: 335rpx;
  278. border-radius: 10rpx;
  279. background-color: #fff;
  280. .item_cover {
  281. width: 335rpx;
  282. height: 463rpx;
  283. border: 10rpx 10rpx 0 0;
  284. }
  285. .item_desc {
  286. padding: 0 22rpx;
  287. font-size: 28rpx;
  288. font-weight: bold;
  289. }
  290. .item_info {
  291. padding: 15rpx 22rpx;
  292. display: flex;
  293. align-items: center;
  294. color: #666666;
  295. font-size: 20rpx;
  296. img {
  297. width: 30rpx;
  298. height: 30rpx;
  299. border-radius: 50%;
  300. }
  301. .text {
  302. margin-left: 12rpx;
  303. width: 150rpx;
  304. overflow: hidden;
  305. text-overflow: ellipsis;
  306. white-space: nowrap;
  307. }
  308. .img {
  309. margin-left: auto;
  310. }
  311. .count {
  312. margin-left: 5rpx;
  313. }
  314. }
  315. }
  316. }
  317. .noData {
  318. display: flex;
  319. flex-direction: column;
  320. justify-content: center;
  321. align-items: center;
  322. padding-bottom: 65rpx;
  323. img {
  324. margin-top: 80rpx;
  325. width: 600rpx;
  326. height: 600rpx;
  327. }
  328. }
  329. }
  330. </style>