diff --git a/package.json b/package.json
index c428b36..f137ef9 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"@tarojs/runtime": "3.6.20",
"@tarojs/shared": "3.6.20",
"@tarojs/taro": "3.6.20",
+ "marked": "^12.0.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"sr-sdk-h5": "^1.3.1",
diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx
index ae95a6f..66b439b 100644
--- a/src/pages/index/index.jsx
+++ b/src/pages/index/index.jsx
@@ -18,251 +18,62 @@ import { AtToast } from "taro-ui";
import { AtIcon } from "taro-ui";
import see from "../../images/see.png";
import group from "../../images/group.png";
+import { marked } from "marked";
+marked.setOptions({
+ breaks: true, // 是否回车换行
+ highlight(code, lang) {
+ // 语法高亮
+ let val = code;
+ if (lang) {
+ val = hljs.highlight(lang, code).value;
+ } else {
+ val = hljs.highlightAuto(code).value;
+ }
+ return val;
+ },
+});
+const renderer = new marked.Renderer();
+// 图片调整300px
+renderer.image = function (href, title, text) {
+ console.log("href, title, text", href, title, text);
+ return `
+
(.*?)<\/p>/;
+ var str = quote;
+ var match = regex.exec(str);
+ if (match != null) {
+ var content = match[1]; // 获取第一个捕获组的内容
+ console.log(content);
+ }
+ return `❣️${content}`;
+};
+
+marked.use({ renderer });
+const markTextStr = marked(
+ ` \n
+ > 测试`
+);
// export default class Index extends Component {
const Index = () => {
- const [current, setcurrent] = useState(0);
- const [openId, setopenId] = useState(null);
- const [h5openid, seth5openid] = useState(null);
-
- const [wxid, setwxid] = useState(null);
-
- const [isOpened, setisOpened] = useState(false);
- const [joinMeetup, setjoinMeetup] = useState(false);
-
- const [id, setid] = useState(null);
- const [userInfo, setuserInfo] = useState({
- wxid: null,
- openId: null,
- h5openid: null,
- bighead: null,
- city: null,
- country: null,
- generator: null,
- id: null,
- labels: null,
- nickname: null,
- province: null,
- remark: null,
- sex: null, //男
- smallhead: null,
- source: null,
- sourceStr: null,
- usertype: null,
- v1: null,
- wxaccount: null,
- });
-
-
-
-
+ const [markText, setmarkText] = useState(null);
const onBridgeReady = () => {
WeixinJSBridge.call("hideOptionMenu");
};
- useEffect(()=>{
- // window.alert('1111')
- getopenId()
- },[])
-
- const h5openidUser = () => {
- try {
- const params = Taro.getCurrentInstance().router.params;
- let hashopenid = window.localStorage.getItem("h5openid");
- let localwxid = window.localStorage.getItem("wxid");
- //发起网络请求
- Taro.request({
- // url: "/api/addH5openid",
- url: "https://kunpeng.hackrobot.cn/addH5openid",
- data: {
- h5openid: hashopenid ?? null,
- wxid: localwxid ?? null, //debug eric 的wxid
- },
- success: function (resUser) {
- console.log(resUser);
- console.log(resUser.data);
- setuserInfo({ ...resUser.data });
- },
- });
- } catch (e) {
- } finally {
- }
- };
-
useEffect(() => {
- let $instance = Taro.getCurrentInstance();
- console.log($instance.router.params);
+ // console.log("markTextStr=>", markTextStr);
+ // setmarkText(markTextStr);
}, []);
- // 获取openid
- const getopenId = () => {
- let hashopenid = null;
- if (window.location.href.includes("openid")) {
- hashopenid = window.location.href
- .split("#")[0]
- .split("?")[1]
- .split("=")[1];
- } else {
- hashopenid = window.localStorage.getItem("h5openid");
- }
- if (!!hashopenid && hashopenid != "undefined" && hashopenid != "null") {
- window.localStorage.setItem("h5openid", hashopenid);
- let localwxid = window.localStorage.getItem("wxid");
- seth5openid(hashopenid);
- // 查询用户信息
- h5openidUser();
- } else {
- // 获取路由参数
- const params = Taro.getCurrentInstance().router.params;
- console.log("params", params);
-
- if (params?.wxid) {
- // 本地存储
- window.localStorage.setItem("wxid", params?.wxid ?? "");
- setwxid(params?.wxid);
- let nowUrl = window.location.href;
- let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
- window.location.href = payUrl;
- }else{
- }
-
-
- }
- };
-
-
- const joinmeet = () => {
- Taro.request({
- method: "POST",
- url: "/api/payh5", //仅为示例,并非真实的接口地址
- // url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址
-
- data: {
- callback_url: window.location.href,
- openid: window.localStorage.getItem("openid"),
- },
- header: {
- "content-type": "application/json", // 默认值
- },
- success: function (res) {
- console.log(res.data);
- WeixinJSBridge.invoke(
- "getBrandWCPayRequest",
- {
- // 以下6个支付参数通过payjs的jsapi接口获取
- // appId: "wxc5205a653b0259bf",
- // timeStamp: "1701401644",
- // nonceStr: "KhOYB0wFV6j9qyQK",
- // package: "prepay_id=wx01113404850024729b35f4d69b73500000",
- // signType: "MD5",
- // paySign: "2A823C8D47CCF871C6C65A56DC228CF8",
- ...(res?.data?.jsapi ?? {}),
- },
- function (res) {
- //发起网络请求
-
- // 付款成功
- if (res.err_msg == "get_brand_wcpay_request:ok") {
- // 邀请加入微信群
- joinWechat();
- WeixinJSBridge.call("closeWindow");
- }
- }
- );
- },
- });
- };
-
- // 通过wxid加群微信群
- const joinWechat = () => {
- Taro.request({
- url: "/api/joinwechat",
- // url: "https://kunpeng.hackrobot.cn/joingroup",
- data: {
- // wxid: "wxid_haqoszjheyuz22",
- wxid: wxid ?? null, //debug eric 的wxid
- },
- method: "POST",
- header: {
- "content-type": "application/json", // 默认值
- },
- success: function (resUser) {
- console.log("resUser--", resUser);
- console.log("加入微信群成功");
- if (resUser?.data?.success == "fail") {
- //已经在群聊中
- handleClick("已经在群聊中", "warning");
- setbtntext("已经在群聊中");
- } else if (resUser?.data?.success == "ok") {
- // 发送群聊邀请
- handleClick("已发送群聊邀请", "warning");
- setbtntext("已发送群聊邀请");
- }
- setdisabled(true);
- },
- });
- };
-
return (
-
-
- 本群是交流平台,请不要发送广告以及敏感内容
-
- 仅聊天,不承诺其他服务和支持
-