feat: 签到打卡

This commit is contained in:
eric
2022-11-20 18:46:01 +08:00
parent 4b8d3ca542
commit bdfa60e264
3 changed files with 34 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@@ -7,6 +7,7 @@ import {
Image, Image,
FormItem, FormItem,
Icon, Icon,
Toast,
} from "@antmjs/vantui"; } from "@antmjs/vantui";
import { Input, View } from "@tarojs/components"; import { Input, View } from "@tarojs/components";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
@@ -18,6 +19,7 @@ import { Uploader } from "@antmjs/vantui";
const CheckIn = () => { const CheckIn = () => {
const formIt = Form.useForm(); const formIt = Form.useForm();
const [bottomheight, setbottomheight] = useState(0); const [bottomheight, setbottomheight] = useState(0);
const [cloudfileID, setcloudfileID] = useState();
const [value, setValue] = useState([ const [value, setValue] = useState([
// { // {
@@ -77,6 +79,7 @@ const CheckIn = () => {
filePath: tempFilePaths?.[0], // 文件路径 filePath: tempFilePaths?.[0], // 文件路径
success: (res: any) => { success: (res: any) => {
console.log("res", res?.fileID); console.log("res", res?.fileID);
setcloudfileID(res?.fileID);
}, },
fail: (err: any) => { fail: (err: any) => {
// handle error // handle error
@@ -105,18 +108,9 @@ const CheckIn = () => {
{/* 留言 */} {/* 留言 */}
<FormItem <FormItem
label="留言" label="留言"
name="userName" name="remark"
required // required
layout="vertical" layout="vertical"
// rules={{
// rule: /[\u4e00-\u9fa5]/,
// message: '用户名仅支持中文',
// }}
trigger="onInput"
validateTrigger="onBlur"
// taro的input的onInput事件返回对应表单的最终值为e.detail.value
valueFormat={(e) => e.detail.value}
// renderRight={<Icon name="user-o" />}
> >
<Field <Field
// label="留言" // label="留言"
@@ -142,13 +136,39 @@ const CheckIn = () => {
position: "fixed", position: "fixed",
width: "95%", width: "95%",
}} }}
onClick={() => {
// 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.navigateTo({
url: "/pages/home/index",
});
}, 2000);
});
}}
> >
<Button type="primary" block> <Button type="primary" block>
</Button> </Button>
</View> </View>
<Dialog id="form-demo3" /> <Dialog id="form-demo3" />
<Toast id="vanToast-demo2" />
</Form> </Form>
</View> </View>
); );

View File

@@ -52,7 +52,7 @@ const my = (props: any) => {
</View> </View>
<View className="cellArr"> <View className="cellArr">
<Cell icon="manager" title="打卡记录" isLink /> {/* <Cell icon="manager" title="打卡记录" isLink /> */}
{/* <Cell icon="manager" title="个人资料" isLink /> */} {/* <Cell icon="manager" title="个人资料" isLink /> */}
<Cell <Cell