Merge branch 'feat/liujie'
This commit is contained in:
@@ -39,7 +39,7 @@ function NTRPTestEntryCard(props: {
|
||||
// 获取测试结果
|
||||
const res = await evaluateService.getLastResult();
|
||||
if (res.code === 0) {
|
||||
setTestFlag(res.data.has_ntrp_level);
|
||||
setTestFlag(res.data.has_test_record);
|
||||
setHasTestInLastMonth(res.data.has_test_in_last_month);
|
||||
}
|
||||
};
|
||||
@@ -117,13 +117,21 @@ function NTRPTestEntryCard(props: {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (!testFlag && !userInfo.phone) {
|
||||
Taro.navigateTo({
|
||||
url: `/login_pages/index/index?redirect=${encodeURIComponent(
|
||||
`/other_pages/ntrp-evaluate/index?stage=${StageType.INTRO}`
|
||||
)}`,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
Taro.navigateTo({
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${
|
||||
testFlag ? StageType.INTRO : StageType.TEST
|
||||
}`,
|
||||
});
|
||||
},
|
||||
[setCallback, testFlag, type, evaluateCallback]
|
||||
[setCallback, testFlag, type, evaluateCallback, userInfo.phone]
|
||||
);
|
||||
|
||||
// 如果最近一个月有测试记录,则不展示
|
||||
|
||||
@@ -1,31 +1,48 @@
|
||||
import React, { useState, useRef, forwardRef, useImperativeHandle } from 'react';
|
||||
import { View, Text, Button, Image } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro';
|
||||
import dayjs from 'dayjs'
|
||||
import { CommonPopup } from '@/components';
|
||||
import orderService from '@/services/orderService';
|
||||
import styles from './index.module.scss'
|
||||
import closeIcon from '@/static/order/orderListClose.svg'
|
||||
import React, {
|
||||
useState,
|
||||
useRef,
|
||||
forwardRef,
|
||||
useImperativeHandle,
|
||||
} from "react";
|
||||
import { View, Text, Button, Image } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import dayjs from "dayjs";
|
||||
import { CommonPopup } from "@/components";
|
||||
import orderService from "@/services/orderService";
|
||||
import styles from "./index.module.scss";
|
||||
import closeIcon from "@/static/order/orderListClose.svg";
|
||||
|
||||
function genRefundNotice (refund_policy) {
|
||||
function genRefundNotice(refund_policy) {
|
||||
if (refund_policy.length === 0) {
|
||||
return {}
|
||||
return {};
|
||||
}
|
||||
const now = dayjs()
|
||||
const deadlines = refund_policy.map(item => dayjs(item.deadline_formatted))
|
||||
let matchPolicyIndex = deadlines.findIndex(d => d.isAfter(now))
|
||||
const now = dayjs();
|
||||
const deadlines = refund_policy.map((item) => dayjs(item.deadline_formatted));
|
||||
let matchPolicyIndex = deadlines.findIndex((d) => d.isAfter(now));
|
||||
if (matchPolicyIndex === -1) {
|
||||
matchPolicyIndex = refund_policy.length - 1
|
||||
matchPolicyIndex = refund_policy.length - 1;
|
||||
}
|
||||
const { deadline_formatted, price, refund_rate } = refund_policy[matchPolicyIndex]
|
||||
const { deadline_formatted, price, refund_rate } =
|
||||
refund_policy[matchPolicyIndex];
|
||||
if (refund_rate === 1) {
|
||||
return { refundPrice: price, notice: `本次可全额退款, ¥${price} 将原路退回,请查收` }
|
||||
return {
|
||||
refundPrice: price,
|
||||
notice: `本次可全额退款, ¥${price} 将原路退回,请查收`,
|
||||
};
|
||||
} else if (refund_rate === 0) {
|
||||
return { refundPrice: 0, notice: `当前退出不可退款,后续流程未明确,@麻真瑜` }
|
||||
return {
|
||||
refundPrice: 0,
|
||||
notice: `当前退出不可退款,后续流程未明确,@麻真瑜`,
|
||||
};
|
||||
}
|
||||
const refundPrice = price * refund_rate
|
||||
const leftHours = dayjs(deadline_formatted).diff(dayjs(), 'hour')
|
||||
return { refundPrice, notice: `距活动开始已不足${leftHours}h,当前退出您需扣除${price - refundPrice}元` }
|
||||
const refundPrice = Number(Math.ceil(price * refund_rate * 100) / 100);
|
||||
const leftHours = dayjs(deadline_formatted).diff(dayjs(), "hour");
|
||||
return {
|
||||
refundPrice,
|
||||
notice: `距活动开始已不足${leftHours}h,当前退出您需扣除${
|
||||
Math.floor((price - refundPrice) * 100) / 100
|
||||
}元`,
|
||||
};
|
||||
}
|
||||
|
||||
function renderCancelContent(checkOrderInfo) {
|
||||
@@ -42,7 +59,7 @@ function renderCancelContent(checkOrderInfo) {
|
||||
};
|
||||
}),
|
||||
];
|
||||
const { notice } = genRefundNotice(refund_policy)
|
||||
const { notice } = genRefundNotice(refund_policy);
|
||||
return (
|
||||
<View className={styles.refundPolicy}>
|
||||
{/* <View className={styles.moduleTitle}>
|
||||
@@ -63,37 +80,35 @@ function renderCancelContent(checkOrderInfo) {
|
||||
}
|
||||
|
||||
export type RefundRef = {
|
||||
show: (item: any, callback: (result: boolean) => void) => void
|
||||
}
|
||||
show: (item: any, callback: (result: boolean) => void) => void;
|
||||
};
|
||||
|
||||
export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
||||
const [visible, setVisible] = useState(false)
|
||||
const [checkOrderInfo, setCheckOrderInfo] = useState({})
|
||||
const [orderData, setOrderData] = useState({})
|
||||
const onDown = useRef<((result: boolean) => void) | null>(null)
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [checkOrderInfo, setCheckOrderInfo] = useState({});
|
||||
const [orderData, setOrderData] = useState({});
|
||||
const onDown = useRef<((result: boolean) => void) | null>(null);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
show: onShow,
|
||||
}))
|
||||
}));
|
||||
|
||||
async function onShow (orderItem, onFinish: (result: boolean) => void) {
|
||||
const {
|
||||
game_info,
|
||||
} = orderItem
|
||||
onDown.current = onFinish
|
||||
setOrderData(orderItem)
|
||||
async function onShow(orderItem, onFinish: (result: boolean) => void) {
|
||||
const { game_info } = orderItem;
|
||||
onDown.current = onFinish;
|
||||
setOrderData(orderItem);
|
||||
const res = await orderService.getCheckOrderInfo(game_info.id);
|
||||
setCheckOrderInfo(res.data);
|
||||
setVisible(true)
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
function onClose () {
|
||||
setVisible(false)
|
||||
onDown.current?.(false)
|
||||
function onClose() {
|
||||
setVisible(false);
|
||||
onDown.current?.(false);
|
||||
}
|
||||
|
||||
async function handleConfirmQuit () {
|
||||
const { order_no, amount } = orderData
|
||||
async function handleConfirmQuit() {
|
||||
const { order_no, amount } = orderData;
|
||||
try {
|
||||
const refundRes = await orderService.applicateRefund({
|
||||
order_no,
|
||||
@@ -106,15 +121,15 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
||||
Taro.showToast({
|
||||
title: "退出成功",
|
||||
icon: "none",
|
||||
})
|
||||
onDown.current?.(true)
|
||||
});
|
||||
onDown.current?.(true);
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.message,
|
||||
icon: "error",
|
||||
});
|
||||
} finally {
|
||||
onClose()
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
return (
|
||||
@@ -129,11 +144,17 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
||||
<View className={styles.container}>
|
||||
<View className={styles.header}>
|
||||
<Text className={styles.title}>退出活动</Text>
|
||||
<Image className={styles.closeIcon} src={closeIcon} onClick={onClose} />
|
||||
<Image
|
||||
className={styles.closeIcon}
|
||||
src={closeIcon}
|
||||
onClick={onClose}
|
||||
/>
|
||||
</View>
|
||||
{renderCancelContent(checkOrderInfo)}
|
||||
<Button className={styles.action} onClick={handleConfirmQuit}>确认并退出</Button>
|
||||
<Button className={styles.action} onClick={handleConfirmQuit}>
|
||||
确认并退出
|
||||
</Button>
|
||||
</View>
|
||||
</CommonPopup>
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -65,12 +65,13 @@
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
height: 162px;
|
||||
height: 100%;
|
||||
flex-wrap: nowrap;
|
||||
|
||||
.participants-list-item {
|
||||
display: flex;
|
||||
width: 108px;
|
||||
height: 100%;
|
||||
padding: 16px 4px 10px 4px;
|
||||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin: 74px 22px 0;
|
||||
margin: 52px 22px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
@@ -150,7 +150,9 @@ function Intro() {
|
||||
|
||||
const { last_test_result = null } = ntrpData || {};
|
||||
const { ntrp_level, create_time, id } = last_test_result || {};
|
||||
const lastTestTime = create_time ? dayjs(create_time).format("YYYY年M月D日") : "";
|
||||
const lastTestTime = create_time
|
||||
? dayjs(create_time).format("YYYY年M月D日")
|
||||
: "";
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
@@ -192,15 +194,16 @@ function Intro() {
|
||||
});
|
||||
}
|
||||
Taro.redirectTo({
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${type}${type === StageType.RESULT ? `&id=${id}` : ""
|
||||
}`,
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${type}${
|
||||
type === StageType.RESULT ? `&id=${id}` : ""
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.introContainer}>
|
||||
<CommonGuideBar />
|
||||
{ntrpData?.has_ntrp_level ? (
|
||||
{ntrpData?.has_test_record ? (
|
||||
<View className={styles.result}>
|
||||
<View className={styles.avatarWrap}>
|
||||
<View className={styles.avatar}>
|
||||
@@ -234,7 +237,9 @@ function Intro() {
|
||||
</View>
|
||||
<View className={styles.levelWrap}>
|
||||
<Text>NTRP</Text>
|
||||
<Text className={styles.level}>{formatNtrpDisplay(ntrp_level || "")}</Text>
|
||||
<Text className={styles.level}>
|
||||
{formatNtrpDisplay(ntrp_level || "")}
|
||||
</Text>
|
||||
</View>
|
||||
<View className={styles.slogan}>
|
||||
<Text>变线+网前,下一步就是赢比赛!</Text>
|
||||
@@ -495,6 +500,10 @@ function Result() {
|
||||
}
|
||||
|
||||
function handleReTest() {
|
||||
if (!userInfo.phone) {
|
||||
handleAuth();
|
||||
return false;
|
||||
}
|
||||
Taro.redirectTo({
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${StageType.TEST}`,
|
||||
});
|
||||
@@ -507,6 +516,15 @@ function Result() {
|
||||
}
|
||||
|
||||
async function handleGoon() {
|
||||
if (!userInfo?.phone) {
|
||||
Taro.redirectTo({
|
||||
url: `/login_pages/index/index?redirect=${encodeURIComponent(
|
||||
`/main_pages/index`
|
||||
)}`,
|
||||
});
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
if (type) {
|
||||
next({ flag: false, score: result?.ntrp_level as string });
|
||||
await delay(1500);
|
||||
@@ -566,7 +584,8 @@ function Result() {
|
||||
|
||||
async function handleSaveImage() {
|
||||
console.log(userInfo);
|
||||
if (!userInfo?.id) {
|
||||
if (!userInfo?.phone) {
|
||||
handleAuth();
|
||||
return;
|
||||
}
|
||||
Taro.getSetting().then(async (res) => {
|
||||
@@ -615,16 +634,19 @@ function Result() {
|
||||
});
|
||||
|
||||
function handleAuth() {
|
||||
if (userInfo?.id) {
|
||||
if (userInfo?.phone) {
|
||||
return true;
|
||||
}
|
||||
const currentPage = getCurrentFullPath();
|
||||
Taro.redirectTo({
|
||||
url: `/login_pages/index/index${currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ""
|
||||
}`,
|
||||
url: `/login_pages/index/index${
|
||||
currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ""
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
function handleGo() {}
|
||||
|
||||
return (
|
||||
<View className={styles.resultContainer}>
|
||||
<CommonGuideBar />
|
||||
@@ -652,7 +674,9 @@ function Result() {
|
||||
</View>
|
||||
<View className={styles.levelWrap}>
|
||||
<Text>NTRP</Text>
|
||||
<Text className={styles.level}>{formatNtrpDisplay(result?.ntrp_level)}</Text>
|
||||
<Text className={styles.level}>
|
||||
{formatNtrpDisplay(result?.ntrp_level)}
|
||||
</Text>
|
||||
</View>
|
||||
<View className={styles.slogan}>
|
||||
<Text>变线+网前,下一步就是赢比赛!</Text>
|
||||
@@ -666,9 +690,11 @@ function Result() {
|
||||
<Text>重新测试</Text>
|
||||
</View>
|
||||
</View>
|
||||
{userInfo?.id ? (
|
||||
{userInfo?.phone ? (
|
||||
<View className={styles.updateTip}>
|
||||
<Text>你的 NTRP 水平已更新为 {formatNtrpDisplay(result?.ntrp_level || "")} </Text>
|
||||
<Text>
|
||||
你的 NTRP 水平已更新为 {formatNtrpDisplay(result?.ntrp_level || "")}{" "}
|
||||
</Text>
|
||||
<Text className={styles.grayTip}>(可在个人信息中修改)</Text>
|
||||
</View>
|
||||
) : (
|
||||
@@ -679,14 +705,14 @@ function Result() {
|
||||
<View className={styles.actions}>
|
||||
<View className={styles.viewGame} onClick={handleGoon}>
|
||||
<Button className={styles.viewGameBtn}>
|
||||
{sourceTypeToTextMap.get(type) || "去看看球局"}
|
||||
{sourceTypeToTextMap.get(type) || "去看看适合你的球局"}
|
||||
</Button>
|
||||
</View>
|
||||
<View className={styles.otherActions}>
|
||||
<View className={styles.share}>
|
||||
<Button
|
||||
className={styles.shareBtn}
|
||||
openType={userInfo?.id ? "share" : undefined}
|
||||
openType={userInfo?.phone ? "share" : undefined}
|
||||
onClick={handleAuth}
|
||||
></Button>
|
||||
<View className={styles.shareBtnCover}>
|
||||
|
||||
Reference in New Issue
Block a user