map.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // pages/map/map.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. house: {},
  8. markers: [],
  9. agency: {}
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let markers = [
  16. {
  17. longitude: Number(options.longitude),
  18. latitude: Number(options.latitude),
  19. housename: options.housename,
  20. iconPath: "none",
  21. callout: {
  22. content: options.housename,
  23. display: 'ALWAYS',
  24. padding: 15,
  25. anchorY: 10
  26. }
  27. }
  28. ]
  29. this.setData({
  30. house: Object.assign(this.data.house, options),
  31. markers,
  32. agency: {
  33. agency_name: options.agency_name,
  34. agency_id: options.agency_id,
  35. phone: options.phone
  36. }
  37. })
  38. },
  39. callTel () {
  40. wx.makePhoneCall({
  41. phoneNumber: this.data.agency.phone
  42. })
  43. },
  44. consultation () {
  45. if (!getApp().globalData.token) {
  46. wx.navigateTo({
  47. url: '/pages/login/login',
  48. })
  49. return
  50. }
  51. wx.navigateTo({
  52. url: `/pages/chat/chat?toId=${this.data.agency.agency_id}&toName=${this.data.agency.agency_name}`
  53. })
  54. },
  55. toNav () {
  56. const { markers } = this.data
  57. wx.openLocation({
  58. latitude: markers[0].latitude,
  59. longitude: markers[0].longitude,
  60. scale: 11,
  61. name: markers[0].housename
  62. })
  63. }
  64. })