|
@@ -1,6 +1,8 @@
|
|
|
import { Component } from 'react'
|
|
|
+import Taro from '@tarojs/taro'
|
|
|
import { connect } from 'react-redux'
|
|
|
-import { View, Button, Text } from '@tarojs/components'
|
|
|
+import {View, Map, Button} from '@tarojs/components'
|
|
|
+import dayjs from 'dayjs';
|
|
|
|
|
|
import { add, minus, asyncAdd } from '../../actions/counter'
|
|
|
|
|
@@ -21,24 +23,127 @@ import './index.less'
|
|
|
}
|
|
|
}))
|
|
|
class Index extends Component {
|
|
|
- componentWillReceiveProps (nextProps) {
|
|
|
- console.log(this.props, nextProps)
|
|
|
+ constructor(props) {
|
|
|
+ super(props);
|
|
|
+ this.state={
|
|
|
+ data:[],
|
|
|
+ newArrder:{},
|
|
|
+ newList:[
|
|
|
+ {
|
|
|
+ longitude: 112.9513,
|
|
|
+ latitude: 28.23529,
|
|
|
+ title:'营销员1',
|
|
|
+ label:{
|
|
|
+ content:'营销员1'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ longitude: 112.9613,
|
|
|
+ latitude: 28.23529,
|
|
|
+ title:'营销员2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ longitude: 112.9713,
|
|
|
+ latitude: 28.23529,
|
|
|
+ title:'营销员3',
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- componentWillUnmount () { }
|
|
|
-
|
|
|
- componentDidShow () { }
|
|
|
+ componentDidShow () {
|
|
|
+ const chooseLocation = requirePlugin('chooseLocation');
|
|
|
+ const location = chooseLocation.getLocation();
|
|
|
+ console.log(location);
|
|
|
+ }
|
|
|
|
|
|
- componentDidHide () { }
|
|
|
+ componentDidMount() {
|
|
|
+ Taro.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ isHighAccuracy:true,
|
|
|
+ success: (res)=> {
|
|
|
+ const latitude = res.latitude
|
|
|
+ const longitude = res.longitude
|
|
|
+ console.log(latitude,longitude)
|
|
|
+ this.setState({
|
|
|
+ newArrder:{
|
|
|
+ latitude,
|
|
|
+ longitude
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ Taro.startLocationUpdateBackground({
|
|
|
+ success:()=>{
|
|
|
+ Taro.onLocationChange((data) => {
|
|
|
+ let arr = this.state.data
|
|
|
+ arr.push({
|
|
|
+ long:data.longitude,
|
|
|
+ latitude:data.latitude
|
|
|
+ })
|
|
|
+ console.log(arr,'arr')
|
|
|
+ this.setState({
|
|
|
+ data:this.state.data
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
render () {
|
|
|
return (
|
|
|
- <View className='index'>
|
|
|
- <Button className='add_btn' onClick={this.props.add}>+</Button>
|
|
|
- <Button className='dec_btn' onClick={this.props.dec}>-</Button>
|
|
|
- <Button className='dec_btn' onClick={this.props.asyncAdd}>async</Button>
|
|
|
- <View><Text>{this.props.counter.num}</Text></View>
|
|
|
- <View><Text>Hello, World</Text></View>
|
|
|
+ <View>
|
|
|
+ <Map
|
|
|
+ id="allmap"
|
|
|
+ {...this.state.newArrder}
|
|
|
+ markers={this.state.newList}
|
|
|
+ polyline={[{
|
|
|
+ points: [{
|
|
|
+ longitude: 112.9513,
|
|
|
+ latitude: 28.23529
|
|
|
+ }, {
|
|
|
+ longitude: 112.9713,
|
|
|
+ latitude: 28.23529
|
|
|
+ }, {
|
|
|
+ longitude: 112.9913,
|
|
|
+ latitude: 28.23529
|
|
|
+ }, {
|
|
|
+ longitude: 112.9313,
|
|
|
+ latitude: 28.23529
|
|
|
+ },{
|
|
|
+ longitude: 112.9313,
|
|
|
+ latitude: 28.23529
|
|
|
+ },{
|
|
|
+ longitude: 112.9313,
|
|
|
+ latitude: 28.23529
|
|
|
+ }],
|
|
|
+ color: "#33c9FFDD",
|
|
|
+ width: 3,
|
|
|
+ dottedLine: true
|
|
|
+ }]}
|
|
|
+ circles={[
|
|
|
+ {
|
|
|
+ longitude: 112.9513,
|
|
|
+ latitude: 28.23529,
|
|
|
+ color:'#DC3E28',
|
|
|
+ fillColor:'#DC3E28',
|
|
|
+ radius:50
|
|
|
+ }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <Button onClick={()=>{
|
|
|
+ const key = 'BP4BZ-JQJED-5DG4N-H6JND-KC5PK-D2BDL'; //使用在腾讯位置服务申请的key
|
|
|
+ const referer = '科德高企培育'; //调用插件的app的名称
|
|
|
+ const location = JSON.stringify({
|
|
|
+ latitude: 39.89631551,
|
|
|
+ longitude: 116.323459711
|
|
|
+ });
|
|
|
+ const category = '生活服务,娱乐休闲';
|
|
|
+
|
|
|
+ Taro.navigateTo({
|
|
|
+ url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&location=' + location + '&category=' + category
|
|
|
+ });
|
|
|
+ }}>选址</Button>
|
|
|
</View>
|
|
|
)
|
|
|
}
|