feat: merge公司-私人

This commit is contained in:
huxiaoshuang
2022-11-23 16:23:01 +08:00
parent e045ef43df
commit e02984a5fc
15 changed files with 273 additions and 63 deletions

View File

@@ -17,12 +17,15 @@ import { getCurrentInstance } from "@tarojs/taro";
import React, { useCallback, useEffect, useState } from "react";
import "./index.scss";
import { Uploader } from "@antmjs/vantui";
import { getparams, getTable, updateTableid } from "../../../../utils/index";
const CheckIn = () => {
const formIt = Form.useForm();
const [bottomheight, setbottomheight] = useState(0);
const [cloudfileID, setcloudfileID] = useState();
const [address, setaddress] = useState(); //地址
const [openid, setopenid] = useState();
const [fileID, setfileID] = useState("");
const [value, setValue] = useState([
// {
// url: "https://img.yzcdn.cn/vant/leaf.jpg",
@@ -64,14 +67,22 @@ const CheckIn = () => {
});
}, []);
let $instance: any = getCurrentInstance();
const { fileID } = $instance?.router?.params;
console.log("fileID---", fileID);
useEffect(() => {
if ($instance?.router?.params?.fileID) {
let $instance: any = getCurrentInstance();
let fileID: any = $instance?.router?.params?.fileID;
if (fileID) {
setfileID(fileID)
uploadTaro([fileID]);
}
Taro.cloud.callFunction({
name: "getOpenid",
complete: async (res: any) => {
// console.log("callFunction test result: ", res);
let openid = res?.result?.event?.userInfo?.openId;
setopenid(openid);
},
});
}, []);
const uploadTaro = (tempFilePaths: any) => {
@@ -128,53 +139,86 @@ const CheckIn = () => {
value=""
icon="location"
isLink
onClick={() => {
Taro.chooseLocation({
success: (res: any) => {
console.log("res", res);
const { address } = res;
setaddress(res?.address);
// setaddress(res?.name)
// address: "广东省深圳市宝安区创业一路1号"
// errMsg: "chooseLocation:ok"
// latitude: 22.55329 //纬度
// longitude: 113.88308 //经度
// name: "宝安区创业一路(深圳市宝安区人民政府)"
},
});
}}
renderTitle={
<View>
<View className="title"></View>
<View className="address">{address}</View>
</View>
}
/>
</View>
{/* 文件上传 */}
{/* <Uploader
fileList={value}
onAfterRead={afterRead}
onDelete={deleteAction}
deletable
maxCount={1}
/> */}
<View
style={{
bottom: `${bottomheight ?? 0}px`,
position: "fixed",
width: "95%",
}}
onClick={() => {
onClick={async () => {
// formIt?.submit()
formIt?.validateFields((errorMessage: any, fieldValues: any) => {
console.log("fieldValues---", fieldValues);
// 提交打卡记录
let postData = {
imagePath: cloudfileID,
remark: fieldValues?.remark,
};
// xxxsubmit()
Toast.success({
message: "打卡成功",
selector: "#vanToast-demo2",
duration: 2000,
});
setTimeout(() => {
// 返回首页 [上一页]
Taro.navigateBack({
// url: "/pages/home/index",
delta: 1,
});
}, 2000);
let postData = {
tableName: "userInfo",
keyValue: { openId: openid },
okFun: (res: any) => {
console.log("提交打卡,res", res);
let newobj = {
tableName: "userInfo",
id: res?.data?.[0]?._id,
objData: {
checkInArr: [
...(res?.data?.[0]?.checkInArr ?? []),
{
imageUrl: cloudfileID,
remark: fieldValues?.remark,
location: address,
},
],
},
okFun: (okFunres: any) => {
console.log("提交打卡,res", okFunres);
Toast.success({
message: "打卡成功",
selector: "#vanToast-demo2",
duration: 2000,
onClose: () => {
// 跳转到打卡页面
// 返回首页 [上一页]
Taro.navigateBack({
// url: "/pages/home/index",
delta: 1,
});
},
});
},
};
updateTableid({ ...newobj });
},
};
// 查询openid
getTable({ ...postData });
});
}}
>

View File

@@ -17,7 +17,7 @@ import { NoticeBar } from "@antmjs/vantui";
import Taro from "@tarojs/taro";
import { Tabbar, TabbarItem } from "@antmjs/vantui";
import TabbarCom from "../components/TabbarCom";
import { getTable, getTableid } from "../../utils/index";
import { getTable, getTableid, phoneLogin } from "../../utils/index";
import { Icon } from "@antmjs/vantui";
import "./index.scss";
import { Search } from "@antmjs/vantui";
@@ -39,6 +39,8 @@ const Home = () => {
// 系统配置
const [systemConfig, setsystemConfig] = useState<any>({});
// const [openid,setopenid]=useState()
const onChange = (e) => {};
useEffect(() => {
@@ -56,11 +58,11 @@ const Home = () => {
success() {},
});
getdetails(); //获取活动详情
getsystemConfig(); //获取系统配置
getdetails(); //获取活动详情
}, []);
const getdetails = () => {
const getdetails = async () => {
let objParams = {
tableName: "details",
// id: "80516fb66370bcf300b8f43c5f4dd52b",
@@ -69,10 +71,10 @@ const Home = () => {
setdetails(res?.data ?? []);
},
};
getTable(objParams);
await getTable(objParams);
};
const getsystemConfig = () => {
const getsystemConfig = async () => {
let objParams = {
tableName: "systemConfig",
// id: "80516fb66370bcf300b8f43c5f4dd52b",
@@ -81,7 +83,7 @@ const Home = () => {
setsystemConfig(res?.data ?? []);
},
};
getTable(objParams);
await getTable(objParams);
};
const uploadTaro = (tempFilePaths: any) => {
@@ -263,9 +265,18 @@ const Home = () => {
icon="star"
text="打卡"
className="iconStyle"
onClick={() => {
onClick={async() => {
// getLocation();
chooseImage();
let isin: any =await phoneLogin();
console.log('isin',isin)
if (isin) {
chooseImage();
} else {
Toast.fail({
message: "请先登录",
selector: "#vanToast-demo2",
});
}
}}
/>
<GridItem
@@ -350,7 +361,6 @@ const Home = () => {
);
})}
{/* 直播live专区 */}
{/* <View>视频号直播</View> */}