1
This commit is contained in:
84
src/App.tsx
Normal file
84
src/App.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
import {useEffect, useState} from 'react';
|
||||
import {Screen1Hook} from './components/Screen1Hook';
|
||||
import {Screen2Upload} from './components/Screen2Upload';
|
||||
import {Screen3Analysis} from './components/Screen3Analysis';
|
||||
import {Screen4Payment} from './components/Screen4Payment';
|
||||
import {Screen5Report} from './components/Screen5Report';
|
||||
import wxLogin from "@/wx/wxLogin";
|
||||
import toast, {Toaster} from "react-hot-toast";
|
||||
import wxShare from "@/wx/wxShare";
|
||||
import {enterpriseAnalyzeApi} from "@/api/service";
|
||||
import {useUserStore} from "@/store/user-store";
|
||||
|
||||
export default function App() {
|
||||
const userStore = useUserStore()
|
||||
//初始化
|
||||
const [init, setInit] = useState(false)
|
||||
const [currentScreen, setCurrentScreen] = useState(1);
|
||||
|
||||
/**
|
||||
* 步骤往下
|
||||
*/
|
||||
const handleNextScreen = () => {
|
||||
setCurrentScreen(prev => Math.min(prev + 1, 5));
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
const handleUpload = async (file) => {
|
||||
handleNextScreen()
|
||||
let res = await enterpriseAnalyzeApi({
|
||||
analys_image: file,
|
||||
analys_type: null,
|
||||
}) as any
|
||||
if (res.analysis_result.analyze_ret != "success") {
|
||||
toast.error("请重新上传结构清晰的组织架构图")
|
||||
setCurrentScreen(prev => prev = 2)
|
||||
return
|
||||
}
|
||||
userStore.setAnalysis(res)
|
||||
handleNextScreen()
|
||||
};
|
||||
|
||||
const handlePayment = () => {
|
||||
handleNextScreen();
|
||||
};
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*/
|
||||
useEffect(() => {
|
||||
wxLogin().then(() => {
|
||||
setInit(true)
|
||||
wxShare().then()
|
||||
})
|
||||
}, []);
|
||||
|
||||
if (!init) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Toaster position="top-center"/>
|
||||
<div className="min-h-screen bg-[#0A0F24] text-white overflow-x-hidden relative">
|
||||
{/* 背景色 */}
|
||||
<div className="fixed inset-0 pointer-events-none">
|
||||
<div
|
||||
className="absolute inset-0 bg-gradient-to-b from-[#7B61FF]/10 via-transparent to-[#00F0FF]/10"/>
|
||||
</div>
|
||||
|
||||
{/* Main content */}
|
||||
<div className="relative z-10">
|
||||
{currentScreen === 1 && <Screen1Hook onNext={handleNextScreen}/>}
|
||||
{currentScreen === 2 && <Screen2Upload onSuccess={handleUpload}/>}
|
||||
{currentScreen === 3 && <Screen3Analysis/>}
|
||||
{currentScreen === 4 && <Screen4Payment onPayment={handlePayment}/>}
|
||||
{currentScreen === 5 && <Screen5Report/>}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user