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

367 lines
11 KiB

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