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

540 lines
12 KiB

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