GaodeHeader.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. Component({
  2. properties: {
  3. type: {
  4. type: String,
  5. value: ''
  6. },
  7. NavigationOrNot: {
  8. type: Boolean,
  9. value: false
  10. }
  11. },
  12. data: {
  13. gaodeType: 'car'
  14. },
  15. lifetimes: {
  16. attached: function() {
  17. // 在组件实例进入页面节点树时执行
  18. },
  19. ready: function() {
  20. // 在组件布局完成后执行
  21. this.initialize()
  22. },
  23. detached: function() {
  24. // 在组件实例被从页面节点树移除时执行
  25. }
  26. },
  27. watch: {
  28. 'properties.NavigationOrNot'(val) {
  29. console.log('type变化', val)
  30. }
  31. },
  32. methods: {
  33. initialize: function() {
  34. // 自定义的初始化方法
  35. console.log('initialize', this.properties)
  36. this.setData({
  37. gaodeType: this.properties.type
  38. })
  39. // 例如设置一些初始状态
  40. },
  41. setType: function(type) {
  42. this.setData({
  43. gaodeType: type
  44. })
  45. this.triggerEvent('changeType', {
  46. gaode_type: type
  47. });
  48. },
  49. goToCar: function() {
  50. // 处理驾车逻辑
  51. console.log('驾车')
  52. this.setType('car')
  53. },
  54. goToWalk: function() {
  55. // 处理步行逻辑
  56. console.log('步行')
  57. this.setType('walk')
  58. },
  59. goToBus: function() {
  60. // 处理公交逻辑
  61. console.log('公交')
  62. this.setType('bus')
  63. },
  64. goToRide: function() {
  65. // 处理骑行逻辑
  66. console.log('骑行')
  67. this.setType('riding')
  68. }
  69. }
  70. })