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

567 lines
12 KiB

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