魏熙美 5 years ago
parent
commit
23014c87ff

+ 27
- 4
src/pages/building/list/add/components/amap.jsx View File

@@ -4,12 +4,15 @@ import { Map, Marker } from 'react-amap';
4 4
 import styles from '../amap.less'
5 5
 
6 6
 class Amap extends React.Component {
7
+
7 8
   constructor(props) {
8 9
     super(props);
10
+    
9 11
     // 高德地图 Marker 实例
10 12
     this.markerInstance = undefined
11 13
     // 高德地图 Map 实例
12 14
     this.mapInstance = undefined
15
+
13 16
     this.amapEvents = {
14 17
       created: mapInstance => {
15 18
         console.log('高德地图 Map 实例创建成功;如果你要亲自对实例进行操作,可以从这里开始。比如:');
@@ -20,7 +23,7 @@ class Amap extends React.Component {
20 23
           // 实例化Autocomplete
21 24
           const autoOptions = {
22 25
             // city 限定城市,默认全国
23
-            city: '全国',
26
+            // city: '025',
24 27
             // input 为绑定输入提示功能的input的DOM ID
25 28
             input: 'amapInput',
26 29
           }
@@ -76,14 +79,34 @@ class Amap extends React.Component {
76 79
       },
77 80
     }
78 81
     this.markerPosition = { longitude: 120, latitude: 30 };
82
+    const { value } = this.props
83
+    console.log('项目地图 value', value)
84
+
85
+
86
+
87
+    this.setMapPosition.bind(this)
79 88
   }
80 89
 
81
-  render() {
90
+  componentDidUpdate(prevProps) {
82 91
     const { value } = this.props
83
-    if (value) {
84
-     // this.markerInstance.setPosition(value.split(','))
92
+    // console.log('项目地图 value', value)
93
+    console.log('this.markerInstance: ', this.markerInstance, this.props)
94
+    if (this.props.value !== prevProps.value) {
95
+      if (value) {
96
+        console.log('项目地图 value', value)
97
+        this.setMapPosition(value)
98
+      }
99
+    }
100
+  }
101
+
102
+  setMapPosition(value) {
103
+    console.log('获取this:', this.markerInstance)
104
+    if (this.markerInstance) {
105
+      // this.markerInstance.setPosition(value)
85 106
     }
107
+  }
86 108
 
109
+  render() {
87 110
     return (
88 111
       <>
89 112
         <div style={{ width: '100%', height: '400px', position: 'relative' }}>

+ 2
- 2
src/pages/integralMall/writeOff.jsx View File

@@ -108,7 +108,7 @@ function header(props) {
108 108
   return (
109 109
     <>
110 110
       <Tabs onChange={callback} type="card">
111
-        <TabPane tab="扫码核销" key="1">
111
+        {/* <TabPane tab="扫码核销" key="1">
112 112
           <Row>
113 113
             <Col span={8} style={{ textAlign: 'center' }}>
114 114
               <img src={erweima} style={{ width: '50px', height: '50px', margin: '30px auto' }} />
@@ -129,7 +129,7 @@ function header(props) {
129 129
             </Col>
130 130
           </Row>
131 131
           <Dialog onEnter={handleEnter} onChange={changeCode} />
132
-        </TabPane>
132
+        </TabPane> */}
133 133
         <TabPane tab="手机号核销" key="2">
134 134
           <Row>
135 135
             <Col span={12} style={{ textAlign: 'center' }}>