update
This commit is contained in:
@@ -45,8 +45,7 @@ const config = {
|
||||
esnextModules: ["taro-ui"],
|
||||
publicPath: "/",
|
||||
staticDirectory: "static",
|
||||
postcss: {
|
||||
autoprefixer: {
|
||||
postcss: { autoprefixer: {
|
||||
enable: true,
|
||||
config: {},
|
||||
},
|
||||
@@ -76,7 +75,7 @@ const config = {
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api/': {
|
||||
target: JSON.parse('"http://localhost:8055"'), //本地调试端口
|
||||
target: JSON.parse('"http://192.168.31.108:28369"'), //本地调试端口
|
||||
pathRewrite: {
|
||||
'^/api/': '/'
|
||||
},
|
||||
|
||||
@@ -23,22 +23,70 @@ import group from "../../images/group.png";
|
||||
const Index = () => {
|
||||
const [current, setcurrent] = useState(0);
|
||||
const [openId, setopenId] = useState(null);
|
||||
const [wxiid, setwxid] = useState(null);
|
||||
const [h5openid, seth5openid] = useState(null);
|
||||
|
||||
const [wxid, setwxid] = useState(null);
|
||||
|
||||
const [isOpened, setisOpened] = useState(false);
|
||||
const [joinMeetup, setjoinMeetup] = useState(false);
|
||||
|
||||
const [id, setid] = useState(null);
|
||||
const [userInfo, setuserInfo] = useState({
|
||||
wxid: null,
|
||||
openId: null,
|
||||
h5openid: null,
|
||||
bighead: null,
|
||||
city: null,
|
||||
country: null,
|
||||
generator: null,
|
||||
id: null,
|
||||
labels: null,
|
||||
nickname: null,
|
||||
province: null,
|
||||
remark: null,
|
||||
sex: null, //男
|
||||
smallhead: null,
|
||||
source: null,
|
||||
sourceStr: null,
|
||||
usertype: null,
|
||||
v1: null,
|
||||
wxaccount: null,
|
||||
});
|
||||
|
||||
// 获取用户标识符
|
||||
useEffect(() => {
|
||||
let newparams = Taro.getCurrentInstance().router.params;
|
||||
let newId = newparams.id;
|
||||
if (newId) {
|
||||
setid(newId);
|
||||
// 获取路由参数
|
||||
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) &&
|
||||
!localh5openid &&
|
||||
localh5openid == "undefined" &&
|
||||
localh5openid == "null"
|
||||
) {
|
||||
// 本地存储
|
||||
window.localStorage.setItem("wxid", params?.wxid ?? "");
|
||||
alert(params?.wxid);
|
||||
setwxid(params?.wxid);
|
||||
getopenId();
|
||||
} else {
|
||||
try {
|
||||
let getuserInfo = Taro.getStorageSync("userInfo");
|
||||
if (getuserInfo) {
|
||||
setuserInfo(getuserInfo);
|
||||
console.log("本地用户信息存在");
|
||||
} else {
|
||||
console.log("本地用户信息,不存在");
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("error", e);
|
||||
}
|
||||
}
|
||||
let newjoinMeetup = window.localStorage.getItem("joinMeetup");
|
||||
setjoinMeetup(newjoinMeetup);
|
||||
}, []);
|
||||
|
||||
const onBridgeReady = () => {
|
||||
WeixinJSBridge.call("hideOptionMenu");
|
||||
};
|
||||
@@ -49,32 +97,67 @@ const Index = () => {
|
||||
}, []);
|
||||
|
||||
// 获取openid
|
||||
const getWxid = () => {
|
||||
const getopenId = () => {
|
||||
let hashopenid = null;
|
||||
if (window.location.href.includes("openid")) {
|
||||
hashopenid = window.location.href
|
||||
.split("#")[0]
|
||||
.split("?")[1]
|
||||
.split("=")[1];
|
||||
// alert("1111==>" + hashopenid);
|
||||
} else {
|
||||
hashopenid = window.localStorage.getItem("openid");
|
||||
hashopenid = window.localStorage.getItem("h5openid");
|
||||
// alert("222==>" + hashopenid);
|
||||
}
|
||||
// let newOpenid = window.localStorage.getItem("openid");
|
||||
if (
|
||||
// (!!newOpenid && newOpenid != "undefined" && newOpenid != "null") ||
|
||||
!!hashopenid &&
|
||||
hashopenid != "undefined" &&
|
||||
hashopenid != "null"
|
||||
) {
|
||||
window.localStorage.setItem("openid", hashopenid);
|
||||
setopenId(hashopenid);
|
||||
if (!!hashopenid && hashopenid != "undefined" && hashopenid != "null") {
|
||||
window.localStorage.setItem("h5openid", hashopenid);
|
||||
// alert(hashopenid);
|
||||
let localwxid = window.localStorage.getItem("wxid");
|
||||
// alert(localwxid);
|
||||
|
||||
seth5openid(hashopenid);
|
||||
try {
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
|
||||
//发起网络请求
|
||||
Taro.request({
|
||||
url: "/api/addH5openid",
|
||||
// url: "https://kunpeng.hackrobot.cn/addH5openid",
|
||||
data: {
|
||||
h5openid: h5openid ?? null,
|
||||
wxid: params?.wxid ?? null, //debug eric 的wxid
|
||||
},
|
||||
success: function (resUser) {
|
||||
console.log(resUser);
|
||||
console.log(resUser.data);
|
||||
setuserInfo({ ...resUser.data });
|
||||
// 本地存储
|
||||
Taro.setStorage({
|
||||
key: "userInfo",
|
||||
data: resUser.data,
|
||||
});
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
} finally {
|
||||
}
|
||||
} else {
|
||||
let nowUrl = window.location.href;
|
||||
// alert(nowUrl);
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
}
|
||||
};
|
||||
|
||||
// useEffect(() => {
|
||||
// let nowUrl = window.location.href;
|
||||
// let localh5openid = window.localStorage.getItem("h5openid");
|
||||
// let localwxid = window.localStorage.getItem("wxid");
|
||||
// alert("localh5openid==>" + localh5openid);
|
||||
// alert("localwxid==>" + localwxid);
|
||||
// alert(nowUrl);
|
||||
// });
|
||||
|
||||
const joinmeet = () => {
|
||||
// alert(window.localStorage.getItem("openid"));
|
||||
Taro.request({
|
||||
@@ -119,13 +202,14 @@ const Index = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 通过wxid加群微信群
|
||||
const joinWechat = () => {
|
||||
Taro.request({
|
||||
url: "/api/joinwechat",
|
||||
// url: "https://kunpeng.hackrobot.cn/joingroup",
|
||||
data: {
|
||||
wxid: "wxid_haqoszjheyuz22",
|
||||
// wxid:wxid ?? null, //debug eric 的wxid
|
||||
// wxid: "wxid_haqoszjheyuz22",
|
||||
wxid: wxid ?? null, //debug eric 的wxid
|
||||
},
|
||||
method: "POST",
|
||||
header: {
|
||||
@@ -149,12 +233,6 @@ const Index = () => {
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getWxid();
|
||||
let newjoinMeetup = window.localStorage.getItem("joinMeetup");
|
||||
setjoinMeetup(newjoinMeetup);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View className="index">
|
||||
<View className="at-article">
|
||||
@@ -214,7 +292,6 @@ const Index = () => {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{/* <AtButton type="primary">立即加入</AtButton> */}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user