tiefen_space_h5/app/my/setting/feedback/page.js

109 lines
3.3 KiB
JavaScript
Raw Normal View History

2024-07-02 23:08:38 +08:00
"use client";
import React, { useState } from "react";
import { Button, TextArea, Toast } from "antd-mobile";
2024-07-02 23:08:38 +08:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2024-07-16 20:20:12 +08:00
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
2024-07-02 23:08:38 +08:00
import { useRouter } from "next/navigation";
import UploadImgs from "@/components/UploadImgs";
2024-07-16 20:20:12 +08:00
import { get } from "@/utils/storeInfo";
import { multiUploadImage } from "@/utils/upload";
2024-07-24 13:53:12 +08:00
import requireAPI from "@/utils/requireAPI";
2024-07-02 23:08:38 +08:00
export default function Feedback() {
const [value, setValue] = useState();
const [assets, setAssets] = useState([]);
const [isSubmitting, setIsSubmitting] = useState(false);
const router = useRouter();
2024-07-16 20:20:12 +08:00
//提交反馈
const handleSubmit = async () => {
if (!value) {
Toast.show({
icon: "fail",
content: "反馈内容不能为空",
position: "top",
});
return;
}
2024-07-24 13:53:12 +08:00
//提交数据
setIsSubmitting(true);
2024-07-16 20:20:12 +08:00
// const media = await multiUpload(assets);
2024-10-22 17:24:02 +08:00
const media = await multiUploadImage(assets, 1);
2024-08-05 18:59:30 +08:00
// console.log("media",media)
2024-07-24 13:53:12 +08:00
const account = await get("account");
try {
const data = await requireAPI("POST", `/api/feedback/create`, {
body: {
mid: account.mid,
discription: value,
credentials: media,
},
});
if (data.ret === -1) {
Toast.show({
icon: "fail",
content: data.msg,
position: "top",
});
return;
}
//提交成功后显示Toast并返回上一页
Toast.show({
icon: "success",
content: "反馈提交成功",
position: "top",
});
router.back();
} catch (error) {
2024-09-09 15:34:31 +08:00
// console.error(error);
2024-07-24 13:53:12 +08:00
} finally {
setIsSubmitting(false);
}
2024-07-16 20:20:12 +08:00
};
2024-07-02 23:08:38 +08:00
return (
<div>
<div className="p-4 fixed top-0 z-10 w-full">
<div className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full absolute">
<FontAwesomeIcon
icon={faAngleLeft}
style={{ maxWidth: "12px" }}
2024-07-02 23:08:38 +08:00
size="xl"
onClick={() => {
router.back();
}}
/>
</div>
<p className="text-base text-center leading-9">意见反馈</p>
</div>
{/* 内容 */}
<div className="pt-16 p-4">
<p className="text-base font-medium text-white">反馈描述</p>
<TextArea
placeholder="请填写详细描述,以便我们更好地为您解决问题"
onChange={(value) => setValue(value)}
value={value}
className="h-32 bg-[#FFFFFF1A] text-white rounded-2xl mt-2 p-2"
2024-08-05 18:34:44 +08:00
style={{ "--placeholder-color": "#FFFFFF80", "--font-size": "16px" }}
2024-07-02 23:08:38 +08:00
/>
<p className="text-base font-medium text-white mt-4 mb-1">
2024-07-17 20:30:33 +08:00
截图最多9张
2024-07-02 23:08:38 +08:00
</p>
2024-07-24 13:53:12 +08:00
<UploadImgs assets={assets} getImgs={setAssets} />
2024-07-02 23:08:38 +08:00
<div className="mt-16">
<Button
shape="rounded"
size="middle"
block
2024-07-16 20:20:12 +08:00
onClick={handleSubmit}
2024-07-02 23:08:38 +08:00
style={{ "--background-color": "#FF669E", color: "#FFFFFF" }}
2024-07-16 20:20:12 +08:00
disabled={isSubmitting}
2024-07-02 23:08:38 +08:00
>
{/* {isSubmitting && <ActivityIndicator size="small" color="white" />} */}
{isSubmitting ? "正在提交..." : "提交"}
</Button>
</div>
</div>
</div>
);
}