TencentLocation.uvue 2.3 KB
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
<template>
	<view>
		<page-head :title="title"></page-head>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="uni-hello-text">
				1. 腾讯定位sdk需在腾讯地图官网申请key。 https://lbs.qq.com/
			</view>
			<view class="uni-hello-text">
				2. 按照readme文档配置apikey
			</view>
			<view class="uni-hello-text">
				3. 需要制作自定义基座运行
			</view>
		</view>
		<view class="uni-btn-v uni-common-mt">
			<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
			<button type="primary" @tap="testGetlocation">获取设备位置信息</button>
			<button type="primary" @tap="testWatchPosition">监听设备位置信息</button>
			<button type="primary" @tap="testClearWatch">停止监听</button>
		</view>
	</view>
</template>

<script>
	// import {
	// 	checkHasIntegration,
	// 	requestPremission,
	// 	getLocation,
	// 	watchPosition,
	// 	clearWatch
	// } from "../../../uni_modules/uts-tencentgeolocation";

	export default {
		data() {
			return {
				title: '腾讯定位SDK集成示例',
			}
		},
		methods: {

			checkLocationPermission: function() {
				// requestPremission();
			},
			testGetlocation: function() {

				// let startRet = getLocation({
				// 	geocode: true,
				// 	success: function(response) {
				// 		console.log(response);
				// 		var addressDesc = response.name + '-' + response.address
				// 		uni.showToast({
				// 			title: '执行结果:' + addressDesc,
				// 			icon: 'none'
				// 		});
				// 	},
				// 	fail: function(msg) {
				// 		uni.showToast({
				// 			title: msg,
				// 			icon: "none"
				// 		})
				// 	}
				// })

				// if (!startRet) {
				// 	uni.showToast({
				// 		title: '定位启动失败,请检查配置',
				// 		icon: 'none'
				// 	});
				// }

			},
			testWatchPosition() {
				// watchPosition({
				// 	geocode: true,
				// 	success: function(response) {
				// 		console.log(response);
				// 		var addressDesc = response.name + '-' + response.address
				// 		uni.showToast({
				// 			title: '执行结果:' + addressDesc,
				// 			icon: 'none'
				// 		});
				// 	},
				// 	fail: function(msg) {
				// 		uni.showToast({
				// 			title: msg,
				// 			icon: "none"
				// 		})
				// 	}
				// })
			},
			testClearWatch() {
				// clearWatch()
			}
		}
	}
</script>

<style>

</style>