rtuNavigateInfoView.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. lng: 116.403119,
  8. lat: 39.913828,
  9. address: '',
  10. name:'',
  11. rtuCode: '',
  12. includepoints: [],
  13. markers: [],
  14. loactionList: [],
  15. scale: 10,
  16. },
  17. onLoad: function (options) {
  18. var openid = wx.getStorageSync('openid');
  19. var rtuCode = options.rtuCode;
  20. this.setData({
  21. rtuCode: rtuCode,
  22. openId: openid
  23. })
  24. let that = this;
  25. wx.request({
  26. url: app.globalData.cloudBase + '/Wx/Project/Rtu/Data/NavigateInfo/' + rtuCode,
  27. method: 'GET',
  28. header: {
  29. "Content-Type": "json"
  30. },
  31. success: function (res) {
  32. console.info(res.data.data)
  33. that.setData({
  34. lat: res.data.data.lat,
  35. lng: res.data.data.lng,
  36. address: res.data.data.address,
  37. name: res.data.data.name
  38. });
  39. }
  40. })
  41. },
  42. submitData: function (event) {
  43. if (this.data.lng.length > 0 || this.data.lat.length > 0) {
  44. var that = this;
  45. const latitude = parseFloat(this.data.lat);
  46. const longitude = parseFloat(this.data.lng);
  47. const name=this.data.address;
  48. const address=this.data.address;
  49. wx.openLocation({
  50. latitude,
  51. longitude,
  52. name,
  53. address,
  54. scale: 12
  55. })
  56. } else {
  57. wx.showToast({
  58. title: '请检查经纬是否已经设置!',
  59. icon: 'none',
  60. duration: 3000
  61. })
  62. }
  63. },
  64. bindAddressKeyInput: function (e) {
  65. this.setData({
  66. address: e.detail.value
  67. })
  68. },
  69. error(e) {
  70. console.log(e.detail)
  71. }
  72. })