Commit 2b1d2184 authored by chenqikuai's avatar chenqikuai

1

parent 87a04f76
import { Toast } from 'vant'
import baseAxios, { iRet } from '../index'
import { iNearbyOutLet } from './types'
import Bridge from "@/utils/jsBridge2"
class AddressService {
static instance: AddressService
static getInstance() {
......@@ -12,30 +13,49 @@ class AddressService {
getNearby(data: { bank_code: number; number: number }) {
return new Promise<iRet<iNearbyOutLet[]>>((resolve) => {
if ('geolocation' in window.navigator) {
window.navigator.geolocation.getCurrentPosition(
(position) => {
const la = position.coords.latitude.toString()
const lo = position.coords.longitude.toString()
resolve(
baseAxios<iNearbyOutLet[]>({
method: 'post',
url: '/address/nearby',
data: {
...data,
longitude: lo,
latitude: la,
},
}),
)
},
(error) => {
Toast(error.message)
},
new Bridge().bridge_getGps(null, (params: any)=>{
console.log(params, "show params");
const list = params.split(',')
resolve(
baseAxios<iNearbyOutLet[]>({
method: 'post',
url: '/address/nearby',
data: {
...data,
longitude: list[0],
latitude: list[1],
},
}),
)
} else {
Toast('不支持获取GPS')
}
})
// if ('geolocation' in window.navigator) {
// window.navigator.geolocation.getCurrentPosition(
// (position) => {
// const la = position.coords.latitude.toString()
// const lo = position.coords.longitude.toString()
// resolve(
// baseAxios<iNearbyOutLet[]>({
// method: 'post',
// url: '/address/nearby',
// data: {
// ...data,
// longitude: lo,
// latitude: la,
// },
// }),
// )
// },
// (error) => {
// Toast(error.message)
// },
// )
// } else {
// Toast('不支持获取GPS')
// }
})
}
......
......@@ -511,5 +511,15 @@ jsBridge.prototype.bridge_navigate = function (params, success) {
}
}
/* 跳到导航软件 */
jsBridge.prototype.bridge_getGps = function (params, success) {
if (this.curApp == ANDROID) {
dsBridge.call('bridge_getGps', params, success)
}
else if (this.curApp == IOS) {
this.callHandler('bridge_getGps', params, success)
}
}
export default jsBridge;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment