diff --git a/img/map-icon.png b/img/map-icon.png new file mode 100644 index 0000000..e67ed4a Binary files /dev/null and b/img/map-icon.png differ diff --git a/pages/common/common.wxml b/pages/common/common.wxml index 911cdbe..0013d81 100644 --- a/pages/common/common.wxml +++ b/pages/common/common.wxml @@ -470,4 +470,20 @@ + + + + \ No newline at end of file diff --git a/pages/common/common.wxss b/pages/common/common.wxss index 381df68..441c62e 100644 --- a/pages/common/common.wxss +++ b/pages/common/common.wxss @@ -609,4 +609,73 @@ color: #555555; font-size: 27rpx; margin-bottom: 24rpx; +} + +.header-search { + padding: 20rpx 30rpx 48rpx; + font-size: 0; +} + +.header-search form { + background: #fff; + width: 588rpx; + height: 84rpx; + padding: 0 30rpx; + box-sizing: border-box; + vertical-align: middle; + color: #333; + position: relative; + border-radius: 306rpx; + box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.0784313725490196); +} + +.header-search .search-icon { + width: 30rpx; + height: 30rpx; + vertical-align: sub; +} + +.header-search input { + display: inline-flex; + height: 84rpx; + font-size: 28rpx; + padding: 0 10rpx; + box-sizing: border-box; + background-color: #fff; + text-align: left; +} + +.header-search .clear { + position: absolute; + right: 0; + top: 50%; + padding: 30rpx; + transform: translateY(-50%); +} + +.header-search .clear .clear-icon { + width: 30rpx; + height: 30rpx; +} + +.header-search navigator { + font-size: 30rpx; + display: inline-block; + width: 80rpx; + text-align: right; + vertical-align: middle; +} + +.header-search .map-btn { + width: 84rpx; + height: 84rpx; + border-radius: 232.5rpx; + background-color: #fff; + box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.0784313725490196); + margin-left: 19.5rpx; +} + +.header-search .map-btn .map-btn-icon { + width: 42rpx; + height: 42rpx; } \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 6c48d63..fc2afea 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -228,18 +228,9 @@ Page({ wx.navigateTo({ url, }) - }, - // 新 轮播图 自动滑动事件,修改下标 - bindchangeSwiper(e) { - let current = e.detail.current - this.setData({ - swiperCurrent: current - }) - }, - - // 新 轮播图 点击事件 + // 新 瀑布流 点击事件 handleSwiper(e) { let { appid, @@ -252,13 +243,12 @@ Page({ advtype, } = e.currentTarget.dataset - let requestUrl = advertisingtype == 'lazyloading' ? `${app.globalData.baseURL}/tenement/v2/api/ad/click` : app.globalData.config.FormidInsert + let requestUrl = `${app.globalData.baseURL}/tenement/v2/api/ad/click` miucms.request(requestUrl, { statid }).then(res => {}) // 跳转视频号 - console.log(type,advtype); if ((type == 5) || (type == 'adv' && advtype == "videofeed_5")) { wx.openChannelsActivity({ finderUserName: finderusername, @@ -644,20 +634,5 @@ Page({ } }, - // 轮播图的加载事件 - loadHeadSwiper(e) { - let ratio = app.globalData.screen_data['windowWidth'] / 750 - let originalWidth = e.detail.width; - let originalHeight = e.detail.height; - let height = originalHeight / originalWidth * 690 * ratio - - if (height > this.data.HeadSwiperHeight) { - this.setData({ - HeadSwiperHeight: height - }) - } - - - }, }) \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json index 51f7442..7175646 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -1,14 +1,15 @@ { - "navigationBarTitleText": "寄托租房", - "enablePullDownRefresh": false, - "usingComponents": { - "header-nav": "../../template/headerNav/index", - "filtrate-box": "../../template/filtrate/filtrate", - "go-login": "../../template/goLogin/goLogin", - "head-swiper": "../../template/headSwiper/headSwiper", - "form-id": "../../template/formId/formId", - "fix-footer": "../../template/fixFooter/fixFooter", - "announcement-popup": "../../template/announcementPopup/announcementPopup", - "to-top": "/template/toTop/toTop" - } + "navigationBarTitleText": "寄托租房", + "enablePullDownRefresh": false, + "usingComponents": { + "header-nav": "../../template/headerNav/index", + "filtrate-box": "../../template/filtrate/filtrate", + "go-login": "../../template/goLogin/goLogin", + "head-swiper": "../../template/headSwiper/headSwiper", + "xin-head-swiper": "/template/xinHeadSwiper/xinHeadSwiper", + "form-id": "../../template/formId/formId", + "fix-footer": "../../template/fixFooter/fixFooter", + "announcement-popup": "../../template/announcementPopup/announcementPopup", + "to-top": "/template/toTop/toTop" + } } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index a18f49a..ee0c00c 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -25,21 +25,11 @@ - - - - - - - - - - - - - - + + + + @@ -211,7 +201,7 @@ - + @@ -271,7 +261,7 @@ diff --git a/pages/index/index.wxss b/pages/index/index.wxss index b3670da..698cca6 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -986,56 +986,12 @@ page { background-color: #fff; } -.headSwiper-swiper { - position: relative; -} - -.headSwiper { - width: 690rpx; - margin: 32rpx auto 30rpx; - position: relative; - border-radius: 20rpx; -} - -.headSwiper .headSwiper-img { - width: 690rpx; - height: 292.5rpx; - border-radius: 20rpx; -} - -.headSwiper .indication-point { - position: absolute; - bottom: 20rpx; - right: 15rpx; - height: 18rpx; - border-radius: 45rpx; - background-color: rgba(255, 255, 255, 0.501960784313725); - padding: 0 9rpx; -} - -.headSwiper .indication-point .indication-point-item { - width: 12rpx; - height: 12rpx; - border-radius: 50%; - border: 1rpx solid #aaaaaa; - background-color: transparent; -} - -.headSwiper .indication-point .indication-point-item:not(:last-of-type) { - margin-right: 4rpx; -} - -.headSwiper .indication-point .indication-point-item.pitch { - border: none; - background-color: #000000; -} - .search-box { width: 690rpx; height: 72rpx; border-radius: 345rpx; border: 1rpx solid rgba(235, 235, 235, 1); - margin: 12rpx auto 0; + margin: 12rpx auto 32rpx; background-color: #fff; } diff --git a/pages/personList/personList.js b/pages/personList/personList.js index 7e572a8..49e8d0e 100644 --- a/pages/personList/personList.js +++ b/pages/personList/personList.js @@ -120,10 +120,22 @@ Page({ initState: false, langs: {}, // 语言包数据 - isNewVersions: false, + operationsTop: false, // 操作栏 是否在顶部 + + isNewVersions: true, }, onPageScroll(e) { + if (e.scrollTop > this.operationsHeight && !this.data.operationsTop) { + this.setData({ + operationsTop: true + }) + } else if (e.scrollTop <= this.operationsHeight && this.data.operationsTop) { + this.setData({ + operationsTop: false + }) + } + if (e.scrollTop > 1000 && !this.data.showTOTOP) { this.setData({ showTOTOP: true @@ -149,7 +161,6 @@ Page({ title: '加载中', }) - this.getDtailsLangs() // 先全局吧 let that = this; var location = []; @@ -194,8 +205,12 @@ Page({ StudentapartmentNew: app.globalData.StudentapartmentNew, listTab: app.globalData.listTab, initState: true, - isloding: false + isloding: false, + langs: app.globalData.langs, }) + + app.globalData['langs'] ? '' : this.getDtailsLangs() // 先全局吧 + this.getgroupSearch(); this.get_list(); this.getAd(); @@ -224,44 +239,50 @@ Page({ this.setData({ langs: data }) - console.log(this.data.langs); app.globalData['langs'] = data }) }, // 专门梳理v4出现的 语音包 及 不同房源值的处理 - handleDetailData(item) { - console.log("item", item); - let tabList = [] - + handleDetailData(data) { let langs = this.data.langs || {} if (Object.keys(langs).length == 0) { setTimeout(() => { - this.handleDetailData() + this.handleDetailData(data) }, 300) } else { + data.forEach(ele => { + // 这个是将 详情键 替换语言包里的值 + let list = ['type', 'rentalduration', 'intermediary', "property", "elevator", "sunshinearea", "gender"] + if (Array.isArray(ele['floor'])) list.push('floor') // 判断 楼层是否需要 替换值, 因为在求房源里是多个值 + let differentNames = { // 需要替换的 键名 + "intermediary": "intermediary_text" + } + list.forEach(element => { + if (ele[element] == -1) {} else if (ele[element] == 0) ele[differentNames[element] ? differentNames[element] : element] = '不限' // 当 值为 [0] 时为不限 + else ele[differentNames[element] ? differentNames[element] : element] = langs[element][ele[element]] + }) + let tabArr = ["gptype", "property", "elevator", "sunshinearea", "gender"] + let tabList = [] + tabArr.forEach(el => { + if (ele[el] && ele[el] != -1) tabList.push(ele[el]) + }) - let judgeArr = ['acreage', 'rent'] - judgeArr.forEach(element => { - if (Array.isArray(item[element])) item[element] = item[element][0] + ' ~ ' + item[element][1] + ele['tabList'] = tabList + + let location = langs.location // 遍历替换区域的值 所有房源 + let pendingData = ele['location'] + ele['location'] = `${location[Math.trunc(pendingData)]} > ${location[pendingData]}` }) - // 这个是将 详情键 替换语言包里的值 - let list = ['type', 'rentalduration', 'intermediary'] - if (Array.isArray(item['floor'])) list.push('floor') // 判断 楼层是否需要 替换值, 因为在求房源里是多个值 - let differentNames = { // 需要替换的 键名 - "intermediary": "intermediary_text" - } - list.forEach(element => { - if (item[element] == 0) item[differentNames[element] ? differentNames[element] : element] = '不限' // 当 值为 [0] 时为不限 - else item[differentNames[element] ? differentNames[element] : element] = langs[element][item[element]] + let lists = this.data.lists + lists = lists.concat(data) + this.setData({ + lists }) - let location = langs.location // 遍历替换区域的值 所有房源 - let pendingData = item['location'] - item['location'] = `${location[Math.trunc(pendingData)]} > ${location[pendingData]}` - return item + } }, @@ -445,6 +466,7 @@ Page({ 'type': this.data.types.value, location: that.data.location.value, school: that.data.school.value, + // school: 309, page: this.data.page, // intermediarytype: 2, intermediary: 0 @@ -463,16 +485,18 @@ Page({ } data = data.data if (isNewVersions) { - data.data.forEach(element => { - element = this.handleDetailData(element) + this.handleDetailData(data.data) + } + + if (!isNewVersions) { + that.data.lists = that.data.lists.concat(data.data) + this.setData({ + lists: that.data.lists, }) } - console.log("data123", data); - - that.data.lists = that.data.lists.concat(data.data) that.setData({ - lists: that.data.lists, + // lists: that.data.lists, page: data.page * data.limit >= data.count ? 0 : data.page + 1, user: data.user, loading: false, @@ -795,7 +819,6 @@ Page({ gender: obj.gender, leaseterm: obj.leaseterm, publish: obj.publish, - } this.setData({ selectGroupIndex: index, @@ -823,11 +846,11 @@ Page({ miucms.closeAD(e.detail.id) }, + // 新筛选 的 整合中转 submitOperations(e) { let { type } = e.detail - console.log(type); if (type == "rent") this.submitMoney(e) if (type == "orderby") this.submitOrderby(e) if (type == "types") this.submittype(e) @@ -835,4 +858,23 @@ Page({ }, + // 记录 轮播图的高度 // 随便计算 筛选的高度 + // 筛选到顶部的高度 + recordSwiperHeight(e) { + let swiperHeight = e.detail + let screen_data = this.data.screen_data + wx.createSelectorQuery().select("#list-operations").boundingClientRect((rect) => { + if (!rect) return + let top = rect.top - screen_data['totalTopHeight'] + this.operationsHeight = top + }).exec() + }, + + // 公共跳转 + publicJumps(e) { + let url = e.currentTarget.dataset.url + wx.navigateTo({ + url, + }) + }, }) \ No newline at end of file diff --git a/pages/personList/personList.json b/pages/personList/personList.json index 8e45d3c..17d2c29 100644 --- a/pages/personList/personList.json +++ b/pages/personList/personList.json @@ -16,6 +16,9 @@ "tab": "./tab/tab", "announcement-popup": "/template/announcementPopup/announcementPopup", "common-list": "/template/commonList/commonList", - "list-operations": "/template/listOperations/listOperations" - } + "list-operations": "/template/listOperations/listOperations", + "xin-head-swiper": "/template/xinHeadSwiper/xinHeadSwiper" + }, + "navigationBarTextStyle": "black" + } \ No newline at end of file diff --git a/pages/personList/personList.wxml b/pages/personList/personList.wxml index 4245b37..1725bcc 100644 --- a/pages/personList/personList.wxml +++ b/pages/personList/personList.wxml @@ -3,25 +3,35 @@ - {{ topTitle }} - - - - + + + {{ topTitle }} + + + + + + + {{ topTitle }} + + + + + - + {{ item['keyword'] }} - + - + - + @@ -53,10 +63,7 @@ - - - - + diff --git a/pages/personList/personList.wxss b/pages/personList/personList.wxss index 323af70..2d2530a 100644 --- a/pages/personList/personList.wxss +++ b/pages/personList/personList.wxss @@ -1,4 +1,6 @@ /**index.wxss**/ +@import '/pages/common/common.wxss'; + .bold { font-weight: bold } @@ -463,4 +465,34 @@ .list { /* background-color: rgba(246, 246, 246, 1); */ +} + +.new-list { + padding-top: 36rpx; + background-color: rgba(246, 246, 246, 1); + box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.156862745098039); + border-radius: 60rpx 60rpx 0 0; + margin-top: 8rpx; + min-height: 600rpx; +} + +.bj { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 900rpx; + background: linear-gradient(0deg, rgba(255, 255, 255, 1) 2%, rgba(176, 216, 255, 1) 115%); + z-index: -1; +} + +.list-operations { + position: sticky; + z-index: 1000; +} + +.list-operations.list-operations-top{ + background-color: #fff; + border-bottom: 1rpx solid #ebebeb; + } \ No newline at end of file diff --git a/pages/personList/tab/tab.js b/pages/personList/tab/tab.js index 2822e71..523de5d 100644 --- a/pages/personList/tab/tab.js +++ b/pages/personList/tab/tab.js @@ -7,13 +7,14 @@ Component({ StudentapartmentNew: Boolean, page: String, listTab: Object, + isNewVersions: Boolean }, /** * 组件的初始数据 */ data: { - isNewVersions: true, + // isNewVersions: true, tabList: [{ name: "个人房源", value: "personList", diff --git a/pages/personList/tab/tab.wxml b/pages/personList/tab/tab.wxml index 6651019..238112f 100644 --- a/pages/personList/tab/tab.wxml +++ b/pages/personList/tab/tab.wxml @@ -1,23 +1,23 @@ - - {{ item.name }} + + {{ item.name }} - - - 个人房源 - + + + 个人房源 + - - {{ '中介房源' }} - - - - 学生公寓 - - + + 学生公寓 + + \ No newline at end of file diff --git a/pages/personList/tab/tab.wxss b/pages/personList/tab/tab.wxss index 3584e38..5146c59 100644 --- a/pages/personList/tab/tab.wxss +++ b/pages/personList/tab/tab.wxss @@ -110,6 +110,7 @@ justify-content: space-between; font-size: 30rpx; color: #000000; + margin-bottom: 15rpx; } diff --git a/pages/search/search.js b/pages/search/search.js index e2589cd..3ab8029 100644 --- a/pages/search/search.js +++ b/pages/search/search.js @@ -3,427 +3,562 @@ var app = getApp() var config = {}; var miucms = require('../../utils/miucms.js'); Page({ - - /** - * 页面的初始数据 - */ - data: { - isloding: true, - showTOTOP: false, - kw: '', - log: [], - hot: [], - focus: false, - list: [], - search: false, - loading: false, - complete: false, - status: 0, - q: '', - options: {}, - tab: 'hongkongrental', - otherrental: { - page: { - next_page: 1 - }, - list: [], - loading: false - }, - hongkongrental: { - page: { - next_page: 1 - }, - list: [], - loading: false - }, - studentapartment: { - page: { - next_page: 1 - }, - list: [], - loading: false - } - }, - onPageScroll(e) { - if (e.scrollTop > 1000 && !this.data.showTOTOP) { - this.setData({ - showTOTOP: true - }) - } else if (e.scrollTop < 1000 && this.data.showTOTOP) { - this.setData({ - showTOTOP: false - }) - } - }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var that = this; - this.setData({ - focus: options.kw ? false : true, - kw: options.kw || '', - tab: options.tab || 'hongkongrental' - }) - this.get_config() - wx.getStorage({ - key: 'searchHistoryList', - success: function (res) { - that.setData({ - log: res.data || [] - }) - }, - }) - - }, - get_config() { - var that = this; - if (app.globalData.config.lists) { - config = app.globalData.config; - - that.setData({ - status: app.globalData.status - }) - that.get_content() - if (that.data.kw.trim().length > 0) { - that.submit() - } - } else { - setTimeout(function () { - that.get_config() - }, 200) - } - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - if (!app.globalData.config.lists) { - return false - } - this.getDatas() - }, - cancle() { - var pages = getCurrentPages(); - if (pages.length == 1) { - wx.reLaunch({ - url: `/pages/index/index` - }); - } else { - wx.navigateBack(); //返回上一页 - } - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - const that = this; - let url = `/pages/search/search?kw=${that.data.kw}&tab=${that.data.tab}`; - return { - path: url, - title: '寄托香港租房', - - } - }, - - input: function (e) { - this.setData({ - kw: e.detail.value - }) - }, - // 提交 - submit: function () { - // this.data.kw = this.data.kw.trim(); - if (this.data.kw == '') { - wx.showToast({ - title: '请输入内容~', - icon: 'none' - }) - return false - } - if (this.data.log.indexOf(this.data.kw) == -1) { - // 未存在历史记录列表中 - this.data.log.unshift(this.data.kw) - // 最多存10条内容 - if (this.data.log.length > 10) { - this.data.log.length = 10 - } - this.setData({ - log: this.data.log - }) - wx.setStorage({ - key: 'searchHistoryList', - data: this.data.log, - }) - } - this.clearAllData() - this.clear_list() - }, - // 清空历史记录 - clear_keywords: function () { - let that = this; - wx.showModal({ - title: '提示', - content: '确定删除全部记录?', - confirmColor: '#bc322f', - success: function (res) { - if (res.confirm === true) { - if (!app.globalData.config || !app.globalData.config.lists) { - return false - } - miucms.request(app.globalData.config.lists.removesearchlog, {}).then(data => { - - if (data.extraparam.mode == 'right') { - that.setData({ - log: [] - }) - wx.setStorage({ - key: 'searchHistoryList', - data: [], - }) - } - }) - - } - } - }) - - }, - // 获取热词 - get_content: function () { - var that = this; - var sendData = Object.assign({}, this.data.options, { - session: wx.getStorageSync('session'), - }) - miucms.request(app.globalData.config.lists.search, {}).then(data => { - that.setData({ - hot: data.hot, - isloding: false - }) - }).catch(res => {}) - - }, - // 点击热词或者历史记录item - select_kw: function (e) { - wx.pageScrollTo({ - scrollTop: 0, - duration: 200, - }) - var kw = e.currentTarget.dataset.kw; - this.setData({ - kw: kw - }) - this.clearAllData() - app.globalData.kw = kw; - this.clear_list() - }, - clearAllData() { - // 清空所有数据 - this.setData({ - otherrental: { - page: { - next_page: 1 - }, + /** + * 页面的初始数据 + */ + data: { + isloding: true, + showTOTOP: false, + kw: '', + log: [], + hot: [], + focus: false, list: [], - loading: false - }, - hongkongrental: { - page: { - next_page: 1 - }, - list: [], - loading: false - }, - studentapartment: { - page: { - next_page: 1 - }, - list: [], - loading: false - } - }) - }, - // 清空list - clear_list: function () { - let tab = this.data.tab; - this.data[tab] = { - page: { - next_page: 1 - }, - list: [], - loading: false - } - this.setTabData() - this.searchKW() - }, - // setData - setTabData() { - let tab = this.data.tab; - switch (tab) { - case 'otherrental': - this.setData({ - otherrental: this.data.otherrental - }) - break; - case 'studentapartment': - this.setData({ - studentapartment: this.data.studentapartment - }) - break; - case 'hongkongrental': - this.setData({ - hongkongrental: this.data.hongkongrental - }) - break; - } - }, - searchdata: '', - // 搜索关键词 - searchKW: function () { - var that = this; - if (!app.globalData.config.search) { - return false - } - this.setData({ - loading: true - }) - console.log("this.data.kw", this.data.kw); - miucms.request(app.globalData.config.search.global, { - // miucms.request(`${app.globalData.baseURL}/tenement/housingresources/lists`, { - 'keyword': this.data.kw - }).then(data => { - // console.log("data", data); - if (data.code != 200) { - wx.showToast({ - title: data.message, - icon: 'none' - }) - - that.setData({ - loading: false, - otherrental: { - page: { - next_page: 0 - }, - list: [], - loading: false - }, - hongkongrental: { - page: { - next_page: 0 - }, - list: [], - loading: false - }, - studentapartment: { - page: { - next_page: 0 - }, - list: [], - loading: false - } - }) - return false - } - let count = data.data.count; - this.searchdata = data.data.searchdata; - for (let i in data.data.count) { - if (data.data.count[i] == 0) { - this.data[i].page.next_page = 0; - } else { - this.data[i].page.next_page = 1; - } - } - this.setData({ - search: true, - otherrental: this.data.otherrental, - studentapartment: this.data.studentapartment, - hongkongrental: this.data.hongkongrental, + search: false, loading: false, - kw: data.data.keyword - }) - this.getDatas() - }).catch(res => {}) + complete: false, + status: 0, + q: '', + options: {}, + // tab: 'hongkongrental', + tab: 'personal', + tabList: { + personal: "个人房源", + intermediary: "中介房源", + studentapartment: "学生公寓", + }, + otherrental: { + page: { + next_page: 1 + }, + list: [], + loading: false + }, + hongkongrental: { + page: { + next_page: 1 + }, + list: [], + loading: false + }, + studentapartment: { + page: { + next_page: 1 + }, + list: [], + loading: false + }, + screen_data: {}, - }, - // 清空 - clearKW() { - this.setData({ - kw: '', - focus: true - }) - }, - // 更换tab - changeTab(e) { - this.setData({ - tab: e.currentTarget.dataset.tab - }) - let tab = this.data.tab; - if (!this.data[tab].page.next_page || this.data[tab].list.length > 0) { - // 如果当前tab下数量为0 ,则不再加载 - return false; - } - this.getKWdata() - }, - // 搜索相关tab关键词 - getDatas() { - let tab = this.data.tab; - if (!this.data[tab].page.next_page) { - // 如果当前tab下数量为0 ,则不再加载 - return false; - } - this.getKWdata() - }, - getKWdata() { + personal: { + data: [], + page: 1, + count: 0, + searchid: "" + }, + intermediary: { + data: [], + page: 1, + count: 0, + searchid: "" + }, + studentapartment: { + data: [], + page: 1, + count: 0, + searchid: "" + }, + langs: {}, // 语言包数据 - let urlObj = { - otherrental: app.globalData.config.search.otherrental, - // hongkongrental: app.globalData.config.search.hongkongrental, - hongkongrental: `${app.globalData.baseURL}/tenement/housingresources/lists`, - studentapartment: app.globalData.config.search.studentapartment, - } - let tab = this.data.tab; - let url = urlObj[tab]; - this.data[tab].loading = true; - this.setTabData() - miucms.request(url, { - 'searchdata': this.searchdata, - page: this.data[tab].page.next_page - }).then(data => { - // console.log(data); - this.data[tab].list = this.data[tab].list.concat(data.data.data); - this.data[tab].loading = false; + isNewVersions: true, - if (data.data.data.length > 0) { - this.data[tab].page.next_page += 1; - } else { - this.data[tab].page.next_page = 0; - } - this.setTabData() - }).catch(res => {}) - }, - // 点击广告 - clickAD(e) { - miucms.clickAD(e.detail.id) - }, - // 关闭广告 - closeAD(e) { - let index = e.currentTarget.dataset.index; - let tab = e.currentTarget.dataset.tab; + }, + onPageScroll(e) { + if (e.scrollTop > 1000 && !this.data.showTOTOP) { + this.setData({ + showTOTOP: true + }) + } else if (e.scrollTop < 1000 && this.data.showTOTOP) { + this.setData({ + showTOTOP: false + }) + } + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var that = this; + this.setData({ + focus: options.kw ? false : true, + kw: options.kw || '', + // tab: options.tab || 'hongkongrental' + tab: options.tab || 'personal' + }) + this.get_config() + wx.getStorage({ + key: 'searchHistoryList', + success: function (res) { + that.setData({ + log: res.data || [] + }) + }, + }) - this.data[tab].list.splice(index, 1) - if (tab == 'hongkongrental') { - this.setData({ - hongkongrental: this.data.hongkongrental - }) - } else { - this.setData({ - otherrental: this.data.otherrental - }) - } + }, + get_config() { + var that = this; + if (app.globalData.config.lists) { + config = app.globalData.config; + that.setData({ + status: app.globalData.status, + screen_data: app.globalData.screen_data, + langs: app.globalData.langs, + }) + that.get_content() + app.globalData['langs'] ? '' : this.getDtailsLangs() + + if (that.data.kw.trim().length > 0) that.submit() + } else { + setTimeout(function () { + that.get_config() + }, 200) + } + }, + + // 获取语言包 保存全局 + getDtailsLangs() { + miucms.request(`${app.globalData.baseURL}/tenement/v2/api/details/langs`).then(res => { + if (res.code != 200) return + let data = res.data + this.setData({ + langs: data + }) + app.globalData['langs'] = data + }) + }, + + // 专门梳理v4出现的 语音包 及 不同房源值的处理 + handleDetailData(data) { + let langs = this.data.langs || {} + if (Object.keys(langs).length == 0) { + setTimeout(() => { + this.handleDetailData(data) + }, 300) + } else { + let tab = this.data.tab + data.forEach(ele => { + // 这个是将 详情键 替换语言包里的值 + let list = ['type', 'rentalduration', 'intermediary', "property", "elevator", "sunshinearea", "gender"] + if (Array.isArray(ele['floor'])) list.push('floor') // 判断 楼层是否需要 替换值, 因为在求房源里是多个值 + let differentNames = { // 需要替换的 键名 + "intermediary": "intermediary_text" + } + list.forEach(element => { + if (ele[element] == -1) {} else if (ele[element] == 0) ele[differentNames[element] ? differentNames[element] : element] = '不限' // 当 值为 [0] 时为不限 + else ele[differentNames[element] ? differentNames[element] : element] = langs[element][ele[element]] + }) + let tabArr = ["gptype", "property", "elevator", "sunshinearea", "gender"] + let tabList = [] + tabArr.forEach(el => { + if (ele[el] && ele[el] != -1) tabList.push(ele[el]) + }) + ele['tabList'] = tabList + let location = langs.location // 遍历替换区域的值 所有房源 + let pendingData = ele['location'] + ele['location'] = `${location[Math.trunc(pendingData)]} > ${location[pendingData]}` + }) + let tabData = this.data[tab]["list"] || [] + tabData = tabData.concat(data) + this.setData({ + [`${tab}.list`]: tabData, + }) + + } + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + if (!app.globalData.config.lists) return false + this.getResultList() + }, + cancle() { + var pages = getCurrentPages(); + if (pages.length == 1) { + wx.reLaunch({ + url: `/pages/index/index` + }); + } else wx.navigateBack(); //返回上一页 + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + const that = this; + let url = `/pages/search/search?kw=${that.data.kw}&tab=${that.data.tab}`; + return { + path: url, + title: app.globalData.topTitle, + } + }, + + input: function (e) { + this.setData({ + kw: e.detail.value + }) + }, + // 提交 + submit: function () { + // this.data.kw = this.data.kw.trim(); + if (this.data.kw == '') { + wx.showToast({ + title: '请输入内容~', + icon: 'none' + }) + return false + } + if (this.data.log.indexOf(this.data.kw) == -1) { + // 未存在历史记录列表中 + this.data.log.unshift(this.data.kw) + // 最多存10条内容 + if (this.data.log.length > 10) { + this.data.log.length = 10 + } + this.setData({ + log: this.data.log + }) + wx.setStorage({ + key: 'searchHistoryList', + data: this.data.log, + }) + } + this.clearAllData() + this.clear_list() + }, + // 清空历史记录 + clear_keywords: function () { + let that = this; + wx.showModal({ + title: '提示', + content: '确定删除全部记录?', + confirmColor: '#bc322f', + success: function (res) { + if (res.confirm === true) { + if (!app.globalData.config || !app.globalData.config.lists) { + return false + } + miucms.request(app.globalData.config.lists.removesearchlog, {}).then(data => { + + if (data.extraparam.mode == 'right') { + that.setData({ + log: [] + }) + wx.setStorage({ + key: 'searchHistoryList', + data: [], + }) + } + }) + + } + } + }) + + }, + // 获取热词 + get_content: function () { + var that = this; + var sendData = Object.assign({}, this.data.options, { + session: wx.getStorageSync('session'), + }) + miucms.request(app.globalData.config.lists.search, {}).then(data => { + that.setData({ + hot: data.hot, + isloding: false + }) + }).catch(res => {}) + + }, + // 点击热词或者历史记录item + select_kw: function (e) { + wx.pageScrollTo({ + scrollTop: 0, + duration: 200, + }) + var kw = e.currentTarget.dataset.kw; + this.setData({ + kw + }) + this.clearAllData() + app.globalData.kw = kw; + this.clear_list() + }, + clearAllData() { + // 清空所有数据 + this.setData({ + otherrental: { + page: { + next_page: 1 + }, + list: [], + loading: false + }, + hongkongrental: { + page: { + next_page: 1 + }, + list: [], + loading: false + }, + studentapartment: { + page: { + next_page: 1 + }, + list: [], + loading: false + } + }) + }, + // 清空list + clear_list: function () { + let tab = this.data.tab; + this.data[tab] = { + page: { + next_page: 1 + }, + list: [], + loading: false + } + this.setTabData() + this.searchKW() + }, + setTabData() { + let tab = this.data.tab; + switch (tab) { + case 'otherrental': + this.setData({ + otherrental: this.data.otherrental + }) + break; + case 'studentapartment': + this.setData({ + studentapartment: this.data.studentapartment + }) + break; + case 'hongkongrental': + this.setData({ + hongkongrental: this.data.hongkongrental + }) + break; + } + }, + searchdata: '', + // 搜索关键词 + searchKW: function () { + var that = this; + if (!app.globalData.config.search) { + return false + } + this.setData({ + loading: true + }) + miucms.request(app.globalData.config.search.global, { + // miucms.request(`${app.globalData.baseURL}/tenement/housingresources/lists`, { + 'keyword': this.data.kw + }).then(data => { + // console.log("data", data); + if (data.code != 200) { + wx.showToast({ + title: data.message, + icon: 'none' + }) + + that.setData({ + loading: false, + otherrental: { + page: { + next_page: 0 + }, + list: [], + loading: false + }, + hongkongrental: { + page: { + next_page: 0 + }, + list: [], + loading: false + }, + studentapartment: { + page: { + next_page: 0 + }, + list: [], + loading: false + } + }) + return false + } + let count = data.data.count; + this.searchdata = data.data.searchdata; + for (let i in data.data.count) { + if (data.data.count[i] == 0) { + this.data[i].page.next_page = 0; + } else { + this.data[i].page.next_page = 1; + } + } + this.setData({ + search: true, + otherrental: this.data.otherrental, + studentapartment: this.data.studentapartment, + hongkongrental: this.data.hongkongrental, + loading: false, + kw: data.data.keyword + }) + this.getDatas() + }).catch(res => {}) + + }, + + // 搜索初始化 新的 自动覆盖上面的 + searchKW() { + miucms.wxget(`${app.globalData.baseURL}/tenement/v2/api/search`, { + 'keyword': this.data.kw + }).then(res => { + if (res.code != 200) return + let data = res.data + let { + personal, + intermediary, + studentapartment + } = data + + this.setData({ + ...data + }) + + console.log(); + + this.getResultList() + }) + }, + + // 请求结果列表 + getResultList() { + let tab = this.data.tab + let tabData = this.data[tab] + if (tabData['page'] == 0) return // 需要加一个请求中 + + console.log(tabData); + let searchid = tabData['searchid'] + let url = tab == 'studentapartment' ? `${ app.globalData.baseURL }/tenement/apartment/filterConditions` : `${ app.globalData.baseURL }/tenement/v2/api/lists` + let requestData = { + searchid, + page: tabData['page'] || 1, + intermediary: 6 + } + + miucms.request(url, requestData).then(res => { + if (res.code != 200) return + let data = res.data + let concreteData = data.data + this.handleDetailData(concreteData) + + // if (!tabData['list']) tabData['list'] = [] + // tabData['list'].push(...concreteData) + tabData['page'] = data.page * data.limit >= data.count ? 0 : data.page + 1 + + this.setData({ + search: true, + [tab]: tabData, + }) + + }) + }, + + // 清空 + clearKW() { + this.setData({ + kw: '', + focus: true + }) + }, + // 更换tab + changeTab(e) { + console.log(e.currentTarget.dataset.tab, 0); + this.setData({ + tab: e.currentTarget.dataset.tab + }) + let tab = this.data.tab; + // 如果当前tab下数量为0 ,则不再加载 + if (this.data[tab].page == 0 || this.data[tab].list) return false; + + // this.getKWdata() + this.getResultList() + }, + // 搜索相关tab关键词 + getDatas() { + let tab = this.data.tab; + if (!this.data[tab].page.next_page) { + // 如果当前tab下数量为0 ,则不再加载 + return false; + } + this.getKWdata() + }, + getKWdata() { + let urlObj = { + otherrental: app.globalData.config.search.otherrental, + // hongkongrental: app.globalData.config.search.hongkongrental, + hongkongrental: `${app.globalData.baseURL}/tenement/housingresources/lists`, + studentapartment: app.globalData.config.search.studentapartment, + } + let tab = this.data.tab; + let url = urlObj[tab]; + this.data[tab].loading = true; + this.setTabData() + miucms.request(url, { + 'searchdata': this.searchdata, + page: this.data[tab].page.next_page + }).then(data => { + // console.log(data); + this.data[tab].list = this.data[tab].list.concat(data.data.data); + this.data[tab].loading = false; + + if (data.data.data.length > 0) { + this.data[tab].page.next_page += 1; + } else { + this.data[tab].page.next_page = 0; + } + this.setTabData() + }).catch(res => {}) + }, + // 点击广告 + clickAD(e) { + miucms.clickAD(e.detail.id) + }, + // 关闭广告 + closeAD(e) { + let index = e.currentTarget.dataset.index; + let tab = e.currentTarget.dataset.tab; + + this.data[tab].list.splice(index, 1) + if (tab == 'hongkongrental') { + this.setData({ + hongkongrental: this.data.hongkongrental + }) + } else { + this.setData({ + otherrental: this.data.otherrental + }) + } + + miucms.closeAD(e.detail.id) + }, - miucms.closeAD(e.detail.id) - } }) \ No newline at end of file diff --git a/pages/search/search.json b/pages/search/search.json index 1d73251..c8d284a 100644 --- a/pages/search/search.json +++ b/pages/search/search.json @@ -1,11 +1,13 @@ { - "navigationBarTitleText": "搜索", - "enablePullDownRefresh": false, - "usingComponents": { - "header-nav": "../../template/headerNav/index", - "brands-item":"../irentList/listItem/listItem", - "to-top": "../../template/toTop/toTop", - "ads": "../show/ads/ads", - "house-item": "../restOfWorld/houseItem/houseItem" - } + "navigationBarTitleText": "搜索", + "enablePullDownRefresh": false, + "usingComponents": { + "header-nav": "../../template/headerNav/index", + "brands-item": "../irentList/listItem/listItem", + "to-top": "../../template/toTop/toTop", + "ads": "../show/ads/ads", + "house-item": "../restOfWorld/houseItem/houseItem", + "list-operations": "/template/listOperations/listOperations", + "common-list": "/template/commonList/commonList" + } } \ No newline at end of file diff --git a/pages/search/search.wxml b/pages/search/search.wxml index 0500d9b..0451190 100644 --- a/pages/search/search.wxml +++ b/pages/search/search.wxml @@ -1,91 +1,107 @@ - + - - 搜索 - -
- - - - -
- 取消 - 搜索 - -
- - - - 历史搜索 - - - - - {{ item }} - + + 搜索 + + + + + + 历史搜索 + + + + + + {{ item }} + + + + 热门搜索 + + {{ item }} + + - - - 热门搜索 - - - {{ item }} - - - - - - 个人房源 - 品牌公寓 - - - 求房源 - - -