feat: 签到打卡

This commit is contained in:
eric
2022-11-20 14:18:19 +08:00
parent b812ece697
commit e307431687
3 changed files with 44 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -9,11 +9,18 @@ import {
Icon,
} from "@antmjs/vantui";
import { Input, View } from "@tarojs/components";
import { getCurrentInstance } from "@tarojs/taro";
import React, { useCallback, useEffect } from "react";
import './index.scss'
const CheckIn = () => {
const formIt = Form.useForm();
let $instance:any = getCurrentInstance()
const {fileID}=$instance?.router?.params
console.log('fileID---',fileID)
useEffect(() => {
// 设置标题
definePageConfig({
@@ -38,7 +45,7 @@ const CheckIn = () => {
width="100%"
height="180px"
fit="cover"
src="https://img.yzcdn.cn/vant/cat.jpeg"
src={fileID}
/>
</View>
<FormItem

View File

@@ -150,14 +150,42 @@ const Home = () => {
text="打卡"
className="iconStyle"
onClick={() => {
// Toast.success({
// message: "打卡成功",
// selector: "#vanToast-demo2",
// });
// 相机拍照
Taro.chooseImage({
count: 1, // 默认9
// , 'compressed'
sizeType: ["original"], // 可以指定是原图还是压缩图,默认二者都有
// 'album',
sourceType: ["camera"], // 可以指定来源是相册还是相机默认二者都有在H5浏览器端支持使用 `user` 和 `environment`分别指定为前后摄像头
success: function (res: any) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
let tempFilePaths = res.tempFilePaths;
console.log("tempFilePaths===", tempFilePaths);
// 跳转到目的页面,打开新页面
Taro.navigateTo({
url: "/pages/home/components/CheckIn/index",
// 云开发存储文件 [/自动创建文件路径]
Taro.cloud.uploadFile({
cloudPath: `images/dev/example.png`,
filePath: tempFilePaths?.[0], // 文件路径
success: (res: any) => {
// get resource ID
console.log("res", res.fileID);
// 跳转到目的页面,打开新页面
Taro.navigateTo({
url: `/pages/home/components/CheckIn/index?fileID=${res?.fileID}`,
});
// Toast.success({
// message: "打卡成功",
// selector: "#vanToast-demo2",
// });
},
fail: (err: any) => {
// handle error
console.log("err", err);
},
});
},
});
}}
/>