update
This commit is contained in:
@@ -37,6 +37,7 @@ const Index = () => {
|
|||||||
const [current, setcurrent] = useState(0);
|
const [current, setcurrent] = useState(0);
|
||||||
const [openId, setopenId] = useState(null);
|
const [openId, setopenId] = useState(null);
|
||||||
const [wxid, setwxid] = useState(null);
|
const [wxid, setwxid] = useState(null);
|
||||||
|
const [userInfo, setuserInfo] = useState(null);
|
||||||
|
|
||||||
const [open, setopen] = useState(false);
|
const [open, setopen] = useState(false);
|
||||||
const [referer, setreferer] = useState(window.document.referrer);
|
const [referer, setreferer] = useState(window.document.referrer);
|
||||||
@@ -70,6 +71,31 @@ const Index = () => {
|
|||||||
// 获取到openid
|
// 获取到openid
|
||||||
window.localStorage.setItem("openid", hashopenid);
|
window.localStorage.setItem("openid", hashopenid);
|
||||||
setopenId(hashopenid);
|
setopenId(hashopenid);
|
||||||
|
// 查询数据库是否存在openid
|
||||||
|
Taro.request({
|
||||||
|
method: "GET",
|
||||||
|
// url: `/api/add?openid=${hashopenid}`, //仅为示例,并非真实的接口地址
|
||||||
|
url: `/api/user/${window.localStorage.getItem("openid")}`, //仅为示例,并非真实的接口地址
|
||||||
|
success: function (res) {
|
||||||
|
if (res?.data?.userInfo) {
|
||||||
|
//判断wxid是否存在
|
||||||
|
if (res?.data?.userInfo?.wxid) {
|
||||||
|
// 有完整的用户信息userInfo
|
||||||
|
setuserInfo(res?.data?.userInfo);
|
||||||
|
window.localStorage.setItem("userInfo", userInfo);
|
||||||
|
} else {
|
||||||
|
//不完整的openid用户信息
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 新增openid用户
|
||||||
|
// addopenidUser()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function (finy) {
|
||||||
|
// tg消息通知
|
||||||
|
tgMessage();
|
||||||
|
},
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
let nowUrl = window.location.href;
|
let nowUrl = window.location.href;
|
||||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||||
@@ -81,34 +107,94 @@ const Index = () => {
|
|||||||
const getWxidFromUrl = () => {
|
const getWxidFromUrl = () => {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const urlwxid = urlParams.get("wxid");
|
const urlwxid = urlParams.get("wxid");
|
||||||
if (!!urlwxid){
|
if (!!urlwxid) {
|
||||||
setwxid(urlwxid);
|
setwxid(urlwxid);
|
||||||
// 绑定wxid与openid到数据库
|
window.localStorage.setItem("wxid", wxid);
|
||||||
|
|
||||||
// 优先查询openid是否存在数据库
|
// 优先查询openid是否存在数据库
|
||||||
Taro.request({
|
Taro.request({
|
||||||
method:'GET',
|
method: "GET",
|
||||||
url: `/api/user/${openId}`, //仅为示例,并非真实的接口地址
|
url: `/api/user/${urlwxid}`, //仅为示例,并非真实的接口地址
|
||||||
// url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址
|
// url: `/api/user/${window.localStorage.getItem("openid")}`, //仅为示例,并非真实的接口地址
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
window.alert(res)
|
if (res?.data?.userInfo) {
|
||||||
|
//判断wxid是否存在
|
||||||
|
if (res?.data?.userInfo?.openid) {
|
||||||
|
// 有完整的用户信息userInfo
|
||||||
|
setuserInfo(res?.data?.userInfo);
|
||||||
|
window.localStorage.setItem("userInfo", userInfo);
|
||||||
|
} else {
|
||||||
|
// 绑定wxid与openid到数据库
|
||||||
|
wxidTapopenid(urlwxid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 新增wxid用户
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function (finy) {
|
||||||
|
// tg消息通知
|
||||||
|
tgMessage();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// tg消息通知
|
||||||
|
tgMessage();
|
||||||
}
|
}
|
||||||
return wxid;
|
return wxid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 绑定wxid与openid
|
||||||
|
const wxidTapopenid = (newWxid) => {
|
||||||
|
const userUpdateData = {
|
||||||
|
openid: window.localStorage.getItem("openid"), // 只更新 openid 字段
|
||||||
|
};
|
||||||
|
Taro.request({
|
||||||
|
method: "PUT",
|
||||||
|
// url: `/api/user/${urlwxid}`, //仅为示例,并非真实的接口地址
|
||||||
|
url: `/api/user/${newWxid}`, //仅为示例,并非真实的接口地址
|
||||||
|
data: userUpdateData,
|
||||||
|
header: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
success: function (res) {},
|
||||||
|
fail: function (err) {},
|
||||||
|
complete: function (finy) {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 新增openid用户
|
||||||
|
const addopenidUser = () => {
|
||||||
|
const userUpdateData = {
|
||||||
|
openid: window.localStorage.getItem("openid"), // 只更新 openid 字段
|
||||||
|
};
|
||||||
|
Taro.request({
|
||||||
|
method: "GET",
|
||||||
|
// url: `/api/user/${urlwxid}`, //仅为示例,并非真实的接口地址
|
||||||
|
url: `/api/user/${window.localStorage.getItem("openid")}`, //仅为示例,并非真实的接口地址
|
||||||
|
data: userUpdateData,
|
||||||
|
header: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
success: function (res) {},
|
||||||
|
fail: function (err) {},
|
||||||
|
complete: function (finy) {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 网页查看通知
|
// 网页查看通知
|
||||||
const tgMessage = () => {
|
const tgMessage = () => {
|
||||||
Taro.request({
|
Taro.request({
|
||||||
method:'GET',
|
method: "GET",
|
||||||
url: `/api/tgMessage?openid=${openId}`, //仅为示例,并非真实的接口地址
|
url: `/api/tgMessage?openid=${window.localStorage.getItem("openid")}`, //仅为示例,并非真实的接口地址
|
||||||
// url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址
|
// url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
console.log('访问提醒发送成功');
|
console.log("访问提醒发送成功");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 入群申请
|
// 入群申请
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -119,7 +205,7 @@ const Index = () => {
|
|||||||
// window.alert(window.localStorage.getItem('openid'))
|
// window.alert(window.localStorage.getItem('openid'))
|
||||||
// 获取wxid参数
|
// 获取wxid参数
|
||||||
getWxidFromUrl();
|
getWxidFromUrl();
|
||||||
tgMessage()
|
// tgMessage();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
@@ -224,7 +310,7 @@ const Index = () => {
|
|||||||
style="width: 30px;height:30px;background: #fff;"
|
style="width: 30px;height:30px;background: #fff;"
|
||||||
src={nomad}
|
src={nomad}
|
||||||
/>
|
/>
|
||||||
<View className="bookNmae">数字游民</View>
|
<View className="bookNmae">数字游民手册</View>
|
||||||
</View>
|
</View>
|
||||||
<View className="subtitle">多元自动化收入</View>
|
<View className="subtitle">多元自动化收入</View>
|
||||||
<View className="bookText">
|
<View className="bookText">
|
||||||
@@ -232,14 +318,15 @@ const Index = () => {
|
|||||||
1. 微信运营:云手机+机器人+AIGC
|
1. 微信运营:云手机+机器人+AIGC
|
||||||
<br />
|
<br />
|
||||||
2. 自媒体:youtube获利+wordpress <br />
|
2. 自媒体:youtube获利+wordpress <br />
|
||||||
3. 跨境电商:amazon<br />
|
3. 跨境电商:amazon
|
||||||
4. 软件saas:独立开发<br />
|
<br />
|
||||||
5. 知识付费:如何出版一本书?<br />
|
4. 软件saas:独立开发
|
||||||
|
<br />
|
||||||
|
5. 知识付费:如何出版一本书?
|
||||||
|
<br />
|
||||||
</View>
|
</View>
|
||||||
<View className="bookPrice">
|
<View className="bookPrice">
|
||||||
<View className="join">立即阅读</View>
|
<View className="join">预约</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -290,16 +377,17 @@ const Index = () => {
|
|||||||
|
|
||||||
{/* 右边 */}
|
{/* 右边 */}
|
||||||
<View className="meetup-right">
|
<View className="meetup-right">
|
||||||
<View className="title">
|
<View className="title">数字游民 | 自由职业者沙龙</View>
|
||||||
数字游民 | 自由职业者沙龙
|
|
||||||
</View>
|
|
||||||
<View className="address">
|
<View className="address">
|
||||||
<AtIcon value="map-pin" size="30" color="#F00"></AtIcon>
|
<AtIcon value="map-pin" size="30" color="#F00"></AtIcon>
|
||||||
<span>深圳市龙华区</span>
|
<span>深圳市龙华区</span>
|
||||||
</View>
|
</View>
|
||||||
<View className="meetBtn">
|
<View className="meetBtn">
|
||||||
<View ><AtIcon value="clock" size="30" color="#F00"></AtIcon>18:00--20:00</View>
|
<View>
|
||||||
<View className="join">了解详情</View>
|
<AtIcon value="clock" size="30" color="#F00"></AtIcon>
|
||||||
|
19:00--21:00
|
||||||
|
</View>
|
||||||
|
<View className="join">立即报名</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
.bookImg {
|
.bookImg {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #1bb14e;
|
// background-color: #1bb14e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.book-middle{
|
.book-middle{
|
||||||
|
|||||||
Reference in New Issue
Block a user