feat: 签到打卡
This commit is contained in:
2
dist/pages/home/index.js
vendored
2
dist/pages/home/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -9,11 +9,18 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
} from "@antmjs/vantui";
|
} from "@antmjs/vantui";
|
||||||
import { Input, View } from "@tarojs/components";
|
import { Input, View } from "@tarojs/components";
|
||||||
|
import { getCurrentInstance } from "@tarojs/taro";
|
||||||
import React, { useCallback, useEffect } from "react";
|
import React, { useCallback, useEffect } from "react";
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
const CheckIn = () => {
|
const CheckIn = () => {
|
||||||
const formIt = Form.useForm();
|
const formIt = Form.useForm();
|
||||||
|
|
||||||
|
let $instance:any = getCurrentInstance()
|
||||||
|
const {fileID}=$instance?.router?.params
|
||||||
|
console.log('fileID---',fileID)
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 设置标题
|
// 设置标题
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
@@ -38,7 +45,7 @@ const CheckIn = () => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
height="180px"
|
height="180px"
|
||||||
fit="cover"
|
fit="cover"
|
||||||
src="https://img.yzcdn.cn/vant/cat.jpeg"
|
src={fileID}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<FormItem
|
<FormItem
|
||||||
|
|||||||
@@ -150,14 +150,42 @@ const Home = () => {
|
|||||||
text="打卡"
|
text="打卡"
|
||||||
className="iconStyle"
|
className="iconStyle"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// Toast.success({
|
// 相机拍照
|
||||||
// message: "打卡成功",
|
Taro.chooseImage({
|
||||||
// selector: "#vanToast-demo2",
|
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({
|
Taro.cloud.uploadFile({
|
||||||
url: "/pages/home/components/CheckIn/index",
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user