作者 朱振飞

提交

... ... @@ -20,7 +20,7 @@ function openView(fmName, fmUrl, winTitle, winName, winUrl, fmParams, winParams)
localStorage.setItem(item,winParams[item])
}
}
window.location.href = winName+'.html'
window.location.href = fmUrl+'.html'
// var options = {
// name: '',
// url: '',
... ...
... ... @@ -170,27 +170,10 @@
</body>
</html>
<!--<script src="https://webapi.amap.com/maps?v=1.4.8&key= ef53760bd959a4df08b7d4587280e642"></script>
<script type="text/javascript">
var map = new AMap.Map('container', {
center:[117.000923,36.675807],
zoom:11
});
</script>-->
<script>
var map = {}
window.onLoad = function() {
map = new AMap.Map('container');
}
var url = 'https://webapi.amap.com/maps?v=1.4.8&key=ef53760bd959a4df08b7d4587280e642&callback=onLoad';
var jsapi = document.createElement('script');
jsapi.charset = 'utf-8';
jsapi.src = url;
document.head.appendChild(jsapi);
</script>
<script type="text/javascript" src="../../assets/js/weui.min.js"></script>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script ty></script>
<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=ef53760bd959a4df08b7d4587280e642&&plugin=AMap.ToolBar,AMap.IndoorMap'></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
... ... @@ -203,6 +186,8 @@
<script type="text/javascript" src="https://cache.amap.com/lbs/static/PlaceSearchRender.js"></script>
<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
<script>
var map = {}
map = new AMap.Map('container');
var app = new Vue({
el: '#app',
data: {
... ... @@ -228,12 +213,11 @@
centerPoint: []
},
created: function() {
loadEnd();
apiready = function() {
app.get_city();
app.getUsedAddress()
// apiready = function() {
this.get_city();
this.getUsedAddress()
}
// }
// app.getNearBy();
// app.cityname = getcity() ? getcity() : api.pageParam.cityname;
... ... @@ -273,28 +257,26 @@
// 定位当前城市
get_city: function() {
app.map = new AMap.Map('container', {});
app.map.plugin('AMap.Geolocation', function() {
var app = this ;
// app.map = new AMap.Map('container', {});
map.plugin('AMap.Geolocation', function() {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
timeout: 10000
});
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete)
AMap.event.addListener(geolocation, 'error', onError)
function onComplete(data) {
// console.log(JSON.stringify(data));
alert(JSON.stringify(data));
app.cityname = data.addressComponent.province;
console.log(app.cityname);
app.lng = data.position.lng;
app.lat = data.position.lat;
// console.log(app.lng);
// console.log(app.lat);
// console.log(app.lng);
// console.log(app.lat);
//
// 获取附近地址
app.map = new AMap.Map('container', {});
... ... @@ -332,9 +314,47 @@
}
})
},
//获取当前坐标
getNowCity(){
mapObj = new AMap.Map('iCenter');
mapObj.plugin('AMap.Geolocation', function () {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
maximumAge: 0, //定位结果缓存0毫秒,默认:0
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
showButton: true, //显示定位按钮,默认:true
buttonPosition: 'LB', //定位按钮停靠位置,默认:'LB',左下角
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
zoomToAccuracy:true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
});
mapObj.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
});
function onComplete(obj){
var res = '经纬度:' + obj.position +
'\n精度范围:' + obj.accuracy +
'米\n定位结果的来源:' + obj.location_type +
'\n状态信息:' + obj.info +
'\n地址:' + obj.formattedAddress +
'\n地址信息:' + JSON.stringify(obj.addressComponent, null, 4);
alert(res);
}
function onError(obj) {
alert(obj.info + '--' + obj.message);
console.log(obj);
}
},
// 获取搜索地址
getCity: function() {
var app = this;
if(app.keyword == '') {
app.address_show = true;
} else {
... ... @@ -355,7 +375,6 @@
locationList = result.poiList.pois
// console.log(JSON.stringify(result));
app.keywords = locationList;
if(status === 'complete' && result.info === 'OK') {
placeSearchRender.autoRender({
placeSearchInstance: placeSearch,
... ... @@ -372,6 +391,7 @@
},
// 搜索地址
search_word: function() {
var app = this;
if(app.keyword == '') {
toastMsg('请输入搜索内容')
} else {
... ...
... ... @@ -187,13 +187,13 @@
appointment: function () {
var app = this
if (app.cid == 5 || app.cid == 7 || app.cid == 8 || app.cid == 10) {
openView('doc_package_f', 'index/doc_package_f', app.care_name, 'doc_package_f', false, {
openView('doc_package_f', '../index/doc_package_f', app.care_name, 'doc_package_f', false, {
id: app.id,
cid: app.cid,
cityname: app.cityname
})
} else {
openView('pay_form_f', 'index/pay_form_f', app.care_name, 'pay_form_f', false, {
openView('pay_form_f', '../index/pay_form_f', app.care_name, 'pay_form_f', false, {
id: app.id,
cityname: app.cityname,
cid: app.cid
... ...
... ... @@ -10,6 +10,13 @@
</head>
<body>
<header>
<div class="index_header">
<div class="close_left" @click.stop="close"><span class="iconfont icon-fanhui"></span></div>
<div>选择城市</div>
<div></div>
</div>
</header>
<div class="city">
<div class="city-wrapper city-wrapper-hook">
<div class="scroller-hook">
... ... @@ -96,10 +103,8 @@
var anchor = shortcutList[shortcutList.indexOf(touch.anchor) + delta];
scrollTo(anchor);
e.preventDefault();
e.stopPropagation();
});
function scrollTo(anchor) {
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="log"></div>
<input type="number" placeholder="123132">
<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=8e9d3050695ac868cc67257d84a5f740&plugin=AMap.ToolBar,AMap.IndoorMap'></script>
<script type="text/javascript">
var log = document.getElementsByClassName('log')[0];
mapObj = new AMap.Map('iCenter');
mapObj.plugin('AMap.Geolocation', function () {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
maximumAge: 0, //定位结果缓存0毫秒,默认:0
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
showButton: true, //显示定位按钮,默认:true
buttonPosition: 'LB', //定位按钮停靠位置,默认:'LB',左下角
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
zoomToAccuracy:true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
});
mapObj.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', function(obj){
var res = '经纬度:' + obj.position +
'\n精度范围:' + obj.accuracy +
'米\n定位结果的来源:' + obj.location_type +
'\n状态信息:' + obj.info +
'\n地址:' + obj.formattedAddress +
'\n地址信息:' + JSON.stringify(obj.addressComponent, null, 4);
console.log(res)
AMap.service(["AMap.PlaceSearch"], function() {
var placeSearch = new AMap.PlaceSearch({
pageSize: 10, // 每页10条
pageIndex: 1, // 获取第一页
city: res.province// 指定城市名(如果你获取不到城市名称,这个参数也可以不传,注释掉)
});
// 第一个参数是关键字,这里传入的空表示不需要根据关键字过滤
// 第二个参数是经纬度,数组类型
// 第三个参数是半径,周边的范围
// 第四个参数为回调函数
placeSearch.searchNearBy(app.cityname, [obj.position], 1000, function(status, result) {
console.log(JSON.stringify(status))
if(result.info === 'OK') {
var locationList = result.poiList.pois; // 周边地标建筑列表
//console.log(JSON.stringify(locationList))
app.nearList = locationList          // 生成地址列表html
//           createLocationHtml(locationList);
} else {
console.log('获取位置信息失败!');
}
});
});
});//返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
});
function onComplete(obj){
var res = '经纬度:' + obj.position +
'\n精度范围:' + obj.accuracy +
'米\n定位结果的来源:' + obj.location_type +
'\n状态信息:' + obj.info +
'\n地址:' + obj.formattedAddress +
'\n地址信息:' + JSON.stringify(obj.addressComponent, null, 4);
console.log(res)
AMap.service(["AMap.PlaceSearch"], function() {
var placeSearch = new AMap.PlaceSearch({
pageSize: 10, // 每页10条
pageIndex: 1, // 获取第一页
city: res.province// 指定城市名(如果你获取不到城市名称,这个参数也可以不传,注释掉)
});
// 第一个参数是关键字,这里传入的空表示不需要根据关键字过滤
// 第二个参数是经纬度,数组类型
// 第三个参数是半径,周边的范围
// 第四个参数为回调函数
placeSearch.searchNearBy(app.cityname, [obj.position], 1000, function(status, result) {
console.log(JSON.stringify(status))
if(result.info === 'OK') {
var locationList = result.poiList.pois; // 周边地标建筑列表
//console.log(JSON.stringify(locationList))
app.nearList = locationList          // 生成地址列表html
//           createLocationHtml(locationList);
} else {
console.log('获取位置信息失败!');
}
});
});
}
function onError(obj) {
alert(obj.info + '--' + obj.message);
console.log(obj);
}
</script>
//获取位置按钮
<button class = 'bt' onclick='geo.getCurrentPosition()'>获取位置</button>
<button class = 'bt' onclick='geo.watchPosition()'>连续定位</button>
<button class = 'bt' onclick='geo.clearWatch()'>停止定位</button>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -86,6 +86,122 @@
.doc_footer {
z-index: 0;
}
/*地址样式*/
.city_top {
position: fixed;
left: 0;
top: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.25rem;
font-size: 0.3rem;
color: #333;
border: 1px solid #f5f5f5;
background-color: #fff;
}
.city_name_box {
display: flex;
align-items: center;
flex: 1;
}
.city_name_box .iconfont {
margin: 0 0.1rem 0 0;
}
.city_input {
flex: 3;
margin: 0 0.1rem 0 0.1rem;
background-color: #f2f2f2;
padding: 0 0 0 0.2rem;
border-radius: 0.1rem;
}
.city_input input {
width: 100%;
padding: 0.2rem 0.25rem;
color: #333;
font-size: 0.26rem;
}
.city_input input::-webkit-input-placeholder {
color: #aaa;
}
.city_item {
padding: 0.3rem 0.25rem;
color: #999;
font-size: 0.26rem;
display: flex;
justify-content: space-between;
}
.choose_box {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 0.24rem;
color: #333;
padding: 0.2rem 0.25rem;
border-bottom: 1px solid #f2f2f2;
margin-top: 1.3rem;
}
.position {
display: flex;
align-items: center;
}
.position span {
margin-left: 0.2rem;
}
.city_name {
color: #333;
font-size: 0.3rem;
}
.city_address {
font-size: 0.26rem;
}
.my_address {
margin: 0.25rem;
}
.my_address .iconfont {
margin: 0 0.1rem 0 0;
color: #ccc;
}
.address_title {
font-size: 14px;
color: #999;
}
.choose_city {
font-size: 18px;
}
.address_item {
color: #424242;
font-size: 16px;
padding: 0.26rem 0.5rem 0.26rem 0.2rem;
border-bottom: 1px solid #f2f2f2;
}
.city_container{
width: 100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 15;
background-color: #FFF;
overflow-y: auto;
}
</style>
<body>
<div id="loadStart"></div>
... ... @@ -115,10 +231,10 @@
<div class="service_icon"><span class="iconfont icon-yonghu"></span><span>服务对象</span></div>
<div class="service_input"><input type="text" placeholder="请输入姓名" v-model.trim="user_name"></div>
</div>
<div class="service_input_box" @click.stop="dateSelect" id="sever">
<div class="service_input_box" @click.stop="dateSelect" id="sever" >
<div class="service_icon"><span class="iconfont icon-shijian1"></span><span>服务时间</span></div>
<div class="service_input"><span v-if="date_info" class="date_info">{{date_info}}</span><span v-else>{{default_date}}</span>
</div>
<div class="service_input"><span v-if="date_info" class="date_info">{{date_info}}</span><span v-else>{{default_date}}</span></div>
<!--<input id="sever" autofocus placeholder="1" type="hidden">-->
</div>
<div class="service_input_box">
<div class="service_icon"><span class="iconfont icon-dianhua-1"></span><span>联系电话</span></div>
... ... @@ -140,10 +256,10 @@
</div>
</div>
</div>
<div class="service_input_box" @click="broSelect">
<div class="service_icon"><span
class="iconfont icon-baoyuefuwux"></span><span>出生日期</span></div>
<div class="service_input"><span v-if="broth_info" class="date_info">{{broth_info}}</span><span v-else>{{default_bro}}</span>
<div class="service_input_box" @click="broSelect" id="broDate">
<div class="service_icon">
<span class="iconfont icon-baoyuefuwux"></span><span>出生日期</span></div>
<div class="service_input"><span v-if="broth_info" class="date_info">{{broth_info}}</span><span v-else>{{default_bro}}</span>
</div>
</div>
<div class="service_input_box" @click="openMap">
... ... @@ -163,8 +279,7 @@
<div v-if="is_idcard==0"></div>
<div v-else>
<div class="service_input_box">
<div class="service_icon"><span class="iconfont icon-credentials_icon"></span><span>身份证号</span>
</div>
<div class="service_icon"><span class="iconfont icon-credentials_icon"></span><span>身份证号</span></div>
<div class="service_input"><input type="text" placeholder="输入身份证号码我们将为您投保"
v-model.trim="user_id_card" maxlength="18">
</div>
... ... @@ -255,6 +370,45 @@
<span class="doc_appointment" @click="appointment()">去 预 约</span>
</div>
</div>
<!--地址选择-->
<div class="city_container" v-if="city">
<div v-cloak>
<div id="container"></div>
<div class="city_top">
<div class="city_name_box" @click="choose_city_fun">
<span class="iconfont icon-dizhi"></span>
<div class="clamp1">{{cityname}}</div>
</div>:
<div class="city_input"><input type="search" placeholder="请输入你的服务地址" v-model="keyword" @input="getCity"></div>
<div class="main_color" @click="search_word">搜索</div>
</div>
<div class="choose_box" @click="choose_now">
<span class="choose_city">{{street}}</span>
<div class="main_color position"><span class="iconfont icon-zhongxindingwei"></span><span>重新定位</span></div>
</div>
<div v-if="address_show">
<div class="my_address">
<div class="address_title"><span class="iconfont icon-shouye"></span><span> 我的服务地址</span></div>
<div class="address_item nodata" v-if="user_address_list.length==0">暂无服务地址</div>
<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>
<span>{{item.address}}{{item.address_info}}</span>
</div>
</div>
<div class="my_address">
<div class="address_title"><span class="iconfont icon-dizhi"></span><span>我的附近地址</span></div>
<div class="address_item" v-for="(item,index) in nearList" @click="choose_address(item.address,'',item.lon,item.lat)">
<span>{{item.address}}</span>
</div>
</div>
</div>
<div v-for="(item,index) in keywords" class="city_item" @click="choose_address(item.address,item.name,item.lon,item.lat)" v-else>
<div>
<div class="city_name">{{item.name}}</div>
<div class="city_address">{{item.address}}</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
... ... @@ -270,6 +424,8 @@
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script type="text/javascript" src="../../assets/js/datePicker.js"></script>
<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=ef53760bd959a4df08b7d4587280e642&&plugin=AMap.ToolBar,AMap.IndoorMap'></script>
<script>
var app = new Vue({
el: '#app',
... ... @@ -325,15 +481,35 @@
ill_case: '',
unit: '',
pos: 'fixed',
city: true,
lat: '',
lng: '',
keyword: '',
keywords: [],
cities: [],
street: '',
nearList: [],
user_address_list: [],
address_show: true,
latitude: '',
longitude: '',
//经度
lng: '',
//纬度
lat: '',
map: {},
//经纬度
centerPoint: []
},
created: function () {
var app = this;
app.getUserIndexInfo();
$api.rmStorage('city');
app.id = localStorage.getItem('id');
app.applyInfo();
app.cityname = localStorage.getItem('cityName');
this.getUserIndexInfo();
this.id = localStorage.getItem('id');
this.applyInfo();
this.cityname = localStorage.getItem('cityName');
//获取当前地址
this.get_city()
// api.addEventListener({
// name: 'choose_city'
... ... @@ -406,17 +582,52 @@
methods: {
// 选择服务日期
dateSelect: function () {
api.openWin({
name: 'getSev_w',
url: '../common/getSev_w.html'
// api.openWin({
// name: 'getSev_w',
// url: '../common/getSev_w.html'
// });
var calendar = new datePicker();
calendar.init({
'trigger': '#sever', /*按钮选择器,用于触发弹出插件*/
'type': 'datetime', /*模式:date日期;datetime日期时间;time时间;ym年月;*/
// 'minDate':getTimeDetil(3), /*最小日期*/
'minDate': formatDate(new Date(getTimeDetil(3)), 1), /*最小日期*/
'maxDate': '', /*最大日期*/
'onSubmit': function () {/*确认时触发事件*/
console.log(calendar.value);
if (checkDate(calendar.value, 1)) {
app.date_info = calendar.value;
calendar.onClose()
} else {
toastMsg('请选择3小时之后到7天之内的服务时间');
}
},
'onClose': function () {/*取消时触发事件*/
// api.closeWin();
}
});
},
// 选择生日
broSelect: function () {
api.openWin({
name: 'getBro_w',
url: '../common/getBro_w.html'
var calendar = new datePicker();
calendar.init({
'trigger': '#broDate', /*按钮选择器,用于触发弹出插件*/
'type': 'date', /*模式:date日期;datetime日期时间;time时间;ym年月;*/
// 'minDate':getTimeDetil(3), /*最小日期*/
'minDate': '', /*最小日期*/
'maxDate': formatDate(new Date(), 1), /*最大日期*/
'onSubmit': function () {/*确认时触发事件*/
console.log(calendar.value);
if (calendar.value) {
app.broth_info = calendar.value;
calendar.onClose()
}
},
'onClose': function () {/*取消时触发事件*/
// api.closeWin();
}
})
},
// 上传证明
... ... @@ -433,11 +644,7 @@
"XX-Device-Type": getDevice(),
'XX-Token': getToken()
};
console.log(header);
getRequest('post', 'portal/Goods/applyInfo', post, header).then(function (res) {
console.log(JSON.stringify(res));
// alert(JSON.stringify(res))
if (res.data.code == 1) {
app.is_idcard = res.data.data.is_idcard;
app.is_toolbar = res.data.data.is_toolbar;
... ... @@ -528,35 +735,225 @@
},
// 选择服务地址
openMap: function () {
openView('choose_address', 'common/choose_address', '选择服务地址', 'choose_address', false, {cityname: app.cityname});
openView('choose_address', '../common/choose_address', '选择服务地址', 'choose_address', false, {cityname: app.cityname});
},
// 获取协议
openIsPro: function () {
var app = this;
app.isPro = !app.isPro;
window.location.href = '../common/tool_fm.html';
// api.openFrame({
// bgColor: 'rgba(0,0,0,0.05)',
// name: 'tool_fm',
// url: '../common/tool_fm.html',
// bounces: false,
// animation: {
// type: "push",
// subType: "from_bottom",
// duration: 300
// },
// rect: {
// x: 0,
// y: 0,
// w: 'auto',
// h: 'auto'
// }
// })
},
// 去协议
getAgreement: function (name, id) {
openView('agree_content', 'common/agree_content', name, 'agree_content', false, {id: id})
},
//地址方法
// 获取我的服务地址
getUsedAddress: function() {
var header = {
"XX-Device-Type": getDevice(),
'XX-Token': getToken()
};
console.log(header)
getRequest('post', 'portal/Goods/getUsedAddress', null, header).then(function(res) {
//alert(JSON.stringify(res));
if(res.data.code == 1) {
app.user_address_list = res.data.data;
toastMsg(res.data.msg)
}
loadEnd();
})
},
// 重新获取当前定位信息
choose_now: function() {
var app = this;
toastMsg('正在重新定位');
app.get_city();
setTimeout(function() {
// api.hideProgress();
}, 2000);
},
// 定位当前城市
get_city: function() {
var app = this ;
map = new AMap.Map('container', {});
map.plugin('AMap.Geolocation', function() {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000
});
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete)
AMap.event.addListener(geolocation, 'error', onError)
function onComplete(data) {
alert(JSON.stringify(data));
app.cityname = data.addressComponent.province;
console.log(app.cityname);
app.lng = data.position.lng;
app.lat = data.position.lat;
app.street = data.addressComponent.street;
// console.log(app.lng);
// console.log(app.lat);
//
// 获取附近地址
app.map = new AMap.Map('container', {});
AMap.service(["AMap.PlaceSearch"], function() {
var placeSearch = new AMap.PlaceSearch({
pageSize: 10, // 每页10条
pageIndex: 1, // 获取第一页
city: app.cityname // 指定城市名(如果你获取不到城市名称,这个参数也可以不传,注释掉)
});
// 第一个参数是关键字,这里传入的空表示不需要根据关键字过滤
// 第二个参数是经纬度,数组类型
// 第三个参数是半径,周边的范围
// 第四个参数为回调函数
placeSearch.searchNearBy(app.cityname, [app.lng, app.lat], 1000, function(status, result) {
console.log(JSON.stringify(status))
if(result.info === 'OK') {
var locationList = result.poiList.pois; // 周边地标建筑列表
//console.log(JSON.stringify(locationList))
app.nearList = locationList          // 生成地址列表html
//           createLocationHtml(locationList);
} else {
console.log('获取位置信息失败!');
}
});
});
}
function onError(erro) {
console.log(erro)
// 定位出错
toastMsg('请开启定位功能')
}
})
},
//获取当前坐标
getNowCity(){
mapObj = new AMap.Map('iCenter');
mapObj.plugin('AMap.Geolocation', function () {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
maximumAge: 0, //定位结果缓存0毫秒,默认:0
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
showButton: true, //显示定位按钮,默认:true
buttonPosition: 'LB', //定位按钮停靠位置,默认:'LB',左下角
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
zoomToAccuracy:true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
});
mapObj.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
});
function onComplete(obj){
var res = '经纬度:' + obj.position +
'\n精度范围:' + obj.accuracy +
'米\n定位结果的来源:' + obj.location_type +
'\n状态信息:' + obj.info +
'\n地址:' + obj.formattedAddress +
'\n地址信息:' + JSON.stringify(obj.addressComponent, null, 4);
alert(res);
}
function onError(obj) {
alert(obj.info + '--' + obj.message);
console.log(obj);
}
},
// 获取搜索地址
getCity: function() {
var app = this;
if(app.keyword == '') {
app.address_show = true;
} else {
app.address_show = false;
var aMap = api.require('aMap');
var placeSearchOptions = { //构造地点查询类
pageSize: 10,
pageIndex: 1,
city: app.cityname //城市
};
var placeSearch = new AMap.PlaceSearch(placeSearchOptions);
//关键字查询,您如果想修改结果展现效果,请参考页面:https://lbs.amap.com/fn/css-style/
placeSearch.search(app.keyword, callback);
var placeSearchRender = new Lib.AMap.PlaceSearchRender();
function callback(status, result) {
locationList = result.poiList.pois
// console.log(JSON.stringify(result));
app.keywords = locationList;
if(status === 'complete' && result.info === 'OK') {
placeSearchRender.autoRender({
placeSearchInstance: placeSearch,
methodName: "search",
methodArgumments: [app.keyword, callback],
data: result,
map: map,
panel: "panel"
});
}
}
}
},
// 搜索地址
search_word: function() {
var app = this;
if(app.keyword == '') {
toastMsg('请输入搜索内容')
} else {
app.getCity();
}
},
// 选择地址
choose_address: function(address, name, longitude, latitude) {
api.sendEvent({
name: 'choose_city',
extra: {
address: address,
name: name,
longitude: longitude,
latitude: latitude,
city: app.cityname
}
});
closeWindow();
},
// 切换城市
choose_city_fun: function() {
api.openWin({
url: '../index/city_win.html',
name: 'city_win'
});
$api.rmStorage('city')
},
getName: function(lon, lat) {
var aMap = api.require('aMap');
aMap.getNameFromCoords({
lon: lon,
lat: lat,
}, function(ret, err) {
if(ret.status) {
// alert(JSON.stringify(ret))
app.cityname = ret.city
} else {
// toastMsg(err.code);
}
});
},
// 去预约
appointment: function () {
var app = this;
... ...