diff --git a/components/detail-announcement/detail-announcement.js b/components/detail-announcement/detail-announcement.js index 8a81dd8..be7daae 100644 --- a/components/detail-announcement/detail-announcement.js +++ b/components/detail-announcement/detail-announcement.js @@ -1,4 +1,5 @@ const $api = require('../../utils/api').API; +const WKT = require('../../utils/terraformer-wkt-parser.min'); Component({ options: { addGlobalClass: true @@ -85,25 +86,31 @@ Component({ // var landListedId = 'CQ202106280037' if (this.properties.info.transactionStatus == 'toBeListed') { $api.AJAX('GET', 'applets/landtolistlonlat/list/' + proposedseriaId, true).then(res => { - var latitude = res.data[0].landLonLat.split(';')[0].split(',')[0] - var longitude = res.data[0].landLonLat.split(';')[0].split(',')[1] - wx.openLocation({ - latitude: Number(longitude), - longitude: Number(latitude), - name: res.data[0].name, - scale: 28 - }) + 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] + wx.openLocation({ + latitude: Number(longitude), + longitude: Number(latitude), + name: res.data[0].name, + scale: 28 + }) + } }) } else { $api.AJAX('GET', 'applets/landlistedlonlat/list/' + landListedId, true).then(res => { - var latitude = res.data[0].landLonLat.split(';')[0].split(',')[0] - var longitude = res.data[0].landLonLat.split(';')[0].split(',')[1] - wx.openLocation({ - latitude: Number(longitude), - longitude: Number(latitude), - name: res.data[0].name, - scale: 28 - }) + 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] + wx.openLocation({ + latitude: Number(longitude), + longitude: Number(latitude), + name: res.data[0].name, + scale: 28 + }) + } }) } }