feat: 打卡上传地理位置
This commit is contained in:
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
@@ -130,7 +130,7 @@ const Home = () => {
|
||||
};
|
||||
|
||||
// 上传到云存储
|
||||
const uploadTaro = (tempFilePaths: any) => {
|
||||
const uploadTaro = (tempFilePaths: any,lbsInfo:any) => {
|
||||
// 云开发存储文件 [/自动创建文件路径]
|
||||
Taro.cloud.uploadFile({
|
||||
cloudPath: `images/checkIn/${new Date()?.getTime()}.png`,
|
||||
@@ -138,7 +138,7 @@ const Home = () => {
|
||||
success: (res: any) => {
|
||||
// get resource ID
|
||||
console.log("res", res?.fileID);
|
||||
checkIn({ imageUrl: res?.fileID });
|
||||
checkIn({ imageUrl: res?.fileID,lbsInfo: lbsInfo});
|
||||
|
||||
// 跳转到目的页面,打开新页面
|
||||
// Taro.navigateTo({
|
||||
@@ -168,6 +168,7 @@ const Home = () => {
|
||||
|
||||
// 签到
|
||||
const checkIn = async (data: any) => {
|
||||
console.log('data=====',data)
|
||||
let postData = {
|
||||
tableName: "userInfo",
|
||||
keyValue: { openId: openid },
|
||||
@@ -183,6 +184,8 @@ const Home = () => {
|
||||
{
|
||||
imageUrl: data?.imageUrl,
|
||||
checkTime: new Date().valueOf(), //打卡时间
|
||||
latitude:data?.lbsInfo?.latitude,
|
||||
longitude:data?.lbsInfo?.longitude
|
||||
// remark: fieldValues?.remark,
|
||||
// location: address,
|
||||
},
|
||||
@@ -228,7 +231,7 @@ const Home = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const chooseImage = () => {
|
||||
const chooseImage = (lbsInfo:any) => {
|
||||
// 相机拍照
|
||||
Taro.chooseImage({
|
||||
count: 1, // 默认9
|
||||
@@ -245,7 +248,7 @@ const Home = () => {
|
||||
// url: `/pages/home/components/CheckIn/index?fileID=${tempFilePaths?.[0]}`,
|
||||
// });
|
||||
|
||||
uploadTaro(tempFilePaths);
|
||||
uploadTaro(tempFilePaths,lbsInfo);
|
||||
},
|
||||
complete: () => {
|
||||
// 刷新页面数据
|
||||
@@ -377,12 +380,17 @@ const Home = () => {
|
||||
// 获取定位信息
|
||||
Taro.getLocation({
|
||||
type: "gcj02", //返回可以用于 Taro.openLocation的经纬度
|
||||
success: function (res) {
|
||||
success: function (res: any) {
|
||||
console.log("lbs", res);
|
||||
const latitude = res.latitude;
|
||||
const longitude = res.longitude;
|
||||
const latitude = res?.latitude;
|
||||
const longitude = res?.longitude;
|
||||
let lbsInfo = {
|
||||
latitude: res?.latitude,
|
||||
longitude: res?.longitude,
|
||||
};
|
||||
|
||||
// 拍照上传
|
||||
chooseImage();
|
||||
chooseImage(lbsInfo);
|
||||
},
|
||||
});
|
||||
// chooseImage();
|
||||
|
||||
Reference in New Issue
Block a user