681 lines
21 KiB
JavaScript
681 lines
21 KiB
JavaScript
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
bgcolor: String,
|
|
// brands: Object,
|
|
brands: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (res.value === "") return
|
|
let conditionObj = this.data.conditionObj
|
|
let obj = res.obj
|
|
conditionObj.brand['valueText'] = obj[res.value]
|
|
this.setData({
|
|
conditionObj
|
|
})
|
|
}
|
|
},
|
|
// roomtype: Object,
|
|
roomtype: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (res.value === "") return
|
|
let conditionObj = this.data.conditionObj
|
|
let obj = res.obj
|
|
conditionObj.house['valueText'] = obj[res.value]
|
|
this.setData({
|
|
conditionObj
|
|
})
|
|
}
|
|
},
|
|
// roomlistings: Object,
|
|
roomlistings: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (res.value === "") return
|
|
let conditionObj = this.data.conditionObj
|
|
let obj = res.obj
|
|
conditionObj.floor['valueText'] = obj[res.value]
|
|
this.setData({
|
|
conditionObj
|
|
})
|
|
}
|
|
},
|
|
moreCondition: {
|
|
type: Object,
|
|
observer(res) {
|
|
let data = res.data
|
|
if (data.gender) this.data.gender.value = data.gender
|
|
if (data.leaseterm) this.data.leaseterm.value = data.leaseterm
|
|
if (data.publish) this.data.publish.value = data.publish
|
|
|
|
if (data.isverified) this.data.moreOtherValue.isverified = data.isverified
|
|
if (data.iselevator) this.data.moreOtherValue.iselevator = data.iselevator
|
|
if (data.issunshinearea) this.data.moreOtherValue.issunshinearea = data.issunshinearea
|
|
|
|
|
|
this.setData(this.data)
|
|
}
|
|
},
|
|
screen_data: Object,
|
|
// money: Object,
|
|
money: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (res.rent_max == 0) return
|
|
const rent = this.data.rent
|
|
const rent_min = (res.rent_min - rent.min) / rent.step
|
|
const rent_max = (res.rent_max - rent.min) / rent.step
|
|
let conditionObj = this.data.conditionObj
|
|
conditionObj.rent.valueText = `${res.rent_min} ~ ${res.rent_max}`
|
|
|
|
this.setData({
|
|
conditionObj,
|
|
rentValue: [rent_min, rent_max]
|
|
})
|
|
}
|
|
},
|
|
tabTitle: String,
|
|
operationstype: {
|
|
type: String,
|
|
observer(res) {
|
|
if (!res) return
|
|
let key = res
|
|
|
|
let conditionAllConfig = this.data.conditionAllConfig
|
|
let moreOtherKey = this.data.moreOtherKey
|
|
|
|
if (res == "personhousing" || res == 'intermediaryhousing' || res == "askinghousing") key = "housing"
|
|
let obj = {}
|
|
let conditionObj = conditionAllConfig[key]
|
|
|
|
if (res == "askinghousing") {
|
|
// obj['isindependentsuite'] = '独立套房'
|
|
conditionObj['types']['name'] = '求租方式'
|
|
this.data.gender['title'] = '求租者性别'
|
|
this.setData({
|
|
gender: this.data.gender
|
|
})
|
|
} else if (res == "personhousing") obj['isverified'] = '认证房源'
|
|
else if (res == "intermediaryhousing") obj['isintermediary'] = '认证中介'
|
|
moreOtherKey = Object.assign(obj, moreOtherKey)
|
|
this.setData({
|
|
moreOtherKey,
|
|
conditionObj,
|
|
})
|
|
}
|
|
},
|
|
location: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (!res) return
|
|
let data = res.data
|
|
if (!data) return
|
|
let value = res.value
|
|
let targetData = this.workingWithObject("location", data)
|
|
let areaPitchValueOne = this.data.areaPitchValueOne
|
|
let conditionObj = this.data.conditionObj
|
|
let areaPitchValueTwo = this.data.areaPitchValueTwo
|
|
if (value) {
|
|
let obj = {}
|
|
areaPitchValueOne = parseInt(value[0]) || 0
|
|
value.forEach(el => {
|
|
if ((el ^ 0) == el) el = 0 // 选择不限
|
|
conditionObj["school"]['valueText'] = targetData[areaPitchValueOne].title + '/...'
|
|
obj[el] = true
|
|
})
|
|
areaPitchValueTwo = obj
|
|
}
|
|
|
|
this.setData({
|
|
areaData: targetData,
|
|
areaPitchValueOne,
|
|
areaPitchValueTwo,
|
|
conditionObj,
|
|
})
|
|
}
|
|
},
|
|
school: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (!res) return
|
|
let list = res.list
|
|
list[0] = "不限"
|
|
let conditionObj = this.data.conditionObj
|
|
let areaState = this.data.areaState
|
|
if (res.value) {
|
|
conditionObj["school"]['valueText'] = "学校"
|
|
areaState = "school"
|
|
}
|
|
|
|
this.setData({
|
|
schoolData: res.list,
|
|
schoolValue: res.value || 0,
|
|
conditionObj,
|
|
areaState,
|
|
})
|
|
}
|
|
},
|
|
types: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (!res) return
|
|
let data = res.data
|
|
if (!data) return
|
|
let conditionObj = this.data.conditionObj
|
|
let targetData = this.workingWithObject("types", data)
|
|
let typesValue = res.value || 0
|
|
|
|
if (typesValue) conditionObj["types"]['valueText'] = `${targetData[Math.trunc(typesValue)]['title']}/...`
|
|
|
|
this.setData({
|
|
typesData: targetData,
|
|
typesValue,
|
|
conditionObj
|
|
})
|
|
}
|
|
},
|
|
|
|
orderbyy: {
|
|
type: Object,
|
|
observer(res) {
|
|
this.data.orderby.value = res.value
|
|
|
|
let conditionObj = this.data.conditionObj
|
|
conditionObj.orderby['valueText'] = this.data.orderby.obj[res.value]
|
|
this.setData({
|
|
orderby: this.data.orderby,
|
|
conditionObj,
|
|
})
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
conditionState: "", // brand rent house floor school
|
|
conditionAllConfig: {
|
|
student: {
|
|
brand: {
|
|
name: "品牌",
|
|
valueKey: "brands"
|
|
},
|
|
rent: {
|
|
name: "租金",
|
|
},
|
|
house: {
|
|
name: "房型",
|
|
valueKey: "roomtype"
|
|
},
|
|
floor: {
|
|
name: "楼型",
|
|
valueKey: "roomlistings"
|
|
},
|
|
},
|
|
housing: {
|
|
school: {
|
|
name: "区域",
|
|
valueKey: "brands"
|
|
},
|
|
types: {
|
|
name: "出租方式",
|
|
valueKey: "types"
|
|
},
|
|
rent: {
|
|
name: "租金",
|
|
},
|
|
moreCondition: {
|
|
name: "更多",
|
|
valueKey: "brands",
|
|
valueText: "更多",
|
|
},
|
|
orderby: {
|
|
name: "排序方式",
|
|
valueKey: "orderby",
|
|
valueText: "综合",
|
|
},
|
|
},
|
|
placeSelect: {
|
|
types: {
|
|
name: "出租方式",
|
|
valueKey: "types"
|
|
},
|
|
rent: {
|
|
name: "租金",
|
|
},
|
|
moreCondition: {
|
|
name: "更多",
|
|
last: true,
|
|
valueKey: "brands",
|
|
},
|
|
},
|
|
placeSelectList: {
|
|
types: {
|
|
name: "出租方式",
|
|
valueKey: "types"
|
|
},
|
|
rent: {
|
|
name: "租金",
|
|
},
|
|
moreCondition: {
|
|
name: "更多",
|
|
valueKey: "brands",
|
|
},
|
|
orderby: {
|
|
name: "最新",
|
|
valueKey: "orderby",
|
|
show: false,
|
|
valueText: "综合",
|
|
}
|
|
}
|
|
},
|
|
conditionObj: {},
|
|
rent: {
|
|
min: 1000,
|
|
max: 50000,
|
|
rate: 490,
|
|
defaultMin: 50,
|
|
defaultMax: 80,
|
|
step: 100,
|
|
for: 491
|
|
},
|
|
rentValue: [40, 80], // 租金的默认值 (40 * rent['step']) + rent['min']
|
|
|
|
areaState: "area", // area school 区域 弹窗的状态
|
|
areaData: {}, // 区域弹窗的数据
|
|
areaPitchValueOne: 0, // 区域选中 的 一级
|
|
areaPitchValueTwo: { // 区域选中 的 二级
|
|
0: true
|
|
},
|
|
|
|
schoolData: {}, // 学校弹窗 数据
|
|
schoolValue: "", // 学校弹窗 选中数据
|
|
orderby: {
|
|
value: 'default',
|
|
list: {
|
|
"default": "综合",
|
|
"updatetime": "最新发布",
|
|
"hotnum": "热门",
|
|
"rentasc": "价格从低到高",
|
|
"rentdesc": "价格从高到低",
|
|
},
|
|
obj: {
|
|
"default": "综合",
|
|
"updatetime": "最新发布",
|
|
"hotnum": "热门",
|
|
"rentasc": "价格从低到高",
|
|
"rentdesc": "价格从高到低",
|
|
},
|
|
},
|
|
typesData: {}, // 出租方式
|
|
typesValue: 0, //
|
|
leaseterm: {
|
|
title: '租期',
|
|
value: "0",
|
|
list: {
|
|
0: "不限",
|
|
1: "一年以上",
|
|
2: "低于一年",
|
|
}
|
|
},
|
|
gender: {
|
|
title: '性别要求',
|
|
value: "0",
|
|
list: {
|
|
0: "不限",
|
|
1: "女",
|
|
2: "男",
|
|
}
|
|
},
|
|
publish: {
|
|
title: '发布时间',
|
|
value: '0',
|
|
list: {
|
|
'0': '不限',
|
|
'triduum': "三天",
|
|
"hebdomad": "一周",
|
|
'onemonth': '一个月内',
|
|
'twomonth': '二个月内',
|
|
'trimester': '三个月内'
|
|
},
|
|
},
|
|
moreOtherValue: {
|
|
issunshinearea: 0, // 阳台
|
|
iselevator: 0, // 电梯
|
|
isverified: 0, // 认证房源
|
|
isintermediary: 0, // 认证中介
|
|
isindependentsuite: 0, // 独立套房
|
|
},
|
|
moreOtherKey: {
|
|
iselevator: "有电梯", // 电梯
|
|
issunshinearea: "有阳台", // 阳台
|
|
},
|
|
|
|
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
// 处理对象数据
|
|
workingWithObject(type, data) {
|
|
let targetData = {}
|
|
for (let key in data) {
|
|
key = Number(key)
|
|
if (key % 1 === 0) {
|
|
targetData[key] = {}
|
|
targetData[key]['title'] = data[key]
|
|
} else {
|
|
let obj = targetData[Math.trunc(key)]['data']
|
|
if (!obj) obj = {} // 没有时的创建
|
|
if (JSON.stringify(obj) == "{}" && type == "location") obj[0] = "不限"
|
|
if (JSON.stringify(obj) == "{}" && type == "types") obj[Math.trunc(key)] = "不限"
|
|
obj[key] = data[key]
|
|
targetData[Math.trunc(key)]['data'] = obj
|
|
}
|
|
}
|
|
|
|
return targetData
|
|
},
|
|
setValue(e) {
|
|
let {
|
|
key,
|
|
value
|
|
} = e.currentTarget.dataset
|
|
this.setData({
|
|
[key]: value
|
|
})
|
|
|
|
this.triggerEvent('isOpenOperations', this.data.conditionState ? true : false)
|
|
|
|
},
|
|
|
|
changeItem(e) {
|
|
let conditionState = this.data.conditionState
|
|
let value = e.currentTarget.dataset.value
|
|
|
|
let conditionObj = this.data.conditionObj
|
|
let valueKey = conditionObj[conditionState].valueKey
|
|
let obj = this.data[valueKey].obj
|
|
conditionObj[conditionState]['valueText'] = obj[value]
|
|
this.triggerEvent('submit', {
|
|
type: conditionState,
|
|
value
|
|
})
|
|
|
|
this.setData({
|
|
conditionState: "",
|
|
conditionObj
|
|
})
|
|
|
|
this.triggerEvent('isOpenOperations', false)
|
|
},
|
|
|
|
// 滑动租金数据 事件
|
|
bindChangeRent(e) {
|
|
let value = e.detail.value
|
|
let rentValue = this.data.rentValue
|
|
rentValue[0] = value[0]
|
|
rentValue[1] = value[1]
|
|
this.setData({
|
|
rentValue
|
|
})
|
|
},
|
|
|
|
// 处理 租金的 事件
|
|
handleRant(e) {
|
|
let type = e.currentTarget.dataset.type
|
|
let conditionState = this.data.conditionState
|
|
let rentValue = this.data.rentValue
|
|
let rent = this.data.rent
|
|
rentValue.sort(function (a, b) {
|
|
return a - b
|
|
})
|
|
let rent_min = 0
|
|
let rent_max = 0
|
|
let conditionObj = this.data.conditionObj
|
|
if (type != 'unlimited') {
|
|
rent_min = (rentValue[0] * rent['step']) + rent['min']
|
|
rent_max = (rentValue[1] * rent['step']) + rent['min']
|
|
conditionObj[conditionState]['valueText'] = `${rent_min} ~ ${rent_max}`
|
|
} else conditionObj[conditionState]['valueText'] = ""
|
|
|
|
this.triggerEvent('submit', {
|
|
type: conditionState,
|
|
rent_min,
|
|
rent_max,
|
|
})
|
|
|
|
this.setData({
|
|
conditionState: "",
|
|
conditionObj
|
|
})
|
|
this.triggerEvent('isOpenOperations', false)
|
|
},
|
|
|
|
// 处理区域选择 的 二级
|
|
handleAreaPitchValue(e) {
|
|
let {
|
|
type,
|
|
value
|
|
} = e.currentTarget.dataset
|
|
let areaPitchValueTwo = this.data.areaPitchValueTwo
|
|
|
|
if (type == "areaPitchValueOne") {
|
|
areaPitchValueTwo = {
|
|
0: true
|
|
}
|
|
this.setData({
|
|
areaPitchValueOne: value,
|
|
areaPitchValueTwo,
|
|
})
|
|
return
|
|
}
|
|
|
|
|
|
if (value == 0) {
|
|
areaPitchValueTwo = {
|
|
0: true
|
|
}
|
|
} else {
|
|
delete areaPitchValueTwo[0]
|
|
if (areaPitchValueTwo[value]) areaPitchValueTwo[value] = false
|
|
else areaPitchValueTwo[value] = true
|
|
}
|
|
this.setData({
|
|
areaPitchValueTwo,
|
|
})
|
|
|
|
},
|
|
|
|
// 点击区域弹窗 的确定
|
|
clickAreaPitch(e) {
|
|
let {
|
|
type
|
|
} = e.currentTarget.dataset
|
|
|
|
let conditionObj = this.data.conditionObj
|
|
let conditionState = this.data.conditionState
|
|
|
|
let areaPitchValueOne = this.data.areaPitchValueOne
|
|
let areaPitchValueTwo = this.data.areaPitchValueTwo
|
|
let areaData = this.data.areaData
|
|
|
|
if (type == "reset") {
|
|
this.setData({
|
|
areaPitchValueOne: 0,
|
|
areaPitchValueTwo: {
|
|
0: true
|
|
},
|
|
})
|
|
} else {
|
|
let location = []
|
|
|
|
|
|
if (areaPitchValueOne == 0) {} else if (!areaPitchValueTwo[0]) { // 选择二级的
|
|
for (const key in areaPitchValueTwo) {
|
|
if (areaPitchValueTwo[key]) location.push(key)
|
|
}
|
|
} else location.push(areaPitchValueOne) // 选择一级的
|
|
|
|
if (areaPitchValueOne == 0) conditionObj[conditionState]['valueText'] = null
|
|
else {
|
|
conditionObj[conditionState]['valueText'] = `${ (areaData[areaPitchValueOne] && areaData[areaPitchValueOne].title) || '港岛' }/...`
|
|
}
|
|
|
|
this.setData({
|
|
conditionState: "",
|
|
conditionObj,
|
|
})
|
|
this.triggerEvent('isOpenOperations', false)
|
|
this.triggerEvent("submit", {
|
|
type: conditionState,
|
|
school: "",
|
|
location
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
// 处理学校 选中
|
|
handleSchoolPitchValue(e) {
|
|
let value = e.currentTarget.dataset.value
|
|
let conditionObj = this.data.conditionObj
|
|
let conditionState = this.data.conditionState
|
|
|
|
conditionObj[conditionState]['valueText'] = "学校"
|
|
this.setData({
|
|
schoolValue: value,
|
|
areaPitchValueOne: 0,
|
|
areaPitchValueTwo: {
|
|
0: true
|
|
},
|
|
conditionObj,
|
|
conditionState: "",
|
|
})
|
|
|
|
this.triggerEvent('isOpenOperations', false)
|
|
|
|
this.triggerEvent("submit", {
|
|
type: conditionState,
|
|
school: value,
|
|
location: []
|
|
})
|
|
|
|
},
|
|
|
|
// 处理点击 排序
|
|
submitOrderby(e) {
|
|
let value = e.currentTarget.dataset.value
|
|
|
|
let conditionObj = this.data.conditionObj
|
|
let orderby = this.data.orderby
|
|
let conditionState = this.data.conditionState
|
|
orderby["value"] = value
|
|
conditionObj[conditionState]['valueText'] = orderby['list'][value]
|
|
this.setData({
|
|
orderby,
|
|
conditionObj,
|
|
conditionState: "",
|
|
})
|
|
|
|
this.triggerEvent('isOpenOperations', false)
|
|
|
|
this.triggerEvent("submit", {
|
|
orderby: value,
|
|
type: conditionState
|
|
})
|
|
},
|
|
|
|
// 处理点击出租方式
|
|
handleTypesValue(e) {
|
|
let {
|
|
value,
|
|
text
|
|
} = e.currentTarget.dataset
|
|
let conditionObj = this.data.conditionObj
|
|
let conditionState = this.data.conditionState
|
|
let typesData = this.data.typesData
|
|
|
|
if (value != 0) conditionObj[conditionState]['valueText'] = `${text}/...`
|
|
else conditionObj[conditionState]['valueText'] = ""
|
|
|
|
this.triggerEvent("submit", {
|
|
types: value,
|
|
type: conditionState
|
|
})
|
|
this.setData({
|
|
typesValue: value,
|
|
conditionObj,
|
|
conditionState: "",
|
|
})
|
|
this.triggerEvent('isOpenOperations', false)
|
|
|
|
},
|
|
|
|
//是否显示发布
|
|
setSelectData(data) {
|
|
let obj = this.data.conditionObj
|
|
if (!obj['orderby']) return
|
|
obj['orderby'].show = data
|
|
obj['moreCondition'].show = data
|
|
// if(obj['orderby'].show)
|
|
// obj.
|
|
this.setData({
|
|
conditionObj: obj,
|
|
conditionState: "",
|
|
})
|
|
this.triggerEvent('isOpenOperations', false)
|
|
},
|
|
|
|
// 处理 更多 确定和重置按钮
|
|
clickMorePitch(e) {
|
|
let type = e.currentTarget.dataset.type
|
|
let moreOtherValue = this.data.moreOtherValue
|
|
if (type == "reset") {
|
|
for (const key in moreOtherValue) {
|
|
moreOtherValue[key] = 0
|
|
}
|
|
this.setData({
|
|
['leaseterm.value']: 0,
|
|
['gender.value']: 0,
|
|
['publish.value']: 0,
|
|
moreOtherValue,
|
|
})
|
|
return
|
|
}
|
|
|
|
this.triggerEvent("submit", {
|
|
type: this.data.conditionState,
|
|
leaseterm: this.data.leaseterm.value,
|
|
gender: this.data.gender.value,
|
|
publish: this.data.publish.value,
|
|
...moreOtherValue
|
|
})
|
|
|
|
this.setData({
|
|
conditionState: "",
|
|
})
|
|
},
|
|
// 关闭页面
|
|
page_header_back() {
|
|
this.setData({
|
|
conditionState: "",
|
|
})
|
|
},
|
|
|
|
// 选择更多的其他 筛选
|
|
moreOtherItem(e) {
|
|
let type = e.currentTarget.dataset.type
|
|
let moreOtherValue = this.data.moreOtherValue
|
|
moreOtherValue[type] = moreOtherValue[type] == 0 ? 1 : 0
|
|
this.setData({
|
|
moreOtherValue
|
|
})
|
|
},
|
|
},
|
|
|
|
}) |