feat: 扫二维码进入
This commit is contained in:
@@ -54,13 +54,25 @@ dayjs.locale("zh-cn");
|
|||||||
const useSceneRedirect = (defaultPage: string) => {
|
const useSceneRedirect = (defaultPage: string) => {
|
||||||
useLoad((options) => {
|
useLoad((options) => {
|
||||||
if (options.scene) {
|
if (options.scene) {
|
||||||
const decoded = decodeURIComponent(options.scene);
|
try {
|
||||||
const params = Object.fromEntries(new URLSearchParams(decoded));
|
const decoded = decodeURIComponent(options.scene || "");
|
||||||
const query = Object.entries(params)
|
const params: Record<string, string> = {};
|
||||||
.map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
|
decoded.split("&").forEach((pair) => {
|
||||||
.join("&");
|
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();
|
// const posterRef = useRef();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changeMessageType();
|
if (id) {
|
||||||
}, []);
|
changeMessageType();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
async function changeMessageType() {
|
async function changeMessageType() {
|
||||||
try {
|
try {
|
||||||
@@ -1394,7 +1408,9 @@ function Index() {
|
|||||||
useDidShow(async () => {
|
useDidShow(async () => {
|
||||||
// await updateLocation();
|
// await updateLocation();
|
||||||
// await fetchUserInfo();
|
// await fetchUserInfo();
|
||||||
await fetchDetail();
|
if (id) {
|
||||||
|
await fetchDetail();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateLocation = async () => {
|
const updateLocation = async () => {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ function Intro() {
|
|||||||
<View className={styles.tip}>
|
<View className={styles.tip}>
|
||||||
<Image
|
<Image
|
||||||
className={styles.tipImage}
|
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"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -236,7 +236,7 @@ function Intro() {
|
|||||||
<View className={styles.tip}>
|
<View className={styles.tip}>
|
||||||
<Image
|
<Image
|
||||||
className={styles.tipImage}
|
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"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -244,7 +244,7 @@ function Intro() {
|
|||||||
<View className={styles.radar}>
|
<View className={styles.radar}>
|
||||||
<Image
|
<Image
|
||||||
className={styles.radarImage}
|
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"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user