diff --git a/src/pages/index/componments/KeywordJoin/index.jsx b/src/pages/index/componments/KeywordJoin/index.jsx index 54a570f..3e0210a 100644 --- a/src/pages/index/componments/KeywordJoin/index.jsx +++ b/src/pages/index/componments/KeywordJoin/index.jsx @@ -13,6 +13,8 @@ import { AtSteps, AtForm, AtInput, + AtToast, + AtMessage, } from "taro-ui"; import "./index.scss"; import beijing from "@/images/city/beijing.jpg"; @@ -22,36 +24,37 @@ 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(() => { + // 获取路由参数 + const params = Taro.getCurrentInstance().router.params; + console.log("params", params); + // const [wxid, openId] = params; - // 获取用户标识符 - useEffect(() => { - // 获取路由参数 - const params = Taro.getCurrentInstance().router.params; - console.log("params", params); - // const [wxid, openId] = params; - - if (params.wxid) { - setuserInfo({ - wxid: params?.wxid, //个人号wxid - // openId: params?.openId, //小程序openid - }); - // 本地存储 - - try { - Taro.setStorageSync("wxid", params?.wxid ?? ""); - } catch (e) {} - } - }, []); - + if (params.wxid) { + setuserInfo({ + wxid: params?.wxid, //个人号wxid + // openId: params?.openId, //小程序openid + }); + // 本地存储 + try { + Taro.setStorageSync("wxid", params?.wxid ?? ""); + } catch (e) {} + } + }, []); // useEffect(() => { // // 更新分享-minipro @@ -68,6 +71,13 @@ const KeywordJoin = () => { // }, []); + const handleClick = (text, type) => { + Taro.atMessage({ + message: text, + type: type, + }); + }; + return ( {/* 步骤栏 */} @@ -128,23 +138,40 @@ const KeywordJoin = () => { - - { - // 通过hook加入微信群邀请 - //发起网络请求 - Taro.request({ - // url: "http://127.0.0.1:28369/joingroup", - url: "https://kunpeng.hackrobot.cn/joingroup", - data: { - wxid: localuserInfo?.wxid ?? null, //debug eric 的wxid - }, - success: function (resUser) { - console.log('resUser--',resUser) - console.log('加入微信群成功'); - }, - }); - }}> - 点击加入 + + { + // 通过hook加入微信群邀请 + //发起网络请求 + Taro.request({ + // url: "http://127.0.0.1:28369/joingroup", + url: "https://kunpeng.hackrobot.cn/joingroup", + data: { + wxid: localuserInfo?.wxid ?? null, //debug eric 的wxid + }, + success: function (resUser) { + 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} );