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