兼兼街租房小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

627 lines
13 KiB

  1. <template>
  2. <view class="container">
  3. <!-- 吸顶搜索地址栏 -->
  4. <u-sticky bg-color="#fff">
  5. <view class="sticky">
  6. <view class="city">
  7. 长沙
  8. </view>
  9. <view class="search_btn">
  10. <u-search placeholder="请输入您要搜索的城市" v-model="keyword" @search="toSearch" @focus="toSearch"></u-search>
  11. </view>
  12. </view>
  13. </u-sticky>
  14. <!-- </view> -->
  15. <view class="ant-banner-box">
  16. <!-- banner 部分 -->
  17. <swiper class="swiper " circular indicator-dots autoplay :interval="2000" :duration="500"
  18. indicator-active-color="#00a0ff">
  19. <swiper-item v-for="(bannerItem,index) in bannerList" class="ant-title" :key="index" @click="toItem(index)">
  20. <view class="">
  21. <image :src="bannerItem.image" mode=""></image>
  22. </view>
  23. </swiper-item>
  24. </swiper>
  25. </view>
  26. <view class="card_box">
  27. <view class="ant-menu-card">
  28. <view class="ant-flex-line">
  29. <view class="ant-icon-menu">
  30. <view class="ant-icon">
  31. <image :src="image"></image>
  32. </view>
  33. <view class="ant-text">整租</view>
  34. </view>
  35. <view class="ant-icon-menu">
  36. <view class="ant-icon">
  37. <image :src="image"></image>
  38. </view>
  39. <view class="ant-text">新房源</view>
  40. </view>
  41. <view class="ant-icon-menu">
  42. <view class="ant-icon">
  43. <image :src="image"></image>
  44. </view>
  45. <view class="ant-text">合租</view>
  46. </view>
  47. <view class="ant-icon-menu">
  48. <view class="ant-icon">
  49. <image :src="image"></image>
  50. </view>
  51. <view class="ant-text">转租</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 滚动公告 -->
  57. <view class="notice" @click="toNotice">
  58. <u-notice-bar more-icon :speed="200" :list="noticeList"></u-notice-bar>
  59. </view>
  60. <view class="ant-content">
  61. <view class="ant-content-page">
  62. <view class="ant-flex-line">
  63. <view class="ant-page-title">好房源</view>
  64. <view class="ant-page-span">平台甄选</view>
  65. <view class="ant-page-span">品质保障</view>
  66. </view>
  67. <view class="ant-flex-line scroll-view_H_x">
  68. <scroll-view class="scroll-view_H" scroll-x="true" lower-threshold="51" @scrolltolower="scrollTolowerHotList">
  69. <view class="ant-page-image-item" v-for="(item,index) in hotList" @click="toHomeDetails(item.id)">
  70. <image class="ant-page-image-item" mode="aspectFill" :src="item.image ? item.image :image" />
  71. <view class="ant-img-tags">
  72. <!-- <view class="ant-tags-title">{{item.title}}</view> -->
  73. <view class="ant-tags-text">{{item.price}}元起{{item.image? '1':'2'}}</view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </view>
  79. <view class="ant-content-page">
  80. <view class="ant-flex-line ant-head-line" @click="test">
  81. <view class="ant-page-title">推荐房源</view>
  82. </view>
  83. <view class="ant-item-box" v-for="(item,index) in list" @click="toHomeDetails(item.id)">
  84. <view>
  85. <image class="ant-item-image" mode="aspectFill" :src="item.image? item.image : image" />
  86. </view>
  87. <view class="ant-item-content">
  88. <view class="ant-item-title">{{item.title}}</view>
  89. <view class="ant-item-span">{{spliceText(item.titleText,0,39)}}</view>
  90. <view class="ant-item-span">{{item.address}}</view>
  91. <view class="ant-item-span"><span>{{item.payType}}</span></view>
  92. <view class="ant-item-price">{{item.price}} <span>/</span></view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="content-end">
  98. <view class="line" />
  99. <view class="center">湖南瀚海黎明·技术支持</view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. image: "https://vrlab-image4.ljcdn.com/release/auto3dhd/eba09229a901cb5cba66fda38f281405/screenshot/1657677701_15/pc0_m7ks1AA5Y.jpg",
  108. bannerList: [],
  109. addressList: [],
  110. classList: [],
  111. hotList: [],
  112. list: [],
  113. noticeList: [],
  114. lock: true,
  115. size: 20,
  116. page: 1,
  117. total: null,
  118. is_pull: 1, // 1是下拉刷新 2是上拉加载
  119. scrollPage: 1, //横向滚动
  120. scrollSize: 20,
  121. scrollTotal: null,
  122. notice_id: '',
  123. }
  124. },
  125. onLoad() {
  126. this.getBannerList();
  127. this.getAddressList();
  128. this.getClassList();
  129. this.getHotList();
  130. this.getHouseListPage();
  131. this.getNiceInfo();
  132. // 让出导航栏和胶囊的位置
  133. },
  134. // 下拉刷新首页推荐房源
  135. onPullDownRefresh() {
  136. this.is_pull = 1;
  137. this.getHouseListPage()
  138. },
  139. // 上拉加载
  140. onReachBottom() {
  141. this.is_pull = 2;
  142. const page = this.page;
  143. const size = this.size;
  144. const total = this.total;
  145. // 写下限制重复发 以及最后一页
  146. if (page * size > total) {
  147. this.$functions.showToast('没有更多了')
  148. return;
  149. }
  150. this.getHouseListPage()
  151. },
  152. // 好房源 向右加载
  153. // 隐藏微信h5的标题栏
  154. onReady() {
  155. },
  156. methods: {
  157. toItem(index) {
  158. console.log(index)
  159. },
  160. toNotice(){
  161. // 跳转通知
  162. uni.navigateTo({
  163. url: '/pages/notice/notice?state='+ this.notice_id
  164. })
  165. },
  166. //获取轮播图
  167. getBannerList() {
  168. // this.getBannerList()
  169. this.$api.getBannerList().then(res => {
  170. this.bannerList = res.result;
  171. }).catch(err => {
  172. console.log(err, "错误信息")
  173. });
  174. },
  175. //获取地区
  176. getAddressList() {
  177. this.$api.getAddressList().then(res => {
  178. this.addressList = res.result;
  179. }).catch(err => {
  180. console.log(err, "错误信息")
  181. });
  182. },
  183. //获取分类
  184. getClassList() {
  185. this.$api.getClassList().then(res => {
  186. this.classList = res.result;
  187. }).catch(err => {
  188. console.log(err, "错误信息")
  189. });
  190. },
  191. // 向右滚动加载好房源
  192. scrollTolowerHotList() {
  193. // 是否已经是最后
  194. const scrollPage = this.scrollPage;
  195. const scrollSize = this.scrollSize;
  196. const scrollTotal = this.scrollTotal;
  197. if (scrollPage * scrollSize > scrollTotal) {
  198. this.$functions.showToast('没有更多了');
  199. return;
  200. }
  201. this.$functions.showLoading();
  202. this.getHotList();
  203. },
  204. //获取好房源
  205. getHotList() {
  206. this.$api.getHotList().then(res => {
  207. if (this.scrollTotal !== null) {
  208. this.scrollPage += 1;
  209. const hotList = this.hotList;
  210. this.hotList = hotList.concat(res.result.records);
  211. this.$functions.hideLoading();
  212. } else if (this.scrollTotal === null) {
  213. this.scrollSize = res.result.size;
  214. this.scrollTotal = res.result.total;
  215. this.hotList = res.result.records;
  216. }
  217. }).catch(err => {
  218. console.log(err, "错误信息")
  219. });
  220. // this.$request('/job-dev/house/applet/indexHotList',{},'GET', (res) => {
  221. // this.hotList = res.records;
  222. // console.log(res.records)
  223. // })
  224. },
  225. // 截断字
  226. spliceText(text, start_s, length_s) {
  227. const starts = start_s || 0;
  228. const lengths = length_s || 10;
  229. if (text.length < lengths) {
  230. return text;
  231. } else {
  232. return text.slice(starts, lengths) + "...";
  233. }
  234. },
  235. //请求接口获得后台列表数据信息 = 推荐房源
  236. getHouseListPage() {
  237. // 区分上拉加载和下拉刷新 is_pull 下拉 1 上拉 2
  238. const is_pull = this.is_pull;
  239. this.$functions.showLoading();
  240. this.$api.getHouseListPage().then(res => {
  241. // this.list = res.result;
  242. if (this.page === 1 || this.total == null || is_pull === 1) {
  243. this.total = res.result.total;
  244. this.size = res.result.size;
  245. }
  246. console.log(is_pull)
  247. if (is_pull === 1) {
  248. // 下拉
  249. console.log(123132)
  250. this.page = 1;
  251. this.list = res.result.records;
  252. // 停止下拉
  253. uni.stopPullDownRefresh();
  254. } else {
  255. // 加载
  256. this.page += 1;
  257. this.list = this.list.concat(res.result.records);
  258. }
  259. this.$functions.hideLoading();
  260. }).catch(err => {
  261. this.$functions.hideLoading();
  262. console.log(err, "错误信息")
  263. });
  264. // this.$request('/job-dev/house/applet/indexListPage',{},'GET', (res) => {
  265. // this.list = res.records;
  266. // console.log(res.records)
  267. // })
  268. },
  269. // 下拉刷新 首页推荐房源分页下拉加载,上拉刷新。如果加载完了提示 没有更多了
  270. getNiceInfo() {
  271. this.$api.getNiceInfo().then(res => {
  272. console.log(res, "tonggaos")
  273. this.noticeList.push(res.result[0].title);
  274. this.notice_id = res.result[0].id;
  275. }).catch(err => {
  276. console.log(err)
  277. })
  278. },
  279. // 跳转详情页
  280. toHomeDetails(id) {
  281. uni.navigateTo({
  282. url: '/pages/homeDetails/homeDetails?id=' + id
  283. })
  284. },
  285. // 跳转 搜索页面
  286. toSearch() {
  287. uni.navigateTo({
  288. url: '/pages/search/search'
  289. })
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .container {
  296. background-color: #FFF !important;
  297. // position: relative;
  298. }
  299. /deep/ .u-sticky {
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. height: 90rpx;
  304. border-bottom: 1px solid #aaa9a5;
  305. background-color: #fff;
  306. .sticky {
  307. display: flex;
  308. align-items: center;
  309. .city {
  310. padding-right: 20rpx;
  311. }
  312. }
  313. }
  314. .notice {
  315. width: 92%;
  316. margin: 0 30rpx;
  317. /deep/ .u-notice-bar {
  318. border-radius: 25rpx;
  319. }
  320. /deep/ .u-notice__content {
  321. height: 100%;
  322. }
  323. }
  324. .ant-float {
  325. // position: fixed;
  326. top: 60rpx;
  327. left: 24rpx;
  328. z-index: -2;
  329. .ant-select {
  330. width: 120rpx;
  331. padding: 10rpx 24rpx;
  332. color: #fff;
  333. font-weight: bolder;
  334. position: relative;
  335. }
  336. .ant-select::after {
  337. content: "";
  338. position: absolute;
  339. top: 8rpx;
  340. right: 55rpx;
  341. width: 12rpx;
  342. height: 12rpx;
  343. border-bottom: 2rpx solid #FFF;
  344. border-right: 2rpx solid #FFF;
  345. transform: rotate(45deg);
  346. }
  347. .ant-input {
  348. height: 48rpx;
  349. min-width: 460rpx;
  350. line-height: 48rpx;
  351. background: rgba(255, 255, 255, .4);
  352. border-radius: 8rpx;
  353. padding: 6rpx 24rpx;
  354. color: #333;
  355. font-size: 20rpx;
  356. }
  357. .ant-input::placeholder {
  358. color: #FFF;
  359. font-size: 20rpx;
  360. }
  361. }
  362. .ant-banner-box {
  363. top: 0;
  364. z-index: -3;
  365. background-color: #FFF;
  366. width: 100%;
  367. .swiper {
  368. width: 100%;
  369. height: 500rpx;
  370. image {
  371. width: 100%;
  372. height: 500rpx;
  373. border-bottom-left-radius: 100rpx;
  374. border-bottom-right-radius: 100rpx;
  375. }
  376. }
  377. .ant-banner {
  378. width: 100vw;
  379. height: 500rpx;
  380. border-bottom-left-radius: 100rpx;
  381. border-bottom-right-radius: 100rpx;
  382. }
  383. .ant-title {
  384. color: #FFF;
  385. font-size: 42rpx;
  386. font-weight: bolder;
  387. text-align: center;
  388. position: absolute;
  389. // top: 45%;
  390. width: 100%;
  391. line-height: 50rpx;
  392. }
  393. }
  394. .card_box {
  395. // position: absolute;
  396. display: flex;
  397. justify-content: center;
  398. width: 100%;
  399. margin: 24rpx 0;
  400. height: 210rpx;
  401. .ant-menu-card {
  402. // position: absolute;
  403. // top: -40rpx;
  404. z-index: 1;
  405. margin: 0 24rpx;
  406. width: calc(100vw - 96rpx);
  407. background-color: #FFF;
  408. border-radius: 16rpx;
  409. min-height: 100rpx;
  410. padding: 24rpx;
  411. box-shadow: 10rpx 10rpx 20rpx rgba(134, 136, 136, 0.2);
  412. .ant-icon-menu {
  413. width: 150rpx;
  414. flex: 1;
  415. .ant-icon {
  416. width: 80rpx;
  417. height: 80rpx;
  418. margin: 8rpx auto;
  419. border-radius: 50%;
  420. // border: 1rpx dashed red;
  421. image {
  422. width: 80rpx;
  423. height: 80rpx;
  424. border-radius: 50%;
  425. }
  426. }
  427. .ant-text {
  428. width: 100%;
  429. font-size: 22rpx;
  430. color: #222;
  431. font-weight: bold;
  432. line-height: 40rpx;
  433. text-align: center;
  434. }
  435. }
  436. }
  437. }
  438. .ant-content {
  439. margin-top: 24rpx;
  440. padding: 48rpx 24rpx 20rpx;
  441. width: calc(100vw - 48rpx);
  442. overflow: hidden;
  443. .ant-content-page {
  444. border-radius: 16rpx;
  445. min-height: 100rpx;
  446. // padding: 24rpx 0;
  447. margin-bottom: 24rpx;
  448. .scroll-view_H {
  449. // width: 100%;
  450. white-space: nowrap;
  451. width: 100%;
  452. height: 300rpx;
  453. }
  454. .ant-page-title {
  455. color: #000;
  456. font-size: 32rpx;
  457. font-weight: bolder;
  458. line-height: 62rpx;
  459. width: 140rpx;
  460. }
  461. .ant-head-line {
  462. width: 100%;
  463. border-bottom: 1rpx solid #ccc;
  464. margin-bottom: 20rpx;
  465. }
  466. .ant-page-span {
  467. color: #aaa;
  468. font-size: 20rpx;
  469. margin-right: 10rpx;
  470. }
  471. .ant-page-image-item {
  472. display: inline-block;
  473. border-radius: 4rpx;
  474. width: 240rpx;
  475. height: 300rpx;
  476. margin: 0 10rpx 0 0;
  477. flex-shrink: 0;
  478. position: relative;
  479. .ant-img-tags {
  480. background-color: rgba(255, 255, 255, .8);
  481. width: calc(240rpx - 36rpx);
  482. height: 50rpx;
  483. position: absolute;
  484. bottom: 8rpx;
  485. left: 8rpx;
  486. padding: 20rpx 10rpx;
  487. border-radius: 4rpx;
  488. .ant-tags-title {
  489. line-height: 30rpx;
  490. color: #000;
  491. font-size: 24rpx;
  492. }
  493. .ant-tags-text {
  494. font-size: 18rpx;
  495. color: #888;
  496. line-height: 40rpx;
  497. }
  498. }
  499. }
  500. }
  501. }
  502. .ant-item-box {
  503. display: flex;
  504. min-height: 80rpx;
  505. margin-bottom: 20rpx;
  506. .ant-item-image {
  507. width: 200rpx;
  508. height: 200rpx;
  509. border-radius: 4rpx;
  510. }
  511. .ant-item-content {
  512. color: #888;
  513. font-size: 28rpx;
  514. line-height: 42rpx;
  515. padding: 0 20rpx;
  516. .ant-item-title {
  517. color: #000;
  518. font-weight: bold;
  519. font-size: 32rpx;
  520. }
  521. .ant-item-span {
  522. color: #888;
  523. line-height: 40rpx;
  524. font-size: 24rpx;
  525. span {
  526. margin-right: 20rpx;
  527. font-size: 18rpx;
  528. background-color: #eee;
  529. padding: 5rpx 8rpx;
  530. border-radius: 4rpx;
  531. }
  532. }
  533. .ant-item-price {
  534. color: #4996f5;
  535. line-height: 48rpx;
  536. font-size: 34rpx;
  537. font-weight: bolder;
  538. span {
  539. line-height: 42rpx;
  540. font-size: 22rpx;
  541. font-weight: normal;
  542. margin-left: 10rpx
  543. }
  544. }
  545. }
  546. }
  547. </style>