feat: 获取openid
This commit is contained in:
@@ -63,7 +63,10 @@ const config = {
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
router: {
|
||||
mode: 'browser', // 或者是 'browser'
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
src/images/avatar.jpg
Normal file
BIN
src/images/avatar.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ const Meetup = () => {
|
||||
</View>
|
||||
</AtCard>
|
||||
|
||||
{/* <View className="indexTablebar">
|
||||
<View className="indexTablebar">
|
||||
<AtTabBar
|
||||
tabList={[
|
||||
{ title: "首页", text: "" },
|
||||
@@ -137,7 +137,7 @@ const Meetup = () => {
|
||||
onClick={(value) => handleClick(value)}
|
||||
current={current}
|
||||
/>
|
||||
</View> */}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,12 +9,26 @@ import { AtCard } from "taro-ui";
|
||||
import { AtImagePicker } from "taro-ui";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { AtAvatar } from "taro-ui";
|
||||
|
||||
import { AtTag } from "taro-ui";
|
||||
import { AtList, AtListItem } from "taro-ui";
|
||||
import avatar from "../../images/avatar.jpg";
|
||||
|
||||
// export default class Index extends Component {
|
||||
const My = () => {
|
||||
const [current, setcurrent] = useState(2);
|
||||
const [wxid, setwxid] = useState(null);
|
||||
|
||||
useEffect(()=>{
|
||||
getWxid()
|
||||
},[])
|
||||
|
||||
const getWxid = () => {
|
||||
let newWxid = window.localStorage.getItem("wxid");
|
||||
if (!!newWxid) {
|
||||
setwxid(newWxid);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClick = (value) => {
|
||||
console.log("value", value);
|
||||
setcurrent(value);
|
||||
@@ -36,7 +50,13 @@ const My = () => {
|
||||
return (
|
||||
<View className="my">
|
||||
{/* <Text>Hello world!</Text> */}
|
||||
{/* <AtAvatar image='https://cdn.huodongxing.com/logo/202312/8732019012100/promoteMini.png'></AtAvatar> */}
|
||||
|
||||
<View className="myAtAvatar">
|
||||
<AtAvatar className="AtAvatar" image={avatar}></AtAvatar>
|
||||
<AtTag type="primary" circle>
|
||||
新注册用户
|
||||
</AtTag>
|
||||
</View>
|
||||
|
||||
<AtList>
|
||||
<AtListItem
|
||||
@@ -54,7 +74,7 @@ const My = () => {
|
||||
/>
|
||||
</AtList>
|
||||
|
||||
{/* <View className="indexTablebar">
|
||||
<View className="indexTablebar">
|
||||
<AtTabBar
|
||||
tabList={[
|
||||
{ title: "首页", text: "" },
|
||||
@@ -64,7 +84,7 @@ const My = () => {
|
||||
onClick={(value) => handleClick(value)}
|
||||
current={current}
|
||||
/>
|
||||
</View> */}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
.my{
|
||||
|
||||
|
||||
.myAtAvatar{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
// background-color: #f4ffb8;
|
||||
// padding-left: 20px;
|
||||
// padding-right: 20px;
|
||||
.AtAvatar{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.indexTablebar {
|
||||
position: fixed;
|
||||
|
||||
Reference in New Issue
Block a user