feat: 获取openid
This commit is contained in:
@@ -22,6 +22,32 @@ const Index = () => {
|
||||
const [current, setcurrent] = useState(0);
|
||||
const [isOpened, setisOpened] = useState(false);
|
||||
|
||||
|
||||
// 获取openid
|
||||
const getWxid = () => {
|
||||
let newparams = Taro.getCurrentInstance().router.params;
|
||||
let urlopenid = newparams.openid;
|
||||
// window.alert(urlopenid)
|
||||
let newOpenid = window.localStorage.getItem("openid");
|
||||
// window.alert(newOpenid)
|
||||
|
||||
if (newOpenid || urlopenid) {
|
||||
// window.alert('存在')
|
||||
window.localStorage.setItem("openid", urlopenid);
|
||||
// window.alert(urlopenid);
|
||||
} else {
|
||||
// window.alert('不存在')
|
||||
let nowUrl = window.location.href;
|
||||
window.alert(nowUrl)
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getWxid();
|
||||
}, []);
|
||||
|
||||
const handleClick = (value) => {
|
||||
console.log("value", value);
|
||||
setcurrent(value);
|
||||
@@ -199,7 +225,7 @@ const Index = () => {
|
||||
</View>
|
||||
</AtCard>
|
||||
|
||||
{/* <View className="indexTablebar">
|
||||
<View className="indexTablebar">
|
||||
<AtTabBar
|
||||
tabList={[
|
||||
{ title: "首页", text: "" },
|
||||
@@ -209,7 +235,7 @@ const Index = () => {
|
||||
onClick={(value) => handleClick(value)}
|
||||
current={current}
|
||||
/>
|
||||
</View> */}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user