's'
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Component } from "react";
|
import { Component } from "react";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro ,{useRouter}from "@tarojs/taro";
|
||||||
import { View, Text, Image, Button } from "@tarojs/components";
|
import { View, Text, Image, Button } from "@tarojs/components";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import { AtTabBar } from "taro-ui";
|
import { AtTabBar } from "taro-ui";
|
||||||
@@ -101,6 +101,8 @@ const Index = () => {
|
|||||||
const [headers, setHeaders] = useState([]); // 存储所有 <h1> 的内容
|
const [headers, setHeaders] = useState([]); // 存储所有 <h1> 的内容
|
||||||
const contentRef = useRef(null); // 用于获取渲染后的 DOM
|
const contentRef = useRef(null); // 用于获取渲染后的 DOM
|
||||||
|
|
||||||
|
const router = useRouter(); // Taro 3+ 获取路由参数
|
||||||
|
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
breaks: true, // 是否回车换行
|
breaks: true, // 是否回车换行
|
||||||
gfm: true, //使用经批准的 GitHub Flavored Markdown (GFM) 规范
|
gfm: true, //使用经批准的 GitHub Flavored Markdown (GFM) 规范
|
||||||
@@ -430,7 +432,7 @@ const Index = () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('清空存储失败:', error);
|
console.error('清空存储失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '清空失败',
|
title: '清空存储失败',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -441,8 +443,11 @@ const Index = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 判断是否在微信
|
// 判断是否在微信
|
||||||
isWeChatFun()
|
isWeChatFun()
|
||||||
// 测试用=>清除缓存
|
// 方法1:Taro 3+ 推荐方式(支持小程序 + H5)
|
||||||
// clearAllStorage()
|
if (router && router.params && router.params.type === 'clean') {
|
||||||
|
clearAllStorage();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
getOrCreateUserId(); // 确保 userId 存在
|
getOrCreateUserId(); // 确保 userId 存在
|
||||||
@@ -560,17 +565,17 @@ const Index = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 生成或获取 userId(修改为无下划线)
|
// 生成或获取 userId(修改为无下划线)
|
||||||
const getOrCreateUserId = () => {
|
const getOrCreateUserId = () => {
|
||||||
let userId = Taro.getStorageSync("userId");
|
let userId = Taro.getStorageSync("userId");
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
// 修改这里:去掉下划线
|
// 修改这里:去掉下划线
|
||||||
userId = `user${Date.now()}`; // 示例:user1766043770158
|
userId = `user${Date.now()}`; // 示例:user1766043770158
|
||||||
Taro.setStorageSync("userId", userId);
|
Taro.setStorageSync("userId", userId);
|
||||||
console.log('新生成 userId:', userId);
|
console.log('新生成 userId:', userId);
|
||||||
}
|
}
|
||||||
return userId;
|
return userId;
|
||||||
};
|
};
|
||||||
|
|
||||||
const payh5 = (type, total_fee = 1000) => {
|
const payh5 = (type, total_fee = 1000) => {
|
||||||
const userId = getOrCreateUserId(); // ← 新增:获取 userId
|
const userId = getOrCreateUserId(); // ← 新增:获取 userId
|
||||||
|
|||||||
Reference in New Issue
Block a user