feat: 获取路由参数

This commit is contained in:
hackrobot
2024-03-20 08:50:56 +08:00
parent cf671a6388
commit c1e414bdd8
9 changed files with 48 additions and 11 deletions

View File

@@ -8,6 +8,14 @@ import guangzhou from "@/images/city/guangzhou.jpg";
import shanghai from "@/images/city/shanghai.jpg";
import shenzhen from "@/images/city/shenzhen.jpg";
import touxiang from "@/images/index/touxiang.jpg";
import a1 from "@/images/meetup/a1.jpg";
import a2 from "@/images/meetup/a2.jpg";
import a3 from "@/images/meetup/a3.jpg";
import a4 from "@/images/meetup/a4.png";
import a5 from "@/images/meetup/a5.jpg";
import a6 from "@/images/meetup/a6.jpg";
import TabbarCom from "@/componments/TabbarCom";
import QrCode from "@/componments/QrCode";
@@ -16,13 +24,37 @@ import { useEffect, useState } from "react";
export default function Index() {
// 用户基本信息
const [userInfo, setuserInfo] = useState({});
const [userInfo, setuserInfo] = useState({
wxid: null,
openId: null,
});
const [isOpened, setisOpened] = useState(false);
useLoad(() => {
console.log("Page loaded.");
});
// 获取用户标识符
useEffect(() => {
// 获取路由参数
const params = Taro.getCurrentInstance().router.params;
console.log("params", params);
// const [wxid, openId] = params;
setuserInfo({
wxid: params?.wxid, //个人号wxid
// openId: params?.openId, //小程序openid
});
if (wxid) {
// 本地存储
try {
Taro.setStorage({
wxid: wxid,
openId: openId,
});
} catch (e) {}
}
}, []);
useEffect(() => {
// 更新分享-minipro
Taro.updateShareMenu({
@@ -57,21 +89,20 @@ export default function Index() {
}}
>
<View className="CustomHeader">🥂加入微信群-meetup</View>
{/* <View className="CustomAvatar">
<AtAvatar
className="AtAvatar"
circle
image={touxiang}
size="small"
></AtAvatar>
</View> */}
<View className="CustomAvatar">
{[1, 2, 3, 4, 5, 6, 7].map((item, index) => {
{[
{ imagePath: a1 },
{ imagePath: a2 },
{ imagePath: a3 },
{ imagePath: a4 },
{ imagePath: a5 },
{ imagePath: a6 },
].map((item, index) => {
return (
<AtAvatar
className="AtAvatar"
circle
image={touxiang}
image={item.imagePath}
size="small"
></AtAvatar>
);

View File

@@ -59,6 +59,7 @@
width: 70px;
height: 70px;
margin-right: 5px;
margin-top: 5px;
}
}
}

View File

@@ -21,6 +21,11 @@ import TabbarCom from "@/componments/TabbarCom";
import { useEffect, useState } from "react";
const my = () => {
const [open, setopen] = useState(false);
useEffect(()=>{
// 获取路由参数
const params= Taro.getCurrentInstance().router.params
console.log('params',params)
},[])
const handleClick = (value) => {
setopen(true);