feat: 地理位置授权
This commit is contained in:
@@ -6,6 +6,10 @@ cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
|||||||
// 云函数入口函数
|
// 云函数入口函数
|
||||||
exports.main = async (event, context) => {
|
exports.main = async (event, context) => {
|
||||||
const wxContext = cloud.getWXContext()
|
const wxContext = cloud.getWXContext()
|
||||||
var moblie = event.weRunData.data.phoneNumber;
|
// let moblie = event?.weRunData?.data?.phoneNumber;
|
||||||
return moblie
|
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>
|
</image>
|
||||||
</template>
|
</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">
|
<template name="tmpl_0_8">
|
||||||
<block>{{i.v}}</block>
|
<block>{{i.v}}</block>
|
||||||
</template>
|
</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: -webkit-flex;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: flex;
|
display: flex;
|
||||||
-webkit-flex-direction: row;
|
-webkit-flex-direction: column;
|
||||||
-ms-flex-direction: row;
|
-ms-flex-direction: column;
|
||||||
flex-direction: row;
|
flex-direction: column;
|
||||||
-webkit-align-items: center;
|
-webkit-align-items: center;
|
||||||
-ms-flex-align: center;
|
-ms-flex-align: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
-webkit-justify-content: center;
|
-webkit-justify-content: center;
|
||||||
-ms-flex-pack: center;
|
-ms-flex-pack: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
background-color: #f6ffed;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myImage .loginBtn {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 30rpx;
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cellArr {
|
.cellArr {
|
||||||
|
|||||||
3
dist/project.config.json
vendored
3
dist/project.config.json
vendored
@@ -37,5 +37,6 @@
|
|||||||
"editorSetting": {
|
"editorSetting": {
|
||||||
"tabIndent": "insertSpaces",
|
"tabIndent": "insertSpaces",
|
||||||
"tabSize": 2
|
"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/mountainPeak/index",
|
||||||
"pages/my/index",
|
"pages/my/index",
|
||||||
"pages/my/components/Version/index",
|
"pages/my/components/Version/index",
|
||||||
|
],
|
||||||
|
permission: {
|
||||||
|
"scope.userLocation": {
|
||||||
|
desc: "你的位置信息将用于小程序位置接口的效果展示", // 高速公路行驶持续后台定位
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
requiredPrivateInfos: ["getLocation", "chooseLocation"],
|
||||||
|
|
||||||
window: {
|
window: {
|
||||||
backgroundTextStyle: "light",
|
backgroundTextStyle: "light",
|
||||||
navigationBarBackgroundColor: "#fff",
|
navigationBarBackgroundColor: "#fff",
|
||||||
|
|||||||
@@ -106,6 +106,41 @@ const Home = () => {
|
|||||||
// Toast.show(`onCancel`);
|
// 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 (
|
return (
|
||||||
<View className="homeContent">
|
<View className="homeContent">
|
||||||
{/* <Loading type="spinner" /> */}
|
{/* <Loading type="spinner" /> */}
|
||||||
@@ -206,23 +241,8 @@ const Home = () => {
|
|||||||
text="打卡"
|
text="打卡"
|
||||||
className="iconStyle"
|
className="iconStyle"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// 相机拍照
|
getLocation();
|
||||||
Taro.chooseImage({
|
// 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)
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<GridItem
|
<GridItem
|
||||||
|
|||||||
@@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
.myImage{
|
.myImage{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
// background-color: #f6ffed;
|
background-color: #f6ffed;
|
||||||
padding: 20px;
|
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 my = (props: any) => {
|
||||||
// const [active, setActive] = react.useState(props?.active ?? 0);
|
// const [active, setActive] = react.useState(props?.active ?? 0);
|
||||||
|
|
||||||
|
|
||||||
// 云函数,-获取手机号
|
// 云函数,-获取手机号
|
||||||
const getLogin = (e:any) => {
|
const getLogin = (e: any) => {
|
||||||
Taro.cloud
|
Taro.cloud
|
||||||
.callFunction({
|
.callFunction({
|
||||||
name: "getPhoneNum",
|
name: "getPhoneNum",
|
||||||
data: {
|
data: {
|
||||||
weRunData: Taro.cloud.CloudID(e.detail.cloudID)
|
weRunData: Taro.cloud.CloudID(e.detail.cloudID),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res:any) => {
|
.then((res: any) => {
|
||||||
console.log('res11')
|
console.log("res11");
|
||||||
console.log('res',res)
|
console.log("res", res);
|
||||||
// this.setState({
|
// this.setState({
|
||||||
// context: res.result,
|
// context: res.result,
|
||||||
// });
|
// });
|
||||||
@@ -44,7 +43,6 @@ const my = (props: any) => {
|
|||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: "我的",
|
navigationBarTitleText: "我的",
|
||||||
});
|
});
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const CardCom = () => {
|
const CardCom = () => {
|
||||||
@@ -65,16 +63,15 @@ const my = (props: any) => {
|
|||||||
// 获取用户手机 [手机号]-需要揭秘
|
// 获取用户手机 [手机号]-需要揭秘
|
||||||
const onGetPhoneNumber = (info: any) => {
|
const onGetPhoneNumber = (info: any) => {
|
||||||
console.log("info", info);
|
console.log("info", info);
|
||||||
getPhoneNumber(info)
|
getPhoneNumber(info);
|
||||||
// Taro.cloud.openapi.phonenumber.getPhoneNumber({code:'code'})
|
// Taro.cloud.openapi.phonenumber.getPhoneNumber({code:'code'})
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPhoneNumber = (e:any) => {
|
const getPhoneNumber = (e: any) => {
|
||||||
console.log('点击获取手机事件', e.detail.cloudID);
|
console.log("点击获取手机事件", e.detail.cloudID);
|
||||||
// 调用云函数获取手机号
|
// 调用云函数获取手机号
|
||||||
getLogin(e)
|
getLogin(e);
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="myContent">
|
<View className="myContent">
|
||||||
@@ -82,34 +79,33 @@ const my = (props: any) => {
|
|||||||
|
|
||||||
{/* 头像 */}
|
{/* 头像 */}
|
||||||
<View className={`myImage`}>
|
<View className={`myImage`}>
|
||||||
{/* 微信开放api-用户头像 */}
|
|
||||||
{/* <OpenData type="userAvatarUrl"></OpenData> */}
|
|
||||||
<Image
|
<Image
|
||||||
round
|
round
|
||||||
width="100px"
|
width="100px"
|
||||||
height="100px"
|
height="100px"
|
||||||
src="cloud://cloud1-5g5xrgza12a0dd6d.636c-cloud1-5g5xrgza12a0dd6d-1253665791/images/images-2.jpg"
|
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>
|
||||||
|
|
||||||
<View>
|
{/* <Button
|
||||||
<Button
|
|
||||||
open-type="getUserInfo"
|
open-type="getUserInfo"
|
||||||
lang="zh_CN"
|
lang="zh_CN"
|
||||||
onGetUserInfo={onGetUserInfo}
|
onGetUserInfo={onGetUserInfo}
|
||||||
>
|
>
|
||||||
获取用户信息
|
获取用户信息
|
||||||
</Button>
|
</Button> */}
|
||||||
<Button
|
|
||||||
open-type="getPhoneNumber"
|
|
||||||
lang="zh_CN"
|
|
||||||
onGetPhoneNumber={onGetPhoneNumber}
|
|
||||||
>
|
|
||||||
获取手机信息
|
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<View>
|
<View>
|
||||||
<Tabs sticky={true}>
|
<Tabs sticky={true}>
|
||||||
|
|||||||
Reference in New Issue
Block a user