提交 41057398 编写于 作者: 杜庆泉's avatar 杜庆泉

location page format

上级 ebaefb23
<template> <template>
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-list"> <view class="uni-list">
<radio-group @change="radioChange"> <radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value" <radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line': ''" :value="item.value" :class="index < items.length - 1 ? 'uni-list-cell-line': ''" :value="item.value"
:checked="index === current"> :checked="index === current">
{{item.name}} {{item.name}}
</radio> </radio>
</radio-group> </radio-group>
</view> </view>
<view class="uni-list-cell uni-list-cell-pd"> <view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">高度信息</view> <view class="uni-list-cell-db">高度信息</view>
<switch :checked="altitudeSelect" @change="altitudeChange" /> <switch :checked="altitudeSelect" @change="altitudeChange" />
</view> </view>
<view class="uni-list-cell uni-list-cell-pd"> <view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">开启高精度定位</view> <view class="uni-list-cell-db">开启高精度定位</view>
<switch :checked="isHighAccuracySelect" @change="highAccuracySelectChange" /> <switch :checked="isHighAccuracySelect" @change="highAccuracySelectChange" />
</view> </view>
<view class="uni-list-cell uni-list-cell-pd"> <view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否解析地址信息</view> <view class="uni-list-cell-db">是否解析地址信息</view>
<switch :checked="geocodeSelect" @change="geocodeChange" /> <switch :checked="geocodeSelect" @change="geocodeChange" />
</view> </view>
<text>{{exeRet}}</text> <text>{{exeRet}}</text>
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn" type="default" @tap="getLocationTap">获取定位</button> <button class="uni-btn" type="default" @tap="getLocationTap">获取定位</button>
</view> </view>
</view>
</view> </view>
</view>
</template> </template>
<script lang="uts"> <script lang="uts">
type ItemType = { type ItemType = {
value : string, value : string,
name : string, name : string,
} }
export default { export default {
data() { data() {
return { return {
title: 'get-location', title: 'get-location',
altitudeSelect:false, altitudeSelect: false,
isHighAccuracySelect:false, isHighAccuracySelect: false,
geocodeSelect:false, geocodeSelect: false,
exeRet:'', exeRet: '',
items: [{ items: [{
value: 'gcj02', value: 'gcj02',
name: 'gcj02' name: 'gcj02'
},
{
value: 'wgs84',
name: 'wgs84'
}
] as ItemType[],
current: 0,
}
}, },
methods: { {
altitudeChange: function (e : SwitchChangeEvent) { value: 'wgs84',
this.altitudeSelect = e.detail.value name: 'wgs84'
},
geocodeChange: function (e : SwitchChangeEvent) {
this.geocodeSelect = e.detail.value
},
highAccuracySelectChange: function (e : SwitchChangeEvent) {
this.isHighAccuracySelect = e.detail.value
},
radioChange(e : RadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
getLocationTap: function () {
uni.showLoading({
title:'定位中'
})
console.log(this.altitudeSelect)
uni.getLocation(({
type: this.items[this.current].value,
altitude:this.altitudeSelect,
isHighAccuracy:this.isHighAccuracySelect,
geocode:this.geocodeSelect,
success: function (res:any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
},
fail: function (res:any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
} ,
complete: function (res:any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
}
}));
}
} }
] as ItemType[],
current: 0,
}
},
methods: {
altitudeChange: function (e : SwitchChangeEvent) {
this.altitudeSelect = e.detail.value
},
geocodeChange: function (e : SwitchChangeEvent) {
this.geocodeSelect = e.detail.value
},
highAccuracySelectChange: function (e : SwitchChangeEvent) {
this.isHighAccuracySelect = e.detail.value
},
radioChange(e : RadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
getLocationTap: function () {
uni.showLoading({
title: '定位中'
})
uni.getLocation(({
type: this.items[this.current].value,
altitude: this.altitudeSelect,
isHighAccuracy: this.isHighAccuracySelect,
geocode: this.geocodeSelect,
success: function (res : any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
},
fail: function (res : any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
},
complete: function (res : any) {
uni.hideLoading()
console.log(res);
this.exeRet = JSON.stringify(res)
}
}));
}
} }
</script> }
\ No newline at end of file </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册