index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '地图', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. latitude: 41.57385,
  13. longitude: 126.22398,
  14. markers:[
  15. {id: 3,latitude: 41.57385,longitude: 126.22398,},
  16. {id: 4,latitude: 41.811979,longitude: 126.918087,},
  17. // {latitude: 41.811979,longitude: 126.918087,}
  18. ],
  19. },
  20. toEdit: function (e) {
  21. const { id } = e.currentTarget.dataset;
  22. wx.navigateTo({ url: `/pages/map/detail?id=${id}` })
  23. },
  24. back: function () {
  25. wx.navigateBack({ url: '/pages/home/index' })
  26. },
  27. /**
  28. * 标示点移动触发
  29. */
  30. regionchange(e) {
  31. console.log(e.type)
  32. },
  33. /**
  34. * 点击标识点触发
  35. */
  36. markertap(e) {
  37. console.log(e)
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. // 计算高度
  44. this.searchHeight()
  45. },
  46. onLoad: function () {
  47. var that = this;
  48. wx.getLocation({
  49. type: "wgs84",
  50. success: function (res) {
  51. var latitude = res.latitude;
  52. var longitude = res.longitude;
  53. //console.log(res.latitude);
  54. that.setData({
  55. latitude: res.latitude,
  56. longitude: res.longitude,
  57. markers: [{
  58. latitude: res.latitude,
  59. longitude: res.longitude
  60. }]
  61. })
  62. }
  63. })
  64. },
  65. // 计算高度
  66. searchHeight: function () {
  67. let frameStyle = this.data.frameStyle;
  68. let client = app.globalData.client;
  69. // 减去状态栏
  70. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  71. // 是否减去底部菜单
  72. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  73. if (infoHeight) this.setData({ infoHeight: infoHeight })
  74. },
  75. /**
  76. * 生命周期函数--监听页面初次渲染完成
  77. */
  78. onReady: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面显示
  82. */
  83. onShow: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面隐藏
  87. */
  88. onHide: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面卸载
  92. */
  93. onUnload: function () {
  94. },
  95. /**
  96. * 页面相关事件处理函数--监听用户下拉动作
  97. */
  98. onPullDownRefresh: function () {
  99. },
  100. /**
  101. * 页面上拉触底事件的处理函数
  102. */
  103. onReachBottom: function () {
  104. },
  105. /**
  106. * 用户点击右上角分享
  107. */
  108. onShareAppMessage: function () {
  109. }
  110. })