提交 f5828da0 编写于 作者: 雪洛's avatar 雪洛

fix: getLocation在非app端去除provider逻辑

上级 b7533be5
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</view> </view>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<!-- #ifdef APP -->
<view class="uni-list-cell-db">定位服务商provider(如系统定位,腾讯定位等)</view> <view class="uni-list-cell-db">定位服务商provider(如系统定位,腾讯定位等)</view>
<view class="uni-list" style="margin-bottom: 20px"> <view class="uni-list" style="margin-bottom: 20px">
<radio-group @change="radioChangePV"> <radio-group @change="radioChangePV">
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
</radio> </radio>
</radio-group> </radio-group>
</view> </view>
<!-- #endif -->
<view class="uni-list-cell-db">定位类型</view> <view class="uni-list-cell-db">定位类型</view>
<view class="uni-list"> <view class="uni-list">
<radio-group @change="radioChange"> <radio-group @change="radioChange">
...@@ -55,7 +57,7 @@ ...@@ -55,7 +57,7 @@
</template> </template>
<script lang="uts"> <script lang="uts">
export type LocationItem = { id : string, name : string, provider ?: UniProvider } export type LocationItem = { id : string, name : string, provider ?: UniProvider }
export type ItemType = { value : string, name : string } export type ItemType = { value : 'wgs84' | 'gcj02', name : 'wgs84' | 'gcj02' }
export default { export default {
data() { data() {
...@@ -81,10 +83,13 @@ ...@@ -81,10 +83,13 @@
} }
}, },
onLoad: function () { onLoad: function () {
// #ifdef APP
this.getProvider() this.getProvider()
// #endif
}, },
methods: { methods: {
getProvider() { getProvider() {
// #ifdef APP
uni.getProvider({ uni.getProvider({
service: "location", service: "location",
success: (e) => { success: (e) => {
...@@ -116,6 +121,7 @@ ...@@ -116,6 +121,7 @@
this.currentProvider = index this.currentProvider = index
} }
}) })
// #endif
}, },
altitudeChange: function (e : UniSwitchChangeEvent) { altitudeChange: function (e : UniSwitchChangeEvent) {
this.altitudeSelect = e.detail.value this.altitudeSelect = e.detail.value
...@@ -148,6 +154,7 @@ ...@@ -148,6 +154,7 @@
} }
}, },
getLocationTap: function () { getLocationTap: function () {
// #ifdef APP
if (this.providerList.length == 0) { if (this.providerList.length == 0) {
uni.showToast({ uni.showToast({
title: '未获取到provider,请确定基座中包含location功能', title: '未获取到provider,请确定基座中包含location功能',
...@@ -156,11 +163,14 @@ ...@@ -156,11 +163,14 @@
console.log("未获取到provider,请确定基座中包含location功能") console.log("未获取到provider,请确定基座中包含location功能")
return return
} }
// #endif
uni.showLoading({ uni.showLoading({
title: '定位中' title: '定位中'
}) })
uni.getLocation(({ uni.getLocation(({
// #ifdef APP
provider: this.providerList[this.currentProvider].id, provider: this.providerList[this.currentProvider].id,
// #endif
type: this.items[this.current].value, type: this.items[this.current].value,
altitude: this.altitudeSelect, altitude: this.altitudeSelect,
isHighAccuracy: this.isHighAccuracySelect, isHighAccuracy: this.isHighAccuracySelect,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册