diff --git a/config/index.js b/config/index.js index bdff777..e7fc93b 100644 --- a/config/index.js +++ b/config/index.js @@ -67,9 +67,24 @@ const config = { router: { mode: 'browser', // 或者是 'browser' }, + // defineConstants: { + // HOST: '"/api"' + // }, + // devServer: { + // proxy: { + // '/api/': { + // target: JSON.parse('"http://localhost:8082"'), + // pathRewrite: { + // '^/api/': '/' + // }, + // changeOrigin: true + // } + // } + // } } } + module.exports = function (merge) { if (process.env.NODE_ENV === 'development') { return merge({}, config, require('./dev')) diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index fe5aef1..62ce944 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -38,9 +38,9 @@ const Index = () => { } else { // window.alert('不存在') let nowUrl = window.location.href; - window.alert(nowUrl) + // window.alert(nowUrl) let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`; - window.location.href = payUrl; + // window.location.href = payUrl; } }; @@ -214,7 +214,7 @@ const Index = () => { className="submitBtn" onClick={() => { Taro.navigateTo({ - url: "/pages/meetup/Detail/index?id=20231206&openid='", + url: "/pages/meetup/Detail/index?id=20231206", }); }} > diff --git a/src/pages/meetup/Detail/index.jsx b/src/pages/meetup/Detail/index.jsx index 13f20dd..ef2f3c7 100644 --- a/src/pages/meetup/Detail/index.jsx +++ b/src/pages/meetup/Detail/index.jsx @@ -17,9 +17,17 @@ import { AtList, AtListItem } from "taro-ui"; // export default class Index extends Component { const Detail = () => { const [current, setcurrent] = useState(2); - const [id, setid] = useState(2); - const [openid, setopenid] = useState(2); + const [id, setid] = useState(null); + const [openid, setopenid] = useState(null); + const [joinMeetup, setjoinMeetup] = useState(false); + useEffect(() => { + let newparams = Taro.getCurrentInstance().router.params; + let newId = newparams.id; + if (newId) { + setid(newId); + } + }, []); const handleClick = (value) => { console.log("value", value); @@ -40,11 +48,57 @@ const Detail = () => { } }; + const onBridgeReady = () => { + WeixinJSBridge.call("hideOptionMenu"); + }; + useEffect(() => { - let $instance =Taro. getCurrentInstance() + let $instance = Taro.getCurrentInstance(); // console.log("11"); - console.log($instance.router.params) + console.log($instance.router.params); + // if (typeof WeixinJSBridge == "undefined") { + // if (document.addEventListener) { + // document.addEventListener("WeixinJSBridgeReady", onBridgeReady, false); + // } else if (document.attachEvent) { + // document.attachEvent("WeixinJSBridgeReady", onBridgeReady); + // document.attachEvent("onWeixinJSBridgeReady", onBridgeReady); + // } + // } }, []); + + const joinmeet = () => { + console.log("111"); + Taro.request({ + method:'POST', + url: "/api//payh5", //仅为示例,并非真实的接口地址 + data: {}, + header: { + "content-type": "application/json", // 默认值 + }, + success: function (res) { + console.log(res.data); + window.alert(res.data); + WeixinJSBridge.invoke( + "getBrandWCPayRequest", + { + // 以下6个支付参数通过payjs的jsapi接口获取 + // appId: "wxc5205a653b0259bf", + // timeStamp: "1701401644", + // nonceStr: "KhOYB0wFV6j9qyQK", + // package: "prepay_id=wx01113404850024729b35f4d69b73500000", + // signType: "MD5", + // paySign: "2A823C8D47CCF871C6C65A56DC228CF8", + ...res.data, + }, + function (res) { + if (res.err_msg == "get_brand_wcpay_request:ok") { + WeixinJSBridge.call("closeWindow"); + } + } + ); + }, + }); + }; return ( {/* Hello world! */} @@ -86,7 +140,11 @@ const Detail = () => { */} - + joinmeet()} + > 立即报名