feat:微信群加入按钮/提示

This commit is contained in:
hackrobot
2024-04-07 22:00:57 +08:00
parent d2c4fb676c
commit f14fcdc0af

View File

@@ -13,6 +13,8 @@ import {
AtSteps,
AtForm,
AtInput,
AtToast,
AtMessage,
} from "taro-ui";
import "./index.scss";
import beijing from "@/images/city/beijing.jpg";
@@ -22,14 +24,17 @@ import shenzhen from "@/images/city/shenzhen.jpg";
import touxiang from "@/images/index/touxiang.jpg";
import TabbarCom from "@/componments/TabbarCom";
import { useEffect, useState } from "react";
import { set } from "lodash";
const KeywordJoin = () => {
const [current, setcurrent] = useState(0);
const [value, setvalue] = useState(null);
const [localuserInfo, setlocaluserInfo] = useState(Taro.getStorageSync("userInfo"));
const [disabled, setdisabled] = useState(false);
const [btntext, setbtntext] = useState('立即加入');
const [localuserInfo, setlocaluserInfo] = useState(
Taro.getStorageSync("userInfo")
);
// 获取用户标识符
useEffect(() => {
@@ -51,8 +56,6 @@ const KeywordJoin = () => {
}
}, []);
// useEffect(() => {
// // 更新分享-minipro
// Taro.updateShareMenu({
@@ -68,6 +71,13 @@ const KeywordJoin = () => {
// }, []);
const handleClick = (text, type) => {
Taro.atMessage({
message: text,
type: type,
});
};
return (
<View className="KeywordJoin">
{/* 步骤栏 */}
@@ -128,8 +138,12 @@ const KeywordJoin = () => {
</View>
</View>
</View>
<View className="tabbbarDiv"></View>
<AtButton type="primary" className="jsonWechatBtn" onClick={()=>{
<AtMessage />
<AtButton
type="primary"
className="jsonWechatBtn"
disabled={disabled}
onClick={() => {
// 通过hook加入微信群邀请
//发起网络请求
Taro.request({
@@ -139,12 +153,25 @@ const KeywordJoin = () => {
wxid: localuserInfo?.wxid ?? null, //debug eric 的wxid
},
success: function (resUser) {
console.log('resUser--',resUser)
console.log('加入微信群成功');
console.log("resUser--", resUser);
console.log("加入微信群成功");
if (resUser?.data?.success == "fail") {
//已经在群聊中
handleClick("已经在群聊中", "warning");
setbtntext("已经在群聊中")
} else if (resUser?.data?.success == "ok") {
// 发送群聊邀请
handleClick("已发送群聊邀请", "warning");
setbtntext("已发送群聊邀请")
}
setdisabled(true);
},
});
}}>
点击加入
}}
>
{btntext}
</AtButton>
</View>
);