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.
 

354 lines
9.2 KiB

// pages/look-list/look-list.js
const moment = require('../../utils/moment.min');
const $api = require('../../utils/api').API;
Page({
/**
* 页面的初始数据
*/
data: {
active: '',
tabs: [{id: 1, name: '排序'}, {id: 2, name: '日期'}, {id: 3, name: '交易状态'}, {id: 4, name: '区域'}, {
id: 5,
name: '类型'
}],
list: [],
refresher: false,
setScroll: true,
inputShow: false,
region: ["500000", "500100"],
nowTime: new Date(),
page: {
size: 10,
current: 1,
startDate: '',
endDate: '',
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: ["500000", "500100"],
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 cityName = res.detail.value[2];
if (cityName) {
this.setData({
['page.canton']: cityName
})
}
;
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();
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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() {
$api.getLandlistedPage(this.data.page).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) {
console.log(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
})
}
;
}
},
// bindAddressChange(res) {
// let cityName = res.detail.value[1]
// let t="page.city"
// if (cityName) {
// this.setData({
// [t]:cityName
// })
// this.refresh()
// };
// },
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;
}
},
demo() {
console.log(999)
},
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
})
}
})