Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d25d9358
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5977
Star
89
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d25d9358
编写于
6月 28, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
初步增加定位测试示例
上级
80a199eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
160 addition
and
1 deletion
+160
-1
pages.json
pages.json
+6
-0
pages/API/action-sheet/action-sheet.uvue
pages/API/action-sheet/action-sheet.uvue
+45
-1
pages/API/get-location/get-location.uvue
pages/API/get-location/get-location.uvue
+107
-0
pages/tabBar/API/API.uvue
pages/tabBar/API/API.uvue
+2
-0
未找到文件。
pages.json
浏览文件 @
d25d9358
...
...
@@ -132,6 +132,12 @@
"navigationBarTitleText"
:
"消息提示框"
}
},
{
"path"
:
"pages/API/get-location/get-location"
,
"style"
:
{
"navigationBarTitleText"
:
"获取定位"
}
},
{
"path"
:
"pages/API/quitApp/quitApp"
,
"style"
:
{
...
...
pages/API/action-sheet/action-sheet.uvue
浏览文件 @
d25d9358
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<radio-group @change="radioChange">
<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"
:checked="index === current">
{{item.name}}
</radio>
</radio-group>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义itemColor</view>
<switch :checked="itemColorCustom" />
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="target" type="default" @tap="actionSheetTap">弹出action sheet</button>
...
...
@@ -9,10 +24,29 @@
</view>
</template>
<script lang="ts">
type ItemType = {
value : string,
name : string,
}
export default {
data() {
return {
title: 'action-sheet',
itemColorCustom:false,
items: [{
value: '标题',
name: '有标题'
},
{
value: '',
name: '无标题'
},
{
value: '超长标题测试内容,测试超过显示最大范围之后的样式-超长标题测试内容,测试超过显示最大范围之后的样式',
name: '超长标题'
}
] as ItemType[],
current: 0,
// #ifdef H5
buttonRect: {},
// #endif
...
...
@@ -28,10 +62,19 @@
},
// #endif
methods: {
radioChange(e : RadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
this.current = i;
break;
}
}
},
actionSheetTap() {
console.log("itemColorCustom === " + this.itemColorCustom)
const that = this
uni.showActionSheet({
title:
'标题'
,
title:
this.items[this.current].value
,
itemList: ['item1', 'item2', 'item3', 'item4'],
// #ifdef H5
popover: {
...
...
@@ -49,6 +92,7 @@
}
})
},
// #ifdef H5
getNodeInfo() {
uni.createSelectorQuery().select('.target').boundingClientRect().exec((ret) => {
...
...
pages/API/get-location/get-location.uvue
0 → 100644
浏览文件 @
d25d9358
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-list">
<radio-group @change="radioChange">
<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"
:checked="index === current">
{{item.name}}
</radio>
</radio-group>
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">高度信息</view>
<switch :checked="altitudeSelect" @change="altitudeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">开启高精度定位</view>
<switch :checked="isHighAccuracySelect" @change="highAccuracySelectChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否解析地址信息</view>
<switch :checked="geocodeSelect" @change="geocodeChange" />
</view>
<text>{{exeRet}}</text>
<view class="uni-btn-v">
<button class="uni-btn" type="default" @tap="getLocationTap">获取定位</button>
</view>
</view>
</view>
</template>
<script lang="ts">
type ItemType = {
value : string,
name : string,
}
export default {
data() {
return {
title: 'get-location',
altitudeSelect:false,
isHighAccuracySelect:false,
geocodeSelect:false,
exeRet:'',
items: [{
value: 'gcj02',
name: 'gcj02'
},
{
value: 'wgs84',
name: 'wgs84'
}
] as ItemType[],
current: 0,
}
},
methods: {
altitudeChange: function (e : SwitchChangeEvent) {
this.altitudeSelect = e.detail.value
},
geocodeChange: function (e : SwitchChangeEvent) {
this.geocodeChange = 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,
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
pages/tabBar/API/API.uvue
浏览文件 @
d25d9358
...
...
@@ -198,6 +198,7 @@
},
//#endif
//#ifdef APP-ANDROID
{
name: "退出应用",
url: "quitApp",
...
...
@@ -296,6 +297,7 @@
{
name: "获取当前位置",
url: "get-location",
enable: true
},
{
name: "使用地图查看位置",
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录