feat: 地理位置授权
This commit is contained in:
@@ -6,6 +6,10 @@ cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
var moblie = event.weRunData.data.phoneNumber;
|
||||
return moblie
|
||||
// let moblie = event?.weRunData?.data?.phoneNumber;
|
||||
return {
|
||||
event:event,
|
||||
context:context,
|
||||
// moblie:moblie
|
||||
}
|
||||
}
|
||||
|
||||
2
dist/app.js
vendored
2
dist/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/app.json
vendored
2
dist/app.json
vendored
@@ -1 +1 @@
|
||||
{"pages":["pages/home/index","pages/home/components/CheckIn/index","pages/home/components/Certified/index","pages/activityList/index","pages/formSubmit/index","pages/activityList/components/details/index","pages/mountainPeak/index","pages/my/index","pages/my/components/Version/index"],"window":{"backgroundTextStyle":"light","navigationBarBackgroundColor":"#fff","navigationBarTitleText":"WeChat","navigationBarTextStyle":"black"}}
|
||||
{"pages":["pages/home/index","pages/home/components/CheckIn/index","pages/home/components/Certified/index","pages/activityList/index","pages/formSubmit/index","pages/activityList/components/details/index","pages/mountainPeak/index","pages/my/index","pages/my/components/Version/index"],"permission":{"scope.userLocation":{"desc":"你的位置信息将用于小程序位置接口的效果展示"}},"requiredPrivateInfos":["getLocation","chooseLocation"],"window":{"backgroundTextStyle":"light","navigationBarBackgroundColor":"#fff","navigationBarTitleText":"WeChat","navigationBarTextStyle":"black"}}
|
||||
4
dist/base.wxml
vendored
4
dist/base.wxml
vendored
@@ -129,10 +129,6 @@
|
||||
</image>
|
||||
</template>
|
||||
|
||||
<template name="tmpl_0_37">
|
||||
<open-data type="{{i.p4}}" open-gid="{{i.p3}}" lang="{{xs.b(i.p2,'en')}}" default-text="{{i.p1}}" default-avatar="{{i.p0}}" binderror="eh" style="{{i.st}}" class="{{i.cl}}" bindtap="eh" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}"></open-data>
|
||||
</template>
|
||||
|
||||
<template name="tmpl_0_8">
|
||||
<block>{{i.v}}</block>
|
||||
</template>
|
||||
|
||||
2
dist/pages/home/index.js
vendored
2
dist/pages/home/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/pages/my/index.js
vendored
2
dist/pages/my/index.js
vendored
File diff suppressed because one or more lines are too long
14
dist/pages/my/index.wxss
vendored
14
dist/pages/my/index.wxss
vendored
@@ -21,16 +21,24 @@
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-flex-direction: row;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-webkit-flex-direction: column;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
-webkit-align-items: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
background-color: #f6ffed;
|
||||
padding: 20rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.myImage .loginBtn {
|
||||
position: absolute;
|
||||
bottom: 30rpx;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.cellArr {
|
||||
|
||||
3
dist/project.config.json
vendored
3
dist/project.config.json
vendored
@@ -37,5 +37,6 @@
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
}
|
||||
},
|
||||
"cloudfunctionTemplateRoot": "cloudfunctionTemplate/"
|
||||
}
|
||||
16
project.private.config.json
Normal file
16
project.private.config.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "我的",
|
||||
"pathName": "pages/my/index",
|
||||
"query": "",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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