与牧同行-小程序用户端
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.

119 lines
1.8 KiB

6 days ago
  1. // pages/map/map.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. markers: {
  8. longitude: null,
  9. latitude: null
  10. },
  11. activeTab: '',
  12. },
  13. // 切换标签页
  14. switchTab(e) {
  15. const tab = e.currentTarget.dataset.tab;
  16. this.setData({
  17. activeTab: tab
  18. });
  19. // 这里可以添加切换标签后的逻辑
  20. if (tab === 'clinic') {
  21. // 药店诊所相关操作
  22. console.log('切换到药店诊所');
  23. } else if (tab === 'guide') {
  24. // 办事指南相关操作
  25. console.log('切换到办事指南');
  26. }
  27. },
  28. // 获取当前位置信息
  29. getlocation() {
  30. var that = this
  31. wx.getLocation({
  32. isHighAccuracy: true,
  33. type: 'gcj02',
  34. success: function (res) {
  35. console.log(res);
  36. that.setData({
  37. ['markers.longitude']: res.longitude,
  38. ['markers.latitude']: res.latitude
  39. })
  40. }
  41. })
  42. },
  43. // 地图
  44. getMap() {
  45. wx.chooseLocation({
  46. success: res => {
  47. console.log(111, res);
  48. this.setData({
  49. ['markers.longitude']: res.longitude,
  50. ['markers.latitude']: res.latitude
  51. })
  52. }
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad(options) {
  59. this.getlocation()
  60. },
  61. /**
  62. * 生命周期函数--监听页面初次渲染完成
  63. */
  64. onReady() {
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow() {
  70. },
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide() {
  75. },
  76. /**
  77. * 生命周期函数--监听页面卸载
  78. */
  79. onUnload() {
  80. },
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh() {
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom() {
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage() {
  95. }
  96. })