增加发布仅上海地区可发布、发布防抖
This commit is contained in:
@@ -7,6 +7,8 @@ import {
|
||||
EvaluateCallback,
|
||||
EvaluateScene,
|
||||
} from "@/store/evaluateStore";
|
||||
import { useListState } from "@/store/listStore";
|
||||
|
||||
import { navigateTo, redirectTo, navigateBack } from "@/utils/navigation";
|
||||
import { requireLoginWithPhone } from "@/utils/helper";
|
||||
import styles from "./index.module.scss";
|
||||
@@ -24,6 +26,11 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
|
||||
const { onVisibleChange } = props;
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
|
||||
const {
|
||||
area
|
||||
} = useListState();
|
||||
|
||||
|
||||
// 使用 useEffect 监听 isVisible 变化,确保所有情况都能触发回调
|
||||
useEffect(() => {
|
||||
onVisibleChange?.(isVisible);
|
||||
@@ -59,6 +66,16 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
|
||||
});
|
||||
};
|
||||
const handleMenuItemClick = (type: "individual" | "group" | "ai") => {
|
||||
const [_, address] = area;
|
||||
if (address !== '上海') {
|
||||
(Taro as any).showModal({
|
||||
title: '提示',
|
||||
content: '仅上海地区开放,您可加入社群或切换城市',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (!userInfo.ntrp_level) {
|
||||
ntrpRef.current.show({
|
||||
type: EvaluateScene.publish,
|
||||
|
||||
@@ -106,8 +106,15 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
||||
})
|
||||
setShowDetail(true)
|
||||
},
|
||||
fail: (err) => {
|
||||
fail: (err: { errMsg: string }) => {
|
||||
console.error('选择位置失败:', err)
|
||||
const { errMsg } = err || {};
|
||||
if (!errMsg.includes('fail cancel')) {
|
||||
Taro.showToast({
|
||||
title: errMsg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -145,12 +145,15 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
||||
istance: null
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
fail: (err: { errMsg: string }) => {
|
||||
console.error('选择位置失败:', err)
|
||||
const { errMsg } = err || {};
|
||||
if (!errMsg.includes('fail cancel')) {
|
||||
Taro.showToast({
|
||||
title: '位置选择失败',
|
||||
icon: 'error'
|
||||
})
|
||||
title: errMsg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ const PublishBall: React.FC = () => {
|
||||
defaultFormData,
|
||||
]);
|
||||
const [checked, setChecked] = useState(true);
|
||||
const [publishLoading, setPublishLoading] = useState(false);
|
||||
const [titleBar, setTitleBar] = useState("发布球局");
|
||||
// 控制是否响应全局键盘(由具体输入框 focus/blur 控制)
|
||||
const [shouldReactToKeyboard, setShouldReactToKeyboard] = useState(false);
|
||||
@@ -372,9 +373,10 @@ const PublishBall: React.FC = () => {
|
||||
const { republish } = params || {};
|
||||
if (activityType === "individual") {
|
||||
const isValid = validateFormData(formData[0]);
|
||||
if (!isValid) {
|
||||
if (!isValid || publishLoading) {
|
||||
return;
|
||||
}
|
||||
setPublishLoading(true);
|
||||
const {
|
||||
activityInfo,
|
||||
descriptionInfo,
|
||||
@@ -435,13 +437,15 @@ const PublishBall: React.FC = () => {
|
||||
title: res.message,
|
||||
icon: "none",
|
||||
});
|
||||
setPublishLoading(false);
|
||||
}
|
||||
}
|
||||
if (activityType === "group") {
|
||||
const isValid = formData.every((item) => validateFormData(item));
|
||||
if (!isValid) {
|
||||
if (!isValid || publishLoading) {
|
||||
return;
|
||||
}
|
||||
setPublishLoading(true);
|
||||
if (checkAdjacentDataSame(formData)) {
|
||||
Taro.showToast({
|
||||
title: "信息不可与前序场完全一致",
|
||||
@@ -505,6 +509,7 @@ const PublishBall: React.FC = () => {
|
||||
title: res.message,
|
||||
icon: "none",
|
||||
});
|
||||
setPublishLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user