修改用户授权调用位置和逻辑

This commit is contained in:
张成
2025-11-18 08:00:38 +08:00
parent 4568e758a7
commit 988f57aa5e
12 changed files with 343 additions and 81 deletions

View File

@@ -7,6 +7,7 @@ import OrderService from "@/services/orderService";
import { EvaluateCallback, EvaluateScene } from "@/store/evaluateStore";
import { MATCH_STATUS, IsSubstituteSupported } from "@/services/detailService";
import { GameManagePopup, NTRPEvaluatePopup } from "@/components";
import { useUserInfo } from "@/store/userStore";
import img from "@/config/images";
import RMB_ICON from "@/static/detail/rmb.svg";
import { toast, navto } from "@/utils/helper";
@@ -76,6 +77,7 @@ export default function StickyButton(props) {
currentUserInfo,
} = props;
const [commentCount, setCommentCount] = useState(0);
const userInfo = useUserInfo();
const ntrpRef = useRef<{
show: (evaluateCallback: EvaluateCallback) => void;
}>({ show: () => {} });
@@ -93,6 +95,36 @@ export default function StickyButton(props) {
const { ntrp_level } = currentUserInfo || {};
// 检查手机号绑定的包装函数
const checkPhoneAndExecute = (action: () => void) => {
return () => {
if (!userInfo?.phone) {
Taro.showModal({
title: '提示',
content: '该功能需要绑定手机号',
confirmText: '去绑定',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
const currentPath = Taro.getCurrentInstance().router?.path || '';
const currentParams = Taro.getCurrentInstance().router?.params || {};
const queryString = Object.keys(currentParams)
.map(key => `${key}=${currentParams[key]}`)
.join('&');
const fullPath = queryString ? `${currentPath}?${queryString}` : currentPath;
Taro.navigateTo({
url: `/login_pages/index/index?redirect=${encodeURIComponent(fullPath)}`,
});
}
}
});
return;
}
action();
};
};
const matchNtrpReq = matchNtrpRequestment(
ntrp_level,
skill_level_min,
@@ -224,14 +256,14 @@ export default function StickyButton(props) {
<Text className={styles.btnText}></Text>
</>
),
action: async () => {
action: checkPhoneAndExecute(async () => {
const res = await OrderService.getUnpaidOrder(id);
if (res.code === 0) {
navto(
`/order_pages/orderDetail/index?id=${res.data.order_info.order_id}`
);
}
},
}),
};
} else if (!matchNtrpReq) {
return {
@@ -255,7 +287,7 @@ export default function StickyButton(props) {
<Text className={styles.btnText}></Text>
</>
),
action: handleJoinGame,
action: checkPhoneAndExecute(handleJoinGame),
};
} else if (can_join) {
return {
@@ -268,7 +300,7 @@ export default function StickyButton(props) {
</>
);
},
action: handleJoinGame,
action: checkPhoneAndExecute(handleJoinGame),
};
} else if (can_assess) {
return {
@@ -279,7 +311,7 @@ export default function StickyButton(props) {
<Text className={styles.btnText}></Text>
</>
),
action: handleSelfEvaluate,
action: checkPhoneAndExecute(handleSelfEvaluate),
};
}
return {