feat: 订单详情 & 问卷调查
This commit is contained in:
@@ -1,51 +1,51 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { View } from '@tarojs/components'
|
||||
import { check_login_status } from '@/services/loginService'
|
||||
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { View } from "@tarojs/components";
|
||||
import { check_login_status } from "@/services/loginService";
|
||||
|
||||
export function getCurrentFullPath(): string {
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currentPage = pages.at(-1)
|
||||
const pages = Taro.getCurrentPages();
|
||||
const currentPage = pages.at(-1);
|
||||
|
||||
if (currentPage) {
|
||||
console.log(currentPage, 'currentPage get')
|
||||
const route = currentPage.route
|
||||
const options = currentPage.options || {}
|
||||
console.log(currentPage, "currentPage get");
|
||||
const route = currentPage.route;
|
||||
const options = currentPage.options || {};
|
||||
|
||||
const query = Object.keys(options)
|
||||
.map(key => `${key}=${options[key]}`)
|
||||
.join('&')
|
||||
.map((key) => `${key}=${options[key]}`)
|
||||
.join("&");
|
||||
|
||||
return query ? `/${route}?${query}` : `/${route}`
|
||||
return query ? `/${route}?${query}` : `/${route}`;
|
||||
}
|
||||
return ''
|
||||
return "";
|
||||
}
|
||||
|
||||
export default function withAuth<P extends object>(WrappedComponent: React.ComponentType<P>) {
|
||||
export default function withAuth<P extends object>(
|
||||
WrappedComponent: React.ComponentType<P>,
|
||||
) {
|
||||
const ComponentWithAuth: React.FC<P> = (props: P) => {
|
||||
const [authed, setAuthed] = useState(false)
|
||||
const [authed, setAuthed] = useState(false);
|
||||
useEffect(() => {
|
||||
const is_login = check_login_status()
|
||||
setAuthed(is_login)
|
||||
const is_login = check_login_status();
|
||||
setAuthed(is_login);
|
||||
|
||||
if (!is_login) {
|
||||
const currentPage = getCurrentFullPath()
|
||||
const currentPage = getCurrentFullPath();
|
||||
// Taro.redirectTo({
|
||||
// url: `/pages/login/index/index${
|
||||
// currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ''
|
||||
// }`,
|
||||
// })
|
||||
}
|
||||
}, [])
|
||||
}, []);
|
||||
|
||||
// if (!authed) {
|
||||
// return <View style={{ width: '100vh', height: '100vw', backgroundColor: 'white', position: 'fixed', top: 0, left: 0, zIndex: 999 }} /> // 空壳,避免 children 渲染出错
|
||||
// }
|
||||
|
||||
return <WrappedComponent {...props} />
|
||||
}
|
||||
return <WrappedComponent {...props} />;
|
||||
};
|
||||
|
||||
return ComponentWithAuth
|
||||
}
|
||||
return ComponentWithAuth;
|
||||
}
|
||||
|
||||
@@ -1,43 +1,46 @@
|
||||
import React, { useState } from 'react'
|
||||
import { View, Text, Image } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import img from '@/config/images'
|
||||
import './index.scss'
|
||||
import PublishMenu from '../PublishMenu'
|
||||
export type currentPageType = 'games' | 'message' | 'personal'
|
||||
import React, { useState } from "react";
|
||||
import { View, Text, Image } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import img from "@/config/images";
|
||||
import "./index.scss";
|
||||
import PublishMenu from "../PublishMenu";
|
||||
export type currentPageType = "games" | "message" | "personal";
|
||||
|
||||
const GuideBar = (props) => {
|
||||
const { currentPage } = props
|
||||
const { currentPage } = props;
|
||||
|
||||
const guideItems = [
|
||||
{
|
||||
code: 'list',
|
||||
text: '球局',
|
||||
code: "list",
|
||||
text: "球局",
|
||||
},
|
||||
{
|
||||
code: 'message',
|
||||
text: '消息',
|
||||
code: "message",
|
||||
text: "消息",
|
||||
},
|
||||
{
|
||||
code: 'personal',
|
||||
text: '我的',
|
||||
code: "personal",
|
||||
text: "我的",
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const handlePublish = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/publishBall/index',
|
||||
})
|
||||
}
|
||||
url: "/pages/publishBall/index",
|
||||
});
|
||||
};
|
||||
|
||||
const handlePageChange = (code: string) => {
|
||||
if (code === currentPage) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
let url = `/pages/${code}/index`
|
||||
if (code === 'personal') {
|
||||
url = '/mod_user/pages/myself/index'
|
||||
let url = `/pages/${code}/index`;
|
||||
if (code === "personal") {
|
||||
url = "/mod_user/pages/myself/index";
|
||||
}
|
||||
if (code === "message") {
|
||||
url = "/mod_user/message/index";
|
||||
}
|
||||
Taro.redirectTo({
|
||||
url: url,
|
||||
@@ -45,18 +48,18 @@ const GuideBar = (props) => {
|
||||
Taro.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300,
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className='guide-bar-container'>
|
||||
<View className='guide-bar'>
|
||||
<View className="guide-bar-container">
|
||||
<View className="guide-bar">
|
||||
{/* guide area on the left */}
|
||||
<View className='guide-bar-pages'>
|
||||
<View className="guide-bar-pages">
|
||||
{guideItems.map((item) => (
|
||||
<View
|
||||
className={`guide-bar-pages-item ${currentPage === item.code ? 'guide-bar-pages-item-active' : ''}`}
|
||||
className={`guide-bar-pages-item ${currentPage === item.code ? "guide-bar-pages-item-active" : ""}`}
|
||||
onClick={() => handlePageChange(item.code)}
|
||||
>
|
||||
<Text>{item.text}</Text>
|
||||
@@ -70,7 +73,7 @@ const GuideBar = (props) => {
|
||||
<PublishMenu />
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default GuideBar
|
||||
export default GuideBar;
|
||||
|
||||
12
src/components/NTRPEvaluatePopup/index.module.scss
Normal file
12
src/components/NTRPEvaluatePopup/index.module.scss
Normal file
@@ -0,0 +1,12 @@
|
||||
@use "~@/scss/images.scss" as img;
|
||||
|
||||
.container {
|
||||
width: calc(100vw - 40px);
|
||||
height: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
99
src/components/NTRPEvaluatePopup/index.tsx
Normal file
99
src/components/NTRPEvaluatePopup/index.tsx
Normal file
@@ -0,0 +1,99 @@
|
||||
import React, {
|
||||
useState,
|
||||
useImperativeHandle,
|
||||
useEffect,
|
||||
forwardRef,
|
||||
} from "react";
|
||||
import { Button, Input, View, Text } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import CommonPopup from "../CommonPopup";
|
||||
import { getCurrentFullPath } from "@/components/Auth";
|
||||
import { useUserInfo, useUserActions } from "@/store/userStore";
|
||||
import style from "./index.module.scss";
|
||||
|
||||
export enum EvaluateType {
|
||||
EDIT = "edit",
|
||||
EVALUATE = "evaluate",
|
||||
}
|
||||
|
||||
export enum DisplayConditionType {
|
||||
AUTO = "auto",
|
||||
ALWAYS = "always",
|
||||
}
|
||||
|
||||
export enum SceneType {
|
||||
LIST = "list",
|
||||
PUBLISH = "publish",
|
||||
PERSONAL = "personal",
|
||||
DETAIL = "detail",
|
||||
}
|
||||
|
||||
interface NTRPEvaluatePopupProps {
|
||||
types: EvaluateType[];
|
||||
displayCondition: DisplayConditionType;
|
||||
scene: SceneType;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
function showCondition(scene, ntrp) {
|
||||
if (scene === "list") {
|
||||
// TODO: 显示频率
|
||||
return Math.random() < 0.1 && [0, undefined].includes(ntrp);
|
||||
}
|
||||
return [0, undefined].includes(ntrp);
|
||||
}
|
||||
|
||||
const NTRPEvaluatePopup = (props: NTRPEvaluatePopupProps, ref) => {
|
||||
const {
|
||||
types = ["edit", "evaluate"],
|
||||
displayCondition = "auto",
|
||||
scene = "list",
|
||||
} = props;
|
||||
const [visible, setVisible] = useState(false);
|
||||
const { ntrp } = useUserInfo();
|
||||
const { fetchUserInfo } = useUserActions();
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
show: () => setVisible(true),
|
||||
}));
|
||||
|
||||
function handleEvaluate() {
|
||||
setVisible(false);
|
||||
// TODO: 实现NTRP评估逻辑
|
||||
Taro.navigateTo({
|
||||
url: `/mod_user/ntrp-evaluate/index?redirect=${encodeURIComponent(getCurrentFullPath())}`,
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// fetchUserInfo();
|
||||
}, []);
|
||||
|
||||
const showEntry =
|
||||
displayCondition === "auto"
|
||||
? showCondition(scene, ntrp)
|
||||
: displayCondition === "always";
|
||||
|
||||
return (
|
||||
<>
|
||||
<CommonPopup
|
||||
title="NTRP评估"
|
||||
visible={visible}
|
||||
onClose={() => setVisible(false)}
|
||||
position="center"
|
||||
hideFooter
|
||||
enableDragToClose={false}
|
||||
>
|
||||
<View className={style.container}>
|
||||
{/* TODO: 直接修改NTRP水平 */}
|
||||
<Text>您还未测评。。。</Text>
|
||||
<Text>请先进行NTRP评估</Text>
|
||||
<Button onClick={handleEvaluate}>开始评估</Button>
|
||||
</View>
|
||||
</CommonPopup>
|
||||
{showEntry && props.children}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(NTRPEvaluatePopup);
|
||||
@@ -1,40 +1,42 @@
|
||||
import ActivityTypeSwitch from './ActivityTypeSwitch'
|
||||
import TextareaTag from './TextareaTag'
|
||||
import FormSwitch from './FormSwitch'
|
||||
import ImageUpload from './ImageUpload'
|
||||
import Range from './Range'
|
||||
import NumberInterval from './NumberInterval'
|
||||
import ActivityTypeSwitch from "./ActivityTypeSwitch";
|
||||
import TextareaTag from "./TextareaTag";
|
||||
import FormSwitch from "./FormSwitch";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import Range from "./Range";
|
||||
import NumberInterval from "./NumberInterval";
|
||||
|
||||
import TimeSelector from './TimeSelector'
|
||||
import TitleTextarea from './TitleTextarea'
|
||||
import CommonPopup from './CommonPopup'
|
||||
import TimePicker from './TimePicker/TimePicker'
|
||||
import { CalendarUI, DialogCalendarCard } from './Picker'
|
||||
import CommonDialog from './CommonDialog'
|
||||
import PublishMenu from './PublishMenu/PublishMenu'
|
||||
import UploadCover from './UploadCover'
|
||||
import EditModal from './EditModal/index'
|
||||
import withAuth from './Auth'
|
||||
import { CustomPicker, PopupPicker } from './Picker'
|
||||
import TimeSelector from "./TimeSelector";
|
||||
import TitleTextarea from "./TitleTextarea";
|
||||
import CommonPopup from "./CommonPopup";
|
||||
import TimePicker from "./TimePicker/TimePicker";
|
||||
import { CalendarUI, DialogCalendarCard } from "./Picker";
|
||||
import CommonDialog from "./CommonDialog";
|
||||
import PublishMenu from "./PublishMenu/PublishMenu";
|
||||
import UploadCover from "./UploadCover";
|
||||
import EditModal from "./EditModal/index";
|
||||
import withAuth from "./Auth";
|
||||
import { CustomPicker, PopupPicker } from "./Picker";
|
||||
import NTRPEvaluatePopup from "./NTRPEvaluatePopup";
|
||||
|
||||
export {
|
||||
ActivityTypeSwitch,
|
||||
TextareaTag,
|
||||
FormSwitch,
|
||||
ImageUpload,
|
||||
Range,
|
||||
NumberInterval,
|
||||
TimeSelector,
|
||||
TitleTextarea,
|
||||
CommonPopup,
|
||||
TimePicker,
|
||||
DialogCalendarCard,
|
||||
CalendarUI,
|
||||
CommonDialog,
|
||||
PublishMenu,
|
||||
UploadCover,
|
||||
EditModal,
|
||||
withAuth,
|
||||
CustomPicker,
|
||||
PopupPicker
|
||||
}
|
||||
export {
|
||||
ActivityTypeSwitch,
|
||||
TextareaTag,
|
||||
FormSwitch,
|
||||
ImageUpload,
|
||||
Range,
|
||||
NumberInterval,
|
||||
TimeSelector,
|
||||
TitleTextarea,
|
||||
CommonPopup,
|
||||
TimePicker,
|
||||
DialogCalendarCard,
|
||||
CalendarUI,
|
||||
CommonDialog,
|
||||
PublishMenu,
|
||||
UploadCover,
|
||||
EditModal,
|
||||
withAuth,
|
||||
CustomPicker,
|
||||
PopupPicker,
|
||||
NTRPEvaluatePopup,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user