map.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. console.log(options)
  16. let markers = [
  17. {
  18. longitude: Number(options.longitude),
  19. latitude: Number(options.latitude),
  20. housename: options.housename,
  21. iconPath: "none",
  22. callout: {
  23. content: options.housename,
  24. display: 'ALWAYS',
  25. padding: 15,
  26. anchorY: 10
  27. }
  28. }
  29. ]
  30. this.setData({
  31. house: Object.assign(this.data.house, options),
  32. markers,
  33. agency: {
  34. agency_name: options.agency_name,
  35. agency_id: options.agency_id,
  36. phone: options.phone
  37. }
  38. })
  39. },
  40. callTel () {
  41. wx.makePhoneCall({
  42. phoneNumber: this.data.agency.phone
  43. })
  44. },
  45. consultation () {
  46. wx.navigateTo({
  47. url: `/pages/chat/chat?toId=${this.data.agency.agency_id}&toName=${this.data.agency.agency_name}`
  48. })
  49. },
  50. toNav () {
  51. const { markers } = this.data
  52. wx.openLocation({
  53. latitude: markers[0].latitude,
  54. longitude: markers[0].longitude,
  55. scale: 11,
  56. name: markers[0].housename
  57. })
  58. }
  59. })