Commit 2b1d2184 authored by chenqikuai's avatar chenqikuai

1

parent 87a04f76
import { Toast } from 'vant' import { Toast } from 'vant'
import baseAxios, { iRet } from '../index' import baseAxios, { iRet } from '../index'
import { iNearbyOutLet } from './types' import { iNearbyOutLet } from './types'
import Bridge from "@/utils/jsBridge2"
class AddressService { class AddressService {
static instance: AddressService static instance: AddressService
static getInstance() { static getInstance() {
...@@ -12,30 +13,49 @@ class AddressService { ...@@ -12,30 +13,49 @@ class AddressService {
getNearby(data: { bank_code: number; number: number }) { getNearby(data: { bank_code: number; number: number }) {
return new Promise<iRet<iNearbyOutLet[]>>((resolve) => { return new Promise<iRet<iNearbyOutLet[]>>((resolve) => {
if ('geolocation' in window.navigator) {
window.navigator.geolocation.getCurrentPosition( new Bridge().bridge_getGps(null, (params: any)=>{
(position) => { console.log(params, "show params");
const la = position.coords.latitude.toString()
const lo = position.coords.longitude.toString() const list = params.split(',')
resolve(
baseAxios<iNearbyOutLet[]>({ resolve(
method: 'post', baseAxios<iNearbyOutLet[]>({
url: '/address/nearby', method: 'post',
data: { url: '/address/nearby',
...data, data: {
longitude: lo, ...data,
latitude: la, longitude: list[0],
}, latitude: list[1],
}), },
) }),
},
(error) => {
Toast(error.message)
},
) )
} 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) { ...@@ -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; 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