租房小程序前端代码
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.

381 lines
11 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
5 months ago
5 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
5 months ago
5 months ago
9 months ago
6 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <view>
  3. <view class="se-px-40 se-py-20" style="background-color: #1EC77A;">
  4. <view class="se-bgc-white se-br-50 se-c-black se-px-20 se-py-5 se-flex se-flex-ai-c se-fs-26">
  5. <view class="location-container se-b-r se-pl-10 se-pr-20 se-flex se-flex-h se-h-40 se-lh-40" @click="handleAreaChange()">
  6. <text class="location-text se-pr-20">{{city?city:'未知'}}</text>
  7. <!-- <uv-icon name="arrow-down-fill"></uv-icon> -->
  8. </view>
  9. <view class="search-container se-flex-1 se-ml-20">
  10. <uv-search :disabled="true" @click="onSearch()" :showAction="false" bgColor="transparent" placeholder="请输入租房信息" v-model="keyword"></uv-search>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- backdrop -->
  15. <view class=" se-mb-20">
  16. <uv-swiper height="300rpx"
  17. keyName="image"
  18. :list="bannerList"></uv-swiper>
  19. <!-- <image class="se-w-vw-100 se-h-400" src="@/static/image/banner.png" mode=""></image> -->
  20. </view>
  21. <!-- se-mt-300 -->
  22. <view class="se-grid se-bgc-white se-py-30">
  23. <!-- <navigator url="/pages_subpack/category/index" v-for="(item, index) in nav" :key="index" class="se-flex-v-c se-mb-20">
  24. <image class="se-a-100 se-br-20" :src="item.img" mode=""></image>
  25. <text class="se-w-150 se-h-60 se-lh-30 se-c-black se-fs-22 se-ta-c se-mt-10 se-toe-2">{{item.name}}</text>
  26. </navigator> -->
  27. <navigator :url="item.url+`?id=`+item.id+`&title=`+item.title" v-for="(item, index) in nav" :key="index" class="se-flex-v-c se-mb-20">
  28. <image class="se-a-100 se-br-20" :src="item.image" mode=""></image>
  29. <text class="se-w-150 se-h-60 se-lh-30 se-c-black se-fs-22 se-ta-c se-mt-10 se-toe-2">{{item.title}}</text>
  30. </navigator>
  31. </view>
  32. <view class="se-mt-20 se-bgc-white se-px-20 se-py-10 se-ta-l se-c-orange se-flex se-flex-ai-c se-fs-24" @click="toNotice">
  33. <image class="se-a-80" src="@/static/image/aed60x.png" mode=""></image>
  34. <text class="se-ml-10">{{noticeObj.title}}</text>
  35. </view>
  36. <view class="se-bgc-white se-my-20">
  37. <uv-tabs @click="onClickHouseType" :list="houseTypeList" keyName="title" :activeStyle="{color:'#000000'}" :inactiveStyle="{color:'#666666'}" :lineColor="`url(${lineBg}) 100% 100%`"></uv-tabs>
  38. </view>
  39. <!-- <view class="se-pb-200">
  40. <view v-if="list.length>0">
  41. <view @click="onDetail(item)" class="se-my-10 se-mx-20 se-px-20 se-py-20 se-br-20 se-bgc-white se-flex" v-for="(item,index) in list" :key="index">
  42. <view class="se-pos se-w-260 se-h-180">
  43. <image v-if="item.iconImage" class="se-a-80 se-pos-lt" :src="item.iconImage" mode=""></image>
  44. <image class="se-w-260 se-h-180 se-br-10" :src="item.images[0]" mode=""></image>
  45. </view>
  46. <view class="se-pl-10 se-w-p-100">
  47. <view class="se-c-black se-fs-28">
  48. {{item.title}}
  49. </view>
  50. <view class="se-flex se-flex-h-sb se-flex-ai-c se-fs-24 se-mt-10 se-c-66">
  51. <text>{{item.homeType}}</text>
  52. <text>{{item.timeGo}}</text>
  53. </view>
  54. <view class="se-flex se-flex-h-sb se-flex-ai-c se-mt-10">
  55. <template v-if="item.iconTitles.length>0">
  56. <view class="se-flex">
  57. <view class="se-display-ib se-c-white se-bgc-orange se-fs-22 se-br-8 se-px-10 se-py-5 se-mr-10" v-for="(items,indexs) in item.iconTitles" :key="indexs">
  58. {{items}}
  59. </view>
  60. </view>
  61. </template>
  62. <template v-else><view></view></template>
  63. <view class="se-c-66 se-flex se-flex-ai-c">
  64. <uv-icon name="eye"></uv-icon>
  65. <text class="se-ml-5 se-fs-18">{{item.num}}</text>
  66. </view>
  67. </view>
  68. <view class="se-flex se-flex-h-sb se-flex-ai-c se-mt-10">
  69. <text class="se-c-red se-fs-24 se-fw-6 se-toe-1">{{item.price}}/{{item.unit}}</text>
  70. <text class="se-c-66 se-fs-22 se-toe-1">{{item.address}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view v-else>
  76. <uv-empty mode="list" ></uv-empty>
  77. </view>
  78. </view> -->
  79. <homeList :list="list" />
  80. <!-- 发布房源 -->
  81. <view class="se-pos-fixed se-pos-rc" style="right: 30rpx;top: 70vh;">
  82. <image @click="onNavigator()" class="se-a-150" src="@/static/image/discover.png" mode=""></image>
  83. </view>
  84. <!-- 地址 -->
  85. <citySelect ref="citySelectRef" :zIndex="0" @city-change="handleCityChange"></citySelect>
  86. </view>
  87. </template>
  88. <script>
  89. import { housePageList,houseType,noticeObjApi,getConfig,commonIndexIndexIcon, getInfo, getBanner } from "@/common/api.js"
  90. import citySelect from "@/components/cityselect/index.vue"
  91. const lineBg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAANCAYAAAC3mX7tAAAAAXNSR0IArs4c6QAAAbxJREFUOE+lk0FrE1EUhc+ZDOhMigjZdNcWdCPJqNCdlkZw4TKL2mVwkKLQ/gAFRcEu/AEKuumDrEopNEsXSlNoV+2iTYIbBdNdNwGpmRmFyVx5oQk6mYSpvt1799z7zTnvDQPlBAJcRGxZOLXotn7Gz8ftZePaROCZP+IaEh36a04LxFS8mMmgcKFcb54H9Kvi5LtdNIZ6BMf0lVMDMD88UJ7abuP1eUDeWuEZyVcJPZ/oKeclgRcJxRMrG17l4udOGthZbF8ATMb1IvKcXiU/y66xnziM2LQf1O+nAfnq+hYgpSStCeMmdcFXzi6AWyMGrlvZcGmUs54T31QQLIzo37Pd+u0eKFD5osDYHvPlJyLyNopYnbgUtrSuc2pOG4aUSC4nxTWYFXHOfni02wPp5anCO4KP0sSUViOQ91m38VjrByDZLprBt/ZHkAkvMO3oP3QiO9ZM7i7v1MK/QHoj6sblQLrV/4ZpCDMluoff++iBo/6Bdua32m/+NUYdlz2dW+k7GQnqF84eyOqY1xjPcw8Rn+iLTwp6yFFcpP8zhLxHsgjBFRrI9WKO0AbxVURqMOVDttw8GHeTvwFKoZ4cmcUYJAAAAABJRU5ErkJggg==";
  92. import QQMapWX from "@/util/qqmap-wx-jssdk.min.js"
  93. import homeList from '@/components/home/homeList.vue'
  94. export default{
  95. components:{
  96. citySelect,
  97. homeList,
  98. },
  99. data(){
  100. return{
  101. city:"",
  102. keyword:"",
  103. lineBg: lineBg,
  104. bannerList:[
  105. {
  106. image : "https://image.hhlm1688.com/2025-08-05/b9b3d015-fcaf-4667-8946-ad9436503a25.jpg"
  107. }
  108. ],
  109. nav:[],
  110. noticeObj:{},
  111. houseTypeList:[],
  112. classId:null,
  113. pageNo:1,
  114. pageSize:10,
  115. list:[]
  116. }
  117. },
  118. onShareAppMessage() {
  119. let share = {
  120. title:this.$utils.getkeyContent('logo_name').keyContent,
  121. path:"/pages/home/index?userId="+uni.getStorageSync('userInfo').id,
  122. success:(res) => {
  123. console.info(res)
  124. },
  125. fail:(err)=>{
  126. console.info(err)
  127. }
  128. }
  129. console.info(share)
  130. return share
  131. },
  132. onLoad(options) {
  133. //#ifdef MP-WEIXIN
  134. wx.showShareMenu({
  135. withShareTicket: true,
  136. menus: ['shareAppMessage', 'shareTimeline']
  137. });
  138. //#endif
  139. if(options.userId){
  140. uni.setStorageSync('userId',options.userId)
  141. }
  142. uni.chooseAddress({
  143. success(res) {
  144. console.info(res)
  145. }
  146. })
  147. this.getLocation()
  148. this.onCommonIndexIndexIcon()
  149. this.onNotice();
  150. this.onHousePageList();
  151. this.onHouseType();
  152. this.getBanner();
  153. // this.onGetConfig()
  154. },
  155. onPullDownRefresh() {
  156. let that = this
  157. that.pageNo = 1
  158. that.list = []
  159. that.onHousePageList()
  160. },
  161. onReachBottom() {
  162. let that = this
  163. that.pageNo = that.pageNo + 1
  164. that.onHousePageList()
  165. },
  166. methods:{
  167. getLocation(){
  168. const that = this;
  169. wx.getLocation({
  170. type: 'wgs84',
  171. success: function (res) {
  172. console.log('当前位置的经度:' + res.longitude);
  173. console.log('当前位置的纬度:' + res.latitude);
  174. const qqmapsdk = new QQMapWX({
  175. key: 'TT7BZ-Z3LW4-KOAUB-KWHOA-SBJJ6-Y5B6R' // 必填
  176. });
  177. qqmapsdk.reverseGeocoder({
  178. location: {
  179. latitude: res.latitude,
  180. longitude: res.longitude
  181. },
  182. success: function(response) {
  183. that.city = response.result.ad_info.city
  184. console.log('逆地理编码结果:', response);
  185. },
  186. fail: function(error) {
  187. console.error('逆地理编码失败:', error);
  188. }
  189. });
  190. }
  191. })
  192. },
  193. getBanner(){
  194. getBanner()
  195. .then(res => {
  196. this.bannerList = res.result.records
  197. })
  198. },
  199. onNavigator(){
  200. let token = uni.getStorageSync('token');
  201. if(!token){
  202. uni.navigateTo({
  203. url:"/pages/auth/index"
  204. })
  205. return ;
  206. }
  207. getInfo({}).then(result=>{
  208. uni.navigateTo({
  209. // url:"/pages_subpack/house/index"
  210. url:"/pages_subpack/house/select"
  211. })
  212. }).catch(err=>{
  213. })
  214. },
  215. onCommonIndexIndexIcon(){
  216. let that = this
  217. commonIndexIndexIcon({}).then(response=>{
  218. console.info('onCommonIndexIndexIcon',response)
  219. that.nav = response.result
  220. // 检查是否已存在地图导览入口
  221. let hasMapGuide = that.nav.some(item => item.url === '/pages_subpack/tourGuide/tourGuide')
  222. if(!hasMapGuide) {
  223. // 添加地图导览入口
  224. // that.nav.push({
  225. // id: 'map_guide',
  226. // title: '地图导览',
  227. // image: 'https://tennis-oss.xzaiyp.top/2024-12-08/9704d4a0-e8d8-40fc-a2b6-28b928013a60.png',
  228. // url: '/pages/tourGuide/tourGuide'
  229. // })
  230. }
  231. }).catch(error=>{
  232. })
  233. },
  234. onSearch(){
  235. uni.navigateTo({
  236. url:"/pages_subpack/category/index"
  237. })
  238. },
  239. onLogin(){
  240. console.info("onLogin")
  241. uni.navigateTo({
  242. url:"/pages/auth/index"
  243. })
  244. },
  245. onNotice(){
  246. noticeObjApi({}).then(response=>{
  247. console.info('noticeObj',response)
  248. this.noticeObj = response.result
  249. }).catch(error=>{
  250. })
  251. },
  252. onHouseType(){
  253. houseType({}).then(response=>{
  254. console.info('houseType',response)
  255. this.houseTypeList = response.result
  256. }).catch(error=>{
  257. })
  258. },
  259. onClickHouseType(event){
  260. console.info(event)
  261. let that = this
  262. that.pageNo = 1
  263. that.classId = event.id
  264. that.list =[]
  265. that.onHousePageList()
  266. },
  267. onHousePageList(){
  268. let that = this
  269. let params={
  270. classId:that.classId,
  271. pageNo:that.pageNo,
  272. pageSize:that.pageSize
  273. }
  274. housePageList(params).then((response) => {
  275. uni.stopPullDownRefresh()
  276. console.info("responseindexsindexsindexs",response.result.records)
  277. response.result.records.forEach((items,indexs)=>{
  278. if(items.image){
  279. items.images = items.image.split(',')
  280. }else{
  281. items.images = []
  282. }
  283. if(items.homeImage){
  284. items.homeImages = items.homeImage.split(',')
  285. }else{
  286. items.homeImages = []
  287. }
  288. if(items.iconTitle){
  289. items.iconTitles = items.iconTitle.split(',')
  290. }else{
  291. items.iconTitles = []
  292. }
  293. })
  294. console.info('response.resultindexsindexsindexs',response.result.records)
  295. that.list = that.list.concat(response.result.records)
  296. }).catch((error) =>{
  297. })
  298. },
  299. handleAreaChange(){
  300. // uni.chooseAddress({
  301. // success(res) {
  302. // console.info(res)
  303. // }
  304. // })
  305. uni.navigateTo({
  306. url:"/pages_subpack/tourGuide/tourGuide"
  307. })
  308. // this.$refs.citySelectRef.open()
  309. },
  310. handleCityChange(e) {
  311. console.info(e)
  312. this.city = e.city.label
  313. // this.form.area = e.province.label + '-' + e.city.label + '-' + e.area.label;
  314. },
  315. onDetail(event){
  316. uni.navigateTo({
  317. url:"/pages_subpack/detail/index?id="+event.id
  318. })
  319. },
  320. toNotice(){
  321. uni.navigateTo({
  322. url:"/pages_subpack/notice/index"
  323. })
  324. }
  325. }
  326. }
  327. </script>
  328. <style>
  329. page{
  330. background-color: #f5f5f5;
  331. }
  332. .se-grid{
  333. border-top-right-radius: 50rpx;
  334. border-top-left-radius: 50rpx;
  335. }
  336. .backdrop{
  337. width: 750rpx;
  338. height: 350rpx;
  339. position: absolute;
  340. top: 0;
  341. left: 0;
  342. z-index: -1;
  343. /* border-radius: 0 0 14% 14%; */
  344. }
  345. .nobreak {
  346. white-space: nowrap;
  347. }
  348. /* 位置显示优化 */
  349. .location-container {
  350. min-width: 0;
  351. max-width: 200rpx;
  352. flex-shrink: 0;
  353. }
  354. .location-text {
  355. white-space: nowrap;
  356. overflow: hidden;
  357. text-overflow: ellipsis;
  358. max-width: 140rpx;
  359. display: inline-block;
  360. }
  361. .search-container {
  362. min-width: 0;
  363. }
  364. </style>