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