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.
 

421 lines
11 KiB

// pages/look-list/look-list.js
const $api = require('../../utils/api').API;
const CITY = wx.getStorageSync('city')
Page({
/**
* 页面的初始数据
*/
data: {
multiIndex: [],
multiRegion: [],
active: '',
tabs: [{
id: 1,
name: '排序'
}, {
id: 2,
name: '日期'
}, {
id: 3,
name: '交易状态'
}, {
id: 4,
name: '区域'
}, {
id: 5,
name: '类型'
}],
list: [],
refresher: false,
setScroll: true,
inputShow: false,
nowTime: new Date(),
page: {
size: 10,
current: 1,
startDate: '',
endDate: '',
city: CITY,
canton: '',
transactionStatus: '',
measureStatus: '',
landCode: ''
},
searchNode: {
date: {
height: 0,
bottom: 0
},
sale: {
height: 0,
bottom: 0
},
calcu: {
height: 0,
bottom: 0
}
},
measureStatus: '',
transactionStatus: '',
arraySale: [],
arrayCalcu: [],
saleList: [],
calcuList: [],
saleNum: null,
calcuNum: null,
region: [],
title: '', //传递待测算名
// 搜索框
is_search: false,
is_focusing: false, //是否聚焦
},
// 地图搜索框
searchFun() {
this.setData({
is_search: true,
is_focusing: true,
})
},
//隐藏
blurFun() {
this.setData({
is_search: this.data.page.landCode ? true : false,
is_focusing: false,
})
},
// 清空搜索内容
emptyFun() {
this.setData({
['page.landCode']: '',
is_focusing: true,
})
this.refresh();
},
// 选择城市
bindAddressChangeCity(res) {
let value = res.detail.value;
let city = this.data.multiRegion[0][value[0]]
let canton = this.data.multiRegion[1][value[1]]
if (city && city !== '全部') {
wx.setStorageSync('city', city)
}
this.setData({
['page.city']: city,
['page.canton']: canton
})
this.refresh()
},
changeRadio(e) {
let type = e.currentTarget.dataset.type;
switch (type) {
case 'sale':
this.setData({
saleNum: e.currentTarget.dataset.num,
'page.transactionStatus': this.data.saleList[e.currentTarget.dataset.num].value
});
break;
case 'calcu':
this.setData({
calcuNum: e.currentTarget.dataset.num,
'page.measureStatus': this.data.calcuList[e.currentTarget.dataset.num].value
});
break;
}
},
comeBack() {
wx.navigateBack({
delta: 1
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.title) {
this.setData({
title: options.title,
})
}
$api.getDict('land_transaction').then(res => {
this.setData({
saleList: res.data
})
})
$api.getDict('measure_status').then(res => {
if (this.data.title == '待测算') {
res.data.map((itme, index) => {
if (itme.label == this.data.title) {
console.log(itme)
this.setData({
calcuNum: index,
['page.measureStatus']: itme.value,
})
}
})
}
this.setData({
calcuList: res.data
})
this.refresh();
})
$api.getCityList().then(res => {
let data = res.data
data.unshift('全部')
this.setData({
multiRegion: [data, ['全部']]
})
let city = wx.getStorageSync('city')
let index = data.indexOf(city);
if (city && city !== '' && index !== -1) {
$api.getAreaList(city).then(res => {
let data = res.data
data.unshift('全部')
this.setData({
'page.city': city,
multiIndex: [index],
'multiRegion[1]': data
})
})
}
})
},
bindMultiPickerColumnChange(e) {
if (e.detail.column === 0 && e.detail.value === 0) {
this.setData({
'multiRegion[1]': ['全部']
})
} else if (e.detail.column === 0) {
let city = this.data.multiRegion[e.detail.column][e.detail.value];
$api.getAreaList(city).then(res => {
let data = res.data
data.unshift('全部')
this.setData({
'multiRegion[1]': data
})
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
// 清空
empty(e) {
let name = e.currentTarget.dataset.name;
if (name == 'time') {
this.setData({
['page.startDate']: '',
['page.endDate']: '',
})
} else if (name == 'saleNum') {
this.setData({
['page.transactionStatus']: '',
[name]: null
})
} else {
this.setData({
[name]: null
})
}
},
tabDowm(e) {
let active = e.currentTarget.dataset.id
if (active === this.data.active) {
this.setData({
active: '',
setScroll: true
})
} else {
this.setData({
active,
setScroll: false
})
}
},
getList() {
let t = "page.current"
let p = this.data.page.current + 1
this.setData({
[t]: p
})
$api.getLandlistedPage(this.data.page).then(res => {
let list = this.data.list.concat(res.data.records)
this.setData({
list
})
})
},
refresh() {
let params = this.data.page;
if (params.canton && params.canton === '全部') {
params.canton = ''
}
$api.getLandlistedPage(params).then(res => {
res.data.records.map(e => {
for (let key in e) {
if (!e[key]) {
e[key] = ''
}
}
})
let t = "page.current"
this.setData({
list: [],
[t]: 1,
})
this.setData({
list: res.data.records,
refresher: false
})
})
},
goSearch() {
this.inShow();
this.setData({
'searchNode.date.height': 0,
'searchNode.date.bottom': 0,
})
this.refresh()
},
hideMark() {
this.setData({
active: '',
setScroll: true
})
},
inShow() {
for (let key in this.data.searchNode) {
if (this.data.searchNode[key].height > 0) {
this.setData({
[`searchNode.${key}`]: {
height: 0,
bottom: 0
}
})
}
}
},
comeDetail(e) {
let id = e.currentTarget.dataset.id;
let status = e.currentTarget.dataset.status;
if (status !== 'toBeListed') {
wx.navigateTo({
url: '/pages/look-detail/look-detail?id=' + id,
})
} else {
wx.navigateTo({
url: '/pages/lookStay-detail/lookStay-detail?id=' + id,
})
}
},
bindTimeChange(res) {
let queryDate = res.detail.value
if (res.currentTarget.dataset.type == 'start') {
let t = "page.startDate"
if (queryDate) {
this.setData({
[t]: queryDate
})
};
} else {
let t = "page.endDate"
if (queryDate) {
this.setData({
[t]: queryDate
})
};
}
},
bindSaleChange(res) {
let value = this.data.arraySale[res.detail.value].value;
let label = this.data.arraySale[res.detail.value].label
let t = "page.transactionStatus"
if (value) {
this.setData({
[t]: value,
transactionStatus: label
})
this.refresh()
};
},
bindCalcuChange(res) {
let value = this.data.arrayCalcu[res.detail.value].value;
let label = this.data.arrayCalcu[res.detail.value].label
let t = "page.measureStatus"
if (value) {
this.setData({
[t]: value,
measureStatus: label
})
this.refresh()
};
},
showDown(e) {
const _this = this;
console.log(this.data.searchNode)
for (let key in this.data.searchNode) {
if (this.data.searchNode[key].height > 0) {
this.setData({
[`searchNode.${key}`]: {
height: 0,
bottom: 0
}
})
}
}
switch (e.currentTarget.dataset.type) {
case 'date':
setTimeout(() => {
_this.setData({
'searchNode.date.height': 200,
'searchNode.date.bottom': -200,
});
}, 300)
break;
case 'sale':
setTimeout(() => {
_this.setData({
'searchNode.sale.height': 200,
'searchNode.sale.bottom': -200,
});
}, 300)
break;
case 'calcu':
setTimeout(() => {
_this.setData({
'searchNode.calcu.height': 200,
'searchNode.calcu.bottom': -200,
});
}, 300)
break;
}
},
vmodel(e) {
let t = "page.landCode"
this.setData({
[t]: e.detail.value
})
this.refresh();
},
showInput() {
if (this.data.inputShow == true) {
return false
}
this.setData({
inputShow: true
})
},
hideInput() {
this.setData({
inputShow: false
})
}
})