dffe
This commit is contained in:
@@ -53,43 +53,43 @@ const Index = () => {
|
||||
wxaccount: null,
|
||||
});
|
||||
|
||||
// // 获取用户标识符
|
||||
// useEffect(() => {
|
||||
// // 获取路由参数
|
||||
// const params = Taro.getCurrentInstance().router.params;
|
||||
// console.log("params", params);
|
||||
// let localwxid = window.localStorage.getItem("wxid");
|
||||
// let localh5openid = window.localStorage.getItem("h5openid");
|
||||
|
||||
// 获取用户标识符
|
||||
useEffect(() => {
|
||||
// 获取路由参数
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
console.log("params", params);
|
||||
let localwxid = window.localStorage.getItem("wxid");
|
||||
let localh5openid = window.localStorage.getItem("h5openid");
|
||||
|
||||
if (params?.wxid || localwxid) {
|
||||
// 本地存储
|
||||
window.localStorage.setItem("wxid", params?.wxid ?? "");
|
||||
// alert(params?.wxid);
|
||||
setwxid(params?.wxid);
|
||||
if (
|
||||
!localh5openid ||
|
||||
localh5openid == "undefined" ||
|
||||
localh5openid == "null"
|
||||
) {
|
||||
getopenId();
|
||||
} else {
|
||||
h5openidUser();
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
// if (
|
||||
// params?.wxid &&
|
||||
// (!localh5openid ||
|
||||
// localh5openid == "undefined" ||
|
||||
// localh5openid == "null")
|
||||
// ) {
|
||||
// // 本地存储
|
||||
// window.localStorage.setItem("wxid", params?.wxid ?? "");
|
||||
// // alert(params?.wxid);
|
||||
// setwxid(params?.wxid);
|
||||
// getopenId();
|
||||
// }
|
||||
// }, []);
|
||||
|
||||
const onBridgeReady = () => {
|
||||
WeixinJSBridge.call("hideOptionMenu");
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
getopenId()
|
||||
},[])
|
||||
|
||||
const h5openidUser = () => {
|
||||
try {
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
let hashopenid = window.localStorage.getItem("h5openid");
|
||||
let localwxid = window.localStorage.getItem("wxid");
|
||||
alert ("hashopenid",hashopenid)
|
||||
alert ("localwxid",localwxid)
|
||||
alert("hashopenid", hashopenid);
|
||||
alert("localwxid", localwxid);
|
||||
|
||||
//发起网络请求
|
||||
Taro.request({
|
||||
@@ -136,10 +136,24 @@ const Index = () => {
|
||||
// 查询用户信息
|
||||
h5openidUser();
|
||||
} else {
|
||||
let nowUrl = window.location.href;
|
||||
// alert(nowUrl);
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
// 获取路由参数
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
console.log("params", params);
|
||||
|
||||
if (params?.wxid) {
|
||||
// 本地存储
|
||||
window.localStorage.setItem("wxid", params?.wxid ?? "");
|
||||
// alert(params?.wxid);
|
||||
setwxid(params?.wxid);
|
||||
let nowUrl = window.location.href;
|
||||
// alert(nowUrl);
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
}else{
|
||||
alert('没有wxid')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user