/**
* @file 微信小程序JSAPI
* @author 崔健 cuijian03@baidu.com 2017.01.10
*/
/**
* 百度地图微信小程序API类
*
* @class
*/
class BMapWX {
/**
* 百度地图微信小程序API类
*
* @constructor
*/
constructor(param) {
this.ak = param["ak"];
}
/**
* 使用微信接口进行定位
*
* @param {string} type 坐标类型
* @param {Function} success 成功执行
* @param {Function} fail 失败执行
* @param {Function} complete 完成后执行
*/
getWXLocation(type, success, fail, complete) {
type = type || 'gcj02',
success = success || function () {};
fail = fail || function () {};
complete = complete || function () {};
wx.getLocation({
type: type,
success: success,
fail: fail,
complete:complete
});
}
/**
* POI周边检索
*
* @param {Object} param 检索配置
* 参数对象结构可以参考
* http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-placeapi
*/
search(param) {
var that = this;
param = param || {};
let searchparam = {
query: param["query"] || '生活服务$美食&酒店',
scope: param["scope"] || 1,
filter: param["filter"] || '',
coord_type: param["coord_type"] || 2,
page_size: param["page_size"] || 10,
page_num: param["page_num"] || 0,
output: param["output"] || 'json',
ak: that.ak,
sn: param["sn"] || '',
timestamp: param["timestamp"] || '',
radius: param["radius"] || 2000,
ret_coordtype: 'gcj02ll'
};
let otherparam = {
iconPath: param["iconPath"],
iconTapPath: param["iconTapPath"],
width: param["width"],
height: param["height"],
alpha: param["alpha"] || 1,
success: param["success"] || function () {},
fail: param["fail"] || function () {}
};
let type = 'gcj02';
let locationsuccess = function (result) {
searchparam["location"] = result["latitude"] + ',' + result["longitude"];
wx.request({
url: 'https://api.map.baidu.com/place/v2/search',
data: searchparam,
header: {
"content-type": "application/json"
},
method: 'GET',
success(data) {
let res = data["data"];
if (res["status"] === 0) {
let poiArr = res["results"];
// outputRes 包含两个对象,
// originalData为百度接口返回的原始数据
// wxMarkerData为小程序规范的marker格式
let outputRes = {};
outputRes["originalData"] = res;
outputRes["wxMarkerData"] = [];
for (let i = 0; i < poiArr.length; i++) {
outputRes["wxMarkerData"][i] = {
id: i,
latitude: poiArr[i]["location"]["lat"],
longitude: poiArr[i]["location"]["lng"],
title: poiArr[i]["name"],
iconPath: otherparam["iconPath"],
iconTapPath: otherparam["iconTapPath"],
address: poiArr[i]["address"],
telephone: poiArr[i]["telephone"],
alpha: otherparam["alpha"],
width: otherparam["width"],
height: otherparam["height"]
}
}
otherparam.success(outputRes);
} else {
otherparam.fail({
errMsg: res["message"],
statusCode: res["status"]
});
}
},
fail(data) {
otherparam.fail(data);
}
});
}
let locationfail = function (result) {
otherparam.fail(result);
};
let locationcomplete = function (result) {
};
if (!param["location"]) {
that.getWXLocation(type, locationsuccess, locationfail, locationcomplete);
} else {
let longitude = param.location.split(',')[1];
let latitude = param.location.split(',')[0];
let errMsg = 'input location';
let res = {
errMsg: errMsg,
latitude: latitude,
longitude: longitude
};
locationsuccess(res);
}
}
/**
* sug模糊检索
*
* @param {Object} param 检索配置
* 参数对象结构可以参考
* http://lbsyun.baidu.com/index.php?title=webapi/place-suggestion-api
*/
suggestion(param) {
var that = this;
param = param || {};
let suggestionparam = {
query: param["query"] || '',
region: param["region"] || '全国',
city_limit: param["city_limit"] || false,
output: param["output"] || 'json',
ak: that.ak,
sn: param["sn"] || '',
timestamp: param["timestamp"] || '',
ret_coordtype: 'gcj02ll'
};
let otherparam = {
success: param["success"] || function () {},
fail: param["fail"] || function () {}
};
wx.request({
url: 'https://api.map.baidu.com/place/v2/suggestion',
data: suggestionparam,
header: {
"content-type": "application/json"
},
method: 'GET',
success(data) {
let res = data["data"];
if (res["status"] === 0) {
otherparam.success(res);
} else {
otherparam.fail({
errMsg: res["message"],
statusCode: res["status"]
});
}
},
fail(data) {
otherparam.fail(data);
}
});
}
/**
* rgc检索(坐标->地点描述)
*
* @param {Object} param 检索配置
* 参数对象结构可以参考
* http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding
*/
regeocoding(param) {
var that = this;
param = param || {};
let regeocodingparam = {
coordtype: param["coordtype"] || 'gcj02ll',
pois: param["pois"] || 0,
output: param["output"] || 'json',
ak: that.ak,
sn: param["sn"] || '',
timestamp: param["timestamp"] || '',
ret_coordtype: 'gcj02ll'
};
let otherparam = {
iconPath: param["iconPath"],
iconTapPath: param["iconTapPath"],
width: param["width"],
height: param["height"],
alpha: param["alpha"] || 1,
success: param["success"] || function () {},
fail: param["fail"] || function () {}
};
let type = 'gcj02';
let locationsuccess = function (result) {
regeocodingparam["location"] = result["latitude"] + ',' + result["longitude"];
wx.request({
url: 'https://api.map.baidu.com/geocoder/v2/',
data: regeocodingparam,
header: {
"content-type": "application/json"
},
method: 'GET',
success(data) {
let res = da
没有合适的资源?快使用搜索试试~ 我知道了~
医疗健康类小程序-5套独特风格-压缩包内含5套不同小程序
共60个文件
wxss:12个
js:11个
gif:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 23 浏览量
2024-03-29
20:40:36
上传
评论
收藏 10.46MB RAR 举报
温馨提示
医疗健康类小程序-5套独特风格-压缩包内含5套不同小程序
资源推荐
资源详情
资源评论
收起资源包目录
医疗健康类小程序5套.rar (60个子文件)
first-aid-master
pages
appeal
appeal.js 926B
appeal.wxss 933B
appeal.json 36B
appeal.wxml 640B
tutorial
tutorial.wxss 1KB
tutorial.js 920B
tutorial.json 36B
tutorial.wxml 2KB
index
index.wxml 355B
index.js 478B
index.wxss 268B
isBreath
isBreath.wxss 501B
isBreath.wxml 398B
isBreath.js 174B
isBreath.json 47B
unconsciousnessStudy
unconsciousnessStudy.wxml 139B
unconsciousnessStudy.wxss 59B
unconsciousnessStudy.json 47B
unconsciousnessStudy.js 2KB
logs
logs.json 54B
logs.js 266B
logs.wxml 194B
logs.wxss 106B
breathe
breathe.wxss 2KB
breathe.wxml 2KB
breathe.json 60B
breathe.js 1KB
burning
burning.json 44B
burning.wxss 59B
burning.js 414B
burning.wxml 139B
app.json 903B
assets
images
sst3.gif 36KB
telephone-large.svg 3KB
Scald.svg 6KB
huxi.gif 26KB
right-large.svg 1KB
selected-tutorial-tabbar.png 1KB
cewo.gif 193KB
tutorial-tabbar.png 1KB
appeal-tabbar.png 2KB
panduan.gif 119KB
wrong-large.svg 1KB
rghx.gif 157KB
dingwei.gif 160KB
sst1.gif 34KB
sst2.gif 103KB
unconsciousness.svg 6KB
selected-appeal-tabbar.png 2KB
anya.gif 103KB
hujiu.gif 45KB
app.js 719B
utils
util.js 460B
libs
bmap-wx.js 13KB
animate.wxss 23KB
app.wxss 194B
components
steps
steps.wxss 866B
steps.wxml 417B
tutorial-list
tutorialList.wxss 501B
tutorialList.wxml 503B
共 60 条
- 1
资源评论
飞影铠甲
- 粉丝: 3241
- 资源: 207
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功