index.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { Component } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import { connect } from 'react-redux'
  4. import {View, Map, Button} from '@tarojs/components'
  5. import dayjs from 'dayjs';
  6. import { add, minus, asyncAdd } from '../../actions/counter'
  7. import './index.less'
  8. @connect(({ counter }) => ({
  9. counter
  10. }), (dispatch) => ({
  11. add () {
  12. dispatch(add())
  13. },
  14. dec () {
  15. dispatch(minus())
  16. },
  17. asyncAdd () {
  18. dispatch(asyncAdd())
  19. }
  20. }))
  21. class Index extends Component {
  22. constructor(props) {
  23. super(props);
  24. this.state={
  25. data:[],
  26. newArrder:{},
  27. newList:[
  28. {
  29. longitude: 112.9513,
  30. latitude: 28.23529,
  31. title:'营销员1',
  32. label:{
  33. content:'营销员1'
  34. }
  35. },
  36. {
  37. longitude: 112.9613,
  38. latitude: 28.23529,
  39. title:'营销员2',
  40. },
  41. {
  42. longitude: 112.9713,
  43. latitude: 28.23529,
  44. title:'营销员3',
  45. }
  46. ],
  47. }
  48. }
  49. componentDidShow () {
  50. }
  51. componentDidMount() {
  52. //获得当前位置
  53. Taro.getLocation({
  54. type: 'gcj02',
  55. isHighAccuracy:true,
  56. success: (res)=> {
  57. const latitude = res.latitude
  58. const longitude = res.longitude
  59. this.setState({
  60. newArrder:{
  61. latitude,
  62. longitude
  63. },
  64. })
  65. }
  66. })
  67. }
  68. render () {
  69. return (
  70. <View>
  71. <Map
  72. id="allmap"
  73. {...this.state.newArrder}
  74. markers={this.state.newList}
  75. />
  76. </View>
  77. )
  78. }
  79. }
  80. export default Index