1
|
<!doctype html>
|
1
|
<!doctype html>
|
2
|
<html lang="en">
|
2
|
<html lang="en">
|
3
|
-<head>
|
3
|
+
|
|
|
4
|
+ <head>
|
4
|
<meta charset="UTF-8">
|
5
|
<meta charset="UTF-8">
|
5
|
- <meta name="viewport"
|
|
|
6
|
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
6
|
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
7
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8
|
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
|
8
|
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
|
9
|
<title></title>
|
9
|
<title></title>
|
10
|
- <script src="../../assets/js/fontsize.js"></script>
|
|
|
11
|
- <link rel="stylesheet" href="../../assets/css/api.css"/>
|
10
|
+ <!--<link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>-->
|
12
|
<link rel="stylesheet" href="../../assets/icon/iconfont.css">
|
11
|
<link rel="stylesheet" href="../../assets/icon/iconfont.css">
|
13
|
- <style type="text/css">
|
|
|
14
|
- body {
|
|
|
15
|
- padding-bottom: 1rem;
|
|
|
16
|
- }
|
12
|
+ <script src="../../assets/js/fontsize.js"></script>
|
|
|
13
|
+ <link rel="stylesheet" href="../../assets/css/weui.min.css">
|
|
|
14
|
+ <link rel="stylesheet" href="../../assets/css/api.css" />
|
17
|
|
15
|
|
18
|
- .city_top {
|
|
|
19
|
- position: fixed;
|
|
|
20
|
- left: 0;
|
|
|
21
|
- top: 0;
|
|
|
22
|
- width: 100%;
|
|
|
23
|
- display: flex;
|
|
|
24
|
- align-items: center;
|
|
|
25
|
- justify-content: space-between;
|
|
|
26
|
- padding: 0.25rem;
|
|
|
27
|
- font-size: 0.3rem;
|
|
|
28
|
- color: #333;
|
|
|
29
|
- border: 1px solid #f5f5f5;
|
|
|
30
|
- background-color: #fff;
|
|
|
31
|
- }
|
|
|
32
|
|
16
|
|
33
|
- .city_name_box {
|
|
|
34
|
- display: flex;
|
|
|
35
|
- align-items: center;
|
|
|
36
|
- flex: 1;
|
|
|
37
|
- }
|
17
|
+ <!-- <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>-->
|
|
|
18
|
+ <style type="text/css">
|
|
|
19
|
+ body {
|
|
|
20
|
+ padding-bottom: 1rem;
|
|
|
21
|
+ }
|
38
|
|
22
|
|
39
|
- .city_name_box .iconfont {
|
|
|
40
|
- margin: 0 0.1rem 0 0;
|
|
|
41
|
- }
|
23
|
+ .city_top {
|
|
|
24
|
+ position: fixed;
|
|
|
25
|
+ left: 0;
|
|
|
26
|
+ top: 0;
|
|
|
27
|
+ width: 100%;
|
|
|
28
|
+ display: flex;
|
|
|
29
|
+ align-items: center;
|
|
|
30
|
+ justify-content: space-between;
|
|
|
31
|
+ padding: 0.25rem;
|
|
|
32
|
+ font-size: 0.3rem;
|
|
|
33
|
+ color: #333;
|
|
|
34
|
+ border: 1px solid #f5f5f5;
|
|
|
35
|
+ background-color: #fff;
|
|
|
36
|
+ }
|
42
|
|
37
|
|
43
|
- .city_input {
|
|
|
44
|
- flex: 3;
|
|
|
45
|
- margin: 0 0.1rem 0 0.1rem;
|
|
|
46
|
- background-color: #f2f2f2;
|
|
|
47
|
- padding: 0 0 0 0.2rem;
|
|
|
48
|
- border-radius: 0.1rem;
|
|
|
49
|
- }
|
38
|
+ .city_name_box {
|
|
|
39
|
+ display: flex;
|
|
|
40
|
+ align-items: center;
|
|
|
41
|
+ flex: 1;
|
|
|
42
|
+ }
|
50
|
|
43
|
|
51
|
- .city_input input {
|
|
|
52
|
- width: 100%;
|
|
|
53
|
- padding: 0.2rem 0.25rem;
|
|
|
54
|
- color: #333;
|
|
|
55
|
- font-size: 0.26rem;
|
|
|
56
|
- }
|
44
|
+ .city_name_box .iconfont {
|
|
|
45
|
+ margin: 0 0.1rem 0 0;
|
|
|
46
|
+ }
|
57
|
|
47
|
|
58
|
- .city_input input::-webkit-input-placeholder {
|
|
|
59
|
- color: #aaa;
|
|
|
60
|
- }
|
48
|
+ .city_input {
|
|
|
49
|
+ flex: 3;
|
|
|
50
|
+ margin: 0 0.1rem 0 0.1rem;
|
|
|
51
|
+ background-color: #f2f2f2;
|
|
|
52
|
+ padding: 0 0 0 0.2rem;
|
|
|
53
|
+ border-radius: 0.1rem;
|
|
|
54
|
+ }
|
61
|
|
55
|
|
62
|
- .city_item {
|
|
|
63
|
- padding: 0.3rem 0.25rem;
|
|
|
64
|
- color: #999;
|
|
|
65
|
- font-size: 0.26rem;
|
|
|
66
|
- display: flex;
|
|
|
67
|
- justify-content: space-between;
|
|
|
68
|
- }
|
56
|
+ .city_input input {
|
|
|
57
|
+ width: 100%;
|
|
|
58
|
+ padding: 0.2rem 0.25rem;
|
|
|
59
|
+ color: #333;
|
|
|
60
|
+ font-size: 0.26rem;
|
|
|
61
|
+ }
|
69
|
|
62
|
|
70
|
- .choose_box {
|
|
|
71
|
- display: flex;
|
|
|
72
|
- align-items: center;
|
|
|
73
|
- justify-content: space-between;
|
|
|
74
|
- font-size: 0.24rem;
|
|
|
75
|
- color: #333;
|
|
|
76
|
- padding: 0.2rem 0.25rem;
|
|
|
77
|
- border-bottom: 1px solid #f2f2f2;
|
|
|
78
|
- margin-top: 1.3rem;
|
|
|
79
|
- }
|
63
|
+ .city_input input::-webkit-input-placeholder {
|
|
|
64
|
+ color: #aaa;
|
|
|
65
|
+ }
|
80
|
|
66
|
|
81
|
- .position {
|
|
|
82
|
- display: flex;
|
|
|
83
|
- align-items: center;
|
67
|
+ .city_item {
|
|
|
68
|
+ padding: 0.3rem 0.25rem;
|
|
|
69
|
+ color: #999;
|
|
|
70
|
+ font-size: 0.26rem;
|
|
|
71
|
+ display: flex;
|
|
|
72
|
+ justify-content: space-between;
|
|
|
73
|
+ }
|
84
|
|
74
|
|
85
|
- }
|
75
|
+ .choose_box {
|
|
|
76
|
+ display: flex;
|
|
|
77
|
+ align-items: center;
|
|
|
78
|
+ justify-content: space-between;
|
|
|
79
|
+ font-size: 0.24rem;
|
|
|
80
|
+ color: #333;
|
|
|
81
|
+ padding: 0.2rem 0.25rem;
|
|
|
82
|
+ border-bottom: 1px solid #f2f2f2;
|
|
|
83
|
+ margin-top: 1.3rem;
|
|
|
84
|
+ }
|
86
|
|
85
|
|
87
|
- .position span {
|
|
|
88
|
- margin-left: 0.2rem;
|
|
|
89
|
- }
|
86
|
+ .position {
|
|
|
87
|
+ display: flex;
|
|
|
88
|
+ align-items: center;
|
|
|
89
|
+ }
|
90
|
|
90
|
|
91
|
- .city_name {
|
|
|
92
|
- color: #333;
|
|
|
93
|
- font-size: 0.3rem;
|
|
|
94
|
- }
|
91
|
+ .position span {
|
|
|
92
|
+ margin-left: 0.2rem;
|
|
|
93
|
+ }
|
95
|
|
94
|
|
96
|
- .city_address {
|
|
|
97
|
- font-size: 0.26rem;
|
|
|
98
|
- }
|
95
|
+ .city_name {
|
|
|
96
|
+ color: #333;
|
|
|
97
|
+ font-size: 0.3rem;
|
|
|
98
|
+ }
|
99
|
|
99
|
|
100
|
- .my_address {
|
|
|
101
|
- margin: 0.25rem;
|
|
|
102
|
- }
|
100
|
+ .city_address {
|
|
|
101
|
+ font-size: 0.26rem;
|
|
|
102
|
+ }
|
103
|
|
103
|
|
104
|
- .my_address .iconfont {
|
|
|
105
|
- margin: 0 0.1rem 0 0;
|
|
|
106
|
- color: #ccc;
|
|
|
107
|
- }
|
104
|
+ .my_address {
|
|
|
105
|
+ margin: 0.25rem;
|
|
|
106
|
+ }
|
108
|
|
107
|
|
109
|
- .address_title {
|
|
|
110
|
- font-size: 14px;
|
|
|
111
|
- color: #999;
|
|
|
112
|
- }
|
108
|
+ .my_address .iconfont {
|
|
|
109
|
+ margin: 0 0.1rem 0 0;
|
|
|
110
|
+ color: #ccc;
|
|
|
111
|
+ }
|
113
|
|
112
|
|
114
|
- .choose_city {
|
|
|
115
|
- font-size: 18px;
|
|
|
116
|
- }
|
113
|
+ .address_title {
|
|
|
114
|
+ font-size: 14px;
|
|
|
115
|
+ color: #999;
|
|
|
116
|
+ }
|
117
|
|
117
|
|
118
|
- .address_item {
|
|
|
119
|
- color: #424242;
|
|
|
120
|
- font-size: 16px;
|
|
|
121
|
- padding: 0.26rem 0.5rem 0.26rem 0.2rem;
|
|
|
122
|
- border-bottom: 1px solid #f2f2f2;
|
|
|
123
|
- }
|
118
|
+ .choose_city {
|
|
|
119
|
+ font-size: 18px;
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+ .address_item {
|
|
|
123
|
+ color: #424242;
|
|
|
124
|
+ font-size: 16px;
|
|
|
125
|
+ padding: 0.26rem 0.5rem 0.26rem 0.2rem;
|
|
|
126
|
+ border-bottom: 1px solid #f2f2f2;
|
|
|
127
|
+ }
|
124
|
</style>
|
128
|
</style>
|
125
|
-</head>
|
|
|
126
|
-<body>
|
|
|
127
|
-<div id="loadStart"></div>
|
|
|
128
|
-<div id="app" v-cloak>
|
|
|
129
|
- <div class="city_top">
|
129
|
+ </head>
|
|
|
130
|
+
|
|
|
131
|
+ <body>
|
|
|
132
|
+ <div id="loadStart"></div>
|
|
|
133
|
+ <div id="app" v-cloak>
|
|
|
134
|
+
|
|
|
135
|
+ <div id="container"></div>
|
|
|
136
|
+ <div class="city_top">
|
130
|
<div class="city_name_box" @click="choose_city_fun">
|
137
|
<div class="city_name_box" @click="choose_city_fun">
|
131
|
- <span class="iconfont icon-dizhi"></span>
|
|
|
132
|
- <div class="clamp1">{{cityname}}</div>
|
|
|
133
|
- </div>
|
138
|
+ <span class="iconfont icon-dizhi"></span>
|
|
|
139
|
+ <div class="clamp1">{{cityname}}</div>
|
|
|
140
|
+ </div>:
|
134
|
<div class="city_input"><input type="search" placeholder="请输入你的服务地址" v-model="keyword" @input="getCity"></div>
|
141
|
<div class="city_input"><input type="search" placeholder="请输入你的服务地址" v-model="keyword" @input="getCity"></div>
|
135
|
<div class="main_color" @click="search_word">搜索</div>
|
142
|
<div class="main_color" @click="search_word">搜索</div>
|
136
|
- </div>
|
|
|
137
|
- <div class="choose_box" @click="choose_now">
|
143
|
+ </div>
|
|
|
144
|
+ <div class="choose_box" @click="choose_now">
|
138
|
<span class="choose_city">{{street}}</span>
|
145
|
<span class="choose_city">{{street}}</span>
|
139
|
<div class="main_color position"><span class="iconfont icon-zhongxindingwei"></span><span>重新定位</span></div>
|
146
|
<div class="main_color position"><span class="iconfont icon-zhongxindingwei"></span><span>重新定位</span></div>
|
140
|
- </div>
|
|
|
141
|
- <div v-if="address_show">
|
147
|
+ </div>
|
|
|
148
|
+ <div v-if="address_show">
|
142
|
<div class="my_address">
|
149
|
<div class="my_address">
|
143
|
- <div class="address_title"><span class="iconfont icon-shouye"></span><span> 我的服务地址</span></div>
|
|
|
144
|
- <div class="address_item nodata" v-if="user_address_list.length==0">暂无服务地址</div>
|
|
|
145
|
- <div class="address_item" v-for="(item,index) in user_address_list"
|
|
|
146
|
- @click="choose_address(item.address,item.address_info,item.lon,item.lat)" v-else>
|
|
|
147
|
- <span>{{item.address}}{{item.address_info}}</span>
|
|
|
148
|
- </div>
|
150
|
+ <div class="address_title"><span class="iconfont icon-shouye"></span><span> 我的服务地址</span></div>
|
|
|
151
|
+ <div class="address_item nodata" v-if="user_address_list.length==0">暂无服务地址</div>
|
|
|
152
|
+ <div class="address_item" v-for="(item,index) in user_address_list" @click="choose_address(item.address,item.address_info,item.lon,item.lat)" v-else>
|
|
|
153
|
+ <span>{{item.address}}{{item.address_info}}</span>
|
|
|
154
|
+ </div>
|
149
|
</div>
|
155
|
</div>
|
150
|
<div class="my_address">
|
156
|
<div class="my_address">
|
151
|
- <div class="address_title"><span class="iconfont icon-dizhi"></span><span>我的附近地址</span></div>
|
|
|
152
|
- <div class="address_item" v-for="(item,index) in nearList"
|
|
|
153
|
- @click="choose_address(item.address,'',item.lon,item.lat)">
|
|
|
154
|
- <span>{{item.address}}</span>
|
|
|
155
|
- </div>
|
157
|
+ <div class="address_title"><span class="iconfont icon-dizhi"></span><span>我的附近地址</span></div>
|
|
|
158
|
+ <div class="address_item" v-for="(item,index) in nearList" @click="choose_address(item.address,'',item.lon,item.lat)">
|
|
|
159
|
+ <span>{{item.address}}</span>
|
|
|
160
|
+ </div>
|
156
|
</div>
|
161
|
</div>
|
157
|
- </div>
|
|
|
158
|
- <div v-for="(item,index) in keywords" class="city_item"
|
|
|
159
|
- @click="choose_address(item.address,item.name,item.lon,item.lat)" v-else>
|
162
|
+ </div>
|
|
|
163
|
+ <div v-for="(item,index) in keywords" class="city_item" @click="choose_address(item.address,item.name,item.lon,item.lat)" v-else>
|
160
|
<div>
|
164
|
<div>
|
161
|
- <div class="city_name">{{item.name}}</div>
|
|
|
162
|
- <div class="city_address">{{item.address}}</div>
|
165
|
+ <div class="city_name">{{item.name}}</div>
|
|
|
166
|
+ <div class="city_address">{{item.address}}</div>
|
163
|
</div>
|
167
|
</div>
|
|
|
168
|
+ </div>
|
164
|
</div>
|
169
|
</div>
|
165
|
-</div>
|
|
|
166
|
-</body>
|
170
|
+ </body>
|
|
|
171
|
+
|
167
|
</html>
|
172
|
</html>
|
|
|
173
|
+<!--<script src="https://webapi.amap.com/maps?v=1.4.8&key= ef53760bd959a4df08b7d4587280e642"></script>
|
|
|
174
|
+<script type="text/javascript">
|
|
|
175
|
+ var map = new AMap.Map('container', {
|
|
|
176
|
+ center:[117.000923,36.675807],
|
|
|
177
|
+ zoom:11
|
|
|
178
|
+ });
|
|
|
179
|
+</script>-->
|
|
|
180
|
+<script>
|
|
|
181
|
+ var map = {}
|
|
|
182
|
+ window.onLoad = function() {
|
|
|
183
|
+ map = new AMap.Map('container');
|
|
|
184
|
+ }
|
|
|
185
|
+ var url = 'https://webapi.amap.com/maps?v=1.4.8&key=ef53760bd959a4df08b7d4587280e642&callback=onLoad';
|
|
|
186
|
+ var jsapi = document.createElement('script');
|
|
|
187
|
+ jsapi.charset = 'utf-8';
|
|
|
188
|
+ jsapi.src = url;
|
|
|
189
|
+ document.head.appendChild(jsapi);
|
|
|
190
|
+</script>
|
|
|
191
|
+<script type="text/javascript" src="../../assets/js/weui.min.js"></script>
|
168
|
<script type="text/javascript" src="../../assets/js/api.js"></script>
|
192
|
<script type="text/javascript" src="../../assets/js/api.js"></script>
|
|
|
193
|
+<script ty></script>
|
169
|
<script type="text/javascript" src="../../assets/js/public.js"></script>
|
194
|
<script type="text/javascript" src="../../assets/js/public.js"></script>
|
170
|
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
|
195
|
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
|
171
|
<script>
|
196
|
<script>
|
172
|
- new FastClick(document.body);
|
197
|
+ new FastClick(document.body);
|
173
|
</script>
|
198
|
</script>
|
|
|
199
|
+
|
174
|
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
|
200
|
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
|
175
|
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
|
201
|
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
|
176
|
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
|
202
|
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
|
|
|
203
|
+<script type="text/javascript" src="https://cache.amap.com/lbs/static/PlaceSearchRender.js"></script>
|
|
|
204
|
+<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
|
177
|
<script>
|
205
|
<script>
|
178
|
- var app = new Vue({
|
|
|
179
|
- el: '#app',
|
|
|
180
|
- data: {
|
|
|
181
|
- cityname: '',
|
|
|
182
|
- lat: '',
|
|
|
183
|
- lng: '',
|
|
|
184
|
- keyword: '',
|
|
|
185
|
- keywords: [],
|
|
|
186
|
- cities: [],
|
|
|
187
|
- street: '',
|
|
|
188
|
- nearList: [],
|
|
|
189
|
- user_address_list: [],
|
|
|
190
|
- address_show: true,
|
|
|
191
|
- latitude: '',
|
|
|
192
|
- longitude: ''
|
|
|
193
|
- },
|
|
|
194
|
- created: function () {
|
|
|
195
|
- apiready = function () {
|
|
|
196
|
- api.setFrameAttr({
|
|
|
197
|
- name: 'choose_address',
|
|
|
198
|
- bounces: true
|
|
|
199
|
- });
|
|
|
200
|
- app.getNearBy();
|
|
|
201
|
- app.cityname = getcity() ? getcity() : api.pageParam.cityname;
|
|
|
202
|
- api.addEventListener({
|
|
|
203
|
- name: 'city'
|
|
|
204
|
- }, function (ret, err) {
|
|
|
205
|
- // alert(JSON.stringify(ret));
|
|
|
206
|
- app.cityname = ret.value.city;
|
|
|
207
|
- });
|
|
|
208
|
- app.getUsedAddress();
|
|
|
209
|
- }
|
|
|
210
|
- },
|
|
|
211
|
- methods: {
|
|
|
212
|
- // 获取我的服务地址
|
|
|
213
|
- getUsedAddress: function () {
|
|
|
214
|
- var header = {
|
|
|
215
|
- "XX-Device-Type": getDevice(),
|
|
|
216
|
- 'XX-Token': getToken()
|
|
|
217
|
- };
|
|
|
218
|
- getRequest('post', 'portal/Goods/getUsedAddress', null, header).then(function (res) {
|
|
|
219
|
- // alert(JSON.stringify(res));
|
|
|
220
|
- if (res.data.code == 1) {
|
|
|
221
|
- app.user_address_list = res.data.data;
|
|
|
222
|
- } else {
|
|
|
223
|
- toastMsg(res.data.msg)
|
|
|
224
|
- }
|
|
|
225
|
- })
|
|
|
226
|
- },
|
206
|
+ var app = new Vue({
|
|
|
207
|
+ el: '#app',
|
|
|
208
|
+ data: {
|
|
|
209
|
+ cityname: '',
|
|
|
210
|
+ lat: '',
|
|
|
211
|
+ lng: '',
|
|
|
212
|
+ keyword: '',
|
|
|
213
|
+ keywords: [],
|
|
|
214
|
+ cities: [],
|
|
|
215
|
+ street: '',
|
|
|
216
|
+ nearList: [],
|
|
|
217
|
+ user_address_list: [],
|
|
|
218
|
+ address_show: true,
|
|
|
219
|
+ latitude: '',
|
|
|
220
|
+ longitude: '',
|
|
|
221
|
+ //经度
|
|
|
222
|
+ lng: '',
|
|
|
223
|
+
|
|
|
224
|
+ //纬度
|
|
|
225
|
+ lat: '',
|
|
|
226
|
+ map: {},
|
|
|
227
|
+ //经纬度
|
|
|
228
|
+ centerPoint: []
|
|
|
229
|
+ },
|
|
|
230
|
+ created: function() {
|
|
|
231
|
+ loadEnd();
|
|
|
232
|
+ apiready = function() {
|
|
|
233
|
+ app.get_city();
|
|
|
234
|
+ app.getUsedAddress()
|
|
|
235
|
+
|
|
|
236
|
+ }
|
|
|
237
|
+
|
|
|
238
|
+ // app.getNearBy();
|
|
|
239
|
+ // app.cityname = getcity() ? getcity() : api.pageParam.cityname;
|
|
|
240
|
+ // api.addEventListener({
|
|
|
241
|
+ // name: 'city'
|
|
|
242
|
+ // }, function (ret, err) {
|
|
|
243
|
+ // // alert(JSON.stringify(ret));
|
|
|
244
|
+ // app.cityname = ret.value.city;
|
|
|
245
|
+ // });
|
|
|
246
|
+ // app.getUsedAddress();
|
|
|
247
|
+ },
|
|
|
248
|
+ methods: {
|
|
|
249
|
+ // 获取我的服务地址
|
|
|
250
|
+ getUsedAddress: function() {
|
|
|
251
|
+ var header = {
|
|
|
252
|
+ "XX-Device-Type": getDevice(),
|
|
|
253
|
+ 'XX-Token': getToken()
|
|
|
254
|
+ };
|
|
|
255
|
+ console.log(header)
|
|
|
256
|
+ getRequest('post', 'portal/Goods/getUsedAddress', null, header).then(function(res) {
|
|
|
257
|
+ //alert(JSON.stringify(res));
|
|
|
258
|
+ if(res.data.code == 1) {
|
|
|
259
|
+ app.user_address_list = res.data.data;
|
|
|
260
|
+ toastMsg(res.data.msg)
|
|
|
261
|
+ }
|
|
|
262
|
+ loadEnd();
|
|
|
263
|
+ })
|
|
|
264
|
+ },
|
227
|
// 重新获取当前定位信息
|
265
|
// 重新获取当前定位信息
|
228
|
- choose_now: function () {
|
|
|
229
|
- api.showProgress({
|
|
|
230
|
- title: '正在重新定位',
|
|
|
231
|
- text: '定位中...',
|
|
|
232
|
- modal: true
|
|
|
233
|
- });
|
|
|
234
|
- app.getNearBy();
|
|
|
235
|
- setTimeout(function() {
|
|
|
236
|
- api.hideProgress();
|
|
|
237
|
- }, 2000)
|
|
|
238
|
- },
|
|
|
239
|
- // 获取附近地址
|
|
|
240
|
- getNearBy: function () {
|
|
|
241
|
- var aMap = api.require('aMap');
|
|
|
242
|
- aMap.open({
|
|
|
243
|
- rect: {
|
|
|
244
|
- x: 0,
|
|
|
245
|
- y: 0,
|
|
|
246
|
- w: 0,
|
|
|
247
|
- h: 0
|
|
|
248
|
- },
|
|
|
249
|
- }, function (ret, err) {
|
|
|
250
|
- if (ret.status) {
|
|
|
251
|
- aMap.getLocation(function (ret_loc, err_loc) {
|
|
|
252
|
- if (ret_loc.status) {
|
|
|
253
|
- aMap.getNameFromCoords({
|
|
|
254
|
- lon: ret_loc.lon,
|
|
|
255
|
- lat: ret_loc.lat
|
|
|
256
|
- }, function (ret_city, err_city) {
|
|
|
257
|
- if (ret_city.status) {
|
|
|
258
|
- app.getName(ret_loc.lon, ret_loc.lat);
|
|
|
259
|
- app.street = ret_city.street;
|
|
|
260
|
- // app.cityname=ret.
|
|
|
261
|
- aMap.searchNearby({
|
|
|
262
|
- keyword: ret_city.street,
|
|
|
263
|
- lon: ret_loc.lon,
|
|
|
264
|
- lat: ret_loc.lat,
|
|
|
265
|
- radius: 1000,
|
|
|
266
|
- offset: 20,
|
|
|
267
|
- page: 1,
|
|
|
268
|
- sortrule: 0
|
|
|
269
|
- }, function (ret_near, err_near) {
|
|
|
270
|
- if (ret_near.status) {
|
|
|
271
|
- app.nearList = ret_near.pois.slice(0, 10);
|
|
|
272
|
- }
|
|
|
273
|
- loadEnd();
|
|
|
274
|
- });
|
|
|
275
|
-
|
|
|
276
|
- } else {
|
|
|
277
|
- toastMsg(JSON.stringify(err_city));
|
|
|
278
|
- }
|
|
|
279
|
- });
|
|
|
280
|
-
|
|
|
281
|
- } else {
|
|
|
282
|
- toastMsg(JSON.stringify(err_loc));
|
|
|
283
|
- }
|
|
|
284
|
- });
|
|
|
285
|
- } else {
|
|
|
286
|
- toastMsg(JSON.stringify(err));
|
|
|
287
|
- }
|
|
|
288
|
- });
|
|
|
289
|
- },
|
|
|
290
|
- // 获取搜索地址
|
|
|
291
|
- getCity: function () {
|
|
|
292
|
- if (app.keyword == '') {
|
|
|
293
|
- app.address_show = true;
|
|
|
294
|
- } else {
|
|
|
295
|
- app.address_show = false;
|
|
|
296
|
- }
|
|
|
297
|
- var aMap = api.require('aMap');
|
|
|
298
|
- aMap.searchInCity({
|
|
|
299
|
- city: app.cityname,
|
|
|
300
|
- keyword: app.keyword,
|
|
|
301
|
- offset: 20,
|
|
|
302
|
- page: 1,
|
|
|
303
|
- sortrule: 0
|
|
|
304
|
- }, function (ret) {
|
|
|
305
|
- if (ret.status) {
|
|
|
306
|
- app.keywords = ret.pois;
|
|
|
307
|
- // alert(JSON.stringify(app.keywords))
|
|
|
308
|
- }
|
|
|
309
|
- });
|
|
|
310
|
- },
|
|
|
311
|
- // 搜索地址
|
|
|
312
|
- search_word: function () {
|
|
|
313
|
- if (app.keyword == '') {
|
|
|
314
|
- toastMsg('请输入搜索内容')
|
|
|
315
|
- } else {
|
|
|
316
|
- app.getCity();
|
|
|
317
|
- }
|
|
|
318
|
- },
|
|
|
319
|
- // 选择地址
|
|
|
320
|
- choose_address: function (address, name, longitude, latitude) {
|
|
|
321
|
- api.sendEvent({
|
|
|
322
|
- name: 'choose_city',
|
|
|
323
|
- extra: {
|
|
|
324
|
- address: address,
|
|
|
325
|
- name: name,
|
|
|
326
|
- longitude: longitude,
|
|
|
327
|
- latitude: latitude,
|
|
|
328
|
- city: app.cityname
|
|
|
329
|
- }
|
|
|
330
|
- });
|
|
|
331
|
- closeWindow();
|
|
|
332
|
- },
|
|
|
333
|
- // 切换城市
|
|
|
334
|
- choose_city_fun: function () {
|
|
|
335
|
- api.openWin({
|
|
|
336
|
- url: '../index/city_win.html',
|
|
|
337
|
- name: 'city_win'
|
|
|
338
|
- });
|
|
|
339
|
- $api.rmStorage('city')
|
|
|
340
|
- },
|
|
|
341
|
- getName: function (lon, lat) {
|
|
|
342
|
- var aMap = api.require('aMap');
|
|
|
343
|
- aMap.getNameFromCoords({
|
|
|
344
|
- lon: lon,
|
|
|
345
|
- lat: lat,
|
|
|
346
|
- }, function (ret, err) {
|
|
|
347
|
- if (ret.status) {
|
|
|
348
|
- // alert(JSON.stringify(ret))
|
|
|
349
|
- app.cityname = ret.city
|
|
|
350
|
- } else {
|
|
|
351
|
- // toastMsg(err.code);
|
|
|
352
|
- }
|
|
|
353
|
- });
|
|
|
354
|
- }
|
|
|
355
|
- }
|
|
|
356
|
- })
|
|
|
357
|
-</script> |
|
|
|
|
266
|
+ choose_now: function() {
|
|
|
267
|
+
|
|
|
268
|
+ toastMsg('正在重新定位')
|
|
|
269
|
+ app.get_city()
|
|
|
270
|
+ setTimeout(function() {
|
|
|
271
|
+// api.hideProgress();
|
|
|
272
|
+ }, 2000)
|
|
|
273
|
+ },
|
|
|
274
|
+
|
|
|
275
|
+ // 定位当前城市
|
|
|
276
|
+ get_city: function() {
|
|
|
277
|
+
|
|
|
278
|
+ app.map = new AMap.Map('container', {});
|
|
|
279
|
+ app.map.plugin('AMap.Geolocation', function() {
|
|
|
280
|
+ var geolocation = new AMap.Geolocation({
|
|
|
281
|
+ // 是否使用高精度定位,默认:true
|
|
|
282
|
+ enableHighAccuracy: true,
|
|
|
283
|
+ // 设置定位超时时间,默认:无穷大
|
|
|
284
|
+ timeout: 10000,
|
|
|
285
|
+ });
|
|
|
286
|
+ geolocation.getCurrentPosition();
|
|
|
287
|
+ AMap.event.addListener(geolocation, 'complete', onComplete)
|
|
|
288
|
+ AMap.event.addListener(geolocation, 'error', onError)
|
|
|
289
|
+
|
|
|
290
|
+ function onComplete(data) {
|
|
|
291
|
+ // console.log(JSON.stringify(data));
|
|
|
292
|
+
|
|
|
293
|
+ app.cityname = data.addressComponent.province;
|
|
|
294
|
+ console.log(app.cityname);
|
|
|
295
|
+ app.lng = data.position.lng;
|
|
|
296
|
+ app.lat = data.position.lat;
|
|
|
297
|
+ // console.log(app.lng);
|
|
|
298
|
+ // console.log(app.lat);
|
|
|
299
|
+ //
|
|
|
300
|
+ // 获取附近地址
|
|
|
301
|
+ app.map = new AMap.Map('container', {});
|
|
|
302
|
+ AMap.service(["AMap.PlaceSearch"], function() {
|
|
|
303
|
+ var placeSearch = new AMap.PlaceSearch({
|
|
|
304
|
+ pageSize: 10, // 每页10条
|
|
|
305
|
+ pageIndex: 1, // 获取第一页
|
|
|
306
|
+ city: app.cityname // 指定城市名(如果你获取不到城市名称,这个参数也可以不传,注释掉)
|
|
|
307
|
+ });
|
|
|
308
|
+
|
|
|
309
|
+ // 第一个参数是关键字,这里传入的空表示不需要根据关键字过滤
|
|
|
310
|
+ // 第二个参数是经纬度,数组类型
|
|
|
311
|
+ // 第三个参数是半径,周边的范围
|
|
|
312
|
+ // 第四个参数为回调函数
|
|
|
313
|
+
|
|
|
314
|
+ placeSearch.searchNearBy(app.cityname, [app.lng, app.lat], 1000, function(status, result) {
|
|
|
315
|
+
|
|
|
316
|
+ console.log(JSON.stringify(status))
|
|
|
317
|
+ if(result.info === 'OK') {
|
|
|
318
|
+ var locationList = result.poiList.pois; // 周边地标建筑列表
|
|
|
319
|
+ //console.log(JSON.stringify(locationList))
|
|
|
320
|
+ app.nearList = locationList // 生成地址列表html
|
|
|
321
|
+ // createLocationHtml(locationList);
|
|
|
322
|
+ } else {
|
|
|
323
|
+ console.log('获取位置信息失败!');
|
|
|
324
|
+ }
|
|
|
325
|
+ });
|
|
|
326
|
+ });
|
|
|
327
|
+
|
|
|
328
|
+ }
|
|
|
329
|
+
|
|
|
330
|
+ function onError(erro) {
|
|
|
331
|
+ // 定位出错
|
|
|
332
|
+ toastMsg('请开启定位功能')
|
|
|
333
|
+ }
|
|
|
334
|
+ })
|
|
|
335
|
+ },
|
|
|
336
|
+
|
|
|
337
|
+ // 获取搜索地址
|
|
|
338
|
+ getCity: function() {
|
|
|
339
|
+ if(app.keyword == '') {
|
|
|
340
|
+ app.address_show = true;
|
|
|
341
|
+ } else {
|
|
|
342
|
+ app.address_show = false;
|
|
|
343
|
+
|
|
|
344
|
+ var aMap = api.require('aMap');
|
|
|
345
|
+ var placeSearchOptions = { //构造地点查询类
|
|
|
346
|
+ pageSize: 10,
|
|
|
347
|
+ pageIndex: 1,
|
|
|
348
|
+ city: app.cityname //城市
|
|
|
349
|
+ };
|
|
|
350
|
+ var placeSearch = new AMap.PlaceSearch(placeSearchOptions);
|
|
|
351
|
+ //关键字查询,您如果想修改结果展现效果,请参考页面:https://lbs.amap.com/fn/css-style/
|
|
|
352
|
+ placeSearch.search(app.keyword, callback);
|
|
|
353
|
+ var placeSearchRender = new Lib.AMap.PlaceSearchRender();
|
|
|
354
|
+
|
|
|
355
|
+ function callback(status, result) {
|
|
|
356
|
+ locationList = result.poiList.pois
|
|
|
357
|
+// console.log(JSON.stringify(result));
|
|
|
358
|
+ app.keywords = locationList;
|
|
|
359
|
+
|
|
|
360
|
+ if(status === 'complete' && result.info === 'OK') {
|
|
|
361
|
+ placeSearchRender.autoRender({
|
|
|
362
|
+ placeSearchInstance: placeSearch,
|
|
|
363
|
+ methodName: "search",
|
|
|
364
|
+ methodArgumments: [app.keyword, callback],
|
|
|
365
|
+ data: result,
|
|
|
366
|
+ map: map,
|
|
|
367
|
+ panel: "panel"
|
|
|
368
|
+ });
|
|
|
369
|
+ }
|
|
|
370
|
+ }
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+ },
|
|
|
374
|
+ // 搜索地址
|
|
|
375
|
+ search_word: function() {
|
|
|
376
|
+ if(app.keyword == '') {
|
|
|
377
|
+ toastMsg('请输入搜索内容')
|
|
|
378
|
+ } else {
|
|
|
379
|
+ app.getCity();
|
|
|
380
|
+ }
|
|
|
381
|
+ },
|
|
|
382
|
+ // 选择地址
|
|
|
383
|
+ choose_address: function(address, name, longitude, latitude) {
|
|
|
384
|
+ api.sendEvent({
|
|
|
385
|
+ name: 'choose_city',
|
|
|
386
|
+ extra: {
|
|
|
387
|
+ address: address,
|
|
|
388
|
+ name: name,
|
|
|
389
|
+ longitude: longitude,
|
|
|
390
|
+ latitude: latitude,
|
|
|
391
|
+ city: app.cityname
|
|
|
392
|
+ }
|
|
|
393
|
+ });
|
|
|
394
|
+ closeWindow();
|
|
|
395
|
+ },
|
|
|
396
|
+ // 切换城市
|
|
|
397
|
+ choose_city_fun: function() {
|
|
|
398
|
+ api.openWin({
|
|
|
399
|
+ url: '../index/city_win.html',
|
|
|
400
|
+ name: 'city_win'
|
|
|
401
|
+ });
|
|
|
402
|
+ $api.rmStorage('city')
|
|
|
403
|
+ },
|
|
|
404
|
+ getName: function(lon, lat) {
|
|
|
405
|
+ var aMap = api.require('aMap');
|
|
|
406
|
+ aMap.getNameFromCoords({
|
|
|
407
|
+ lon: lon,
|
|
|
408
|
+ lat: lat,
|
|
|
409
|
+ }, function(ret, err) {
|
|
|
410
|
+ if(ret.status) {
|
|
|
411
|
+ // alert(JSON.stringify(ret))
|
|
|
412
|
+ app.cityname = ret.city
|
|
|
413
|
+ } else {
|
|
|
414
|
+ // toastMsg(err.code);
|
|
|
415
|
+ }
|
|
|
416
|
+ });
|
|
|
417
|
+ }
|
|
|
418
|
+ }
|
|
|
419
|
+ })
|
|
|
420
|
+</script> |