feat: merge公司-私人
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user