feat: merge公司-私人
This commit is contained in:
@@ -11,6 +11,8 @@ export default {
|
||||
"pages/my/index",
|
||||
"pages/my/components/Version/index",
|
||||
"pages/my/components/AbountUs/index",
|
||||
"pages/my/components/CheckinDetail/index", //打卡详情
|
||||
|
||||
|
||||
],
|
||||
permission: {
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -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> */}
|
||||
|
||||
|
||||
10
src/pages/my/components/CheckinDetail/index.scss
Normal file
10
src/pages/my/components/CheckinDetail/index.scss
Normal file
@@ -0,0 +1,10 @@
|
||||
.CheckinDetail{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
.checkCom{
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
65
src/pages/my/components/CheckinDetail/index.tsx
Normal file
65
src/pages/my/components/CheckinDetail/index.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import react, { useEffect, useState } from "react";
|
||||
import { Image } from "@antmjs/vantui";
|
||||
|
||||
import "./index.scss";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { getTable } from "../../../../utils/index";
|
||||
|
||||
const CheckinDetail = () => {
|
||||
const [checkArr, setcheckArr] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
// 设置标题
|
||||
definePageConfig({
|
||||
navigationBarTitleText: "打卡记录",
|
||||
});
|
||||
getcheckArr();
|
||||
}, []);
|
||||
|
||||
const getcheckArr = () => {
|
||||
Taro.cloud.callFunction({
|
||||
name: "getOpenid",
|
||||
complete: async (res: any) => {
|
||||
let openid: any = res?.result?.event?.userInfo?.openId;
|
||||
let postData = {
|
||||
tableName: "userInfo",
|
||||
keyValue: {
|
||||
openId: openid,
|
||||
},
|
||||
okFun: (res: any) => {
|
||||
console.log('res',res)
|
||||
let _id = res?.data?._id;
|
||||
setcheckArr(res?.data?.[0]?.checkInArr ?? []);
|
||||
},
|
||||
};
|
||||
getTable({...postData})
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const checkCom = () => {
|
||||
return checkArr.map((item: any) => {
|
||||
return (
|
||||
<View className="checkCom">
|
||||
<View>{item?.remark}</View>
|
||||
<View>
|
||||
<Image
|
||||
width="100%"
|
||||
height="150px"
|
||||
fit="cover"
|
||||
src={item.imageUrl}
|
||||
/>
|
||||
</View>
|
||||
{/* 打卡日期 */}
|
||||
<View>{item?.checkTime}</View>
|
||||
{location&& <View>{item?.location}</View>}
|
||||
</View>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return <View className="CheckinDetail">{checkCom()}</View>;
|
||||
};
|
||||
|
||||
export default CheckinDetail;
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Row,
|
||||
Tabbar,
|
||||
TabbarItem,
|
||||
Toast,
|
||||
} from "@antmjs/vantui";
|
||||
import { OpenData, View } from "@tarojs/components";
|
||||
import react, { useEffect, useState } from "react";
|
||||
@@ -201,7 +202,24 @@ const my = (props: any) => {
|
||||
</View> */}
|
||||
|
||||
<View className="cellArr">
|
||||
<Cell icon="manager" title="打卡记录" isLink />
|
||||
<Cell
|
||||
icon="manager"
|
||||
title="打卡记录"
|
||||
isLink
|
||||
onClick={() => {
|
||||
if (isin) {
|
||||
// 跳转到目的页面,打开新页面
|
||||
Taro.navigateTo({
|
||||
url: "/pages/my/components/CheckinDetail/index",
|
||||
});
|
||||
}else{
|
||||
Toast.fail({
|
||||
message: '请先登录',
|
||||
selector: '#vanToast-demo2',
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/* <Cell icon="manager" title="个人资料" isLink /> */}
|
||||
|
||||
<Cell
|
||||
@@ -243,6 +261,8 @@ const my = (props: any) => {
|
||||
/> */}
|
||||
</View>
|
||||
|
||||
<Toast id="vanToast-demo2" />
|
||||
|
||||
{/* tabbar */}
|
||||
<TabbarCom active={2} />
|
||||
</View>
|
||||
|
||||
@@ -16,9 +16,10 @@ interface Typeint {
|
||||
okFun: any;
|
||||
}
|
||||
|
||||
const params = () => {
|
||||
// 获取params参数
|
||||
export const getparams = () => {
|
||||
let $instance: any = getCurrentInstance();
|
||||
return $instance.router.params;
|
||||
return $instance?.router?.params;
|
||||
};
|
||||
// 添加数据
|
||||
export const addTable: any = ({ env, tableName, objData, okFun }: Typeint) => {
|
||||
@@ -37,19 +38,28 @@ export const addTable: any = ({ env, tableName, objData, okFun }: Typeint) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 获取指定集合数据表
|
||||
export const getTable: any = ({ env, tableName, keyValue, okFun }: Typeint) => {
|
||||
// 获取指定集合数据表 (keyValue指定条件)
|
||||
export const getTable: any = ({ env, tableName, keyValue={}, okFun }: Typeint) => {
|
||||
// 数据库环境
|
||||
const db: any = Taro.cloud.database({
|
||||
env: env,
|
||||
});
|
||||
|
||||
let nowtable: any = db?.collection(tableName);
|
||||
nowtable?.where({ ...(keyValue ?? {}) }).get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
if(Object.keys(keyValue)?.length>0){
|
||||
nowtable?.where(keyValue).get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
}else{
|
||||
nowtable?.get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 获取指定id数据数据
|
||||
@@ -57,7 +67,7 @@ export const getTableid: any = ({
|
||||
env,
|
||||
tableName,
|
||||
id,
|
||||
keyValue,
|
||||
keyValue={},
|
||||
okFun,
|
||||
}: Typeint) => {
|
||||
// 数据库环境
|
||||
@@ -66,14 +76,25 @@ export const getTableid: any = ({
|
||||
});
|
||||
|
||||
let nowtable: any = db?.collection(tableName);
|
||||
nowtable
|
||||
|
||||
if(Object.keys(keyValue)?.length>0){
|
||||
nowtable
|
||||
?.doc(id)
|
||||
// .where({ ...(keyValue ?? {}) })
|
||||
.where(keyValue)
|
||||
.get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
}else{
|
||||
nowtable
|
||||
?.doc(id)?.get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 更新数据
|
||||
|
||||
Reference in New Issue
Block a user