UNPKG

minix-template

Version:

minix template

278 lines (276 loc) 6.44 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-05-12 18:46:03 * @LastEditTime: 2022-05-23 15:41:01 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { baiduList:[ { name:'baiduGeocoder', // url:'pages/base/canlUse/index', describe:'百度开放接口,通过经纬度返回对应的位置信息' }, { name:'geoCode', // url:'pages/base/log/index', describe:'正地理编码' }, { name:'getCityInfo', // url:'pages/base/canlUse/index', describe:'根据百度地图得到的城市名称获取城市的信息,比如该城市对应的气象局对应的ID' }, { name:'getGPSInfo', // url:'pages/base/log/index', describe:'获取gps定位信息' }, { name:'launchMapApp', // url:'pages/base/log/index', describe:'打开用户手机地图软件,传入标记地点' }, { name:'requestLocation', // url:'pages/base/canlUse/index', describe:'定位周边地址' }, { name:'searchMapAddress', // url:'pages/base/log/index', describe:'根据模糊地址,返回地图服务的查询结果数据' }, { name:'searchPOI', // url:'pages/base/log/index', describe:'POI周边搜索' } ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 百度开放接口,通过经纬度返回对应的位置信息 * @param {*} * @return {*} */ baiduGeocoder(){ const params = { latitude: 123, longitude: 156, } this.$app.$def.bridge.baiduGeocoder(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 正地理编码 * @param {*} * @return {*} */ geoCode(){ const params = { city: '武汉市', address: '江夏区', } this.$app.$def.bridge.geoCode(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 根据百度地图得到的城市名称获取城市的信息 * @param {*} * @return {*} */ getCityInfo(){ const params = { cityName: '武汉市' } this.$app.$def.bridge.getCityInfo(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 获取gps定位信息 * @param {*} * @return {*} */ getGPSInfo(){ const params = { accuracy: 3, alwaysAuthorization: 1, distanceFilter: 12, isReqAuthen: true, } this.$app.$def.bridge.getGPSInfo(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 开用户手机地图软件,传入标记地点 * @param {*} * @return {*} */ launchMapApp(){ const params = { from: { coordinateType: 2, //Number,^7.2 非必填,默认为1,1表示使用百度地图,2表示使用高德地图 latitude: '123', //纬度 longitude: '89', //经度 name: 'anony1', //起点的名称 }, to: { coordinateType: 2, //Number,^7.2 非必填,默认为1,1表示使用百度地图,2表示使用高德地图 latitude: '34', //纬度 longitude: '59', //经度 name: 'annoy2', //终点的名称 }, } this.$app.$def.bridge.launchMapApp(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 定位周边地址 * @param {*} * @return {*} */ requestLocation(){ this.$app.$def.bridge.requestLocation().then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 根据模糊地址,返回地图服务的查询结果数据 * @param {*} * @return {*} */ requestLocation(){ const params = { city: '武汉市', keyword: '花山软件新城', } this.$app.$def.bridge.searchMapAddress(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: POI周边搜索 * @param {*} * @return {*} */ searchPOI(){ const params = { pageIndex: 1, //分页 pageCapacity: 10, //每页个数 latitude: '30.40657357380507', longitude: '114.41272248242186', radius: 10000, //半径 单位:m keyword: '阳光100', } this.$app.$def.bridge.searchPOI(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'baiduGeocoder': this.baiduGeocoder() break; case 'geoCode': this.geoCode() break; case 'getCityInfo': this.getCityInfo() break; case 'getGPSInfo': this.getGPSInfo() break; case 'launchMapApp': this.launchMapApp() break; case 'requestLocation': this.requestLocation() break; case 'searchMapAddress': this.searchMapAddress() break; case 'searchPOI': this.searchPOI() break; default: break; } } }