feat: 地理位置授权
This commit is contained in:
@@ -10,14 +10,13 @@ export default {
|
||||
"pages/mountainPeak/index",
|
||||
"pages/my/index",
|
||||
"pages/my/components/Version/index",
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
permission: {
|
||||
"scope.userLocation": {
|
||||
desc: "你的位置信息将用于小程序位置接口的效果展示", // 高速公路行驶持续后台定位
|
||||
},
|
||||
},
|
||||
requiredPrivateInfos: ["getLocation", "chooseLocation"],
|
||||
window: {
|
||||
backgroundTextStyle: "light",
|
||||
navigationBarBackgroundColor: "#fff",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,11 +4,17 @@
|
||||
|
||||
.myImage{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
// background-color: #f6ffed;
|
||||
background-color: #f6ffed;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
.loginBtn{
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,18 @@ import ActiveCard from "../components/ActiveCard";
|
||||
const my = (props: any) => {
|
||||
// const [active, setActive] = react.useState(props?.active ?? 0);
|
||||
|
||||
|
||||
// 云函数,-获取手机号
|
||||
const getLogin = (e:any) => {
|
||||
const getLogin = (e: any) => {
|
||||
Taro.cloud
|
||||
.callFunction({
|
||||
name: "getPhoneNum",
|
||||
data: {
|
||||
weRunData: Taro.cloud.CloudID(e.detail.cloudID)
|
||||
weRunData: Taro.cloud.CloudID(e.detail.cloudID),
|
||||
},
|
||||
})
|
||||
.then((res:any) => {
|
||||
console.log('res11')
|
||||
console.log('res',res)
|
||||
.then((res: any) => {
|
||||
console.log("res11");
|
||||
console.log("res", res);
|
||||
// this.setState({
|
||||
// context: res.result,
|
||||
// });
|
||||
@@ -44,7 +43,6 @@ const my = (props: any) => {
|
||||
definePageConfig({
|
||||
navigationBarTitleText: "我的",
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
const CardCom = () => {
|
||||
@@ -65,16 +63,15 @@ const my = (props: any) => {
|
||||
// 获取用户手机 [手机号]-需要揭秘
|
||||
const onGetPhoneNumber = (info: any) => {
|
||||
console.log("info", info);
|
||||
getPhoneNumber(info)
|
||||
getPhoneNumber(info);
|
||||
// Taro.cloud.openapi.phonenumber.getPhoneNumber({code:'code'})
|
||||
};
|
||||
|
||||
const getPhoneNumber = (e:any) => {
|
||||
console.log('点击获取手机事件', e.detail.cloudID);
|
||||
const getPhoneNumber = (e: any) => {
|
||||
console.log("点击获取手机事件", e.detail.cloudID);
|
||||
// 调用云函数获取手机号
|
||||
getLogin(e)
|
||||
|
||||
}
|
||||
getLogin(e);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="myContent">
|
||||
@@ -82,34 +79,33 @@ const my = (props: any) => {
|
||||
|
||||
{/* 头像 */}
|
||||
<View className={`myImage`}>
|
||||
{/* 微信开放api-用户头像 */}
|
||||
{/* <OpenData type="userAvatarUrl"></OpenData> */}
|
||||
<Image
|
||||
round
|
||||
width="100px"
|
||||
height="100px"
|
||||
src="cloud://cloud1-5g5xrgza12a0dd6d.636c-cloud1-5g5xrgza12a0dd6d-1253665791/images/images-2.jpg"
|
||||
/>
|
||||
|
||||
<View className="loginBtn">
|
||||
<Button
|
||||
type="primary"
|
||||
size="mini"
|
||||
open-type="getPhoneNumber"
|
||||
lang="zh_CN"
|
||||
onGetPhoneNumber={onGetPhoneNumber}
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<Button
|
||||
{/* <Button
|
||||
open-type="getUserInfo"
|
||||
lang="zh_CN"
|
||||
onGetUserInfo={onGetUserInfo}
|
||||
>
|
||||
获取用户信息
|
||||
</Button>
|
||||
<Button
|
||||
open-type="getPhoneNumber"
|
||||
lang="zh_CN"
|
||||
onGetPhoneNumber={onGetPhoneNumber}
|
||||
>
|
||||
获取手机信息
|
||||
</Button>
|
||||
</View>
|
||||
|
||||
|
||||
</Button> */}
|
||||
|
||||
<View>
|
||||
<Tabs sticky={true}>
|
||||
|
||||
Reference in New Issue
Block a user