可以得到经纬度,但是得不到位置信息

来源:1-15 扩展分享:校园网内如何设置虚拟机上网?

老咪_

2021-04-21

<script>
	var QQMapWX=require('../../lib/qqmap-wx-jssdk.min.js')
	var qqmapsdk
	export default {
		data() {
			return {
				canChenkin:false,
				showCamera:true,
				showImage:false,
				photoPath:'',
				btnText:'拍照'
			}
		},
		onLoad: function(){
			qqmapsdk=new QQMapWX({
				key: '3HLBZ-OCEEK-6M2JE-AAXJB-FU5SE-JJBSZ'
			});
		},
		methods: {
			clickBtn:function(){
				let that = this
				if(that.btnText=='拍照'){
					let ctx = uni.createCameraContext()
					ctx.takePhoto({
						//拍照质量
						quality:'high',
						success:function(resp){
							console.log(resp.tempImagePath)
							that.photoPath=resp.tempImagePath
							that.showCamera=false
							that.showImage=true
							that.btnText='签到'
						}
					})
				}
				else{
					uni.showLoading({
						title:"签到中请稍后"
					})
					setTimeout(function(){
						uni.hideLoading()
					},30000)
					uni.getLocation({
						type:"wgs484",
						success:function(resp){
							let latitude = resp.latitude
							let longitude = resp.longitude
							console.log(latitude)
							console.log(longitude) 
							qqmapsdk.reverseGeocoder({
								location:{
									latitude:latitude,
									longtitude:longitude
								},
								success:function(resp){
									console.log(resp.result) 
									let address = resp.result.address
									let addressCompoent = resp.result.address_component
									let nation = addressCompoent.nation
									let province = addressCompoent.province
									let city = addressCompoent.city
									let district = addressCompoent.district
								}   
							})
						}
					})
				}
			},
			afresh:function(){
				let that = this 
				that.showCamera=true
				that.showImage=false
				that.btnText='拍照'
			}
			
		}
	}
</script>

<style lang="less">
	@import url("checkin.less");
</style>

写回答

1回答

神思者

2021-04-22

你的腾讯位置服务开通了吗?还有腾讯位置服务要关联微信小程序APPID

0
0

SpringBoot 在线协同办公小程序开发 全栈式项目实战

未来趋势型业务 + 前后端综合技术栈 + 惊艳的细节打磨

1802 学习 · 1919 问题

查看课程