// 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: '公告信息' }, { id: 2, name: '成交信息' }, { id: 3, name: '呈现项目' }, // { // id: 6, // name: '拟供地块' // } ], sedTabList: [{ id: 4, name: '基础测算' }, { id: 5, name: '高级测算' }], active: 1,//当前选择项 markShow: false, annoutInfo: {}, clinchInfo: {}, presentInfo: { list: {}, more: [] }, latitude: '29.56', longitude: '106.58', basisInfo: {}, seniorInfo: {}, polygons: [], orgiData: {}, isDone: false, mid: '', }, //定位当前 // gotoLocation(id) { // $api.AJAX('GET', 'applets/landlistedlonlat/list/' + id, true).then(res => { // var latitude = res.data[0].landLonLat.split(';')[0].split(',')[0] // var longitude = res.data[0].landLonLat.split(';')[0].split(',')[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(id) { // ===正常拿到数据后做以下操作======== let centerPoint;//经纬度 let geom;//集合 $api.AJAX('GET', 'applets/landlistedlonlat/list/' + id, { landListedId: id }, true).then(res => { console.log(res); if(res.data.length>0){ centerPoint = res.data[0].centerPoint; this.setWKT1(res, 2) let point = WKT.parse(centerPoint); this.setData({ latitude: point.coordinates[1], longitude: point.coordinates[0], }) } }) $api.getLandDetail(this.data.landListedId).then(res => { for (let key in res.data) { if (!res.data[key]) { res.data[key] = '' } } this.setData({ myData: res.data }) $api.getPreSaleDetailList({ landListedId: this.data.landListedId }).then(res => { this.setData({ 'presentInfo.more': res.data }) }) $api.getPreSaleTotal({ landListedId: this.data.landListedId }).then(res => { this.setData({ 'presentInfo.list': res.data }) }) }) }, //复制了一份,因为参数问题 setWKT1(data, id) { let { polygons } = this.data; let newPolygons = data.data.map(item => { console.log(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) }) }, wkt2polygon(geom) { let geomPoints = WKT.parse(geom); 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 polygon = { points, zIndex: 1, } return polygon; }, 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'); console.log(basis); basis.submit() } else { let senior = this.selectComponent('#senior'); senior.submit() } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); let active = options.active; this.setData({ landListedId: options.id, mid: options.mid }) // 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 }) } }, })