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.
298 lines
8.6 KiB
298 lines
8.6 KiB
// pages/look-detail/look-detail.js |
|
const $api = require('../../utils/api').API; |
|
const WKT = require('../../utils/terraformer-wkt-parser.min'); |
|
const util = require('../../utils/util') |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
state: true, |
|
landListedId: '', |
|
myData: {}, |
|
tabList: [{ |
|
id: 1, |
|
name: '拟供地块' |
|
} |
|
], |
|
sedTabList: [{ |
|
id: 4, |
|
name: '基础测算' |
|
}, { |
|
id: 5, |
|
name: '高级测算' |
|
}], |
|
active: 1,//当前选择项 |
|
markShow: false, |
|
annoutInfo: {}, |
|
clinchInfo: {}, |
|
presentInfo: { |
|
list: {}, |
|
more: [] |
|
}, |
|
latitude: 29.467135892012564, |
|
longitude: 106.49036135962103, |
|
basisInfo: {}, |
|
seniorInfo: {}, |
|
polygons: [], |
|
orgiData: {}, |
|
isDone: false, |
|
}, |
|
//定位当前 |
|
gotoLocation(id) { |
|
$api.AJAX('GET', 'applets/landtolistlonlat/list/' + id, true).then(res => { |
|
if (res && res.data && res.data.length > 0) { |
|
let point = WKT.parse(res.data[0].centerPoint).coordinates |
|
let latitude = point[0] |
|
let longitude = point[1] |
|
this.setData({ |
|
latitude: longitude, |
|
longitude: latitude, |
|
}) |
|
} |
|
}) |
|
}, |
|
setMark(e) { |
|
let { |
|
markShow |
|
} = this.data; |
|
$api.getCalulaDeatail(this.data.landListedId).then(res => { |
|
if (res.data) { |
|
this.setData({ |
|
orgiData: res.data |
|
}) |
|
} |
|
if (markShow) { |
|
let active = Number(e.currentTarget.dataset.id) |
|
this.setData({ |
|
state: false, |
|
markShow: false, |
|
active |
|
}) |
|
} else { |
|
this.setData({ |
|
markShow: true |
|
}) |
|
} |
|
}) |
|
}, |
|
|
|
tabDowm(e) { |
|
let active = Number(e.currentTarget.dataset.id) |
|
if (active !== this.data.active) { |
|
this.setData({ |
|
active |
|
}) |
|
} |
|
}, |
|
|
|
comeBack() { |
|
wx.navigateBack({ |
|
delta: 1 |
|
}) |
|
}, |
|
|
|
markHide() { |
|
this.setData({ |
|
markShow: false |
|
}) |
|
}, |
|
getData() { |
|
|
|
$api.AJAX('GET', 'applets/landtolistlonlat/list/' + this.data.landListedId, true).then(res => { |
|
if (res&&res.data&&res.data.length > 0) { |
|
this.setWKT1(res, 3); |
|
if(res.data[0].centerPoint){ |
|
centerPoint = res.data[0].centerPoint; |
|
let point = WKT.parse(centerPoint); |
|
this.setData({ |
|
latitude: point.coordinates[1], |
|
longitude: point.coordinates[0], |
|
}) |
|
} |
|
} |
|
}) |
|
|
|
$api.AJAX('GET', 'applets/landtolist/' + this.data.landListedId, { id: this.data.landListedId }, true).then(res => { |
|
for (let key in res.data) { |
|
if (!res.data[key]) { |
|
res.data[key] = '' |
|
} |
|
} |
|
if (res.data.transactionStatus == 'toBeListed') { |
|
this.setData({ |
|
tabList: [ |
|
{ |
|
id: 1, |
|
name: '拟供地块' |
|
} |
|
] |
|
}) |
|
} |
|
|
|
if(res.data.totalConsArea&&res.data.totalConsArea!=''&&res.data.totalConsArea!=0){ |
|
res.data.bizSpaceRatio=((res.data.bizSpace/res.data.totalConsArea)*100).toFixed(2); |
|
res.data.commerceSpaceRatio=((res.data.commerceSpace/res.data.totalConsArea)*100).toFixed(2); |
|
}else{ |
|
res.data.bizSpaceRatio=0; |
|
res.data.commerceSpaceRatio=0; |
|
} |
|
|
|
let totalConsArea = res.data.totalConsArea; |
|
this.setData({ |
|
myData: res.data |
|
}) |
|
$api.AJAX('GET', 'applets/landlistedconstructionplan/list/' + this.data.landListedId, true).then(res => { |
|
let plan = 0; |
|
let planRatio = 0; |
|
let unplan = 0; |
|
|
|
for(let i in res.data){ |
|
if(res.data[i].constructionType=='1'){ |
|
plan+=res.data[i].constructionArea |
|
}else if(res.data[i].constructionType=='2'){ |
|
unplan+=res.data[i].constructionArea |
|
} |
|
} |
|
if (totalConsArea&&totalConsArea!=''&&totalConsArea!=0){ |
|
planRatio = (plan/totalConsArea*100).toFixed(2); |
|
} |
|
|
|
this.setData({ |
|
'myData.plan': plan, |
|
'myData.planRatio': planRatio, |
|
'myData.unplan': unplan, |
|
}) |
|
}) |
|
}) |
|
}, |
|
|
|
//复制了一份,因为参数问题 |
|
setWKT1(data, id) { |
|
let { |
|
polygons |
|
} = this.data; |
|
let newPolygons = data.data.filter(item=>{ |
|
return item.geoms || item.geom; |
|
}).map(item => { |
|
let geomPoints = WKT.parse(item.geoms || item.geom); |
|
console.log(geomPoints); |
|
let points = []; |
|
geomPoints.coordinates[0].forEach(ele => { |
|
if (typeof (ele[0]) === 'number') { |
|
points.push({ |
|
longitude: ele[0], |
|
latitude: ele[1] |
|
}) |
|
} else { |
|
points = ele.map(once => { |
|
let lonlat = { |
|
longitude: once[0], |
|
latitude: once[1] |
|
} |
|
return lonlat |
|
}) |
|
} |
|
}) |
|
let strokeColor = '' + item.lineColor + util.ten2XO(item.lineOpaqueness); |
|
let strokeWidth = item.strokeWidth ? Number(item.strokeWidth) : 2; |
|
let fillColor = '' + item.fillColor + util.ten2XO(item.fillOpaqueness); |
|
let polygon = { |
|
points, |
|
strokeColor, |
|
strokeWidth, |
|
fillColor, |
|
zIndex: 1, |
|
id |
|
} |
|
return polygon |
|
}); |
|
// polygons = polygons.concat(newPolygons); |
|
this.setData({ |
|
polygons: polygons.concat(newPolygons) |
|
}) |
|
}, |
|
goCalculate() { |
|
if (this.data.active === 4) { |
|
let basis = this.selectComponent('#basis'); |
|
basis.calculate() |
|
} else { |
|
let senior = this.selectComponent('#senior'); |
|
senior.calculate() |
|
} |
|
|
|
}, |
|
clearData() { |
|
if (this.data.active === 4) { |
|
let basis = this.selectComponent('#basis'); |
|
basis.clearData() |
|
} else { |
|
let senior = this.selectComponent('#senior'); |
|
senior.clearData() |
|
} |
|
}, |
|
save() { |
|
if (this.data.active === 4) { |
|
let basis = this.selectComponent('#basis'); |
|
basis.save() |
|
} else { |
|
let senior = this.selectComponent('#senior'); |
|
senior.save() |
|
} |
|
}, |
|
submit() { |
|
if (this.data.active === 4) { |
|
let basis = this.selectComponent('#basis'); |
|
basis.submit() |
|
} else { |
|
let senior = this.selectComponent('#senior'); |
|
senior.submit() |
|
} |
|
|
|
}, |
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
let active = options.active; |
|
this.setData({ |
|
landListedId: options.id |
|
}) |
|
this.gotoLocation(this.data.landListedId); |
|
this.getData(options.id) |
|
if (active) { |
|
active = Number(active); |
|
console.log(active) |
|
if (active > 3) { |
|
this.setData({ |
|
state: false, |
|
active |
|
}) |
|
} else { |
|
this.setData({ |
|
active |
|
}) |
|
} |
|
} |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function () { |
|
if (typeof this.getTabBar === 'function' && |
|
this.getTabBar()) { |
|
this.getTabBar().setData({ |
|
selected: 1 |
|
}) |
|
} |
|
}, |
|
}) |