feat: 扫二维码进入

This commit is contained in:
2025-10-13 14:34:57 +08:00
parent 7dbf512653
commit 099a7a77b8
2 changed files with 28 additions and 12 deletions

View File

@@ -54,13 +54,25 @@ dayjs.locale("zh-cn");
const useSceneRedirect = (defaultPage: string) => {
useLoad((options) => {
if (options.scene) {
const decoded = decodeURIComponent(options.scene);
const params = Object.fromEntries(new URLSearchParams(decoded));
const query = Object.entries(params)
.map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
.join("&");
try {
const decoded = decodeURIComponent(options.scene || "");
const params: Record<string, string> = {};
decoded.split("&").forEach((pair) => {
const [key, value] = pair.split("=");
if (key) params[key] = value ? decodeURIComponent(value) : "";
});
Taro.redirectTo({ url: `/${defaultPage}?${query}` });
// 拼接成 URL query
const query = Object.entries(params)
.map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
.join("&");
Taro.redirectTo({
url: query ? `/${defaultPage}?${query}` : `/${defaultPage}`,
});
} catch (err) {
console.error("scene 解析失败:", err);
}
}
});
};
@@ -324,8 +336,10 @@ const SharePopup = forwardRef(({ id, from, detail, userInfo }, ref) => {
// const posterRef = useRef();
useEffect(() => {
changeMessageType();
}, []);
if (id) {
changeMessageType();
}
}, [id]);
async function changeMessageType() {
try {
@@ -1394,7 +1408,9 @@ function Index() {
useDidShow(async () => {
// await updateLocation();
// await fetchUserInfo();
await fetchDetail();
if (id) {
await fetchDetail();
}
});
const updateLocation = async () => {

View File

@@ -192,7 +192,7 @@ function Intro() {
<View className={styles.tip}>
<Image
className={styles.tipImage}
src="http://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png"
src="https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png"
mode="aspectFit"
/>
</View>
@@ -236,7 +236,7 @@ function Intro() {
<View className={styles.tip}>
<Image
className={styles.tipImage}
src="http://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png"
src="https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png"
mode="aspectFit"
/>
</View>
@@ -244,7 +244,7 @@ function Intro() {
<View className={styles.radar}>
<Image
className={styles.radarImage}
src="http://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/a2e1b639-82a9-4ab8-b767-8605556eafcb.png"
src="https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/a2e1b639-82a9-4ab8-b767-8605556eafcb.png"
mode="aspectFit"
/>
</View>