提交 925f0fda 编写于 作者: VK1688's avatar VK1688

优化choose-location的示例页面

上级 bafbb97c
...@@ -15,7 +15,10 @@ ...@@ -15,7 +15,10 @@
</view> </view>
</view> </view>
<view class="uni-btn-v"> <view class="uni-btn-v">
<text class="tips">注意:Web和App需要正确配置地图服务商的Key并且保证Key的权限和余额足够,才能正常选择位置</text> <text class="tips">注意:\n1. Web和App需要正确配置地图服务商的Key并且保证Key的权限和余额足够,才能正常选择位置\n2. 若没有关联uniCloud空间,则只能全屏地图选点,不能根据POI选择位置\n3. payload参数会原样透传给uni-map-co,可用于用户鉴权</text>
<boolean-data :defaultValue="false" title="是否指定位置为天安门" @change="changeLocationBoolean"></boolean-data>
<boolean-data :defaultValue="false" title="是否携带keyword参数" @change="changeKeywordBoolean"></boolean-data>
<boolean-data :defaultValue="false" title="是否携带payload参数" @change="changePayloadBoolean"></boolean-data>
<button class="btn" type="primary" @tap="chooseLocation">选择位置</button> <button class="btn" type="primary" @tap="chooseLocation">选择位置</button>
<button class="btn" @tap="clear">清空</button> <button class="btn" @tap="clear">清空</button>
</view> </view>
...@@ -38,12 +41,15 @@ ...@@ -38,12 +41,15 @@
} as Location, } as Location,
locationName: '', locationName: '',
locationAddress: '', locationAddress: '',
dialogPagesNum: -1 dialogPagesNum: -1,
hoverLocation: false,
hoverKeyword: false,
hoverPayload: false
} }
}, },
methods: { methods: {
chooseLocation: function () { chooseLocation: function () {
uni.chooseLocation({ let chooseLocationOptions = {
success: (res) => { success: (res) => {
console.log('chooseLocation success', res) console.log('chooseLocation success', res)
this.hasLocation = true this.hasLocation = true
...@@ -51,13 +57,23 @@ ...@@ -51,13 +57,23 @@
this.locationName = res.name this.locationName = res.name
this.locationAddress = res.address this.locationAddress = res.address
} }
}) }
if (this.hoverLocation) {
chooseLocationOptions['latitude'] = 39.908823
chooseLocationOptions['longitude'] = 116.39747
}
if (this.hoverKeyword) {
chooseLocationOptions['keyword'] = '公园'
}
if (this.hoverPayload) {
chooseLocationOptions['payload'] = {
token: 'xxx'
}
}
uni.chooseLocation(chooseLocationOptions)
// 自动化测试 // 自动化测试
setTimeout(() => { setTimeout(() => {
const pages = getCurrentPages() this.test()
const page = pages[pages.length - 1]
const dialogPages = page.getDialogPages()
this.dialogPagesNum = dialogPages.length
}, 500) }, 500)
}, },
formatLocation: function(longitude:number, latitude:number):Location { formatLocation: function(longitude:number, latitude:number):Location {
...@@ -76,6 +92,22 @@ ...@@ -76,6 +92,22 @@
}, },
clear: function () { clear: function () {
this.hasLocation = false this.hasLocation = false
},
changeLocationBoolean(checked : boolean) {
this.hoverLocation = checked
},
changeKeywordBoolean(checked : boolean) {
this.hoverKeyword = checked
},
changePayloadBoolean(checked : boolean) {
this.hoverPayload = checked
},
// 自动化测试
test() {
const pages = getCurrentPages()
const page = pages[pages.length - 1]
const dialogPages = page.getDialogPages()
this.dialogPagesNum = dialogPages.length
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册