From c91df58c3ad4137a0b992f6707a5eafb9ad8077a Mon Sep 17 00:00:00 2001 From: hackrobot Date: Sun, 24 Mar 2024 23:16:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=8E=B7=E5=8F=96openid=E4=B8=8E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.jsx | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index aac7d7d..341daa9 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -39,6 +39,22 @@ export default function Index() { const [userInfo, setuserInfo] = useState({ wxid: null, openId: null, + bighead: null, + city: null, + country: null, + generator: null, + id: null, + labels: null, + nickname: null, + province: null, + remark: null, + sex: null, //男 + smallhead: null, + source: null, + sourceStr: null, + usertype: null, + v1: null, + wxaccount: null, }); const [isOpened, setisOpened] = useState(false); @@ -46,6 +62,28 @@ export default function Index() { console.log("Page loaded."); }); + useEffect(() => { + Taro.login({ + success: function (res) { + if (res.code) { + //发起网络请求 + Taro.request({ + url: "http://127.0.0.1:28369/login", + data: { + code: res.code, + wxid: userInfo?.wxid ?? "wxid_4413224132412", + }, + success: function (resUser) { + console.log(resUser.data); + }, + }); + } else { + console.log("登录失败!" + res.errMsg); + } + }, + }); + }, []); + // 获取用户标识符 useEffect(() => { // 获取路由参数