UNPKG

minix-template

Version:

minix template

108 lines (106 loc) 2.19 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-05-06 16:42:57 * @LastEditTime: 2022-05-23 16:26:13 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { locationList:[ { name:'getLocation', // url:'pages/base/canlUse/index', describe:'获取当前的地理位置' }, { name:'startLocationUpdate', // url:'pages/base/log/index', describe:'监听实时地理位置' }, { name:'stopLocationUpdate', // url:'pages/base/log/index', describe:'取消实时地理位置监听' } ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 获取当前的地理位置 * @param {*} * @return {*} */ getLocation(){ this.$app.$def.bridge.getLocation() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 监听实时地理位置 * @param {*} * @return {*} */ startLocationUpdate(){ this.$app.$def.bridge.startLocationUpdate() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 取消实时地理位置监听 * @param {*} * @return {*} */ stopLocationUpdate(){ this.$app.$def.bridge.stopLocationUpdate() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'getLocation': this.getLocation() break; case 'startLocationUpdate': this.startLocationUpdate() break; case 'stopLocationUpdate': this.stopLocationUpdate() break; default: break; } } }