获取位置提示要获取摄像头,这个怎么解决

mo2844 2019-08-06 06:32:54

大神们,使用微信公众号获取位置的时候小米手机使用公众号提示要使用摄像头,苹果手机则能正常的提示获取位置,这个有遇到过的吗。
//微信初始化完成
function wxInit() {
if (cityname == null || cityname == "" || cityname == "广西") {
wx.getLocation({//获取本地经纬度
type : 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,腾讯、google、高德坐标,可传入'gcj02'
success : function(res) {
lat = res.latitude; // 纬度,浮点数,范围为90 ~ -90
lon = res.longitude; // 经度,浮点数,范围为180 ~ -180。
//5 [默认]腾讯、google、高德坐标
getQQCity("5");
},
fail : function(res) {
//alert('用户拒绝授权获取地理位置');
//initRedList();
}
});
wx.checkJsApi({
jsApiList : [ 'getLocation' ], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success : function(res) {
if (res.checkResult.getLocation == "true"
|| res.checkResult.getLocation == true) {
} else {
//initRedList();
alert("定位失败请检查微信应用设置");
}
}
});
}
}
function getQQCity(coord_type) {
if (lon == "" || lat == "") {
//initRedList();
return;
}
var fn = function(data) {
var isCity2 = 0;
if (data.status == 0) {
//alert(coord_type+"反查地址:"+data.result.address);
//cityname = data.result.address_component.city.replace("市","");
cityname = data.result.address_component.city.substring(0,
2);
var iscity = 0;
for (var i = 0; i < cityList.length; i++) {
if (cityList[i].CITYNAME == cityname) {
cityCode = cityList[i].CITYCODE;
isCity2 = 1;
}
}
if (isCity2 == 0) {
lat = "";
lon = "";
cityname = "广西";
cityCode = "0590";
location.hash = "";
}
$("#js-cityname").text(cityname);
}
if (isCity2 == 1) {
currentPage = 0;
everyPage = 5;
$('.in_probox ul').empty();
initRedList();
batch_id = "0";
initSecKill();
initRecommend();
}

};
var ef = function errinit() {
//initRedList();
};
var url = "https://apis.map.qq.com/ws/geocoder/v1/";
var maps = {
output : "jsonp",
"location" : lat + "," + lon,
"coord_type" : coord_type,
"key" : "M3JBZ-7ATWX-RIB4V-ZO5U2-HWZI2-VBBTE"
};
ajaxTimeout(url, maps, fn, ef, 3000);
}
function ajaxTimeout(url, maps, fn, ef, time) {
var ajaxTimeoutTest = $.ajax({
url : url, //请求的URL
timeout : time, //超时时间设置,单位毫秒
type : 'post', //请求方式,get或post
data : maps, //请求所传参数,json格式
dataType : 'jsonp',//返回的数据格式
jsonp : 'callback',
success : fn,
error : ef,
complete : function(XMLHttpRequest, status) { //请求完成后最终执行参数
if (status == 'timeout') {//超时,status还有success,error等值的情况
ajaxTimeoutTest.abort();
ef();
}
}
});
}
...全文
65 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,143

社区成员

发帖
与我相关
我的任务
社区描述
微信开发即微信公众平台开发,将企业信息、服务、活动等内容通过微信网页的方式进行表现,通过二次开发可以将公众账号由一个媒体型营销工具转化成提供服务的产品。
社区管理员
  • 微信开发
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧