feat: 地理位置授权

This commit is contained in:
eric
2022-11-21 10:38:38 +08:00
parent 8e30656e64
commit 04cbc3adbd
13 changed files with 115 additions and 69 deletions

View File

@@ -106,6 +106,41 @@ const Home = () => {
// Toast.show(`onCancel`);
};
const getLocation = () => {
// 获取地理位置
Taro.getLocation({
type: "wgs84",
success: function (res) {
// 地理位置信息-经纬度
console.log('lbsres---',res)
const latitude = res.latitude;
const longitude = res.longitude;
const speed = res.speed;
const accuracy = res.accuracy;
},
});
};
const chooseImage = () => {
// 相机拍照
Taro.chooseImage({
count: 1, // 默认9
// , 'compressed'
sizeType: ["original"], // 可以指定是原图还是压缩图,默认二者都有
// 'album',
sourceType: ["camera"], // 可以指定来源是相册还是相机默认二者都有在H5浏览器端支持使用 `user` 和 `environment`分别指定为前后摄像头
success: function (res: any) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
let tempFilePaths = res.tempFilePaths;
console.log("tempFilePaths===", tempFilePaths);
Taro.navigateTo({
url: `/pages/home/components/CheckIn/index?fileID=${tempFilePaths?.[0]}`,
});
// uploadTaro(tempFilePaths)
},
});
};
return (
<View className="homeContent">
{/* <Loading type="spinner" /> */}
@@ -206,23 +241,8 @@ const Home = () => {
text="打卡"
className="iconStyle"
onClick={() => {
// 相机拍照
Taro.chooseImage({
count: 1, // 默认9
// , 'compressed'
sizeType: ["original"], // 可以指定是原图还是压缩图,默认二者都有
// 'album',
sourceType: ["camera"], // 可以指定来源是相册还是相机默认二者都有在H5浏览器端支持使用 `user` 和 `environment`分别指定为前后摄像头
success: function (res: any) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
let tempFilePaths = res.tempFilePaths;
console.log("tempFilePaths===", tempFilePaths);
Taro.navigateTo({
url: `/pages/home/components/CheckIn/index?fileID=${tempFilePaths?.[0]}`,
});
// uploadTaro(tempFilePaths)
},
});
getLocation();
// chooseImage();
}}
/>
<GridItem