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

BIN
src/images/meetup/a1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
src/images/meetup/a2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
src/images/meetup/a3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
src/images/meetup/a4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
src/images/meetup/a5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
src/images/meetup/a6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -8,6 +8,14 @@ import guangzhou from "@/images/city/guangzhou.jpg";
import shanghai from "@/images/city/shanghai.jpg"; import shanghai from "@/images/city/shanghai.jpg";
import shenzhen from "@/images/city/shenzhen.jpg"; import shenzhen from "@/images/city/shenzhen.jpg";
import touxiang from "@/images/index/touxiang.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 TabbarCom from "@/componments/TabbarCom";
import QrCode from "@/componments/QrCode"; import QrCode from "@/componments/QrCode";
@@ -16,13 +24,37 @@ import { useEffect, useState } from "react";
export default function Index() { export default function Index() {
// 用户基本信息 // 用户基本信息
const [userInfo, setuserInfo] = useState({}); const [userInfo, setuserInfo] = useState({
wxid: null,
openId: null,
});
const [isOpened, setisOpened] = useState(false); const [isOpened, setisOpened] = useState(false);
useLoad(() => { useLoad(() => {
console.log("Page loaded."); 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(() => { useEffect(() => {
// 更新分享-minipro // 更新分享-minipro
Taro.updateShareMenu({ Taro.updateShareMenu({
@@ -57,21 +89,20 @@ export default function Index() {
}} }}
> >
<View className="CustomHeader">🥂加入微信群-meetup</View> <View className="CustomHeader">🥂加入微信群-meetup</View>
{/* <View className="CustomAvatar">
<AtAvatar
className="AtAvatar"
circle
image={touxiang}
size="small"
></AtAvatar>
</View> */}
<View className="CustomAvatar"> <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 ( return (
<AtAvatar <AtAvatar
className="AtAvatar" className="AtAvatar"
circle circle
image={touxiang} image={item.imagePath}
size="small" size="small"
></AtAvatar> ></AtAvatar>
); );

View File

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

View File

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