个人中心关注-关注或者取消关注未更新状态

This commit is contained in:
caishi 2021-04-23 11:49:56 +08:00
parent 3243aeebc6
commit 63da7adcf9
1 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import "./list.css";
function FocusButton({is_watch , fontClass, starText, is_block , id , successFunc}){
const [ isSpin , setIsSpin ] = useState(false);
const [ watchFlag , setWatchFlag ] = useState(is_watch);
// 关注和取消关注
function focusFunc(flag){
setIsSpin(true);
@ -18,6 +19,7 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
}).then((result) => {
if (result && result.data.status === 0) {
successFunc && successFunc();
setWatchFlag(!watchFlag);
}
setIsSpin(false);
})
@ -25,8 +27,8 @@ function FocusButton({is_watch , fontClass, starText, is_block , id , successFun
};
return (
<Button type={is_watch ? "default" : "primary"} ghost={!is_watch} block={is_block} loading={isSpin} onClick={() => focusFunc(is_watch)}>
{is_watch ? (
<Button type={watchFlag ? "default" : "primary"} ghost={!watchFlag} block={is_block} loading={isSpin} onClick={() => focusFunc(watchFlag)}>
{watchFlag ? (
<span className="">
<i className="iconfont icon-shixing font-15 text-yellow mr-4"></i>
<span className={fontClass || "font-12"}>已关注</span>