兼兼街租房小程序
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.

624 lines
14 KiB

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