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

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